Skip to content

Commit fd3eae4

Browse files
committed
Use version check instead of bumping minimum cmake version
1 parent 1c25da9 commit fd3eae4

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

rosidl_generator_type_description/cmake/rosidl_generator_type_description_generate_interfaces.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# the search will prefer /usr/bin/python3 over /usr/bin/python3.11. And that
2525
# latter functionality is only available in CMake 3.20 or later, so we need
2626
# at least that version.
27-
cmake_minimum_required(VERSION 3.27) # Required by option DEPENDS_EXPLICIT_ONLY of add_custom_command
27+
cmake_minimum_required(VERSION 3.20)
2828
cmake_policy(SET CMP0094 NEW)
2929
set(Python3_FIND_UNVERSIONED_NAMES FIRST)
3030

@@ -78,6 +78,12 @@ rosidl_write_generator_arguments(
7878
INCLUDE_PATHS "${_dependency_paths}"
7979
)
8080

81+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.27)
82+
set(_dep_explicit_only DEPENDS_EXPLICIT_ONLY)
83+
else()
84+
set(_dep_explicit_only "")
85+
endif()
86+
8187
# Create custom command and target to generate the hash output
8288
add_custom_command(
8389
COMMAND Python3::Interpreter
@@ -88,7 +94,7 @@ add_custom_command(
8894
DEPENDS ${target_dependencies}
8995
COMMENT "Generating type hashes for ROS interfaces"
9096
VERBATIM
91-
DEPENDS_EXPLICIT_ONLY
97+
${_dep_explicit_only}
9298
)
9399

94100
set(_target "${rosidl_generate_interfaces_TARGET}__rosidl_generator_type_description")

rosidl_typesupport_introspection_c/cmake/rosidl_typesupport_introspection_c_generate_interfaces.cmake

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

9595
find_package(Python3 REQUIRED COMPONENTS Interpreter)
9696

97+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.27)
98+
set(_dep_explicit_only DEPENDS_EXPLICIT_ONLY)
99+
else()
100+
set(_dep_explicit_only "")
101+
endif()
102+
97103
add_custom_command(
98104
OUTPUT ${_generated_header_files} ${_generated_source_files}
99105
COMMAND Python3::Interpreter
@@ -102,7 +108,7 @@ add_custom_command(
102108
DEPENDS ${target_dependencies}
103109
COMMENT "Generating C introspection for ROS interfaces"
104110
VERBATIM
105-
DEPENDS_EXPLICIT_ONLY
111+
${_dep_explicit_only}
106112
)
107113

108114
# generate header to switch between export and import for a specific package

rosidl_typesupport_introspection_cpp/cmake/rosidl_typesupport_introspection_cpp_generate_interfaces.cmake

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

9595
find_package(Python3 REQUIRED COMPONENTS Interpreter)
9696

97+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.27)
98+
set(_dep_explicit_only DEPENDS_EXPLICIT_ONLY)
99+
else()
100+
set(_dep_explicit_only "")
101+
endif()
102+
97103
add_custom_command(
98104
OUTPUT ${_generated_header_files} ${_generated_source_files}
99105
COMMAND Python3::Interpreter
@@ -102,7 +108,7 @@ add_custom_command(
102108
DEPENDS ${target_dependencies}
103109
COMMENT "Generating C++ introspection for ROS interfaces"
104110
VERBATIM
105-
DEPENDS_EXPLICIT_ONLY
111+
${_dep_explicit_only}
106112
)
107113

108114
set(_target_suffix "__rosidl_typesupport_introspection_cpp")

0 commit comments

Comments
 (0)