* Added ARCHIVE_OUTPUT_DIRECTORY to uf2 output in CMake This Commit enables the use of the ARCHIVE_OUTPUT_DIRECTORY target properties in CMake for the generation of uf2 files. The changeset in lines 47..51 is necessary due to CMake not automatically creating the ARCHIVE_OUTPUT_DIRECTORY if no archive target is present. * rework cmake changes to make it friendler for non absolute paths Co-authored-by: Graham Sanderson <graham.sanderson@raspberrypi.com>
This commit is contained in:
parent
6d15974e96
commit
a88baafc16
@ -44,12 +44,21 @@ function(pico_generate_pio_header TARGET PIO)
|
||||
endfunction()
|
||||
|
||||
function(pico_add_uf2_output TARGET)
|
||||
get_target_property(${TARGET}_archive_directory ${TARGET} ARCHIVE_OUTPUT_DIRECTORY)
|
||||
if (${TARGET}_archive_directory)
|
||||
get_filename_component(output_path "${${TARGET}_archive_directory}"
|
||||
REALPATH BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
file(MAKE_DIRECTORY "${output_path}")
|
||||
set(output_path "${output_path}/")
|
||||
else()
|
||||
set(output_path "")
|
||||
endif()
|
||||
if (NOT ELF2UF2_FOUND)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PICO_SDK_PATH}/tools)
|
||||
find_package(ELF2UF2)
|
||||
endif()
|
||||
if (ELF2UF2_FOUND)
|
||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||
COMMAND ELF2UF2 $<TARGET_FILE:${TARGET}> $<IF:$<BOOL:$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>>,$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>,$<TARGET_PROPERTY:${TARGET},NAME>>.uf2)
|
||||
COMMAND ELF2UF2 $<TARGET_FILE:${TARGET}> ${output_path}$<IF:$<BOOL:$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>>,$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>,$<TARGET_PROPERTY:${TARGET},NAME>>.uf2)
|
||||
endif()
|
||||
endfunction()
|
||||
|
Loading…
Reference in New Issue
Block a user