Skip to content

Commit f1b86f8

Browse files
committed
Use version check instead of bumping minimum cmake version
Signed-off-by: Anthony Welte <[email protected]>
1 parent 0863bd6 commit f1b86f8

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

rosidl_typesupport_c/cmake/rosidl_typesupport_c_generate_interfaces.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,18 @@ rosidl_write_generator_arguments(
8383
# the search will prefer /usr/bin/python3 over /usr/bin/python3.11. And that
8484
# latter functionality is only available in CMake 3.20 or later, so we need
8585
# at least that version.
86-
cmake_minimum_required(VERSION 3.27) # Required by option DEPENDS_EXPLICIT_ONLY of add_custom_command
86+
cmake_minimum_required(VERSION 3.20)
8787
cmake_policy(SET CMP0094 NEW)
8888
set(Python3_FIND_UNVERSIONED_NAMES FIRST)
8989

9090
find_package(Python3 REQUIRED COMPONENTS Interpreter)
9191

92+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.27)
93+
set(_dep_explicit_only DEPENDS_EXPLICIT_ONLY)
94+
else()
95+
set(_dep_explicit_only "")
96+
endif()
97+
9298
get_used_typesupports(typesupports "rosidl_typesupport_c")
9399
add_custom_command(
94100
OUTPUT ${_generated_sources}
@@ -99,7 +105,7 @@ add_custom_command(
99105
DEPENDS ${target_dependencies}
100106
COMMENT "Generating C type support dispatch for ROS interfaces"
101107
VERBATIM
102-
DEPENDS_EXPLICIT_ONLY
108+
${_dep_explicit_only}
103109
)
104110

105111
set(_target_suffix "__rosidl_typesupport_c")

rosidl_typesupport_cpp/cmake/rosidl_typesupport_cpp_generate_interfaces.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,18 @@ rosidl_write_generator_arguments(
8080
# the search will prefer /usr/bin/python3 over /usr/bin/python3.11. And that
8181
# latter functionality is only available in CMake 3.20 or later, so we need
8282
# at least that version.
83-
cmake_minimum_required(VERSION 3.27) # Required by option DEPENDS_EXPLICIT_ONLY of add_custom_command
83+
cmake_minimum_required(VERSION 3.20)
8484
cmake_policy(SET CMP0094 NEW)
8585
set(Python3_FIND_UNVERSIONED_NAMES FIRST)
8686

8787
find_package(Python3 REQUIRED COMPONENTS Interpreter)
8888

89+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.27)
90+
set(_dep_explicit_only DEPENDS_EXPLICIT_ONLY)
91+
else()
92+
set(_dep_explicit_only "")
93+
endif()
94+
8995
get_used_typesupports(typesupports "rosidl_typesupport_cpp")
9096
add_custom_command(
9197
OUTPUT ${_generated_sources}
@@ -96,7 +102,7 @@ add_custom_command(
96102
DEPENDS ${target_dependencies}
97103
COMMENT "Generating C++ type support dispatch for ROS interfaces"
98104
VERBATIM
99-
DEPENDS_EXPLICIT_ONLY
105+
${_dep_explicit_only}
100106
)
101107

102108
set(_target_suffix "__rosidl_typesupport_cpp")

0 commit comments

Comments
 (0)