makes setup_target take output dir for binaries and target mem as arguments
This commit is contained in:
@@ -40,14 +40,24 @@ add_subdirectory(port/moonlight)
|
|||||||
|
|
||||||
function(setup_target TARGET)
|
function(setup_target TARGET)
|
||||||
set(options)
|
set(options)
|
||||||
set(oneValueArgs) # none for now
|
set(oneValueArgs OUTPUT_DIR TARGET_MEM)
|
||||||
set(multiValueArgs LIBRARIES SOURCES)
|
set(multiValueArgs LIBRARIES SOURCES)
|
||||||
cmake_parse_arguments(ST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(ST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
if(ST_UNPARSED_ARGUMENTS)
|
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()
|
endif()
|
||||||
|
|
||||||
|
if(NOT ST_OUTPUT_DIR)
|
||||||
|
set(ST_OUTPUT_DIR ${CMAKE_BINARY_DIR})
|
||||||
|
endif()
|
||||||
|
if(NOT ST_TARGET_MEM)
|
||||||
|
set(ST_TARGET_MEM ${TARGET_MEM})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(${TARGET})
|
add_executable(${TARGET})
|
||||||
|
set_target_properties(${TARGET} PROPERTIES
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY ${ST_OUTPUT_DIR}
|
||||||
|
)
|
||||||
target_add_moonlight_platform(${TARGET})
|
target_add_moonlight_platform(${TARGET})
|
||||||
|
|
||||||
if("netxduo" IN_LIST ST_LIBRARIES)
|
if("netxduo" IN_LIST ST_LIBRARIES)
|
||||||
@@ -63,13 +73,17 @@ function(setup_target TARGET)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_options(${TARGET} PRIVATE
|
target_link_options(${TARGET} PRIVATE
|
||||||
-Wl,-Map=${CMAKE_BINARY_DIR}/${TARGET}.map)
|
-nostartfiles
|
||||||
|
-nostdlib
|
||||||
|
-T ${CMAKE_SOURCE_DIR}/src/${ST_TARGET_MEM}.lds
|
||||||
|
-Wl,--gc-sections
|
||||||
|
-Wl,-Map=${ST_OUTPUT_DIR}/${TARGET}.map)
|
||||||
|
|
||||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||||
COMMAND ${OBJCOPY} -O ihex $<TARGET_FILE:${TARGET}> ${CMAKE_BINARY_DIR}/${TARGET}.hex
|
COMMAND ${OBJCOPY} -O ihex $<TARGET_FILE:${TARGET}> ${ST_OUTPUT_DIR}/${TARGET}.hex
|
||||||
COMMAND ${OBJCOPY} -O binary $<TARGET_FILE:${TARGET}> ${CMAKE_BINARY_DIR}/${TARGET}.bin
|
COMMAND ${OBJCOPY} -O binary $<TARGET_FILE:${TARGET}> ${ST_OUTPUT_DIR}/${TARGET}.bin
|
||||||
COMMAND ${SIZE} $<TARGET_FILE:${TARGET}>
|
COMMAND ${SIZE} $<TARGET_FILE:${TARGET}>
|
||||||
COMMAND ${OBJDUMP} -S $<TARGET_FILE:${TARGET}> > ${TARGET}.dis
|
COMMAND ${OBJDUMP} -S $<TARGET_FILE:${TARGET}> > ${ST_OUTPUT_DIR}/${TARGET}.dis
|
||||||
COMMENT "Creating collateral for ${TARGET}"
|
COMMENT "Creating collateral for ${TARGET}"
|
||||||
)
|
)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -22,11 +22,6 @@ target_compile_options(moonlight_platform_defaults INTERFACE
|
|||||||
-ffunction-sections)
|
-ffunction-sections)
|
||||||
target_link_directories(moonlight_platform_defaults INTERFACE
|
target_link_directories(moonlight_platform_defaults INTERFACE
|
||||||
${THREADX4TGFS_ROOT}/src)
|
${THREADX4TGFS_ROOT}/src)
|
||||||
target_link_options(moonlight_platform_defaults INTERFACE
|
|
||||||
-nostartfiles
|
|
||||||
-nostdlib
|
|
||||||
-T ${THREADX4TGFS_ROOT}/src/${TARGET_MEM}.lds
|
|
||||||
-Wl,--gc-sections)
|
|
||||||
if(NX_DEBUG)
|
if(NX_DEBUG)
|
||||||
target_compile_definitions(moonlight_platform_defaults INTERFACE
|
target_compile_definitions(moonlight_platform_defaults INTERFACE
|
||||||
NX_DEBUG
|
NX_DEBUG
|
||||||
|
|||||||
Reference in New Issue
Block a user