Skip to content
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

Add BSD 3-Clause license for macro extract_package_metadata #25

Merged
merged 3 commits into from
Jan 5, 2021
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
7 changes: 6 additions & 1 deletion cmake_common_scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
cmake_minimum_required(VERSION 3.5.0)
project(cmake_common_scripts VERSION 0.1.0)
include(cmake/extract_package_metadata.cmake)

extract_package_metadata(pkg)
project(${pkg_extracted_name} VERSION ${pkg_extracted_version})

include(cmake/cmake_tools.cmake)

configure_package()

install(FILES
"${CMAKE_CURRENT_LIST_DIR}/cmake/cmake_tools.cmake"
"${CMAKE_CURRENT_LIST_DIR}/cmake/code_coverage.cmake"
"${CMAKE_CURRENT_LIST_DIR}/cmake/extract_package_metadata.cmake"
DESTINATION lib/cmake/${PROJECT_NAME})

201 changes: 0 additions & 201 deletions cmake_common_scripts/LICENSE

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ set(@PROJECT_NAME@_FOUND ON)

include("${CMAKE_CURRENT_LIST_DIR}/cmake_tools.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/code_coverage.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/extract_package_metadata.cmake")
24 changes: 1 addition & 23 deletions cmake_common_scripts/cmake/cmake_tools.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2018 by George Cave - gcave@stablecoder.ca
# Copyright (c) 2020, Southwest Research Institute
#
# 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
Expand Down Expand Up @@ -302,28 +302,6 @@ macro(target_cxx_version target)
endif()
endmacro()

# This extracts package name and version to the following variables
# ${prefix}_extracted_name and ${prefix}_extracted_version
# This was taken from https://github.com/ros-industrial/abb_robot_driver, author Jon Tjerngren
macro(extract_package_metadata prefix)
# Read the package manifest.
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/package.xml" package_xml_str)

# Extract project name.
if(NOT package_xml_str MATCHES "<name>([A-Za-z0-9_]+)</name>")
message(FATAL_ERROR "Could not parse project name from package manifest (aborting)")
else()
set(${prefix}_extracted_name ${CMAKE_MATCH_1})
endif()

# Extract project version.
if(NOT package_xml_str MATCHES "<version>([0-9]+.[0-9]+.[0-9]+)</version>")
message(FATAL_ERROR "Could not parse project version from package manifest (aborting)")
else()
set(${prefix}_extracted_version ${CMAKE_MATCH_1})
endif()
endmacro()

# Find relevant programs
find_program(CLANG_TIDY_EXE NAMES clang-tidy clang-tidy-10 clang-tidy-9 clang-tidy-8)
mark_as_advanced(FORCE CLANG_TIDY_EXE)
Expand Down
49 changes: 49 additions & 0 deletions cmake_common_scripts/cmake/extract_package_metadata.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2020, ABB Schweiz AG
# All rights reserved.
#
# Redistribution and use in source and binary forms, with
# or without modification, are permitted provided that
# the following conditions are met:
#
# * Redistributions of source code must retain the
# above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the
# above copyright notice, this list of conditions
# and the following disclaimer in the documentation
# and/or other materials provided with the
# distribution.
# * Neither the name of ABB nor the names of its
# contributors may be used to endorse or promote
# products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

macro(extract_package_metadata prefix)
# Read the package manifest.
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/package.xml" package_xml_str)

# Extract project name.
if(NOT package_xml_str MATCHES "<name>([A-Za-z0-9_]+)</name>")
message(FATAL_ERROR "Could not parse project name from package manifest (aborting)")
else()
set(${prefix}_extracted_name ${CMAKE_MATCH_1})
endif()

# Extract project version.
if(NOT package_xml_str MATCHES "<version>([0-9]+.[0-9]+.[0-9]+)</version>")
message(FATAL_ERROR "Could not parse project version from package manifest (aborting)")
else()
set(${prefix}_extracted_version ${CMAKE_MATCH_1})
endif()
endmacro()