From bda65cac19ada79a42f29bc0d1c70e2e01248492 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Fri, 1 Aug 2025 20:10:04 -0700 Subject: [PATCH 1/2] Remove version from package name Major version numbers have been removed from all packages in Gazebo Jetty (except gz-tools2), so update the template to remove the version number and the unversioned cmake config template and the extras cmake template, which are no longer needed. Signed-off-by: Steve Peters --- create_gz_vendor_pkg/create_vendor_package.py | 12 +----- .../templates/CMakeLists.txt.jinja | 39 +------------------ .../templates/config.cmake.in | 24 ------------ .../templates/extras.cmake.in | 1 - 4 files changed, 3 insertions(+), 73 deletions(-) delete mode 100644 create_gz_vendor_pkg/templates/config.cmake.in delete mode 100644 create_gz_vendor_pkg/templates/extras.cmake.in diff --git a/create_gz_vendor_pkg/create_vendor_package.py b/create_gz_vendor_pkg/create_vendor_package.py index 59b7d97..7972e05 100644 --- a/create_gz_vendor_pkg/create_vendor_package.py +++ b/create_gz_vendor_pkg/create_vendor_package.py @@ -364,7 +364,7 @@ def main(argv=sys.argv[1:]): "--overwrite_cmake_configs", action="store_true", default=False, - help="If true, overwrites cmake config (.in) files", + help="If true, overwrites cmake config (.in) and dsv files", ) args = parser.parse_args(argv) try: @@ -408,16 +408,6 @@ def main(argv=sys.argv[1:]): shutil.copy(templates_path / file, Path(args.output_dir) / file) if args.overwrite_cmake_configs: - shutil.copy( - templates_path / "config.cmake.in", - Path(args.output_dir) - / f"{cmake_pkg_name(pkg_name_no_version)}-config.cmake.in", - ) - shutil.copy( - templates_path / "extras.cmake.in", - Path(args.output_dir) / f"{vendor_name}-extras.cmake.in", - ) - if pkg_has_dsv(pkg_name_no_version): shutil.copy( templates_path / "vendor.dsv.in", diff --git a/create_gz_vendor_pkg/templates/CMakeLists.txt.jinja b/create_gz_vendor_pkg/templates/CMakeLists.txt.jinja index 38ca404..2123928 100644 --- a/create_gz_vendor_pkg/templates/CMakeLists.txt.jinja +++ b/create_gz_vendor_pkg/templates/CMakeLists.txt.jinja @@ -13,7 +13,7 @@ set(LIB_NAME {{ cmake_pkg_name }}) set(GITHUB_NAME {{ github_pkg_name }}) string(REPLACE "-" "_" LIB_NAME_UNDERSCORE ${LIB_NAME}) set(LIB_NAME_COMP_PREFIX ${LIB_NAME}) -set(LIB_NAME_FULL ${LIB_NAME}${LIB_VER_MAJOR}) +set(LIB_NAME_FULL ${LIB_NAME}) set(LIB_VER ${LIB_VER_MAJOR}.${LIB_VER_MINOR}.${LIB_VER_PATCH}) find_package(ament_cmake_core REQUIRED) @@ -93,39 +93,4 @@ if(NOT ${${LIB_NAME_FULL}_FOUND}) endif() {% endif %} -# The goal is to support versionless package names once the user has found the -# vendor package. Example usage: -# -# find_package(gz_sim_vendor) -# find_package(gz-sim VERSION 8.2.0) # Note gz-sim not gz-sim8 -# -# To accomplish this, we create a `{LIB_NAME}-config.cmake` file that does -# find_package on the underlying package and sets up CMake targets with the -# same name as the original targets sans the version number in the target. -# -# However, since the vendor package is built with `GLOBAL_HOOK`, we can't -# install the `-config.cmake` file we're creating here to where the versioned -# `-config.cmake` from the underlying package is located. If we did, users can -# `find_package` the versionless package without first finding the vendor -# package. Thus, we install the `-config.cmake` file to a nonstandard -# location: `opt/${PROJECT_NAME}/extra_cmake/` and provide a -# `{vendor_name}-extras.cmake` file that adds that path to `CMAKE_PREFIX_PATH`. -ament_package( - CONFIG_EXTRAS_POST "{{ vendor_name }}-extras.cmake.in" -) - -include(CMakePackageConfigHelpers) -include(GNUInstallDirs) - -configure_package_config_file(${LIB_NAME}-config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}-config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LIB_NAME}) - -write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}-config-version.cmake - VERSION ${LIB_VER} - COMPATIBILITY SameMajorVersion) - -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}-config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}-config-version.cmake - DESTINATION "opt/${PROJECT_NAME}/extra_cmake/lib/cmake/${LIB_NAME}") +ament_package() diff --git a/create_gz_vendor_pkg/templates/config.cmake.in b/create_gz_vendor_pkg/templates/config.cmake.in deleted file mode 100644 index 56d06dd..0000000 --- a/create_gz_vendor_pkg/templates/config.cmake.in +++ /dev/null @@ -1,24 +0,0 @@ -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@) - -# 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() - - # 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@) diff --git a/create_gz_vendor_pkg/templates/extras.cmake.in b/create_gz_vendor_pkg/templates/extras.cmake.in deleted file mode 100644 index d490202..0000000 --- a/create_gz_vendor_pkg/templates/extras.cmake.in +++ /dev/null @@ -1 +0,0 @@ -list(PREPEND CMAKE_PREFIX_PATH "@CMAKE_INSTALL_PREFIX@/opt/@PROJECT_NAME@/extra_cmake") From 4453c01d04328b146e1384bd7c71fcb5b53ec956 Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Fri, 1 Aug 2025 20:12:44 -0700 Subject: [PATCH 2/2] Build python bindings (don't skip pybind11) Signed-off-by: Steve Peters --- create_gz_vendor_pkg/create_vendor_package.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/create_gz_vendor_pkg/create_vendor_package.py b/create_gz_vendor_pkg/create_vendor_package.py index 7972e05..9abd59f 100644 --- a/create_gz_vendor_pkg/create_vendor_package.py +++ b/create_gz_vendor_pkg/create_vendor_package.py @@ -315,8 +315,6 @@ def create_cmake_file(src_pkg_xml: Package, extra_params: dict): if pkg_has_docs(pkg_name_no_version) and not build_docs_deprecated(src_pkg_xml): params["cmake_args"] = ["-DBUILD_DOCS:BOOL=OFF"] - if pkg_has_pybind11(pkg_name_no_version): - params["cmake_args"].append("-DSKIP_PYBIND11:BOOL=ON") if pkg_has_swig(pkg_name_no_version): params["cmake_args"].append("-DSKIP_SWIG:BOOL=ON") return template.render(params)