forked from ROMEO/obsw
- Project name is now romeo-obsw - ZYNQ_UART selects which Zynq PS UART is used for stdio
113 lines
3.4 KiB
CMake
113 lines
3.4 KiB
CMake
cmake_minimum_required(VERSION 3.13)
|
|
|
|
# Project Name
|
|
project(romeo-obsw C CXX ASM)
|
|
|
|
|
|
# ##############################################################################
|
|
# Pre-Sources preparation
|
|
# ##############################################################################
|
|
|
|
|
|
|
|
# Specify the C++ standard
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
# Set names and variables
|
|
set(TARGET_NAME ${CMAKE_PROJECT_NAME})
|
|
|
|
# Set path names
|
|
set(FreeRTOS_PATH FreeRTOS-Kernel/)
|
|
set(MISSION_PATH mission/)
|
|
set(FreeRTOS_CONFIG_PATH bsp_z7/freeRTOS)
|
|
set(BSP_PATH bsp_z7)
|
|
|
|
set (LWIP_DIR contrib/lwip)
|
|
|
|
|
|
# ##############################################################################
|
|
# Configuration
|
|
# ##############################################################################
|
|
|
|
set(ZYNQ_UART UART1 CACHE STRING "Which PS UART to use for stdout")
|
|
set_property(CACHE ZYNQ_UART PROPERTY STRINGS UART0 UART1)
|
|
|
|
if(${ZYNQ_UART} STREQUAL UART0)
|
|
add_compile_definitions(ZYNQ_USE_UART0)
|
|
endif()
|
|
|
|
|
|
# ##############################################################################
|
|
# Executable and Sources
|
|
# ##############################################################################
|
|
|
|
# Add executable
|
|
add_executable(${TARGET_NAME})
|
|
|
|
# lwip
|
|
set (LWIP_INCLUDE_DIRS
|
|
"${LWIP_DIR}/src/include"
|
|
"${BSP_PATH}/lwip"
|
|
)
|
|
include(${LWIP_DIR}/src/Filelists.cmake)
|
|
set(lwip_SRCS
|
|
${lwipcore_SRCS}
|
|
${lwipcore4_SRCS}
|
|
${lwipcore6_SRCS}
|
|
${LWIP_DIR}/src/netif/slipif.c
|
|
${LWIP_DIR}/src/apps/tftp/tftp.c
|
|
)
|
|
add_library(lwip ${lwip_SRCS})
|
|
target_include_directories(lwip PUBLIC ${LWIP_INCLUDE_DIRS})
|
|
|
|
#target_compile_options(${TARGET_NAME} PUBLIC -g -O0 -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard)
|
|
|
|
# Add freeRTOS
|
|
set(FREERTOS_PORT GCC_ARM_CA9 CACHE STRING "")
|
|
set(FREERTOS_HEAP 1 CACHE STRING "")
|
|
add_library(freertos_config INTERFACE)
|
|
target_include_directories(freertos_config SYSTEM
|
|
INTERFACE ${FreeRTOS_CONFIG_PATH}) # The config file directory
|
|
target_compile_definitions(freertos_config
|
|
INTERFACE
|
|
projCOVERAGE_TEST=0)
|
|
target_include_directories(
|
|
freertos_config INTERFACE ${BSP_PATH}/ps7_cortexa9_0/include)
|
|
# 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)
|
|
|
|
|
|
add_subdirectory(${FreeRTOS_PATH})
|
|
|
|
add_subdirectory(bsp_z7)
|
|
|
|
|
|
add_subdirectory(common)
|
|
|
|
add_subdirectory(${MISSION_PATH})
|
|
add_subdirectory(mission_rust)
|
|
|
|
# ##############################################################################
|
|
# Post-Sources preparation
|
|
# ##############################################################################
|
|
|
|
# Add libraries for all sources.
|
|
target_link_libraries(lwip PUBLIC freertos_kernel)
|
|
target_link_libraries(${TARGET_NAME} PUBLIC freertos_kernel mission_rust lwip)
|
|
|
|
target_include_directories(
|
|
${TARGET_NAME} PUBLIC ${BSP_PATH})
|
|
|
|
|
|
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}/${FreeRTOS_CONFIG_PATH}/lscript.ld -specs=${CMAKE_SOURCE_DIR}/${FreeRTOS_CONFIG_PATH}/Xilinx.spec )
|
|
|
|
# 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}) |