2020-12-29 01:09:59 +01:00
|
|
|
################################################################################
|
|
|
|
# CMake support for the EIVE OBSW
|
|
|
|
#
|
|
|
|
# Developed in an effort to replace Make with a modern build system.
|
|
|
|
#
|
|
|
|
# Author: R. Mueller
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Pre-Project preparation
|
|
|
|
################################################################################
|
|
|
|
cmake_minimum_required(VERSION 3.13)
|
|
|
|
|
|
|
|
# set(CMAKE_VERBOSE TRUE)
|
|
|
|
|
|
|
|
set(CMAKE_SCRIPT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/buildsystem/cmake")
|
|
|
|
|
|
|
|
if(NOT OS_FSFW)
|
|
|
|
set(OS_FSFW host CACHE STRING "OS for the FSFW.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Perform steps like loading toolchain files where applicable.
|
|
|
|
include(${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake)
|
|
|
|
pre_project_config()
|
|
|
|
|
|
|
|
# Project Name
|
|
|
|
project(fsfw_example ASM C CXX)
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Pre-Sources preparation
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# Specify the C++ standard
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
|
|
|
|
# Set names and variables
|
|
|
|
set(TARGET_NAME ${CMAKE_PROJECT_NAME})
|
|
|
|
set(LIB_FSFW_NAME fsfw)
|
|
|
|
|
|
|
|
# Set path names
|
|
|
|
set(FSFW_PATH fsfw)
|
|
|
|
set(MISSION_PATH mission)
|
|
|
|
|
|
|
|
# Analyse different OS and architecture/target options, determine BSP_PATH,
|
|
|
|
# display information about compiler etc.
|
|
|
|
include (${CMAKE_SCRIPT_PATH}/HardwareOsPreConfig.cmake)
|
|
|
|
pre_source_hw_os_config()
|
|
|
|
|
2020-12-29 01:26:22 +01:00
|
|
|
if(${OS_FSFW} MATCHES linux)
|
|
|
|
set(FSFW_CONFIG_PATH "fsfwconfig")
|
|
|
|
else()
|
2020-12-29 01:09:59 +01:00
|
|
|
set(FSFW_CONFIG_PATH "${BSP_PATH}/fsfwconfig")
|
2020-12-29 01:26:22 +01:00
|
|
|
endif()
|
2020-12-29 01:09:59 +01:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Executable and Sources
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# Add executable
|
|
|
|
add_executable(${TARGET_NAME})
|
|
|
|
|
|
|
|
# Add subdirectories
|
2020-12-29 01:26:22 +01:00
|
|
|
if(${OS_FSFW} MATCHES linux)
|
|
|
|
add_subdirectory(${FSFW_CONFIG_PATH})
|
2020-12-29 01:09:59 +01:00
|
|
|
endif()
|
2020-12-29 01:26:22 +01:00
|
|
|
|
2020-12-29 01:09:59 +01:00
|
|
|
add_subdirectory(${BSP_PATH})
|
|
|
|
add_subdirectory(${FSFW_PATH})
|
|
|
|
add_subdirectory(${MISSION_PATH})
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Post-Sources preparation
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# Add libraries for all sources.
|
|
|
|
target_link_libraries(${TARGET_NAME} PRIVATE
|
|
|
|
${LIB_FSFW_NAME}
|
|
|
|
${LIB_OS_NAME}
|
|
|
|
)
|
|
|
|
|
|
|
|
# Add include paths for all sources.
|
|
|
|
target_include_directories(${TARGET_NAME} PRIVATE
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
${FSFW_CONFIG_PATH}
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
set(WARNING_FLAGS
|
|
|
|
-Wall
|
|
|
|
-Wextra
|
|
|
|
-Wshadow=local
|
|
|
|
-Wimplicit-fallthrough=1
|
|
|
|
-Wno-unused-parameter
|
|
|
|
-Wno-psabi
|
|
|
|
)
|
|
|
|
|
|
|
|
# Remove unused sections.
|
|
|
|
target_compile_options(${TARGET_NAME} PRIVATE
|
|
|
|
"-ffunction-sections"
|
|
|
|
"-fdata-sections"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Removed unused sections.
|
|
|
|
target_link_options(${TARGET_NAME} PRIVATE
|
|
|
|
"-Wl,--gc-sections"
|
|
|
|
)
|
|
|
|
|
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
|
|
|
set(COMPILER_FLAGS "/permissive-")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CMAKE_VERBOSE)
|
|
|
|
message(STATUS "Warning flags: ${WARNING_FLAGS}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
# Compile options for all sources.
|
|
|
|
target_compile_options(${TARGET_NAME} PRIVATE
|
|
|
|
${WARNING_FLAGS}
|
|
|
|
)
|
|
|
|
|
|
|
|
if(${CMAKE_CROSSCOMPILING})
|
|
|
|
include (${CMAKE_SCRIPT_PATH}/HardwareOsPostConfig.cmake)
|
|
|
|
post_source_hw_os_config()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT CMAKE_SIZE)
|
|
|
|
set(CMAKE_SIZE size)
|
|
|
|
if(WIN32)
|
|
|
|
set(FILE_SUFFIX ".exe")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(TGT_BSP)
|
|
|
|
set(TARGET_STRING "Target BSP: ${TGT_BSP}")
|
|
|
|
else()
|
|
|
|
set(TARGET_STRING "Target BSP: Hosted")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
TARGET ${TARGET_NAME}
|
|
|
|
POST_BUILD
|
|
|
|
COMMAND echo "Build directory: ${CMAKE_BINARY_DIR}"
|
|
|
|
COMMAND echo "Target OSAL: ${OS_FSFW}"
|
|
|
|
COMMAND echo "Target Build Type: ${CMAKE_BUILD_TYPE}"
|
|
|
|
COMMAND echo "${TARGET_STRING}"
|
|
|
|
COMMAND ${CMAKE_SIZE} ${TARGET_NAME}${FILE_SUFFIX}
|
|
|
|
)
|
|
|
|
|
|
|
|
include (${CMAKE_SCRIPT_PATH}/BuildType.cmake)
|
|
|
|
set_build_type()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|