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}") set(TESTBENCHES "rtl" "TGCP") list(FIND TESTBENCHES ${BOARD} _index) if(NOT _index EQUAL -1) set(BOARD "testbench/${BOARD}") endif() 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}/init.c) target_link_libraries(bsp PUBLIC startup wrap) target_include_directories(bsp PUBLIC env/${BOARD}) target_link_options(bsp INTERFACE LINKER:--no-warn-rwx-segments -nostartfiles -T ${CMAKE_CURRENT_SOURCE_DIR}/env/${BOARD}/link.lds) if(SEMIHOSTING) target_include_directories(bsp INTERFACE include) target_sources(bsp INTERFACE env/semihosting.c env/trap.c) endif()