diff --git a/tools/cmake/project.cmake b/tools/cmake/project.cmake index 5722c606b5..49b75bc77d 100644 --- a/tools/cmake/project.cmake +++ b/tools/cmake/project.cmake @@ -525,17 +525,17 @@ macro(project project_name) __component_get_target(build_component_target ${build_component}) __component_get_property(whole_archive ${build_component_target} WHOLE_ARCHIVE) if(whole_archive) - if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") - message(STATUS "Component ${build_component} will be linked with -Wl,-force_load") - target_link_libraries(${project_elf} PRIVATE - "-Wl,-force_load" - ${build_component}) - else() + if(linker_type STREQUAL "GNU") message(STATUS "Component ${build_component} will be linked with -Wl,--whole-archive") target_link_libraries(${project_elf} PRIVATE "-Wl,--whole-archive" ${build_component} "-Wl,--no-whole-archive") + elseif(linker_type STREQUAL "Darwin") + message(STATUS "Component ${build_component} will be linked with -Wl,-force_load") + target_link_libraries(${project_elf} PRIVATE + "-Wl,-force_load" + ${build_component}) endif() else() target_link_libraries(${project_elf} PRIVATE ${build_component})