forked from ROMEO/obsw
further cleanup
This commit is contained in:
120
CMakeLists.txt
120
CMakeLists.txt
@ -3,25 +3,21 @@ cmake_minimum_required(VERSION 3.13)
|
||||
# Project Name
|
||||
project(romeo-obsw C ASM)
|
||||
|
||||
# ##############################################################################
|
||||
# Pre-Sources preparation
|
||||
# ##############################################################################
|
||||
|
||||
|
||||
|
||||
# Set names and variables
|
||||
set(TARGET_NAME ${CMAKE_PROJECT_NAME})
|
||||
|
||||
# Set path names
|
||||
set(OBSW_NAME romeo-obsw)
|
||||
set(FreeRTOS_PATH FreeRTOS-Kernel/)
|
||||
set(MISSION_PATH mission/)
|
||||
|
||||
# Compiler Options
|
||||
set(ROMEO_Z7_COMPILE_OPTIONS -c -fmessage-length=0 -g -O0 -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -ffunction-sections -fdata-sections)
|
||||
set(ROMEO_LINUX_COMPILE_OPTIONS -c -fmessage-length=0 -g -O0 -ffunction-sections -fdata-sections)
|
||||
set(ROMEO_Z7_LINK_OPTIONS -Wl,--cref -Wl,-Map=${OBSW_NAME}.map -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -Wl,-build-id=none -T${CMAKE_SOURCE_DIR}/bsp_z7/freeRTOS/lscript.ld -specs=${CMAKE_SOURCE_DIR}/bsp_z7/freeRTOS/Xilinx.spec )
|
||||
set(ROMEO_WARNING_FLAGS
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
-Werror)
|
||||
|
||||
|
||||
# ##############################################################################
|
||||
# Configuration
|
||||
# ##############################################################################
|
||||
|
||||
# CMake options which are only available when crosscompiling
|
||||
if (${CMAKE_CROSSCOMPILING})
|
||||
set(ZYNQ_UART UART1 CACHE STRING "Which PS UART to use for stdout")
|
||||
set_property(CACHE ZYNQ_UART PROPERTY STRINGS UART0 UART1)
|
||||
@ -34,85 +30,95 @@ else()
|
||||
unset(ZYNQ_UART CACHE)
|
||||
endif()
|
||||
|
||||
# ##############################################################################
|
||||
# Executable and Sources
|
||||
# ##############################################################################
|
||||
# Add main executable
|
||||
add_executable(${OBSW_NAME})
|
||||
|
||||
# Add executable
|
||||
add_executable(${TARGET_NAME})
|
||||
|
||||
# lwip
|
||||
# export lwip path, so the bsp can find it
|
||||
if(${CMAKE_CROSSCOMPILING})
|
||||
set (LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/contrib/lwip)
|
||||
endif()
|
||||
|
||||
# Add freeRTOS
|
||||
|
||||
# Platform dependend configuration
|
||||
# Includes setting the FreeRTOS port, compiler options and
|
||||
# selecting the bsp
|
||||
if(${CMAKE_CROSSCOMPILING})
|
||||
#TODO: this somewhat hardcodes zynq as the only cross target
|
||||
set(FREERTOS_PORT GCC_ARM_CA9 CACHE STRING "")
|
||||
set(FREERTOS_HEAP 1 CACHE STRING "")
|
||||
|
||||
# config library for FreeRTOS
|
||||
add_library(freertos_config INTERFACE)
|
||||
|
||||
# The config file directory
|
||||
target_include_directories(freertos_config SYSTEM
|
||||
INTERFACE bsp_z7/freeRTOS) # The config file directory
|
||||
INTERFACE bsp_z7/freeRTOS)
|
||||
|
||||
# no coverage tests
|
||||
target_compile_definitions(freertos_config
|
||||
INTERFACE
|
||||
projCOVERAGE_TEST=0)
|
||||
|
||||
# FreeRTOS config depends on bsp headers
|
||||
target_include_directories(
|
||||
freertos_config INTERFACE bsp_z7/ps7_cortexa9_0/include)
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL armv7a-none-eabihf)
|
||||
# our compiler options, will trickle down through the project
|
||||
target_compile_options(freertos_config INTERFACE -c -fmessage-length=0 -g -O0 -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -ffunction-sections -fdata-sections)
|
||||
else()
|
||||
message(FATAL_ERROR "invalid architecture ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
# Compiler options, we set them on the FreeRTOS config, will trickle down from there
|
||||
target_compile_options(freertos_config INTERFACE ${ROMEO_Z7_COMPILE_OPTIONS})
|
||||
|
||||
# add the bsp
|
||||
add_subdirectory(bsp_z7)
|
||||
target_link_options(${TARGET_NAME} PRIVATE -Wl,--cref -Wl,-Map=${TARGET_NAME}.map -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -Wl,-build-id=none -T${CMAKE_SOURCE_DIR}/bsp_z7/freeRTOS/lscript.ld -specs=${CMAKE_SOURCE_DIR}/bsp_z7/freeRTOS/Xilinx.spec )
|
||||
|
||||
# Link options for cross build
|
||||
target_link_options(${OBSW_NAME} PRIVATE ${ROMEO_Z7_LINK_OPTIONS})
|
||||
else()
|
||||
# So far, only unix port supported when not crosscompiling
|
||||
set(FREERTOS_PORT GCC_POSIX CACHE STRING "")
|
||||
|
||||
# config library for FreeRTOS
|
||||
add_library(freertos_config INTERFACE)
|
||||
|
||||
# The config file directory
|
||||
target_include_directories(freertos_config SYSTEM
|
||||
INTERFACE bsp_linux/freeRTOS) # The config file directory
|
||||
target_compile_options(freertos_config INTERFACE -c -fmessage-length=0 -g -O0 -ffunction-sections -fdata-sections)
|
||||
INTERFACE bsp_linux/freeRTOS)
|
||||
|
||||
# Compiler options, we set them on the FreeRTOS config, will trickle down from there
|
||||
target_compile_options(freertos_config INTERFACE ${ROMEO_LINUX_COMPILE_OPTIONS})
|
||||
|
||||
# No coverage tests, no tracing
|
||||
target_compile_definitions(freertos_config
|
||||
INTERFACE
|
||||
projCOVERAGE_TEST=0
|
||||
projENABLE_TRACING=0)
|
||||
|
||||
# add the bsp
|
||||
add_subdirectory(bsp_linux)
|
||||
endif()
|
||||
|
||||
# Add FreeRTOS
|
||||
add_subdirectory(${FreeRTOS_PATH})
|
||||
|
||||
|
||||
# Common stuff that is not mission code, mostly code shared between bsps
|
||||
add_subdirectory(common)
|
||||
|
||||
add_subdirectory(${MISSION_PATH})
|
||||
# Mission code, in our case C glue between rust and bsp
|
||||
add_subdirectory(mission)
|
||||
|
||||
# The actual mission code, in rust, exported as library `mission_rust`
|
||||
add_subdirectory(mission_rust)
|
||||
|
||||
# We provide a firmware image for an interface board as part of the z7 build
|
||||
# This is a second executable, excluded from `all` builds
|
||||
if(${CMAKE_CROSSCOMPILING})
|
||||
add_subdirectory(sim_interface)
|
||||
endif()
|
||||
|
||||
# ##############################################################################
|
||||
# Post-Sources preparation
|
||||
# ##############################################################################
|
||||
# Link all libraries into the binary
|
||||
# bsp depends on FreeRTOS, so we do not need to link it again
|
||||
target_link_libraries(${OBSW_NAME} PUBLIC bsp mission_rust )
|
||||
|
||||
# Add libraries for all sources.
|
||||
if(${CMAKE_CROSSCOMPILING})
|
||||
|
||||
endif()
|
||||
|
||||
target_link_libraries(${TARGET_NAME} PUBLIC bsp mission_rust lwip )
|
||||
|
||||
# target_include_directories(
|
||||
# ${TARGET_NAME} PUBLIC ${BSP_PATH})
|
||||
# Common link options
|
||||
target_link_options(${OBSW_NAME} PRIVATE "-Wl,--gc-sections")
|
||||
|
||||
|
||||
# Removed unused sections.
|
||||
target_link_options(${TARGET_NAME} PRIVATE "-Wl,--gc-sections")
|
||||
|
||||
if(CMAKE_VERBOSE)
|
||||
message(STATUS "Warning flags: ${WARNING_FLAGS}")
|
||||
endif()
|
||||
|
||||
# Compile options for all sources.
|
||||
target_compile_options(${TARGET_NAME} PRIVATE ${WARNING_FLAGS})
|
||||
# Common compile options
|
||||
target_compile_options(${OBSW_NAME} PRIVATE ${ROMEO_WARNING_FLAGS})
|
Reference in New Issue
Block a user