Skip to content
Snippets Groups Projects
Commit 8e1e8507 authored by Jupp Tscheak's avatar Jupp Tscheak
Browse files

Initial provision of build automation using CMake.


The CMake build scripts support build automation, testing, packaging and installation of the ScenarioAPI.

Signed-off-by: default avatarJupp Tscheak <jupp.tscheak@daimler.com>
parent 0cedc236
No related branches found
No related tags found
1 merge request!5Initial provision of build automation using CMake.
################################################################################
# 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()
################################################################################
# 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)
################################################################################
# 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)
################################################################################
# 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)
################################################################################
# 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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment