makes the port provide its dependencies as a library
This commit is contained in:
@@ -36,54 +36,35 @@ option(NX_DEBUG "compile netxduo debug output in" OFF)
|
||||
set(TARGET_MEM "ram" CACHE STRING "memory map to use")
|
||||
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
|
||||
|
||||
add_subdirectory(port/moonlight)
|
||||
|
||||
function(setup_target TARGET)
|
||||
set(options)
|
||||
set(oneValueArgs) # none for now
|
||||
set(multiValueArgs LIBRARIES SOURCES)
|
||||
cmake_parse_arguments(ST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
if(ST_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "setup_target(${target} ...): unknown args: ${ST_UNPARSED_ARGUMENTS}")
|
||||
message(FATAL_ERROR "setup_target(${TARGET} ...): unknown args: ${ST_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
|
||||
add_executable(${TARGET})
|
||||
target_sources(${TARGET} PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/port/picolibc/port.c
|
||||
${CMAKE_SOURCE_DIR}/port/moonlight/bootup.c
|
||||
${CMAKE_SOURCE_DIR}/port/moonlight/board.c
|
||||
${CMAKE_SOURCE_DIR}/port/moonlight/trap_non_vectored.c
|
||||
${CMAKE_SOURCE_DIR}/port/moonlight/exception.c
|
||||
${CMAKE_SOURCE_DIR}/port/moonlight/vector_table.c
|
||||
)
|
||||
target_add_moonlight_platform(${TARGET})
|
||||
|
||||
if("netxduo" IN_LIST ST_LIBRARIES)
|
||||
target_sources(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/port/moonlight/mnrs_network_driver.c)
|
||||
target_add_moonlight_network_driver(${TARGET})
|
||||
endif()
|
||||
|
||||
if(ST_SOURCES)
|
||||
target_sources(${TARGET} PRIVATE ${ST_SOURCES})
|
||||
endif()
|
||||
|
||||
target_include_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/port/moonlight ${CMAKE_SOURCE_DIR}/src)
|
||||
target_compile_options(${TARGET} PRIVATE
|
||||
-ffreestanding
|
||||
-fno-builtin
|
||||
-fdata-sections
|
||||
-ffunction-sections
|
||||
)
|
||||
if(NX_DEBUG)
|
||||
target_compile_definitions(${TARGET} PRIVATE NX_DEBUG NX_DEBUG_PACKET)
|
||||
endif()
|
||||
target_link_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/src) # needed for linker script includes
|
||||
target_link_options(${TARGET} PRIVATE
|
||||
-nostartfiles
|
||||
-nostdlib
|
||||
-T ${CMAKE_SOURCE_DIR}/src/${TARGET_MEM}.lds
|
||||
-Wl,--gc-sections
|
||||
-Wl,-Map=${CMAKE_BINARY_DIR}/${TARGET}.map
|
||||
)
|
||||
if(ST_LIBRARIES)
|
||||
target_link_libraries(${TARGET} PRIVATE ${ST_LIBRARIES})
|
||||
endif()
|
||||
|
||||
target_link_options(${TARGET} PRIVATE
|
||||
-Wl,-Map=${CMAKE_BINARY_DIR}/${TARGET}.map)
|
||||
|
||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||
COMMAND ${OBJCOPY} -O ihex $<TARGET_FILE:${TARGET}> ${CMAKE_BINARY_DIR}/${TARGET}.hex
|
||||
COMMAND ${OBJCOPY} -O binary $<TARGET_FILE:${TARGET}> ${CMAKE_BINARY_DIR}/${TARGET}.bin
|
||||
|
||||
Reference in New Issue
Block a user