diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..a2f1d3c8fabb0059b48d455ea42d41c45026acff --- /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 0000000000000000000000000000000000000000..48d197499beadf47a9b7b988b8cc846458b6a86f --- /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 0000000000000000000000000000000000000000..24fe7f5ed56423c3a9e45aefb7a0bca5b0aea850 --- /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 0000000000000000000000000000000000000000..63404adc8e3e235f6df6c670d8b42f9f5e112332 --- /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 0000000000000000000000000000000000000000..b1b31d3e0ee7f063970a07a8299a4a7c0c609e5c --- /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)