diff --git a/tools/cmakev2/component.cmake b/tools/cmakev2/component.cmake index bdbb6a7e030..ced972449e9 100644 --- a/tools/cmakev2/component.cmake +++ b/tools/cmakev2/component.cmake @@ -913,11 +913,13 @@ function(idf_component_include name) if(whole_archive) idf_build_get_property(linker_type LINKER_TYPE) if(linker_type STREQUAL "GNU") - target_link_libraries("${component_interface}" INTERFACE - "-Wl,--whole-archive" "${component_real_target}" "-Wl,--no-whole-archive") + target_link_options("${component_interface}" INTERFACE + "SHELL:-Wl,--whole-archive $ -Wl,--no-whole-archive") + target_link_libraries("${component_interface}" INTERFACE "${component_real_target}") elseif(linker_type STREQUAL "Darwin") - target_link_libraries("${component_interface}" INTERFACE - "-Wl,-force_load" "${component_real_target}") + target_link_options("${component_interface}" INTERFACE + "SHELL:-Wl,-force_load $") + target_link_libraries("${component_interface}" INTERFACE "${component_real_target}") endif() else() target_link_libraries("${component_interface}" INTERFACE "${component_real_target}")