|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -# extract information from ament_package.templates |
16 | | -if(NOT TARGET Python3::Interpreter) |
17 | | - message(FATAL_ERROR |
18 | | - "ament_cmake_package_templates: target 'Python3::Interpreter' must exist") |
19 | | -endif() |
| 15 | +get_property(_cmake_role GLOBAL PROPERTY CMAKE_ROLE) |
| 16 | +if("${_cmake_role}" STREQUAL "PROJECT") |
| 17 | + # extract information from ament_package.templates |
| 18 | + if(NOT TARGET Python3::Interpreter) |
| 19 | + message(FATAL_ERROR |
| 20 | + "ament_cmake_package_templates: target 'Python3::Interpreter' must exist") |
| 21 | + endif() |
20 | 22 |
|
21 | | -# stamp script to generate CMake code |
22 | | -set(_generator |
23 | | - "${ament_cmake_core_DIR}/package_templates/templates_2_cmake.py") |
24 | | -stamp("${_generator}") |
| 23 | + # stamp script to generate CMake code |
| 24 | + set(_generator |
| 25 | + "${ament_cmake_core_DIR}/package_templates/templates_2_cmake.py") |
| 26 | + stamp("${_generator}") |
25 | 27 |
|
26 | | -# invoke generator script |
27 | | -set(_generated_file |
28 | | - "${CMAKE_CURRENT_BINARY_DIR}/ament_cmake_package_templates/templates.cmake") |
29 | | -get_executable_path(_python_interpreter Python3::Interpreter CONFIGURE) |
30 | | -set(_cmd |
31 | | - "${_python_interpreter}" |
32 | | - "${_generator}" |
33 | | - "${_generated_file}" |
34 | | -) |
35 | | -execute_process( |
36 | | - COMMAND ${_cmd} |
37 | | - RESULT_VARIABLE _res |
38 | | -) |
39 | | -if(NOT _res EQUAL 0) |
40 | | - string(REPLACE ";" " " _cmd_str "${_cmd}") |
41 | | - message(FATAL_ERROR |
42 | | - "execute_process(${_cmd_str}) returned error code ${_res}") |
43 | | -endif() |
| 28 | + # invoke generator script |
| 29 | + set(_generated_file |
| 30 | + "${CMAKE_CURRENT_BINARY_DIR}/ament_cmake_package_templates/templates.cmake") |
| 31 | + get_executable_path(_python_interpreter Python3::Interpreter CONFIGURE) |
| 32 | + set(_cmd |
| 33 | + "${_python_interpreter}" |
| 34 | + "${_generator}" |
| 35 | + "${_generated_file}" |
| 36 | + ) |
| 37 | + execute_process( |
| 38 | + COMMAND ${_cmd} |
| 39 | + RESULT_VARIABLE _res |
| 40 | + ) |
| 41 | + if(NOT _res EQUAL 0) |
| 42 | + string(REPLACE ";" " " _cmd_str "${_cmd}") |
| 43 | + message(FATAL_ERROR |
| 44 | + "execute_process(${_cmd_str}) returned error code ${_res}") |
| 45 | + endif() |
44 | 46 |
|
45 | | -# load extracted variables into cmake |
46 | | -# for each environment hook defined in `ament_package` |
47 | | -# (e.g. `library_path.bat|sh`) a CMake variable is defined starting with |
48 | | -# `ament_cmake_package_templates_ENVIRONMENT_HOOK_` |
49 | | -# (e.g. `ament_cmake_package_templates_ENVIRONMENT_HOOK_LIBRARY_PATH`) |
50 | | -include("${_generated_file}") |
| 47 | + # load extracted variables into cmake |
| 48 | + # for each environment hook defined in `ament_package` |
| 49 | + # (e.g. `library_path.bat|sh`) a CMake variable is defined starting with |
| 50 | + # `ament_cmake_package_templates_ENVIRONMENT_HOOK_` |
| 51 | + # (e.g. `ament_cmake_package_templates_ENVIRONMENT_HOOK_LIBRARY_PATH`) |
| 52 | + include("${_generated_file}") |
| 53 | +endif() |
0 commit comments