|
|
@@ -152,24 +152,18 @@ function(target_linker_script target deptype scriptfiles)
|
|
|
get_filename_component(search_dir "${abs_script}" DIRECTORY)
|
|
|
get_filename_component(scriptname "${abs_script}" NAME)
|
|
|
|
|
|
- if(deptype STREQUAL INTERFACE OR deptype STREQUAL PUBLIC)
|
|
|
- get_target_property(link_libraries "${target}" INTERFACE_LINK_LIBRARIES)
|
|
|
- else()
|
|
|
- get_target_property(link_libraries "${target}" LINK_LIBRARIES)
|
|
|
- endif()
|
|
|
-
|
|
|
- list(FIND "${link_libraries}" "-L \"${search_dir}\"" found_search_dir)
|
|
|
- if(found_search_dir EQUAL "-1") # not already added as a search path
|
|
|
- target_link_libraries("${target}" "${deptype}" "-L \"${search_dir}\"")
|
|
|
- endif()
|
|
|
-
|
|
|
- target_link_libraries("${target}" "${deptype}" "-T ${scriptname}")
|
|
|
+ target_link_directories("${target}" "${deptype}" ${search_dir})
|
|
|
+ # Regarding the usage of SHELL, see
|
|
|
+ # https://cmake.org/cmake/help/latest/command/target_link_options.html#option-de-duplication
|
|
|
+ target_link_options("${target}" "${deptype}" "SHELL:-T ${scriptname}")
|
|
|
|
|
|
# Note: In ESP-IDF, most targets are libraries and libary LINK_DEPENDS don't propagate to
|
|
|
- # executable(s) the library is linked to. Attach manually to executable once it is known.
|
|
|
- #
|
|
|
- # Property INTERFACE_LINK_DEPENDS is available in CMake 3.13 which should propagate link
|
|
|
- # dependencies.
|
|
|
+ # executable(s) the library is linked to. Since CMake 3.13, INTERFACE_LINK_DEPENDS is
|
|
|
+ # available to solve this. However, when GNU Make generator is used, this property also
|
|
|
+ # propagates INTERFACE_LINK_DEPENDS dependencies to other static libraries.
|
|
|
+ # TODO: see if this is an expected behavior and possibly report this as a bug to CMake.
|
|
|
+ # For the time being, record all linker scripts in __LINK_DEPENDS and attach manually to
|
|
|
+ # the executable target once it is known.
|
|
|
if(NOT __PROCESS)
|
|
|
idf_build_set_property(__LINK_DEPENDS ${abs_script} APPEND)
|
|
|
endif()
|