diff --git a/src/cmake/on_device.cmake b/src/cmake/on_device.cmake index b4c53b96..69e2f346 100644 --- a/src/cmake/on_device.cmake +++ b/src/cmake/on_device.cmake @@ -15,24 +15,38 @@ function(pico_get_runtime_output_directory TARGET output_path_name) set(${output_path_name} ${output_path} PARENT_SCOPE) endfunction() +function(pico_get_output_name TARGET output_name_var) + get_target_property(output_name ${TARGET} OUTPUT_NAME) + # Generator expressions not supported in byproducts + set(output_name_copy ${output_name}) + string(GENEX_STRIP "${output_name}" output_name) + if (NOT output_name OR (NOT output_name STREQUAL output_name_copy)) + get_target_property(output_name ${TARGET} NAME) + endif() + set(${output_name_var} ${output_name} PARENT_SCOPE) +endfunction() + # pico_add_hex_output(TARGET) # \brief\ Generate a hex file for the target function(pico_add_hex_output TARGET) pico_get_runtime_output_directory(${TARGET} output_path) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex $ ${output_path}$>,$,$>.hex VERBATIM) + pico_get_output_name(${TARGET} output_name) + add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex $ ${output_path}$>,$,$>.hex VERBATIM BYPRODUCTS "${output_path}${output_name}.hex") endfunction() # pico_add_bin_output(TARGET) # \brief\ Generate a bin file for the target function(pico_add_bin_output TARGET) pico_get_runtime_output_directory(${TARGET} output_path) - add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary $ ${output_path}$>,$,$>.bin VERBATIM) + pico_get_output_name(${TARGET} output_name) + add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary $ ${output_path}$>,$,$>.bin VERBATIM BYPRODUCTS "${output_path}${output_name}.bin") endfunction() # pico_add_dis_output(TARGET) # \brief\ Generate a disassembly file for the target function(pico_add_dis_output TARGET) pico_get_runtime_output_directory(${TARGET} output_path) + pico_get_output_name(${TARGET} output_name) # PICO_CMAKE_CONFIG: PICO_NO_COPRO_DIS, Disable disassembly listing postprocessing that disassembles RP2350 coprocessor instructions, type=bool, default=0, group=build if (NOT (PICO_NO_COPRO_DIS OR PICO_NO_PICOTOOL OR PICO_RISCV OR PICO_RP2040)) @@ -48,6 +62,7 @@ function(pico_add_dis_output TARGET) COMMAND ${CMAKE_OBJDUMP} -d ${PICO_DISASM_OBJDUMP_ARGS} $ >> ${output_path}$>,$,$>.dis ${EXTRA_COMMAND} VERBATIM + BYPRODUCTS "${output_path}${output_name}.dis" ) endfunction() @@ -88,6 +103,7 @@ function(pico_add_extra_outputs TARGET) COMMAND rm -f "${PICO_SYMLINK_ELF_AS_FILENAME}" COMMAND ln -s -r $ "${PICO_SYMLINK_ELF_AS_FILENAME}" COMMENT "Symlinking from ${PICO_SYMLINK_ELF_AS_FILENAME} to ${TARGET}" + BYPRODUCTS "${PICO_SYMLINK_ELF_AS_FILENAME}" ) endif () # PICO_CMAKE_CONFIG: PICO_NO_UF2, Disable UF2 output, type=bool, default=0, group=build diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 9ec5a232..7a0b5616 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -556,6 +556,7 @@ function(pico_add_uf2_output TARGET) else() set(output_path "") endif() + pico_get_output_name(${TARGET} output_name) get_target_property(${TARGET}_uf2_package_addr ${TARGET} PICOTOOL_UF2_PACKAGE_ADDR) if (${TARGET}_uf2_package_addr) @@ -594,7 +595,8 @@ function(pico_add_uf2_output TARGET) --family ${picotool_family} ${extra_uf2_args} COMMAND_EXPAND_LISTS - VERBATIM) + VERBATIM + BYPRODUCTS "${output_path}${output_name}.uf2") endif() endfunction() diff --git a/tools/extract_cmake_functions.py b/tools/extract_cmake_functions.py index 94dac8d6..38e47ca1 100755 --- a/tools/extract_cmake_functions.py +++ b/tools/extract_cmake_functions.py @@ -57,6 +57,7 @@ allowed_missing_functions = set([ "pico_init_picotool", "pico_add_platform_library", "pico_get_runtime_output_directory", + "pico_get_output_name", "pico_set_printf_implementation", "pico_expand_pico_platform", ])