diff --git a/components/esptool_py/project_include.cmake b/components/esptool_py/project_include.cmake index e2f4abe1e..d3ed6ca85 100644 --- a/components/esptool_py/project_include.cmake +++ b/components/esptool_py/project_include.cmake @@ -49,6 +49,7 @@ idf_build_get_property(build_dir BUILD_DIR) idf_build_get_property(elf_name EXECUTABLE_NAME GENERATOR_EXPRESSION) idf_build_get_property(elf EXECUTABLE GENERATOR_EXPRESSION) +idf_build_get_property(elf_dir EXECUTABLE_DIR GENERATOR_EXPRESSION) if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES AND NOT BOOTLOADER_BUILD) set(unsigned_project_binary "${elf_name}-unsigned.bin") @@ -64,7 +65,7 @@ set(PROJECT_BIN "${elf_name}.bin") if(CONFIG_APP_BUILD_GENERATE_BINARIES) add_custom_command(OUTPUT "${build_dir}/.bin_timestamp" COMMAND ${ESPTOOLPY} elf2image ${ESPTOOLPY_FLASH_OPTIONS} ${esptool_elf2image_args} - -o "${build_dir}/${unsigned_project_binary}" "${elf}" + -o "${build_dir}/${unsigned_project_binary}" "${elf_dir}/${elf}" COMMAND ${CMAKE_COMMAND} -E echo "Generated ${build_dir}/${unsigned_project_binary}" COMMAND ${CMAKE_COMMAND} -E md5sum "${build_dir}/${unsigned_project_binary}" > "${build_dir}/.bin_timestamp" DEPENDS ${elf} @@ -136,7 +137,7 @@ add_custom_target(monitor COMMAND ${CMAKE_COMMAND} -D IDF_PATH="${idf_path}" -D IDF_MONITOR="${idf_path}/tools/idf_monitor.py" - -D ELF_FILE="${elf}" + -D ELF_FILE="${elf_dir}/${elf}" -D WORKING_DIRECTORY="${build_dir}" -P run_idf_monitor.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} diff --git a/docs/en/api-guides/build-system.rst b/docs/en/api-guides/build-system.rst index 0a949aae6..f5d7a6f8b 100644 --- a/docs/en/api-guides/build-system.rst +++ b/docs/en/api-guides/build-system.rst @@ -1217,6 +1217,7 @@ For example, to get the Python interpreter used for the build: - CXX_COMPILE_OPTIONS - compile options applied to all components' C++ source files - EXECUTABLE - project executable; set by call to ``idf_build_executable`` - EXECUTABLE_NAME - name of project executable without extension; set by call to ``idf_build_executable`` + - EXECUTABLE_DIR - path containing the output executable - IDF_PATH - ESP-IDF path; set from IDF_PATH environment variable, if not, inferred from the location of ``idf.cmake`` - IDF_TARGET - target chip for the build; set from the required target argument for ``idf_build_process`` - IDF_VER - ESP-IDF version; set from either a version file or the Git revision of the IDF_PATH repository diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index e6984b76e..d7b91e34f 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -474,8 +474,11 @@ function(idf_build_executable elf) # Set the EXECUTABLE_NAME and EXECUTABLE properties since there are generator expression # from components that depend on it get_filename_component(elf_name ${elf} NAME_WE) + get_target_property(elf_dir ${elf} BINARY_DIR) + idf_build_set_property(EXECUTABLE_NAME ${elf_name}) idf_build_set_property(EXECUTABLE ${elf}) + idf_build_set_property(EXECUTABLE_DIR "${elf_dir}") # Add dependency of the build target to the executable add_dependencies(${elf} __idf_build_target)