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(FreeRTOS_PATH FreeRTOS-Kernel/) set(MISSION_PATH mission/) set (LWIP_DIR contrib/lwip) # ############################################################################## # Configuration # ############################################################################## 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) if(${ZYNQ_UART} STREQUAL UART0) add_compile_definitions(ZYNQ_USE_UART0) endif() else() unset(ZYNQ_UART) unset(ZYNQ_UART CACHE) endif() # ############################################################################## # Executable and Sources # ############################################################################## # Add executable add_executable(${TARGET_NAME}) # lwip set (LWIP_INCLUDE_DIRS "${LWIP_DIR}/src/include" "bsp_z7/lwip/include" #${LWIP_DIR}/contrib/ports/freertos/include ) include(${LWIP_DIR}/src/Filelists.cmake) set(lwip_SRCS ${lwipcore_SRCS} ${lwipcore4_SRCS} ${lwipcore6_SRCS} ${lwipnetif_SRCS} ${lwipapi_SRCS} #${LWIP_DIR}/contrib/ports/freertos/sys_arch.c #${LWIP_DIR}/src/netif/slipif.c #${LWIP_DIR}/src/apps/tftp/tftp.c ) if(${CMAKE_CROSSCOMPILING}) add_library(lwip ${lwip_SRCS}) target_include_directories(lwip PUBLIC ${LWIP_INCLUDE_DIRS}) endif() # Add freeRTOS 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 "") add_library(freertos_config INTERFACE) target_include_directories(freertos_config SYSTEM INTERFACE bsp_z7/freeRTOS) # The config file directory target_compile_definitions(freertos_config INTERFACE projCOVERAGE_TEST=0) 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() 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 ) else() set(FREERTOS_PORT GCC_POSIX CACHE STRING "") add_library(freertos_config INTERFACE) 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) target_compile_definitions(freertos_config INTERFACE projCOVERAGE_TEST=0 projENABLE_TRACING=0) add_subdirectory(bsp_linux) endif() add_subdirectory(${FreeRTOS_PATH}) add_subdirectory(common) add_subdirectory(${MISSION_PATH}) add_subdirectory(mission_rust) # ############################################################################## # Post-Sources preparation # ############################################################################## # Add libraries for all sources. if(${CMAKE_CROSSCOMPILING}) target_link_libraries(lwip PUBLIC freertos_kernel) target_link_libraries(${TARGET_NAME} PUBLIC lwip) endif() target_link_libraries(${TARGET_NAME} PUBLIC freertos_kernel mission_rust) # target_include_directories( # ${TARGET_NAME} PUBLIC ${BSP_PATH}) # 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})