Skip to content

Commit 5b70678

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

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

rosidl_typesupport_fastrtps_c/cmake/rosidl_typesupport_fastrtps_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_files}
99105
COMMAND Python3::Interpreter
@@ -102,7 +108,7 @@ add_custom_command(
102108
DEPENDS ${target_dependencies}
103109
COMMENT "Generating C type support for eProsima Fast-RTPS"
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_fastrtps_cpp/cmake/rosidl_typesupport_fastrtps_cpp_generate_interfaces.cmake

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

105105
find_package(Python3 REQUIRED COMPONENTS Interpreter)
106106

107+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.27)
108+
set(_dep_explicit_only DEPENDS_EXPLICIT_ONLY)
109+
else()
110+
set(_dep_explicit_only "")
111+
endif()
112+
107113
# Add a command that invokes generator at build time
108114
add_custom_command(
109115
OUTPUT ${_generated_files}
@@ -113,7 +119,7 @@ add_custom_command(
113119
DEPENDS ${target_dependencies}
114120
COMMENT "Generating C++ type support for eProsima Fast-RTPS"
115121
VERBATIM
116-
DEPENDS_EXPLICIT_ONLY
122+
${_dep_explicit_only}
117123
)
118124

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

0 commit comments

Comments
 (0)