From 8e1e85076f2002a97ed604a19766e7c1839358cb Mon Sep 17 00:00:00 2001 From: Jupp Tscheak <jupp.tscheak@daimler.com> Date: Wed, 7 Jul 2021 13:02:13 +0200 Subject: [PATCH] Initial provision of build automation using CMake. The CMake build scripts support build automation, testing, packaging and installation of the ScenarioAPI. Signed-off-by: Jupp Tscheak <jupp.tscheak@daimler.com> --- CMakeLists.txt | 41 ++++++++++++++++++++++++ MantleAPI/CMakeLists.txt | 11 +++++++ MantleAPI/include/CMakeLists.txt | 55 ++++++++++++++++++++++++++++++++ cmake/ScenarioAPICPack.cmake | 29 +++++++++++++++++ cmake/ScenarioAPIConfig.cmake.in | 20 ++++++++++++ 5 files changed, 156 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 MantleAPI/CMakeLists.txt create mode 100644 MantleAPI/include/CMakeLists.txt create mode 100644 cmake/ScenarioAPICPack.cmake create mode 100644 cmake/ScenarioAPIConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..a2f1d3c8 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,41 @@ +################################################################################ +# Copyright (c) 2021 Daimler TSS GmbH +# +# This program and the accompanying materials are made available under the terms +# of the Eclipse Public License 2.0 which is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +################################################################################ + +cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR) + +# Add the custom CMake modules to CMake's module path +list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) + +project( + ScenarioAPI + VERSION 0.1.0 + DESCRIPTION "Scenario API, an abstraction layer for environmental simulators" + LANGUAGES CXX) + +# Project setup only if this is the main project +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) + include(CTest) + option(BUILD_DOCUMENTATION "Build the documentation tree." OFF) +endif() + +# Go into the actual project +add_subdirectory(MantleAPI) + +# Should we build documentation for the project? +if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_DOCUMENTATION) + OR ScenarioAPI_BUILD_DOCUMENTATION) + add_subdirectory(doc) +endif() + +# Include the CPack configuration +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + include(ScenarioAPICPack) +endif() diff --git a/MantleAPI/CMakeLists.txt b/MantleAPI/CMakeLists.txt new file mode 100644 index 00000000..48d19749 --- /dev/null +++ b/MantleAPI/CMakeLists.txt @@ -0,0 +1,11 @@ +################################################################################ +# Copyright (c) 2021 Daimler TSS GmbH +# +# This program and the accompanying materials are made available under the terms +# of the Eclipse Public License 2.0 which is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +################################################################################ + +add_subdirectory(include) diff --git a/MantleAPI/include/CMakeLists.txt b/MantleAPI/include/CMakeLists.txt new file mode 100644 index 00000000..24fe7f5e --- /dev/null +++ b/MantleAPI/include/CMakeLists.txt @@ -0,0 +1,55 @@ +################################################################################ +# Copyright (c) 2021 Daimler TSS GmbH +# +# This program and the accompanying materials are made available under the terms +# of the Eclipse Public License 2.0 which is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +################################################################################ + +find_package(units CONFIG REQUIRED) + +file( + GLOB_RECURSE HEADERS + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + CONFIGURE_DEPENDS "*.h") + +add_library(ScenarioAPI INTERFACE) +add_library(ScenarioAPI::ScenarioAPI ALIAS ScenarioAPI) + +target_link_libraries(ScenarioAPI INTERFACE units) + +include(GNUInstallDirs) +set(INSTALL_CONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/ScenarioAPI") + +target_include_directories( + ScenarioAPI INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) + +target_compile_features(ScenarioAPI INTERFACE cxx_std_14) + +include(CMakePackageConfigHelpers) +configure_package_config_file( + "${PROJECT_SOURCE_DIR}/cmake/ScenarioAPIConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/ScenarioAPIConfig.cmake" + INSTALL_DESTINATION ${INSTALL_CONFIG_DIR} + PATH_VARS CMAKE_INSTALL_INCLUDEDIR) + +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/ScenarioAPIConfigVersion.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion) + +install(DIRECTORY MantleAPI TYPE INCLUDE) +install(TARGETS ScenarioAPI EXPORT ScenarioAPITargets) + +install( + EXPORT ScenarioAPITargets + DESTINATION ${INSTALL_CONFIG_DIR} + NAMESPACE ScenarioAPI::) + +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/ScenarioAPIConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/ScenarioAPIConfigVersion.cmake" + DESTINATION ${INSTALL_CONFIG_DIR} + COMPONENT dev) diff --git a/cmake/ScenarioAPICPack.cmake b/cmake/ScenarioAPICPack.cmake new file mode 100644 index 00000000..63404adc --- /dev/null +++ b/cmake/ScenarioAPICPack.cmake @@ -0,0 +1,29 @@ +################################################################################ +# Copyright (c) 2021 Daimler TSS GmbH +# +# This program and the accompanying materials are made available under the terms +# of the Eclipse Public License 2.0 which is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +################################################################################ + +set(CPACK_PACKAGE_NAME "scenario_api") +set(CPACK_PACKAGE_VENDOR "OpenPASS") +set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) +set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Scenario API") +set(CPACK_PACKAGE_FILE_NAME + "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}") +set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) +set(CPACK_PACKAGE_CHECKSUM SHA512) +set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt") +set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md") +set(CPACK_GENERATOR TGZ) +set(CPACK_STRIP_FILES ON) +set(CPACK_SOURCE_GENERATOR ${CPACK_GENERATOR}) + +include(CPack) diff --git a/cmake/ScenarioAPIConfig.cmake.in b/cmake/ScenarioAPIConfig.cmake.in new file mode 100644 index 00000000..b1b31d3e --- /dev/null +++ b/cmake/ScenarioAPIConfig.cmake.in @@ -0,0 +1,20 @@ +################################################################################ +# Copyright (c) 2021 Daimler TSS GmbH +# +# This program and the accompanying materials are made available under the terms +# of the Eclipse Public License 2.0 which is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +################################################################################ + +@PACKAGE_INIT@ + +if(NOT TARGET ScenarioAPI::ScenarioAPI AND NOT ScenarioAPI_BINARY_DIR) + set_and_check(ScenarioAPI_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") + mark_as_advanced(ScenarioAPI_INCLUDE_DIR) + include("${CMAKE_CURRENT_LIST_DIR}/ScenarioAPITargets.cmake") +endif() + +include(CMakeFindDependencyMacro) +find_dependency(units) -- GitLab