diff --git a/ament_cmake/CMakeLists.txt b/ament_cmake/CMakeLists.txt index ee1dd7f7..e180a105 100644 --- a/ament_cmake/CMakeLists.txt +++ b/ament_cmake/CMakeLists.txt @@ -17,6 +17,7 @@ ament_export_dependencies( "ament_cmake_python" "ament_cmake_target_dependencies" "ament_cmake_test" + "ament_cmake_version" ) ament_package() diff --git a/ament_cmake/package.xml b/ament_cmake/package.xml index 24b50bde..352565fd 100644 --- a/ament_cmake/package.xml +++ b/ament_cmake/package.xml @@ -25,6 +25,7 @@ ament_cmake_python ament_cmake_target_dependencies ament_cmake_test + ament_cmake_version ament_cmake diff --git a/ament_cmake_version/CMakeLists.txt b/ament_cmake_version/CMakeLists.txt new file mode 100644 index 00000000..8037285a --- /dev/null +++ b/ament_cmake_version/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.5) + +project(ament_cmake_version NONE) + +find_package(ament_cmake_core REQUIRED) + +ament_package( + CONFIG_EXTRAS "ament_cmake_version-extras.cmake" +) + +install( + DIRECTORY cmake + DESTINATION share/${PROJECT_NAME} +) diff --git a/ament_cmake_version/ament_cmake_version-extras.cmake b/ament_cmake_version/ament_cmake_version-extras.cmake new file mode 100644 index 00000000..af4af0a3 --- /dev/null +++ b/ament_cmake_version/ament_cmake_version-extras.cmake @@ -0,0 +1,21 @@ +# Copyright 2019 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# copied from +# ament_cmake_version/ament_cmake_version-extras.cmake + +find_package(ament_cmake_core QUIET REQUIRED) + +include( + "${ament_cmake_version_DIR}/ament_export_development_version_if_higher_than_manifest.cmake") diff --git a/ament_cmake_version/cmake/ament_export_development_version_if_higher_than_manifest.cmake b/ament_cmake_version/cmake/ament_export_development_version_if_higher_than_manifest.cmake new file mode 100644 index 00000000..764932e8 --- /dev/null +++ b/ament_cmake_version/cmake/ament_export_development_version_if_higher_than_manifest.cmake @@ -0,0 +1,57 @@ +# Copyright 2019 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# Set the exported package version to the passed value if the package +# version in the manifest is lower. +# +# It is recommended to append the suffix ``-dev`` to the passed upcoming +# version number. +# If the package version in the manifest is equal or newer than the passed +# development version this function call becomes a no-op. +# If the function is called multiple times only the higher version number will +# be used. +# +# .. note:: It is indirectly calling``ament_package_xml()`` if that hasn't +# happened already. +# +# :param target: development_version +# :type target: string +# +# @public +# +macro(ament_export_development_version_if_higher_than_manifest development_version) + if(ARGN) + message(FATAL_ERROR + "ament_export_development_version_if_higher_than_manifest() called with unused arguments: ${ARGN}") + endif() + + if(DEFINED _${PROJECT_NAME}_AMENT_PACKAGE) + message(FATAL_ERROR + "ament_export_development_version_if_higher_than_manifest() must be called before " + "ament_package()") + endif() + + # call ament_package_xml() if it has not been called before + if(NOT _AMENT_PACKAGE_NAME) + ament_package_xml() + endif() + + if("${${PROJECT_NAME}_VERSION}" VERSION_LESS "${development_version}") + message(STATUS + "Overriding exported package version '${${PROJECT_NAME}_VERSION}' with " + "development version '${development_version}'") + set(${PROJECT_NAME}_VERSION "${development_version}") + endif() +endmacro() diff --git a/ament_cmake_version/package.xml b/ament_cmake_version/package.xml new file mode 100644 index 00000000..d6f1c7d6 --- /dev/null +++ b/ament_cmake_version/package.xml @@ -0,0 +1,17 @@ + + + + ament_cmake_version + 0.8.0 + The ability to override the exported package version in the ament buildsystem. + Dirk Thomas + Apache License 2.0 + + ament_cmake_core + + ament_cmake_core + + + ament_cmake + +