fsfw-hal/CMakeLists.txt

65 lines
1.5 KiB
CMake
Raw Normal View History

2021-03-23 15:30:45 +01:00
cmake_minimum_required(VERSION 3.13)
2021-03-23 17:46:39 +01:00
# Can also be changed by upper CMakeLists.txt file
find_library(LIB_FSFW_NAME fsfw REQUIRED)
2021-03-23 16:13:09 +01:00
option(FSFW_HAL_ADD_LINUX "Add the Linux HAL to the sources. Required gpiod library" OFF)
option(FSFW_HAL_ADD_RASPBERRY_PI "Add Raspberry Pi specific code to the sources" OFF)
option(FSFW_HAL_ADD_STM32H7 "Add the STM32H7 HAL to the sources" OFF)
2021-04-01 10:59:23 +02:00
option(FSFW_HAL_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON)
2021-03-23 15:30:45 +01:00
set(LIB_FSFW_HAL_NAME fsfw_hal)
2021-03-23 15:35:58 +01:00
set(LINUX_HAL_PATH_NAME linux)
2021-03-23 15:30:45 +01:00
set(STM32H7_PATH_NAME stm32h7)
add_library(${LIB_FSFW_HAL_NAME})
if(NOT LIB_FSFW_NAME)
message(ERROR "LIB_FSFW_NAME needs to be set as a linkable target")
endif()
add_subdirectory(common)
2021-03-23 15:30:45 +01:00
2021-03-23 16:13:09 +01:00
if(FSFW_HAL_ADD_LINUX)
2021-03-23 15:35:58 +01:00
add_subdirectory(${LINUX_HAL_PATH_NAME})
2021-03-23 15:30:45 +01:00
endif()
2021-03-23 16:13:09 +01:00
if(FSFW_HAL_ADD_STM32H7)
2021-03-23 15:30:45 +01:00
add_subdirectory(${STM32H7_PATH_NAME})
endif()
target_link_libraries(${LIB_FSFW_HAL_NAME} PRIVATE
2021-03-23 15:30:45 +01:00
${LIB_FSFW_NAME}
)
2021-04-01 10:59:23 +02:00
2021-04-01 16:20:10 +02:00
target_include_directories(${LIB_FSFW_HAL_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)
2021-04-01 10:59:23 +02:00
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(NOT DEFINED FSFW_WARNING_FLAGS)
set(FSFW_WARNING_FLAGS
-Wall
-Wextra
-Wimplicit-fallthrough=1
-Wno-unused-parameter
)
endif()
target_compile_options(${LIB_FSFW_NAME} PRIVATE
"-ffunction-sections"
"-fdata-sections"
)
target_link_options(${LIB_FSFW_NAME} PRIVATE
"Wl,--gc-sections"
)
if(FSFW_HAL_WARNING_SHADOW_LOCAL_GCC)
list(APPEND WARNING_FLAGS "-Wshadow=local")
endif()
endif()