diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index bc49c98..3ae3b0a 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -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 $ $>,$,$>.uf2) + COMMAND ELF2UF2 $ ${output_path}$>,$,$>.uf2) endif() endfunction()