2020-12-07 01:40:10 +01:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
|
|
|
|
2022-05-09 15:48:04 +02:00
|
|
|
set(MSG_PREFIX "fsfw |")
|
|
|
|
|
2022-05-09 15:50:49 +02:00
|
|
|
# Add the cmake folder so the FindSphinx module is found
|
2022-05-13 13:21:01 +02:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
list(APPEND CMAKE_MODULE_PATH
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules/bilke")
|
|
|
|
list(APPEND CMAKE_MODULE_PATH
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake-modules/rpavlik")
|
2022-05-09 15:50:49 +02:00
|
|
|
|
2022-05-13 13:21:01 +02:00
|
|
|
# ##############################################################################
|
2022-05-09 15:48:04 +02:00
|
|
|
# Version file handling #
|
2022-05-13 13:21:01 +02:00
|
|
|
# ##############################################################################
|
2022-05-09 15:48:04 +02:00
|
|
|
|
2022-07-18 14:46:36 +02:00
|
|
|
set(FSFW_VERSION_IF_GIT_FAILS 5)
|
2022-04-22 14:47:28 +02:00
|
|
|
set(FSFW_SUBVERSION_IF_GIT_FAILS 0)
|
|
|
|
set(FSFW_REVISION_IF_GIT_FAILS 0)
|
|
|
|
|
2022-05-09 15:48:04 +02:00
|
|
|
set(FSFW_GIT_VER_HANDLING_OK FALSE)
|
|
|
|
# Version handling
|
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
|
2022-05-13 13:21:01 +02:00
|
|
|
message(STATUS "${MSG_PREFIX} Determining version information with git")
|
|
|
|
include(FsfwHelpers)
|
|
|
|
determine_version_with_git("--exclude" "docker_*")
|
|
|
|
if(GIT_INFO)
|
|
|
|
set(FSFW_GIT_INFO
|
|
|
|
${GIT_INFO}
|
|
|
|
CACHE STRING "Version information retrieved with git describe")
|
|
|
|
list(GET FSFW_GIT_INFO 1 FSFW_VERSION)
|
|
|
|
list(GET FSFW_GIT_INFO 2 FSFW_SUBVERSION)
|
|
|
|
list(GET FSFW_GIT_INFO 3 FSFW_REVISION)
|
|
|
|
list(GET FSFW_GIT_INFO 4 FSFW_VCS_INFO)
|
|
|
|
if(NOT FSFW_VERSION)
|
|
|
|
set(FSFW_VERSION ${FSFW_VERSION_IF_GIT_FAILS})
|
|
|
|
endif()
|
|
|
|
if(NOT FSFW_SUBVERSION)
|
|
|
|
set(FSFW_SUBVERSION ${FSFW_SUBVERSION_IF_GIT_FAILS})
|
|
|
|
endif()
|
|
|
|
if(NOT FSFW_REVISION)
|
|
|
|
set(FSFW_REVISION ${FSFW_REVISION_IF_GIT_FAILS})
|
|
|
|
endif()
|
|
|
|
set(FSFW_GIT_VER_HANDLING_OK TRUE)
|
|
|
|
else()
|
|
|
|
set(FSFW_GIT_VER_HANDLING_OK FALSE)
|
|
|
|
endif()
|
2022-05-09 15:48:04 +02:00
|
|
|
endif()
|
|
|
|
if(NOT FSFW_GIT_VER_HANDLING_OK)
|
2022-05-13 13:21:01 +02:00
|
|
|
set(FSFW_VERSION ${FSFW_VERSION_IF_GIT_FAILS})
|
|
|
|
set(FSFW_SUBVERSION ${FSFW_SUBVERSION_IF_GIT_FAILS})
|
|
|
|
set(FSFW_REVISION ${FSFW_REVISION_IF_GIT_FAILS})
|
2022-05-09 15:48:04 +02:00
|
|
|
endif()
|
|
|
|
|
2022-05-09 14:53:52 +02:00
|
|
|
set(LIB_FSFW_NAME fsfw)
|
2022-05-13 13:21:01 +02:00
|
|
|
project(${LIB_FSFW_NAME}
|
|
|
|
VERSION ${FSFW_VERSION}.${FSFW_SUBVERSION}.${FSFW_REVISION})
|
2022-05-09 14:53:52 +02:00
|
|
|
|
|
|
|
if(NOT CMAKE_CXX_STANDARD)
|
2022-05-09 15:54:29 +02:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
2022-05-09 15:07:46 +02:00
|
|
|
elseif(${CMAKE_CXX_STANDARD} LESS 17)
|
2022-05-13 13:21:01 +02:00
|
|
|
message(
|
|
|
|
FATAL_ERROR
|
|
|
|
"${MSG_PREFIX} Compiling the FSFW requires a minimum of C++17 support")
|
2022-05-09 14:53:52 +02:00
|
|
|
endif()
|
|
|
|
|
2022-05-10 12:16:38 +02:00
|
|
|
set(FSFW_SOURCES_DIR "${CMAKE_SOURCE_DIR}/src/fsfw")
|
2022-03-28 20:53:39 +02:00
|
|
|
|
2022-05-10 11:19:29 +02:00
|
|
|
set(FSFW_ETL_LIB_NAME etl)
|
2022-07-04 10:27:14 +02:00
|
|
|
set(FSFW_ETL_LINK_TARGET etl::etl)
|
2022-05-12 17:27:39 +02:00
|
|
|
set(FSFW_ETL_LIB_MAJOR_VERSION
|
|
|
|
20
|
|
|
|
CACHE STRING "ETL library major version requirement")
|
|
|
|
set(FSFW_ETL_LIB_VERSION
|
2022-05-30 10:34:03 +02:00
|
|
|
${FSFW_ETL_LIB_MAJOR_VERSION}.28.0
|
2022-05-12 17:27:39 +02:00
|
|
|
CACHE STRING "ETL library exact version requirement")
|
2022-04-27 09:16:52 +02:00
|
|
|
set(FSFW_ETL_LINK_TARGET etl::etl)
|
2022-03-28 20:53:39 +02:00
|
|
|
|
2022-05-12 17:27:39 +02:00
|
|
|
set(FSFW_CATCH2_LIB_MAJOR_VERSION
|
|
|
|
3
|
|
|
|
CACHE STRING "Catch2 library major version requirement")
|
|
|
|
set(FSFW_CATCH2_LIB_VERSION
|
|
|
|
v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5
|
|
|
|
CACHE STRING "Catch2 library exact version requirement")
|
|
|
|
|
|
|
|
# Keep this off by default for now. See PR:
|
|
|
|
# https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/616 for information which
|
|
|
|
# keeping this on by default is problematic
|
|
|
|
option(
|
|
|
|
FSFW_ENABLE_IPO
|
|
|
|
"Enable interprocedural optimization or link-time optimization if available"
|
|
|
|
OFF)
|
2022-05-10 11:56:51 +02:00
|
|
|
if(FSFW_ENABLE_IPO)
|
2022-05-10 13:08:14 +02:00
|
|
|
include(CheckIPOSupported)
|
|
|
|
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR)
|
|
|
|
if(NOT IPO_SUPPORTED)
|
|
|
|
message(STATUS "FSFW | IPO/LTO not supported: ${IPO_ERROR}")
|
|
|
|
endif()
|
2022-05-10 11:56:51 +02:00
|
|
|
endif()
|
2021-12-01 11:04:24 +01:00
|
|
|
|
2021-03-25 18:48:00 +01:00
|
|
|
option(FSFW_GENERATE_SECTIONS
|
2022-05-12 17:27:39 +02:00
|
|
|
"Generate function and data sections. Required to remove unused code" ON)
|
2021-03-25 18:48:00 +01:00
|
|
|
if(FSFW_GENERATE_SECTIONS)
|
2022-05-10 11:19:29 +02:00
|
|
|
option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON)
|
2021-03-25 18:48:00 +01:00
|
|
|
endif()
|
|
|
|
|
2022-07-18 16:08:06 +02:00
|
|
|
option(FSFW_BUILD_TESTS "Build unittest binary in addition to static library"
|
|
|
|
OFF)
|
2022-05-09 15:26:38 +02:00
|
|
|
option(FSFW_CICD_BUILD "Build for CI/CD. This can disable problematic test" OFF)
|
2021-12-01 11:04:24 +01:00
|
|
|
option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF)
|
2022-07-18 11:58:55 +02:00
|
|
|
if(FSFW_BUILD_TESTS)
|
2022-05-10 11:19:29 +02:00
|
|
|
option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON)
|
2021-10-07 13:24:46 +02:00
|
|
|
endif()
|
|
|
|
|
2021-01-19 16:30:17 +01:00
|
|
|
option(FSFW_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON)
|
|
|
|
# Options to exclude parts of the FSFW from compilation.
|
2021-07-14 10:22:58 +02:00
|
|
|
option(FSFW_ADD_INTERNAL_TESTS "Add internal unit tests" ON)
|
2021-08-16 10:49:07 +02:00
|
|
|
option(FSFW_ADD_UNITTESTS "Add regular unittests. Requires Catch2" OFF)
|
2021-07-30 13:47:29 +02:00
|
|
|
option(FSFW_ADD_HAL "Add Hardware Abstraction Layer" ON)
|
2021-07-19 18:26:54 +02:00
|
|
|
|
2022-08-12 13:02:30 +02:00
|
|
|
if(UNIX)
|
2022-08-15 11:26:29 +02:00
|
|
|
option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add Linux peripheral drivers"
|
|
|
|
OFF)
|
|
|
|
option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Attempt to add Linux GPIOD drivers" OFF)
|
2022-08-12 13:02:30 +02:00
|
|
|
endif()
|
|
|
|
|
2021-07-19 18:26:54 +02:00
|
|
|
# Optional sources
|
|
|
|
option(FSFW_ADD_PUS "Compile with PUS sources" ON)
|
|
|
|
option(FSFW_ADD_MONITORING "Compile with monitoring components" ON)
|
|
|
|
|
|
|
|
option(FSFW_ADD_RMAP "Compile with RMAP" OFF)
|
|
|
|
option(FSFW_ADD_DATALINKLAYER "Compile with Data Link Layer" OFF)
|
|
|
|
option(FSFW_ADD_COORDINATES "Compile with coordinate components" OFF)
|
|
|
|
option(FSFW_ADD_TMSTORAGE "Compile with tm storage components" OFF)
|
|
|
|
|
|
|
|
# Contrib sources
|
2021-08-02 15:47:12 +02:00
|
|
|
option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF)
|
2021-01-19 16:30:17 +01:00
|
|
|
|
2021-10-07 13:24:46 +02:00
|
|
|
set(FSFW_TEST_TGT fsfw-tests)
|
2021-12-01 11:04:24 +01:00
|
|
|
set(FSFW_DUMMY_TGT fsfw-dummy)
|
2021-10-07 13:24:46 +02:00
|
|
|
|
2020-12-07 01:40:10 +01:00
|
|
|
add_library(${LIB_FSFW_NAME})
|
2021-10-07 13:24:46 +02:00
|
|
|
|
2022-05-09 02:23:20 +02:00
|
|
|
if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
|
2022-05-12 17:27:39 +02:00
|
|
|
set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION
|
|
|
|
TRUE)
|
2022-05-09 02:23:20 +02:00
|
|
|
endif()
|
|
|
|
|
2022-07-18 11:58:55 +02:00
|
|
|
if(FSFW_BUILD_TESTS)
|
2022-05-12 17:27:39 +02:00
|
|
|
message(
|
2022-05-13 13:21:01 +02:00
|
|
|
STATUS
|
|
|
|
"${MSG_PREFIX} Building the FSFW unittests in addition to the static library"
|
|
|
|
)
|
2022-05-09 11:18:56 +02:00
|
|
|
# Check whether the user has already installed Catch2 first
|
|
|
|
find_package(Catch2 ${FSFW_CATCH2_LIB_MAJOR_VERSION})
|
|
|
|
# Not installed, so use FetchContent to download and provide Catch2
|
|
|
|
if(NOT Catch2_FOUND)
|
2022-05-12 17:27:39 +02:00
|
|
|
message(
|
|
|
|
STATUS
|
2022-05-13 13:21:01 +02:00
|
|
|
"${MSG_PREFIX} Catch2 installation not found. Downloading Catch2 library with FetchContent"
|
2022-05-12 17:27:39 +02:00
|
|
|
)
|
2022-05-09 11:18:56 +02:00
|
|
|
include(FetchContent)
|
2021-10-07 13:24:46 +02:00
|
|
|
|
2022-05-09 11:18:56 +02:00
|
|
|
FetchContent_Declare(
|
|
|
|
Catch2
|
|
|
|
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
2022-05-12 17:27:39 +02:00
|
|
|
GIT_TAG ${FSFW_CATCH2_LIB_VERSION})
|
2021-10-11 16:16:49 +02:00
|
|
|
|
2022-05-09 11:18:56 +02:00
|
|
|
list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2)
|
|
|
|
endif()
|
2021-10-07 13:24:46 +02:00
|
|
|
|
2022-07-18 11:58:55 +02:00
|
|
|
set(FSFW_CONFIG_PATH unittests/testcfg)
|
2022-07-18 11:47:00 +02:00
|
|
|
configure_file(unittests/testcfg/FSFWConfig.h.in FSFWConfig.h)
|
|
|
|
configure_file(unittests/testcfg/TestsConfig.h.in tests/TestsConfig.h)
|
2021-10-07 13:24:46 +02:00
|
|
|
|
2022-05-09 11:18:56 +02:00
|
|
|
project(${FSFW_TEST_TGT} CXX C)
|
|
|
|
add_executable(${FSFW_TEST_TGT})
|
2022-05-12 17:16:10 +02:00
|
|
|
if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
|
2022-05-12 17:27:39 +02:00
|
|
|
set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION
|
|
|
|
TRUE)
|
2022-05-12 17:16:10 +02:00
|
|
|
endif()
|
2022-05-09 11:18:56 +02:00
|
|
|
|
|
|
|
if(FSFW_TESTS_GEN_COV)
|
2022-05-13 13:21:01 +02:00
|
|
|
message(STATUS "${MSG_PREFIX} Generating coverage data for the library")
|
|
|
|
message(STATUS "${MSG_PREFIX} Targets linking against ${LIB_FSFW_NAME} "
|
2022-05-12 17:27:39 +02:00
|
|
|
"will be compiled with coverage data as well")
|
2022-05-09 11:18:56 +02:00
|
|
|
set(CMAKE_BUILD_TYPE "Debug")
|
|
|
|
include(CodeCoverage)
|
|
|
|
endif()
|
2021-10-07 13:24:46 +02:00
|
|
|
endif()
|
|
|
|
|
2022-08-12 13:02:30 +02:00
|
|
|
message(
|
|
|
|
STATUS
|
|
|
|
"${MSG_PREFIX} Finding and/or providing etl library with version ${FSFW_ETL_LIB_MAJOR_VERSION}"
|
|
|
|
)
|
2022-04-11 16:44:20 +02:00
|
|
|
|
2022-03-28 21:10:51 +02:00
|
|
|
# Check whether the user has already installed ETL first
|
2022-05-30 10:45:23 +02:00
|
|
|
find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET)
|
2022-03-28 20:16:11 +02:00
|
|
|
# Not installed, so use FetchContent to download and provide etl
|
2022-04-27 09:16:52 +02:00
|
|
|
if(NOT ${FSFW_ETL_LIB_NAME}_FOUND)
|
2022-05-12 17:27:39 +02:00
|
|
|
message(
|
|
|
|
STATUS
|
2022-08-12 13:02:30 +02:00
|
|
|
"${MSG_PREFIX} No ETL installation was found with find_package. Installing and providing "
|
2022-05-12 17:27:39 +02:00
|
|
|
"etl with FindPackage")
|
2022-05-09 11:18:56 +02:00
|
|
|
include(FetchContent)
|
2022-04-27 09:08:17 +02:00
|
|
|
|
2022-05-09 11:18:56 +02:00
|
|
|
FetchContent_Declare(
|
|
|
|
${FSFW_ETL_LIB_NAME}
|
|
|
|
GIT_REPOSITORY https://github.com/ETLCPP/etl
|
2022-05-12 17:27:39 +02:00
|
|
|
GIT_TAG ${FSFW_ETL_LIB_VERSION})
|
2022-04-27 09:08:17 +02:00
|
|
|
|
2022-05-09 11:18:56 +02:00
|
|
|
list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_ETL_LIB_NAME})
|
2022-04-27 21:53:57 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# The documentation for FetchContent recommends declaring all the dependencies
|
|
|
|
# before making them available. We make all declared dependency available here
|
|
|
|
# after their declaration
|
|
|
|
if(FSFW_FETCH_CONTENT_TARGETS)
|
2022-05-09 11:18:56 +02:00
|
|
|
FetchContent_MakeAvailable(${FSFW_FETCH_CONTENT_TARGETS})
|
|
|
|
if(TARGET ${FSFW_ETL_LIB_NAME})
|
|
|
|
add_library(${FSFW_ETL_LINK_TARGET} ALIAS ${FSFW_ETL_LIB_NAME})
|
|
|
|
endif()
|
|
|
|
if(TARGET Catch2)
|
2022-05-12 17:27:39 +02:00
|
|
|
# Fixes regression -preview4, to be confirmed in later releases Related
|
|
|
|
# GitHub issue: https://github.com/catchorg/Catch2/issues/2417
|
2022-05-09 11:18:56 +02:00
|
|
|
set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "")
|
|
|
|
endif()
|
2022-04-27 09:16:52 +02:00
|
|
|
endif()
|
2022-03-28 20:16:11 +02:00
|
|
|
|
2021-07-13 20:22:54 +02:00
|
|
|
set(FSFW_CORE_INC_PATH "inc")
|
2020-12-07 01:40:10 +01:00
|
|
|
|
2021-07-13 18:53:07 +02:00
|
|
|
set_property(CACHE FSFW_OSAL PROPERTY STRINGS host linux rtems freertos)
|
2020-12-07 12:59:09 +01:00
|
|
|
|
2022-01-18 18:47:29 +01:00
|
|
|
# For configure files
|
2022-05-12 17:27:39 +02:00
|
|
|
target_include_directories(${LIB_FSFW_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
target_include_directories(${LIB_FSFW_NAME}
|
|
|
|
INTERFACE ${CMAKE_CURRENT_BINARY_DIR})
|
2021-05-27 11:56:52 +02:00
|
|
|
|
2021-07-13 18:58:31 +02:00
|
|
|
# Backwards comptability
|
2021-08-16 15:19:03 +02:00
|
|
|
if(OS_FSFW AND NOT FSFW_OSAL)
|
2022-05-13 13:21:01 +02:00
|
|
|
message(
|
|
|
|
WARNING
|
|
|
|
"${MSG_PREFIX} Please pass the FSFW OSAL as FSFW_OSAL instead of OS_FSFW")
|
2022-05-09 11:18:56 +02:00
|
|
|
set(FSFW_OSAL OS_FSFW)
|
2021-07-13 18:58:31 +02:00
|
|
|
endif()
|
|
|
|
|
2021-07-13 18:53:07 +02:00
|
|
|
if(NOT FSFW_OSAL)
|
2022-05-09 11:18:56 +02:00
|
|
|
message(STATUS "No OS for FSFW via FSFW_OSAL set. Assuming host OS")
|
|
|
|
# Assume host OS and autodetermine from OS_FSFW
|
|
|
|
if(UNIX)
|
2022-05-12 17:27:39 +02:00
|
|
|
set(FSFW_OSAL
|
|
|
|
"linux"
|
|
|
|
CACHE STRING "OS abstraction layer used in the FSFW")
|
2022-05-09 11:18:56 +02:00
|
|
|
elseif(WIN32)
|
2022-05-12 17:27:39 +02:00
|
|
|
set(FSFW_OSAL
|
|
|
|
"host"
|
|
|
|
CACHE STRING "OS abstraction layer used in the FSFW")
|
2022-05-09 11:18:56 +02:00
|
|
|
endif()
|
2020-12-17 20:18:16 +01:00
|
|
|
endif()
|
2020-12-17 11:46:50 +01:00
|
|
|
|
2021-07-14 10:22:58 +02:00
|
|
|
set(FSFW_OSAL_DEFINITION FSFW_OSAL_HOST)
|
2021-03-27 21:27:46 +01:00
|
|
|
|
2021-07-13 18:52:19 +02:00
|
|
|
if(FSFW_OSAL MATCHES host)
|
2022-05-09 11:18:56 +02:00
|
|
|
set(FSFW_OS_NAME "Host")
|
|
|
|
set(FSFW_OSAL_HOST ON)
|
2021-07-13 18:52:19 +02:00
|
|
|
elseif(FSFW_OSAL MATCHES linux)
|
2022-05-09 11:18:56 +02:00
|
|
|
set(FSFW_OS_NAME "Linux")
|
|
|
|
set(FSFW_OSAL_LINUX ON)
|
2021-07-13 18:52:19 +02:00
|
|
|
elseif(FSFW_OSAL MATCHES freertos)
|
2022-05-09 11:18:56 +02:00
|
|
|
set(FSFW_OS_NAME "FreeRTOS")
|
|
|
|
set(FSFW_OSAL_FREERTOS ON)
|
2022-05-12 17:27:39 +02:00
|
|
|
target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${LIB_OS_NAME})
|
2021-07-13 18:52:19 +02:00
|
|
|
elseif(FSFW_OSAL STREQUAL rtems)
|
2022-05-09 11:18:56 +02:00
|
|
|
set(FSFW_OS_NAME "RTEMS")
|
|
|
|
set(FSFW_OSAL_RTEMS ON)
|
2020-12-07 12:59:09 +01:00
|
|
|
else()
|
2022-05-12 17:27:39 +02:00
|
|
|
message(
|
2022-05-13 13:21:01 +02:00
|
|
|
WARNING
|
|
|
|
"${MSG_PREFIX} Invalid operating system for FSFW specified! Setting to host.."
|
|
|
|
)
|
2022-05-09 11:18:56 +02:00
|
|
|
set(FSFW_OS_NAME "Host")
|
|
|
|
set(OS_FSFW "host")
|
2020-12-07 12:59:09 +01:00
|
|
|
endif()
|
|
|
|
|
2022-01-18 18:29:54 +01:00
|
|
|
configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h)
|
|
|
|
configure_file(src/fsfw/FSFWVersion.h.in fsfw/FSFWVersion.h)
|
2021-10-27 17:10:37 +02:00
|
|
|
|
2022-05-13 13:21:01 +02:00
|
|
|
message(
|
|
|
|
STATUS "${MSG_PREFIX} Compiling FSFW for the ${FSFW_OS_NAME} operating system"
|
|
|
|
)
|
2020-12-07 12:59:09 +01:00
|
|
|
|
2021-07-13 18:52:19 +02:00
|
|
|
add_subdirectory(src)
|
2021-07-14 11:03:42 +02:00
|
|
|
add_subdirectory(contrib)
|
2022-07-18 11:58:55 +02:00
|
|
|
if(FSFW_BUILD_TESTS)
|
|
|
|
add_subdirectory(unittests)
|
|
|
|
endif()
|
2021-12-01 11:04:24 +01:00
|
|
|
if(FSFW_BUILD_DOCS)
|
2022-05-09 11:18:56 +02:00
|
|
|
add_subdirectory(docs)
|
2021-12-01 11:04:24 +01:00
|
|
|
endif()
|
2020-12-07 01:40:10 +01:00
|
|
|
|
2022-07-18 11:58:55 +02:00
|
|
|
if(FSFW_BUILD_TESTS)
|
2022-05-09 11:18:56 +02:00
|
|
|
if(FSFW_TESTS_GEN_COV)
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
include(CodeCoverage)
|
|
|
|
|
|
|
|
# Remove quotes.
|
2022-05-12 17:27:39 +02:00
|
|
|
separate_arguments(COVERAGE_COMPILER_FLAGS NATIVE_COMMAND
|
|
|
|
"${COVERAGE_COMPILER_FLAGS}")
|
2022-05-09 11:18:56 +02:00
|
|
|
|
|
|
|
# Add compile options manually, we don't want coverage for Catch2
|
2022-05-12 17:27:39 +02:00
|
|
|
target_compile_options(${FSFW_TEST_TGT}
|
|
|
|
PRIVATE "${COVERAGE_COMPILER_FLAGS}")
|
|
|
|
target_compile_options(${LIB_FSFW_NAME}
|
|
|
|
PRIVATE "${COVERAGE_COMPILER_FLAGS}")
|
2022-05-09 11:18:56 +02:00
|
|
|
|
|
|
|
# Exclude directories here
|
|
|
|
if(WIN32)
|
2022-05-12 17:27:39 +02:00
|
|
|
set(GCOVR_ADDITIONAL_ARGS "--exclude-throw-branches"
|
|
|
|
"--exclude-unreachable-branches")
|
|
|
|
set(COVERAGE_EXCLUDES "/c/msys64/mingw64/*" "*/fsfw_hal/*")
|
2022-05-09 11:18:56 +02:00
|
|
|
elseif(UNIX)
|
|
|
|
set(COVERAGE_EXCLUDES
|
2022-05-12 17:27:39 +02:00
|
|
|
"/usr/include/*"
|
|
|
|
"/usr/bin/*"
|
|
|
|
"Catch2/*"
|
|
|
|
"/usr/local/include/*"
|
|
|
|
"*/fsfw_tests/*"
|
|
|
|
"*/catch2-src/*"
|
|
|
|
"*/fsfw_hal/*")
|
2022-05-09 11:18:56 +02:00
|
|
|
endif()
|
|
|
|
|
2022-05-12 17:27:39 +02:00
|
|
|
target_link_options(${FSFW_TEST_TGT} PRIVATE -fprofile-arcs
|
|
|
|
-ftest-coverage)
|
|
|
|
target_link_options(${LIB_FSFW_NAME} PRIVATE -fprofile-arcs
|
|
|
|
-ftest-coverage)
|
|
|
|
# Need to specify this as an interface, otherwise there will the compile
|
|
|
|
# issues
|
|
|
|
target_link_options(${LIB_FSFW_NAME} INTERFACE -fprofile-arcs
|
|
|
|
-ftest-coverage)
|
2022-05-09 11:18:56 +02:00
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
setup_target_for_coverage_gcovr_html(
|
2022-05-12 17:27:39 +02:00
|
|
|
NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT}
|
|
|
|
DEPENDENCIES ${FSFW_TEST_TGT})
|
2022-05-09 11:18:56 +02:00
|
|
|
else()
|
|
|
|
setup_target_for_coverage_lcov(
|
2022-05-12 17:27:39 +02:00
|
|
|
NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT}
|
|
|
|
DEPENDENCIES ${FSFW_TEST_TGT})
|
2022-05-09 11:18:56 +02:00
|
|
|
endif()
|
2021-10-07 13:24:46 +02:00
|
|
|
endif()
|
2022-05-09 11:18:56 +02:00
|
|
|
endif()
|
2022-05-12 17:27:39 +02:00
|
|
|
target_link_libraries(${FSFW_TEST_TGT} PRIVATE Catch2::Catch2
|
|
|
|
${LIB_FSFW_NAME})
|
2021-10-07 13:24:46 +02:00
|
|
|
endif()
|
|
|
|
|
2022-05-12 17:27:39 +02:00
|
|
|
# The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it. If
|
|
|
|
# this is not given, we include the default configuration and emit a warning.
|
2020-12-07 01:40:10 +01:00
|
|
|
if(NOT FSFW_CONFIG_PATH)
|
2022-05-09 11:18:56 +02:00
|
|
|
set(DEF_CONF_PATH misc/defaultcfg/fsfwconfig)
|
|
|
|
if(NOT FSFW_BUILD_DOCS)
|
2022-05-13 13:21:01 +02:00
|
|
|
message(
|
|
|
|
WARNING
|
|
|
|
"${MSG_PREFIX} Flight Software Framework configuration path not set")
|
|
|
|
message(
|
|
|
|
WARNING
|
|
|
|
"${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..")
|
2022-05-09 11:18:56 +02:00
|
|
|
endif()
|
|
|
|
add_subdirectory(${DEF_CONF_PATH})
|
|
|
|
set(FSFW_CONFIG_PATH ${DEF_CONF_PATH})
|
2020-12-07 01:40:10 +01:00
|
|
|
endif()
|
|
|
|
|
2022-05-12 17:27:39 +02:00
|
|
|
# FSFW might be part of a possibly complicated folder structure, so we extract
|
|
|
|
# the absolute path of the fsfwconfig folder.
|
2020-12-19 02:29:22 +01:00
|
|
|
if(IS_ABSOLUTE ${FSFW_CONFIG_PATH})
|
2022-05-09 11:18:56 +02:00
|
|
|
set(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH})
|
2020-12-19 02:29:22 +01:00
|
|
|
else()
|
2022-05-12 17:27:39 +02:00
|
|
|
get_filename_component(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH} REALPATH
|
|
|
|
BASE_DIR ${CMAKE_SOURCE_DIR})
|
2020-12-19 02:29:22 +01:00
|
|
|
endif()
|
|
|
|
|
2021-05-31 16:46:32 +02:00
|
|
|
foreach(INCLUDE_PATH ${FSFW_ADDITIONAL_INC_PATHS})
|
2022-05-09 11:18:56 +02:00
|
|
|
if(IS_ABSOLUTE ${INCLUDE_PATH})
|
|
|
|
set(CURR_ABS_INC_PATH "${INCLUDE_PATH}")
|
|
|
|
else()
|
2022-05-12 17:27:39 +02:00
|
|
|
get_filename_component(CURR_ABS_INC_PATH ${INCLUDE_PATH} REALPATH BASE_DIR
|
|
|
|
${CMAKE_SOURCE_DIR})
|
2022-05-09 11:18:56 +02:00
|
|
|
endif()
|
2021-03-25 15:35:05 +01:00
|
|
|
|
2022-05-09 11:18:56 +02:00
|
|
|
if(CMAKE_VERBOSE)
|
|
|
|
message(STATUS "FSFW include path: ${CURR_ABS_INC_PATH}")
|
|
|
|
endif()
|
2021-03-25 15:35:05 +01:00
|
|
|
|
2022-05-09 11:18:56 +02:00
|
|
|
list(APPEND FSFW_ADD_INC_PATHS_ABS ${CURR_ABS_INC_PATH})
|
2021-03-25 15:35:05 +01:00
|
|
|
endforeach()
|
|
|
|
|
2021-01-13 11:47:04 +01:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
2022-05-09 11:18:56 +02:00
|
|
|
if(NOT DEFINED FSFW_WARNING_FLAGS)
|
|
|
|
set(FSFW_WARNING_FLAGS
|
2022-05-12 17:27:39 +02:00
|
|
|
-Wall
|
|
|
|
-Wextra
|
|
|
|
-Wimplicit-fallthrough=1
|
|
|
|
-Wno-unused-parameter
|
|
|
|
-Wno-psabi
|
|
|
|
-Wduplicated-cond # check for duplicate conditions
|
|
|
|
-Wduplicated-branches # check for duplicate branches
|
|
|
|
-Wlogical-op # Search for bitwise operations instead of logical
|
|
|
|
-Wnull-dereference # Search for NULL dereference
|
|
|
|
-Wundef # Warn if undefind marcos are used
|
|
|
|
-Wformat=2 # Format string problem detection
|
|
|
|
-Wformat-overflow=2 # Formatting issues in printf
|
|
|
|
-Wformat-truncation=2 # Formatting issues in printf
|
|
|
|
-Wformat-security # Search for dangerous printf operations
|
|
|
|
-Wstrict-overflow=3 # Warn if integer overflows might happen
|
|
|
|
-Warray-bounds=2 # Some array bounds violations will be found
|
|
|
|
-Wshift-overflow=2 # Search for bit left shift overflows (<c++14)
|
|
|
|
-Wcast-qual # Warn if the constness is cast away
|
|
|
|
-Wstringop-overflow=4
|
|
|
|
# -Wstack-protector # Emits a few false positives for low level access
|
|
|
|
# -Wconversion # Creates many false positives -Warith-conversion # Use
|
|
|
|
# with Wconversion to find more implicit conversions -fanalyzer # Should
|
|
|
|
# be used to look through problems
|
|
|
|
)
|
2022-05-09 11:18:56 +02:00
|
|
|
endif()
|
2021-03-25 18:48:00 +01:00
|
|
|
|
2022-05-09 11:18:56 +02:00
|
|
|
if(FSFW_GENERATE_SECTIONS)
|
2022-05-12 17:27:39 +02:00
|
|
|
target_compile_options(${LIB_FSFW_NAME} PRIVATE "-ffunction-sections"
|
|
|
|
"-fdata-sections")
|
2022-05-09 11:18:56 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(FSFW_REMOVE_UNUSED_CODE)
|
2022-05-12 17:27:39 +02:00
|
|
|
target_link_options(${LIB_FSFW_NAME} PRIVATE "Wl,--gc-sections")
|
2022-05-09 11:18:56 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(FSFW_WARNING_SHADOW_LOCAL_GCC)
|
|
|
|
list(APPEND WARNING_FLAGS "-Wshadow=local")
|
|
|
|
endif()
|
2021-03-25 18:48:00 +01:00
|
|
|
|
2020-12-20 15:32:03 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
2022-05-09 11:18:56 +02:00
|
|
|
set(COMPILER_FLAGS "/permissive-")
|
2020-12-20 15:32:03 +01:00
|
|
|
endif()
|
2020-12-20 13:21:12 +01:00
|
|
|
|
2020-12-07 01:40:10 +01:00
|
|
|
# Required include paths to compile the FSFW
|
2022-05-12 17:27:39 +02:00
|
|
|
target_include_directories(
|
|
|
|
${LIB_FSFW_NAME} INTERFACE ${CMAKE_SOURCE_DIR} ${FSFW_CONFIG_PATH_ABSOLUTE}
|
|
|
|
${FSFW_CORE_INC_PATH} ${FSFW_ADD_INC_PATHS_ABS})
|
|
|
|
|
|
|
|
# Includes path required to compile FSFW itself as well We assume that the
|
|
|
|
# fsfwconfig folder uses include relative to the project root here!
|
|
|
|
target_include_directories(
|
|
|
|
${LIB_FSFW_NAME} PRIVATE ${CMAKE_SOURCE_DIR} ${FSFW_CONFIG_PATH_ABSOLUTE}
|
|
|
|
${FSFW_CORE_INC_PATH} ${FSFW_ADD_INC_PATHS_ABS})
|
|
|
|
|
|
|
|
target_compile_options(${LIB_FSFW_NAME} PRIVATE ${FSFW_WARNING_FLAGS}
|
|
|
|
${COMPILER_FLAGS})
|
|
|
|
|
2022-07-04 10:27:14 +02:00
|
|
|
target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${FSFW_ADDITIONAL_LINK_LIBS})
|
|
|
|
target_link_libraries(${LIB_FSFW_NAME} PUBLIC ${FSFW_ETL_LINK_TARGET})
|
2022-05-12 17:27:39 +02:00
|
|
|
|
|
|
|
string(
|
|
|
|
CONCAT
|
|
|
|
POST_BUILD_COMMENT
|
2021-10-07 14:20:34 +02:00
|
|
|
"######################################################################\n"
|
2021-10-11 16:06:12 +02:00
|
|
|
"Built FSFW v${FSFW_VERSION}.${FSFW_SUBVERSION}.${FSFW_REVISION}, "
|
2021-10-07 14:20:34 +02:00
|
|
|
"Target OSAL: ${FSFW_OS_NAME}\n"
|
2022-05-12 17:27:39 +02:00
|
|
|
"######################################################################\n")
|
2021-10-07 14:20:34 +02:00
|
|
|
|
|
|
|
add_custom_command(
|
2022-05-09 11:18:56 +02:00
|
|
|
TARGET ${LIB_FSFW_NAME}
|
|
|
|
POST_BUILD
|
2022-05-12 17:27:39 +02:00
|
|
|
COMMENT ${POST_BUILD_COMMENT})
|