Skip to content

Jetty: support package names without version number #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions create_gz_vendor_pkg/create_vendor_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -364,7 +362,7 @@ def main(argv=sys.argv[1:]):
"--overwrite_cmake_configs",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may want to rename this argument since it doesn't write cmake configs anymore, though it does control writing of dsv files

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically those are cmake config files (files ending .in which are supposed to be consumed by cmake's configure)

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:
Expand Down Expand Up @@ -408,16 +406,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",
Expand Down
39 changes: 2 additions & 37 deletions create_gz_vendor_pkg/templates/CMakeLists.txt.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
24 changes: 0 additions & 24 deletions create_gz_vendor_pkg/templates/config.cmake.in

This file was deleted.

1 change: 0 additions & 1 deletion create_gz_vendor_pkg/templates/extras.cmake.in

This file was deleted.