Skip to content
Merged
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
58 changes: 17 additions & 41 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,30 @@ cmake_minimum_required(VERSION 3.10)
project(gz_sensors_vendor)

# Project-specific settings
set(LIB_VER_MAJOR 9)
set(LIB_VER_MINOR 2)
set(LIB_VER_MAJOR 10)
set(LIB_VER_MINOR 0)
set(LIB_VER_PATCH 0)
set(LIB_VER_SUFFIX "")
set(LIB_VER_SUFFIX "-pre1")

# Derived variables
set(LIB_NAME gz-sensors)
set(GITHUB_NAME gz-sensors)
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 gz-sensors)
set(LIB_VER ${LIB_VER_MAJOR}.${LIB_VER_MINOR}.${LIB_VER_PATCH})

option(VENDOR_FROM_LIB_VCS_REF
"Vendor from a VCS ref instead of tag. Uses the value in LIB_VCS_REF if specified or main otherwise"
OFF)
if(NOT VENDOR_FROM_LIB_VCS_REF)
set(LIB_VCS_VER ${GITHUB_NAME}${LIB_VER_MAJOR}_${LIB_VER}${LIB_VER_SUFFIX})
elseif(LIB_VCS_REF)
set(LIB_VCS_VER ${LIB_VCS_REF})
else()
set(LIB_VCS_VER main)
endif()

find_package(ament_cmake_core REQUIRED)
find_package(ament_cmake_vendor_package REQUIRED)
find_package(ament_cmake_export_dependencies REQUIRED)
Expand Down Expand Up @@ -47,7 +58,7 @@ find_package(${LIB_NAME_FULL} ${VERSION_MATCH} ${LIB_VER} COMPONENTS all QUIET)
ament_vendor(${LIB_NAME_UNDERSCORE}_vendor
SATISFIED ${${LIB_NAME_FULL}_FOUND}
VCS_URL https://github.com/gazebosim/${GITHUB_NAME}.git
VCS_VERSION ${GITHUB_NAME}${LIB_VER_MAJOR}_${LIB_VER}${LIB_VER_SUFFIX}
VCS_VERSION ${LIB_VCS_VER}
GLOBAL_HOOK
)

Expand Down Expand Up @@ -81,39 +92,4 @@ if(NOT ${${LIB_NAME_FULL}_FOUND})
ament_environment_hooks("${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.sh")
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 "gz_sensors_vendor-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 gz-sensors-config.cmake.in

This file was deleted.

1 change: 0 additions & 1 deletion gz_sensors_vendor-extras.cmake.in

This file was deleted.

4 changes: 2 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
-->
<version>0.2.2</version>
<description>
Vendor package for: gz-sensors9 9.2.0
Vendor package for: gz-sensors 10.0.0

Gazebo Sensors : Sensor models for simulation
</description>
Expand All @@ -36,7 +36,7 @@
<depend>sdformat_vendor</depend>

<!-- Depend on the package we are vendoring to allow building it from source -->
<depend condition="$GZ_BUILD_FROM_SOURCE != ''">gz-sensors9</depend>
<depend condition="$GZ_BUILD_FROM_SOURCE != ''">gz-sensors</depend>

<test_depend>ament_cmake_copyright</test_depend>
<test_depend>ament_cmake_lint_cmake</test_depend>
Expand Down