From 1317b4b8a0e54ccfdd928ad9485b3aa6cd674f08 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Fri, 26 Sep 2025 13:20:53 -0500 Subject: [PATCH] Overwrite CMake configs by default The default was set to False because we had made a manual change in `gz_cmake_vendor` that we didn't want to overwrite. However, this causes problems when we introduce new config files. For example, we recently added a `.in` files to configure PYTHONPATH for each vendor package. Since the default is False, when the vendor package is created by `release-tools/release.py`, it doesn't include the new config files. The solution here to programmatically achieve what was done manually in gz_cmake_vendor and set `overwrite_cmake_configs` to True by default. Signed-off-by: Addisu Z. Taddese --- create_gz_vendor_pkg/create_vendor_package.py | 2 +- .../templates/config.cmake.in | 34 ++++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/create_gz_vendor_pkg/create_vendor_package.py b/create_gz_vendor_pkg/create_vendor_package.py index 1b27a81..5a66359 100644 --- a/create_gz_vendor_pkg/create_vendor_package.py +++ b/create_gz_vendor_pkg/create_vendor_package.py @@ -391,7 +391,7 @@ def main(argv=sys.argv[1:]): parser.add_argument( "--overwrite_cmake_configs", action="store_true", - default=False, + default=True, help="If true, overwrites cmake config (.in) files", ) args = parser.parse_args(argv) diff --git a/create_gz_vendor_pkg/templates/config.cmake.in b/create_gz_vendor_pkg/templates/config.cmake.in index 56d06dd..5971c60 100644 --- a/create_gz_vendor_pkg/templates/config.cmake.in +++ b/create_gz_vendor_pkg/templates/config.cmake.in @@ -2,23 +2,25 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) find_package(@LIB_NAME@@LIB_VER_MAJOR@ ${@LIB_NAME@_FIND_VERSION} REQUIRED COMPONENTS ${@LIB_NAME@_FIND_COMPONENTS}) -# Set up the core library and add it to the list of all components -add_library(@LIB_NAME_COMP_PREFIX@::@LIB_NAME_COMP_PREFIX@ ALIAS @LIB_NAME@@LIB_VER_MAJOR@::@LIB_NAME@@LIB_VER_MAJOR@) -add_library(@LIB_NAME_COMP_PREFIX@::core ALIAS @LIB_NAME@@LIB_VER_MAJOR@::@LIB_NAME@@LIB_VER_MAJOR@) +if (NOT "@LIB_NAME@" STREQUAL "gz-cmake") + # Set up the core library and add it to the list of all components + add_library(@LIB_NAME_COMP_PREFIX@::@LIB_NAME_COMP_PREFIX@ ALIAS @LIB_NAME@@LIB_VER_MAJOR@::@LIB_NAME@@LIB_VER_MAJOR@) + add_library(@LIB_NAME_COMP_PREFIX@::core ALIAS @LIB_NAME@@LIB_VER_MAJOR@::@LIB_NAME@@LIB_VER_MAJOR@) -# Retrieve the list of components -get_target_property(components @LIB_NAME@@LIB_VER_MAJOR@::requested INTERFACE_LINK_LIBRARIES) + # Retrieve the list of components + get_target_property(components @LIB_NAME@@LIB_VER_MAJOR@::requested INTERFACE_LINK_LIBRARIES) -foreach(component ${components}) - # Skip the core library - if(${component} STREQUAL @LIB_NAME@@LIB_VER_MAJOR@::@LIB_NAME@@LIB_VER_MAJOR@) - continue() - endif() + foreach(component ${components}) + # Skip the core library + if(${component} STREQUAL @LIB_NAME@@LIB_VER_MAJOR@::@LIB_NAME@@LIB_VER_MAJOR@) + continue() + endif() - # Change "gz-libN::gz-libN-component" to "component" - string(REGEX REPLACE "@LIB_NAME@@LIB_VER_MAJOR@::@LIB_NAME@@LIB_VER_MAJOR@-" "" component_name ${component}) - add_library(@LIB_NAME_COMP_PREFIX@::${component_name} ALIAS ${component}) -endforeach() + # Change "gz-libN::gz-libN-component" to "component" + string(REGEX REPLACE "@LIB_NAME@@LIB_VER_MAJOR@::@LIB_NAME@@LIB_VER_MAJOR@-" "" component_name ${component}) + add_library(@LIB_NAME_COMP_PREFIX@::${component_name} ALIAS ${component}) + endforeach() -# Add a root gz-lib alias -add_library(@LIB_NAME_COMP_PREFIX@ ALIAS @LIB_NAME@@LIB_VER_MAJOR@::@LIB_NAME@@LIB_VER_MAJOR@) + # Add a root gz-lib alias + add_library(@LIB_NAME_COMP_PREFIX@ ALIAS @LIB_NAME@@LIB_VER_MAJOR@::@LIB_NAME@@LIB_VER_MAJOR@) +endif()