Newer
Older
################################################################################
# Copyright (c) 2021 Daimler TSS GmbH
# Copyright (c) 2022 Mercedes-Benz Tech Innovation 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
################################################################################
Jupp Tscheak
committed
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
# Add the custom CMake modules to CMake's module path
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Determine if MantleAPI is built as a subproject (using add_subdirectory) or if it is the main project.
if(NOT DEFINED MantleAPI_MAIN_PROJECT)
set(MantleAPI_MAIN_PROJECT OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
DESCRIPTION "MantleAPI, an abstraction layer for environmental simulators"
LANGUAGES CXX
)
# Options that control generation of various targets.
option(MantleAPI_DOC "Generate the doc target." ${MantleAPI_MAIN_PROJECT})
option(MantleAPI_INSTALL "Generate the install target." ${MantleAPI_MAIN_PROJECT})
option(MantleAPI_TEST "Generate the test target." ${MantleAPI_MAIN_PROJECT})
option(MantleAPI_PACKAGE "Generate the package target." ${MantleAPI_MAIN_PROJECT})
option(MantleAPI_ENABLE_WARNINGS "Enable compiler warnings." ${MantleAPI_MAIN_PROJECT})
option(MantleAPI_ENABLE_WERROR "Fail and stop if a warning is triggered." ${MantleAPI_MAIN_PROJECT})
if(MSVC)
if(MantleAPI_ENABLE_WARNINGS)
add_compile_options(/W4)
endif()
if(MantleAPI_ENABLE_WERROR)
add_compile_options(/WX /wd4996)
endif()
else()
if(MantleAPI_ENABLE_WARNINGS)
add_compile_options(-Wall -Wextra)
endif()
if(MantleAPI_ENABLE_WERROR)
add_compile_options(-Werror -Wno-error=deprecated-declarations)
endif()
add_subdirectory(include)
if(MantleAPI_DOC)
add_subdirectory(doc)
endif()
if(MantleAPI_TEST)
enable_testing()
add_subdirectory(test)
endif()
if(MantleAPI_PACKAGE)
include(MantleAPICPack)