-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathFindIgnitionDistribution.cmake
101 lines (79 loc) · 2.73 KB
/
FindIgnitionDistribution.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Copyright (C) 2020 Istituto Italiano di Tecnologia (IIT). All rights reserved.
# This software may be modified and distributed under the terms of the
# GNU Lesser General Public License v2.1 or any later version.
# In this initial implementation, we support only specifying
# the Ignition Gazebo version to determine the Ignition distribution.
# In the future we could pull and parse the tags.yaml file.
set(IGNITION-GAZEBO_CITADEL_VER 3)
set(IGNITION-GAZEBO_DOME_VER 4)
macro(find_ignition_distribution)
set(_prefix "fid")
string(TOUPPER ${_prefix} _prefix)
set(_oneValueArgs
CODENAME
REQUIRED)
set(_multiValueArgs
PACKAGES)
# For each {one,multi}value variable FOO, this command creates
# the variable ${_prefix}_FOO with the passed arg(s)
cmake_parse_arguments(${_prefix}
"${_options}"
"${_oneValueArgs}"
"${_multiValueArgs}"
"${ARGN}")
unset(_options)
unset(_oneValueArgs)
unset(_multiValueArgs)
# Example:
# ${Citadel_FOUND}=TRUE
set(${${_prefix}_CODENAME}_FOUND TRUE)
set(IGNITION_FOUND FALSE)
set(_pkgs_not_found)
# Example:
# ${PKG}=ignition-gazebo
foreach(PKG IN LISTS ${_prefix}_PACKAGES)
# Example:
# ${_codename_upper}=CITADEL
string(TOUPPER ${${_prefix}_CODENAME} _codename_upper)
# Example:
# ${_pkg_upper}=IGNITION-GAZEBO
string(TOUPPER ${PKG} _pkg_upper)
# Example:
# ${_rel_variable_name}=IGNITION-GAZEBO_CITADEL_VER
set(_rel_variable_name ${_pkg_upper}_${_codename_upper}_VER)
if(NOT ${_rel_variable_name})
message(FATAL_ERROR "Failed to find variable ${_rel_variable_name}")
endif()
# Example:
# ${_pkg_name}=ignition-gazebo3
set(_pkg_name ${PKG}${${_rel_variable_name}})
# Find the package
if(${${_prefix}_REQUIRED})
find_package(${_pkg_name} REQUIRED)
else()
find_package(${_pkg_name} QUIET)
endif()
if(NOT ${_pkg_name}_FOUND)
# Example:
# ${Citadel_FOUND}=FALSE
set(${${_prefix}_CODENAME}_FOUND FALSE)
list(APPEND _pkgs_not_found ${_pkg_name})
endif()
endforeach()
# Print missing packages
if(NOT ${${_prefix}_CODENAME}_FOUND)
message(DEBUG "Missing packages of Ignition ${${_prefix}_CODENAME}:")
foreach(PKG IN LISTS _pkgs_not_found)
message(DEBUG " ${PKG}")
endforeach()
endif()
if(${${_prefix}_CODENAME}_FOUND)
set(IGNITION_FOUND TRUE)
endif()
unset(_prefix)
unset(_codename_upper)
unset(_pkg_upper)
unset(_rel_variable_name)
unset(_pkg_name)
unset(_pkgs_not_found)
endmacro()