From e7a4068d7d36aae97b0b75a2c1d14d75d546a075 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Thu, 10 Oct 2024 23:01:27 +0200 Subject: [PATCH 1/2] ament_vendor: Add AMENT_VENDOR_NEVER_VENDOR Signed-off-by: Silvio Traversaro --- .../cmake/ament_vendor.cmake | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ament_cmake_vendor_package/cmake/ament_vendor.cmake b/ament_cmake_vendor_package/cmake/ament_vendor.cmake index c9b963cd..716e9fd7 100644 --- a/ament_cmake_vendor_package/cmake/ament_vendor.cmake +++ b/ament_cmake_vendor_package/cmake/ament_vendor.cmake @@ -49,6 +49,14 @@ # projects. # :type GLOBAL_HOOK: option # +# Beside CMake macro options, the macro is also influenced by the following two +# CMake options, that can be set at the CMake invocation for the project that +# uses ament_vendor() macro: +# * `FORCE_BUILD_VENDOR_PKG`: If ON build vendor packages from source, even if +# system-installed packages are available +# * `AMENT_VENDOR_NEVER_VENDOR`: If ON, raise an error if SATISFIED argument is +# not true instead of building the vendored package +# # @public # macro(ament_vendor TARGET_NAME) @@ -97,6 +105,18 @@ macro(ament_vendor TARGET_NAME) "Build vendor packages from source, even if system-installed packages are available" OFF) + option(AMENT_VENDOR_NEVER_VENDOR + "If ON, raise an error if SATISFIED argument is not true instead of building the vendored package" + OFF) + + if(FORCE_BUILD_VENDOR_PKG AND AMENT_VENDOR_NEVER_VENDOR) + message(FATAL_ERROR "ament_vendor() cannot have both FORCE_BUILD_VENDOR_PKG and AMENT_VENDOR_NEVER_VENDOR options enabled") + endif() + + if(NOT _ARG_SATISFIED AND AMENT_VENDOR_NEVER_VENDOR) + message(FATAL_ERROR "ament_vendor() SATISFIED option is OFF and AMENT_VENDOR_NEVER_VENDOR is ON") + endif() + if(NOT _ARG_SATISFIED OR FORCE_BUILD_VENDOR_PKG) if(_ARG_SATISFIED) message(STATUS "Forcing vendor package build for '${TARGET_NAME}', which is already satisfied") From 66f05b8cd115fda05cfe91114574c48f548f0955 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Fri, 11 Oct 2024 17:11:45 +0200 Subject: [PATCH 2/2] Fix indentation Co-authored-by: Chris Lalancette Signed-off-by: Silvio Traversaro --- ament_cmake_vendor_package/cmake/ament_vendor.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ament_cmake_vendor_package/cmake/ament_vendor.cmake b/ament_cmake_vendor_package/cmake/ament_vendor.cmake index 716e9fd7..e1d4ca12 100644 --- a/ament_cmake_vendor_package/cmake/ament_vendor.cmake +++ b/ament_cmake_vendor_package/cmake/ament_vendor.cmake @@ -110,11 +110,11 @@ macro(ament_vendor TARGET_NAME) OFF) if(FORCE_BUILD_VENDOR_PKG AND AMENT_VENDOR_NEVER_VENDOR) - message(FATAL_ERROR "ament_vendor() cannot have both FORCE_BUILD_VENDOR_PKG and AMENT_VENDOR_NEVER_VENDOR options enabled") + message(FATAL_ERROR "ament_vendor() cannot have both FORCE_BUILD_VENDOR_PKG and AMENT_VENDOR_NEVER_VENDOR options enabled") endif() if(NOT _ARG_SATISFIED AND AMENT_VENDOR_NEVER_VENDOR) - message(FATAL_ERROR "ament_vendor() SATISFIED option is OFF and AMENT_VENDOR_NEVER_VENDOR is ON") + message(FATAL_ERROR "ament_vendor() SATISFIED option is OFF and AMENT_VENDOR_NEVER_VENDOR is ON") endif() if(NOT _ARG_SATISFIED OR FORCE_BUILD_VENDOR_PKG)