diff --git a/tools/cmakev2/component.cmake b/tools/cmakev2/component.cmake index a0262a9ac8f..8a07d0a91d6 100644 --- a/tools/cmakev2/component.cmake +++ b/tools/cmakev2/component.cmake @@ -963,13 +963,17 @@ function(idf_component_include name) idf_die("Unsupported target type '${component_real_target_type}' in component '${component_name}'") endif() + idf_component_get_property(component_dir "${component_name}" COMPONENT_DIR) + idf_component_get_property(embed_files "${component_name}" EMBED_FILES) foreach(file IN LISTS embed_files) + get_filename_component(file "${file}" ABSOLUTE BASE_DIR "${component_dir}") target_add_binary_data(${COMPONENT_TARGET} "${file}" "BINARY") endforeach() idf_component_get_property(embed_txtfiles "${component_name}" EMBED_TXTFILES) foreach(file IN LISTS embed_txtfiles) + get_filename_component(file "${file}" ABSOLUTE BASE_DIR "${component_dir}") target_add_binary_data(${COMPONENT_TARGET} "${file}" "TEXT") endforeach() diff --git a/tools/cmakev2/utilities.cmake b/tools/cmakev2/utilities.cmake index 627cc2ea7a4..a2804964184 100644 --- a/tools/cmakev2/utilities.cmake +++ b/tools/cmakev2/utilities.cmake @@ -837,12 +837,7 @@ function(target_add_binary_data target embed_file embed_type) idf_build_get_property(build_dir BUILD_DIR) idf_build_get_property(idf_path IDF_PATH) - # The target_add_binary_data function is also called within the - # idf_component_include function, which is not executed in the component - # directory context. Therefore, ensure that the absolute path of the - # embedded file is resolved relative to the component directory. - idf_component_get_property(component_directory "${target}" COMPONENT_DIR) - get_filename_component(embed_file "${embed_file}" ABSOLUTE BASE_DIR "${component_directory}") + get_filename_component(embed_file "${embed_file}" ABSOLUTE) get_filename_component(name "${embed_file}" NAME) set(embed_srcfile "${build_dir}/${name}.S")