Skip to content

Commit 0e80c0d

Browse files
committed
Use version check instead of bumping minimum cmake version
1 parent 2d1ea29 commit 0e80c0d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

rosidl_generator_py/cmake/custom_command.cmake

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
# CMake does not allow `add_custom_command()` to depend on files generated in
1919
# a different CMake subdirectory, and this command is invoked after an
2020
# add_subdirectory() call.
21-
cmake_minimum_required(VERSION 3.27) # Required by option DEPENDS_EXPLICIT_ONLY of add_custom_command
21+
cmake_minimum_required(VERSION 3.20)
22+
23+
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.27)
24+
set(_dep_explicit_only DEPENDS_EXPLICIT_ONLY)
25+
else()
26+
set(_dep_explicit_only "")
27+
endif()
28+
2229
add_custom_command(
2330
OUTPUT ${_generated_extension_files} ${_generated_py_files} ${_generated_c_files}
2431
# This assumes that python_cmake_module was found, which is always the case since this is only
@@ -29,7 +36,7 @@ add_custom_command(
2936
DEPENDS ${target_dependencies} ${rosidl_generate_interfaces_TARGET}
3037
COMMENT "Generating Python code for ROS interfaces"
3138
VERBATIM
32-
DEPENDS_EXPLICIT_ONLY
39+
${_dep_explicit_only}
3340
)
3441

3542
if(TARGET ${rosidl_generate_interfaces_TARGET}${_target_suffix})

0 commit comments

Comments
 (0)