makes setup_target function more robust when being called in other CMakeLists.txt files

This commit is contained in:
2026-03-21 15:10:45 +01:00
parent 2433b66dc0
commit 950dd213c8

View File

@@ -47,22 +47,22 @@ function(setup_target TARGET)
add_executable(${TARGET}) add_executable(${TARGET})
target_sources(${TARGET} PRIVATE target_sources(${TARGET} PRIVATE
port/picolibc/port.c ${CMAKE_SOURCE_DIR}/port/picolibc/port.c
port/moonlight/bootup.c ${CMAKE_SOURCE_DIR}/port/moonlight/bootup.c
port/moonlight/board.c ${CMAKE_SOURCE_DIR}/port/moonlight/board.c
port/moonlight/trap_non_vectored.c ${CMAKE_SOURCE_DIR}/port/moonlight/trap_non_vectored.c
port/moonlight/exception.c ${CMAKE_SOURCE_DIR}/port/moonlight/exception.c
port/moonlight/vector_table.c ${CMAKE_SOURCE_DIR}/port/moonlight/vector_table.c
) )
if("netxduo" IN_LIST ST_LIBRARIES) if("netxduo" IN_LIST ST_LIBRARIES)
target_sources(${TARGET} PRIVATE port/moonlight/mnrs_network_driver.c) target_sources(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/port/moonlight/mnrs_network_driver.c)
endif() endif()
if(ST_SOURCES) if(ST_SOURCES)
target_sources(${TARGET} PRIVATE ${ST_SOURCES}) target_sources(${TARGET} PRIVATE ${ST_SOURCES})
endif() endif()
target_include_directories(${TARGET} PRIVATE port/moonlight src) target_include_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/port/moonlight ${CMAKE_SOURCE_DIR}/src)
target_compile_options(${TARGET} PRIVATE target_compile_options(${TARGET} PRIVATE
-ffreestanding -ffreestanding
-fno-builtin -fno-builtin
@@ -72,7 +72,7 @@ function(setup_target TARGET)
if(NX_DEBUG) if(NX_DEBUG)
target_compile_definitions(${TARGET} PRIVATE NX_DEBUG NX_DEBUG_PACKET) target_compile_definitions(${TARGET} PRIVATE NX_DEBUG NX_DEBUG_PACKET)
endif() endif()
target_link_directories(${TARGET} PRIVATE src) # needed for linker script includes target_link_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/src) # needed for linker script includes
target_link_options(${TARGET} PRIVATE target_link_options(${TARGET} PRIVATE
-nostartfiles -nostartfiles
-nostdlib -nostdlib