@@ -293,7 +293,7 @@ endfunction()
293
293
function (_add_variant_link_flags )
294
294
set (oneValueArgs SDK ARCH BUILD_TYPE ENABLE_ASSERTIONS ANALYZE_CODE_COVERAGE
295
295
DEPLOYMENT_VERSION_OSX DEPLOYMENT_VERSION_IOS DEPLOYMENT_VERSION_TVOS DEPLOYMENT_VERSION_WATCHOS
296
- RESULT_VAR_NAME ENABLE_LTO LTO_OBJECT_NAME LIBRARY_SEARCH_DIRECTORIES )
296
+ RESULT_VAR_NAME ENABLE_LTO LTO_OBJECT_NAME LIBRARY_SEARCH_DIRECTORIES_VAR_NAME )
297
297
cmake_parse_arguments (LFLAGS
298
298
""
299
299
"${oneValueArgs} "
@@ -309,7 +309,7 @@ function(_add_variant_link_flags)
309
309
endif ()
310
310
311
311
set (result ${${LFLAGS_RESULT_VAR_NAME}} )
312
- set (library_search_directories ${${LFLAGS_LIBRARY_SEARCH_DIRECTORIES }} )
312
+ set (library_search_directories ${${LFLAGS_LIBRARY_SEARCH_DIRECTORIES_VAR_NAME }} )
313
313
314
314
_add_variant_c_compile_link_flags (
315
315
SDK "${LFLAGS_SDK} "
@@ -363,7 +363,7 @@ function(_add_variant_link_flags)
363
363
endif ()
364
364
365
365
set ("${LFLAGS_RESULT_VAR_NAME} " "${result} " PARENT_SCOPE )
366
- set ("${LFLAGS_LIBRARY_SEARCH_DIRECTORIES } " "${library_search_directories} " PARENT_SCOPE )
366
+ set ("${LFLAGS_LIBRARY_SEARCH_DIRECTORIES_VAR_NAME } " "${library_search_directories} " PARENT_SCOPE )
367
367
endfunction ()
368
368
369
369
# Look up extra flags for a module that matches a regexp.
@@ -463,7 +463,7 @@ endfunction()
463
463
function (swift_target_link_search_directories target directories )
464
464
set (STLD_FLAGS "" )
465
465
foreach (directory ${directories} )
466
- set (STLD_FLAGS " ${CMAKE_LIBRARY_PATH_FLAG}${directory} " )
466
+ set (STLD_FLAGS "${STLD_FLAGS} ${CMAKE_LIBRARY_PATH_FLAG}${directory} " )
467
467
endforeach ()
468
468
set_property (TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS ${STLD_FLAGS} )
469
469
endfunction ()
@@ -1053,7 +1053,7 @@ function(_add_swift_library_single target name)
1053
1053
DEPLOYMENT_VERSION_TVOS "${SWIFTLIB_DEPLOYMENT_VERSION_TVOS} "
1054
1054
DEPLOYMENT_VERSION_WATCHOS "${SWIFTLIB_DEPLOYMENT_VERSION_WATCHOS} "
1055
1055
RESULT_VAR_NAME link_flags
1056
- LIBRARY_SEARCH_DIRECTORIES library_search_directories
1056
+ LIBRARY_SEARCH_DIRECTORIES_VAR_NAME library_search_directories
1057
1057
)
1058
1058
1059
1059
if (SWIFT_ENABLE_GOLD_LINKER AND
@@ -1107,7 +1107,7 @@ function(_add_swift_library_single target name)
1107
1107
COMPILE_FLAGS " ${c_compile_flags} " )
1108
1108
set_property (TARGET "${target} " APPEND_STRING PROPERTY
1109
1109
LINK_FLAGS " ${link_flags} " )
1110
- swift_target_link_search_directories (${target} ${library_search_directories} )
1110
+ swift_target_link_search_directories (" ${target} " " ${library_search_directories} " )
1111
1111
1112
1112
# Adjust the linked libraries for windows targets. On Windows, the link is
1113
1113
# performed against the import library, and the runtime uses the dll. Not
@@ -1163,8 +1163,7 @@ function(_add_swift_library_single target name)
1163
1163
"${SWIFTSTATICLIB_DIR} /${SWIFTLIB_SINGLE_SUBDIR} "
1164
1164
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH} /../lib/swift/${SWIFTLIB_SINGLE_SUBDIR} "
1165
1165
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH} /../lib/swift/${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK} _LIB_SUBDIR}" )
1166
- swift_target_link_search_directories (${target_static}
1167
- ${library_search_directories} )
1166
+ swift_target_link_search_directories ("${target_static} " "${library_search_directories} " )
1168
1167
target_link_libraries ("${target_static} " PRIVATE
1169
1168
${SWIFTLIB_SINGLE_PRIVATE_LINK_LIBRARIES} )
1170
1169
endif ()
@@ -1784,6 +1783,10 @@ function(_add_swift_executable_single name)
1784
1783
set (c_compile_flags )
1785
1784
set (link_flags )
1786
1785
1786
+ # Prepare linker search directories.
1787
+ set (library_search_directories
1788
+ "${SWIFTLIB_DIR} /${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK} _LIB_SUBDIR}" )
1789
+
1787
1790
# Add variant-specific flags.
1788
1791
_add_variant_c_compile_flags (
1789
1792
SDK "${SWIFTEXE_SINGLE_SDK} "
@@ -1801,7 +1804,8 @@ function(_add_swift_executable_single name)
1801
1804
ENABLE_LTO "${SWIFT_TOOLS_ENABLE_LTO} "
1802
1805
LTO_OBJECT_NAME "${name} -${SWIFTEXE_SINGLE_SDK} -${SWIFTEXE_SINGLE_ARCHITECTURE} "
1803
1806
ANALYZE_CODE_COVERAGE "${SWIFT_ANALYZE_CODE_COVERAGE} "
1804
- RESULT_VAR_NAME link_flags )
1807
+ RESULT_VAR_NAME link_flags
1808
+ LIBRARY_SEARCH_DIRECTORIES_VAR_NAME library_search_directories )
1805
1809
1806
1810
if (SWIFTEXE_SINGLE_DISABLE_ASLR )
1807
1811
list (APPEND link_flags "-Wl,-no_pie" )
@@ -1868,8 +1872,7 @@ function(_add_swift_executable_single name)
1868
1872
1869
1873
set_property (TARGET ${name} APPEND_STRING PROPERTY
1870
1874
COMPILE_FLAGS " ${c_compile_flags} " )
1871
- swift_target_link_search_directories (${name}
1872
- "${SWIFTLIB_DIR} /${SWIFT_SDK_${SWIFTEXE_SINGLE_SDK} _LIB_SUBDIR}" )
1875
+ swift_target_link_search_directories ("${name} " "${library_search_directories} " )
1873
1876
set_property (TARGET ${name} APPEND_STRING PROPERTY
1874
1877
LINK_FLAGS " ${link_flags} " )
1875
1878
if (SWIFT_PARALLEL_LINK_JOBS )
0 commit comments