30 lines
969 B
CMake
30 lines
969 B
CMake
cmake_minimum_required(VERSION 3.21)
|
|
project(mnrs-bsp LANGUAGES ASM C)
|
|
|
|
if(NOT DEFINED BOARD)
|
|
message(FATAL_ERROR "No Board selected")
|
|
endif()
|
|
add_compile_definitions("BOARD_${BOARD}")
|
|
# check if we are building for a testbench, adjust the Base accordingly
|
|
set(BOARD_BASE ${BOARD})
|
|
|
|
option(SEMIHOSTING "Enable semihosting support" OFF)
|
|
if(SEMIHOSTING)
|
|
add_compile_definitions(SEMIHOSTING)
|
|
endif()
|
|
|
|
add_library(startup STATIC env/start.S env/entry.S)
|
|
target_include_directories(startup PUBLIC env include)
|
|
|
|
add_subdirectory(libwrap)
|
|
|
|
add_library(bsp STATIC env/${BOARD_BASE}/init.c)
|
|
target_link_libraries(bsp PUBLIC startup wrap)
|
|
target_include_directories(bsp PUBLIC env/${BOARD_BASE})
|
|
target_link_options(bsp INTERFACE LINKER:--no-warn-rwx-segments -nostartfiles -T ${CMAKE_CURRENT_SOURCE_DIR}/env/${BOARD_BASE}/link.lds)
|
|
|
|
if(SEMIHOSTING)
|
|
target_include_directories(bsp INTERFACE include)
|
|
target_sources(bsp INTERFACE env/semihosting.c env/trap.c)
|
|
endif()
|