From 1c25da9d5e4285af015ec1447bb272855c514c04 Mon Sep 17 00:00:00 2001 From: Anthony Welte Date: Tue, 30 Sep 2025 20:30:22 +0000 Subject: [PATCH 1/2] Add DEPENDS_EXPLICIT_ONLY to remove implicit dependencies Signed-off-by: Anthony Welte --- ...rosidl_generator_type_description_generate_interfaces.cmake | 3 ++- ...osidl_typesupport_introspection_c_generate_interfaces.cmake | 3 ++- ...idl_typesupport_introspection_cpp_generate_interfaces.cmake | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/rosidl_generator_type_description/cmake/rosidl_generator_type_description_generate_interfaces.cmake b/rosidl_generator_type_description/cmake/rosidl_generator_type_description_generate_interfaces.cmake index ed29cdab3..eca8802ab 100644 --- a/rosidl_generator_type_description/cmake/rosidl_generator_type_description_generate_interfaces.cmake +++ b/rosidl_generator_type_description/cmake/rosidl_generator_type_description_generate_interfaces.cmake @@ -24,7 +24,7 @@ # the search will prefer /usr/bin/python3 over /usr/bin/python3.11. And that # latter functionality is only available in CMake 3.20 or later, so we need # at least that version. -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.27) # Required by option DEPENDS_EXPLICIT_ONLY of add_custom_command cmake_policy(SET CMP0094 NEW) set(Python3_FIND_UNVERSIONED_NAMES FIRST) @@ -88,6 +88,7 @@ add_custom_command( DEPENDS ${target_dependencies} COMMENT "Generating type hashes for ROS interfaces" VERBATIM + DEPENDS_EXPLICIT_ONLY ) set(_target "${rosidl_generate_interfaces_TARGET}__rosidl_generator_type_description") diff --git a/rosidl_typesupport_introspection_c/cmake/rosidl_typesupport_introspection_c_generate_interfaces.cmake b/rosidl_typesupport_introspection_c/cmake/rosidl_typesupport_introspection_c_generate_interfaces.cmake index dfad37acd..25b77f760 100644 --- a/rosidl_typesupport_introspection_c/cmake/rosidl_typesupport_introspection_c_generate_interfaces.cmake +++ b/rosidl_typesupport_introspection_c/cmake/rosidl_typesupport_introspection_c_generate_interfaces.cmake @@ -88,7 +88,7 @@ rosidl_write_generator_arguments( # the search will prefer /usr/bin/python3 over /usr/bin/python3.11. And that # latter functionality is only available in CMake 3.20 or later, so we need # at least that version. -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.27) # Required by option DEPENDS_EXPLICIT_ONLY of add_custom_command cmake_policy(SET CMP0094 NEW) set(Python3_FIND_UNVERSIONED_NAMES FIRST) @@ -102,6 +102,7 @@ add_custom_command( DEPENDS ${target_dependencies} COMMENT "Generating C introspection for ROS interfaces" VERBATIM + DEPENDS_EXPLICIT_ONLY ) # generate header to switch between export and import for a specific package diff --git a/rosidl_typesupport_introspection_cpp/cmake/rosidl_typesupport_introspection_cpp_generate_interfaces.cmake b/rosidl_typesupport_introspection_cpp/cmake/rosidl_typesupport_introspection_cpp_generate_interfaces.cmake index daedc900f..ba4420fa2 100644 --- a/rosidl_typesupport_introspection_cpp/cmake/rosidl_typesupport_introspection_cpp_generate_interfaces.cmake +++ b/rosidl_typesupport_introspection_cpp/cmake/rosidl_typesupport_introspection_cpp_generate_interfaces.cmake @@ -88,7 +88,7 @@ rosidl_write_generator_arguments( # the search will prefer /usr/bin/python3 over /usr/bin/python3.11. And that # latter functionality is only available in CMake 3.20 or later, so we need # at least that version. -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.27) # Required by option DEPENDS_EXPLICIT_ONLY of add_custom_command cmake_policy(SET CMP0094 NEW) set(Python3_FIND_UNVERSIONED_NAMES FIRST) @@ -102,6 +102,7 @@ add_custom_command( DEPENDS ${target_dependencies} COMMENT "Generating C++ introspection for ROS interfaces" VERBATIM + DEPENDS_EXPLICIT_ONLY ) set(_target_suffix "__rosidl_typesupport_introspection_cpp") From ce8568e8daa1d6a7443695f32f312845f13c73a0 Mon Sep 17 00:00:00 2001 From: Anthony Welte Date: Thu, 2 Oct 2025 19:35:22 +0000 Subject: [PATCH 2/2] Use version check instead of bumping minimum cmake version Signed-off-by: Anthony Welte --- ...enerator_type_description_generate_interfaces.cmake | 10 ++++++++-- ...pesupport_introspection_c_generate_interfaces.cmake | 10 ++++++++-- ...support_introspection_cpp_generate_interfaces.cmake | 10 ++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/rosidl_generator_type_description/cmake/rosidl_generator_type_description_generate_interfaces.cmake b/rosidl_generator_type_description/cmake/rosidl_generator_type_description_generate_interfaces.cmake index eca8802ab..0e420f17a 100644 --- a/rosidl_generator_type_description/cmake/rosidl_generator_type_description_generate_interfaces.cmake +++ b/rosidl_generator_type_description/cmake/rosidl_generator_type_description_generate_interfaces.cmake @@ -24,7 +24,7 @@ # the search will prefer /usr/bin/python3 over /usr/bin/python3.11. And that # latter functionality is only available in CMake 3.20 or later, so we need # at least that version. -cmake_minimum_required(VERSION 3.27) # Required by option DEPENDS_EXPLICIT_ONLY of add_custom_command +cmake_minimum_required(VERSION 3.20) cmake_policy(SET CMP0094 NEW) set(Python3_FIND_UNVERSIONED_NAMES FIRST) @@ -78,6 +78,12 @@ rosidl_write_generator_arguments( INCLUDE_PATHS "${_dependency_paths}" ) +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.27) + set(_dep_explicit_only DEPENDS_EXPLICIT_ONLY) +else() + set(_dep_explicit_only "") +endif() + # Create custom command and target to generate the hash output add_custom_command( COMMAND Python3::Interpreter @@ -88,7 +94,7 @@ add_custom_command( DEPENDS ${target_dependencies} COMMENT "Generating type hashes for ROS interfaces" VERBATIM - DEPENDS_EXPLICIT_ONLY + ${_dep_explicit_only} ) set(_target "${rosidl_generate_interfaces_TARGET}__rosidl_generator_type_description") diff --git a/rosidl_typesupport_introspection_c/cmake/rosidl_typesupport_introspection_c_generate_interfaces.cmake b/rosidl_typesupport_introspection_c/cmake/rosidl_typesupport_introspection_c_generate_interfaces.cmake index 25b77f760..69c64a25f 100644 --- a/rosidl_typesupport_introspection_c/cmake/rosidl_typesupport_introspection_c_generate_interfaces.cmake +++ b/rosidl_typesupport_introspection_c/cmake/rosidl_typesupport_introspection_c_generate_interfaces.cmake @@ -88,12 +88,18 @@ rosidl_write_generator_arguments( # the search will prefer /usr/bin/python3 over /usr/bin/python3.11. And that # latter functionality is only available in CMake 3.20 or later, so we need # at least that version. -cmake_minimum_required(VERSION 3.27) # Required by option DEPENDS_EXPLICIT_ONLY of add_custom_command +cmake_minimum_required(VERSION 3.20) cmake_policy(SET CMP0094 NEW) set(Python3_FIND_UNVERSIONED_NAMES FIRST) find_package(Python3 REQUIRED COMPONENTS Interpreter) +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_header_files} ${_generated_source_files} COMMAND Python3::Interpreter @@ -102,7 +108,7 @@ add_custom_command( DEPENDS ${target_dependencies} COMMENT "Generating C introspection for ROS interfaces" VERBATIM - DEPENDS_EXPLICIT_ONLY + ${_dep_explicit_only} ) # generate header to switch between export and import for a specific package diff --git a/rosidl_typesupport_introspection_cpp/cmake/rosidl_typesupport_introspection_cpp_generate_interfaces.cmake b/rosidl_typesupport_introspection_cpp/cmake/rosidl_typesupport_introspection_cpp_generate_interfaces.cmake index ba4420fa2..39c9600d6 100644 --- a/rosidl_typesupport_introspection_cpp/cmake/rosidl_typesupport_introspection_cpp_generate_interfaces.cmake +++ b/rosidl_typesupport_introspection_cpp/cmake/rosidl_typesupport_introspection_cpp_generate_interfaces.cmake @@ -88,12 +88,18 @@ rosidl_write_generator_arguments( # the search will prefer /usr/bin/python3 over /usr/bin/python3.11. And that # latter functionality is only available in CMake 3.20 or later, so we need # at least that version. -cmake_minimum_required(VERSION 3.27) # Required by option DEPENDS_EXPLICIT_ONLY of add_custom_command +cmake_minimum_required(VERSION 3.20) cmake_policy(SET CMP0094 NEW) set(Python3_FIND_UNVERSIONED_NAMES FIRST) find_package(Python3 REQUIRED COMPONENTS Interpreter) +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_header_files} ${_generated_source_files} COMMAND Python3::Interpreter @@ -102,7 +108,7 @@ add_custom_command( DEPENDS ${target_dependencies} COMMENT "Generating C++ introspection for ROS interfaces" VERBATIM - DEPENDS_EXPLICIT_ONLY + ${_dep_explicit_only} ) set(_target_suffix "__rosidl_typesupport_introspection_cpp")