From 2d1ea296ad0fa6892d09412c4d2464ee794863a6 Mon Sep 17 00:00:00 2001 From: Anthony Welte Date: Tue, 30 Sep 2025 20:29:43 +0000 Subject: [PATCH 1/2] Add DEPENDS_EXPLICIT_ONLY to remove implicit dependencies Signed-off-by: Anthony Welte --- rosidl_generator_py/cmake/custom_command.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rosidl_generator_py/cmake/custom_command.cmake b/rosidl_generator_py/cmake/custom_command.cmake index 203747a6..47b0c32e 100644 --- a/rosidl_generator_py/cmake/custom_command.cmake +++ b/rosidl_generator_py/cmake/custom_command.cmake @@ -18,6 +18,7 @@ # CMake does not allow `add_custom_command()` to depend on files generated in # a different CMake subdirectory, and this command is invoked after an # add_subdirectory() call. +cmake_minimum_required(VERSION 3.27) # Required by option DEPENDS_EXPLICIT_ONLY of add_custom_command add_custom_command( OUTPUT ${_generated_extension_files} ${_generated_py_files} ${_generated_c_files} # This assumes that python_cmake_module was found, which is always the case since this is only @@ -28,6 +29,7 @@ add_custom_command( DEPENDS ${target_dependencies} ${rosidl_generate_interfaces_TARGET} COMMENT "Generating Python code for ROS interfaces" VERBATIM + DEPENDS_EXPLICIT_ONLY ) if(TARGET ${rosidl_generate_interfaces_TARGET}${_target_suffix}) From 69e6e971b07719a3b7bb5dc15752f50fe018897b Mon Sep 17 00:00:00 2001 From: Anthony Welte Date: Thu, 2 Oct 2025 19:35:24 +0000 Subject: [PATCH 2/2] Use version check instead of bumping minimum cmake version Signed-off-by: Anthony Welte --- rosidl_generator_py/cmake/custom_command.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rosidl_generator_py/cmake/custom_command.cmake b/rosidl_generator_py/cmake/custom_command.cmake index 47b0c32e..84e1feca 100644 --- a/rosidl_generator_py/cmake/custom_command.cmake +++ b/rosidl_generator_py/cmake/custom_command.cmake @@ -18,7 +18,12 @@ # CMake does not allow `add_custom_command()` to depend on files generated in # a different CMake subdirectory, and this command is invoked after an # add_subdirectory() call. -cmake_minimum_required(VERSION 3.27) # Required by option DEPENDS_EXPLICIT_ONLY of add_custom_command +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.27) + set(_dep_explicit_only DEPENDS_EXPLICIT_ONLY) +else() + set(_dep_explicit_only "") +endif() + add_custom_command( OUTPUT ${_generated_extension_files} ${_generated_py_files} ${_generated_c_files} # This assumes that python_cmake_module was found, which is always the case since this is only @@ -29,7 +34,7 @@ add_custom_command( DEPENDS ${target_dependencies} ${rosidl_generate_interfaces_TARGET} COMMENT "Generating Python code for ROS interfaces" VERBATIM - DEPENDS_EXPLICIT_ONLY + ${_dep_explicit_only} ) if(TARGET ${rosidl_generate_interfaces_TARGET}${_target_suffix})