@@ -702,14 +702,6 @@ function(_add_swift_lipo_target)
702
702
endif ()
703
703
endfunction ()
704
704
705
- function (swift_target_link_search_directories target directories)
706
- set (STLD_FLAGS "" )
707
- foreach (directory ${directories} )
708
- set (STLD_FLAGS "${STLD_FLAGS} \" ${CMAKE_LIBRARY_PATH_FLAG}${directory} \" " )
709
- endforeach ()
710
- set_property (TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS ${STLD_FLAGS} )
711
- endfunction ()
712
-
713
705
# Add a single variant of a new Swift library.
714
706
#
715
707
# Usage:
@@ -886,22 +878,10 @@ function(_add_swift_library_single target name)
886
878
if (SWIFT_EMBED_BITCODE_SECTION AND NOT SWIFTLIB_SINGLE_DONT_EMBED_BITCODE)
887
879
if ("${SWIFTLIB_SINGLE_SDK} " STREQUAL "IOS" OR "${SWIFTLIB_SINGLE_SDK} " STREQUAL "TVOS" OR "${SWIFTLIB_SINGLE_SDK} " STREQUAL "WATCHOS" )
888
880
list (APPEND SWIFTLIB_SINGLE_C_COMPILE_FLAGS "-fembed-bitcode" )
889
- list (APPEND SWIFTLIB_SINGLE_LINK_FLAGS "-Xlinker" "-bitcode_bundle" "-Xlinker" "-lto_library" "-Xlinker" "${LLVM_LIBRARY_DIR} /libLTO.dylib" )
890
- # If we are asked to hide symbols, pass the obfuscation flag to libLTO.
891
- if (SWIFT_EMBED_BITCODE_SECTION_HIDE_SYMBOLS)
892
- list (APPEND SWIFTLIB_SINGLE_LINK_FLAGS "-Xlinker" "-bitcode_hide_symbols" )
893
- endif ()
894
881
set (embed_bitcode_arg EMBED_BITCODE)
895
882
endif ()
896
883
endif ()
897
884
898
- if (${SWIFTLIB_SINGLE_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
899
- list (APPEND SWIFTLIB_SINGLE_LINK_FLAGS "-Xlinker" "-compatibility_version" "-Xlinker" "1" )
900
- if (SWIFT_COMPILER_VERSION)
901
- list (APPEND SWIFTLIB_SINGLE_LINK_FLAGS "-Xlinker" "-current_version" "-Xlinker" "${SWIFT_COMPILER_VERSION} " )
902
- endif ()
903
- endif ()
904
-
905
885
if (XCODE)
906
886
string (REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR} )
907
887
list (GET split_path -1 dir)
@@ -1433,17 +1413,32 @@ function(_add_swift_library_single target name)
1433
1413
set (PLIST_INFO_BUILD_VERSION)
1434
1414
endif ()
1435
1415
1436
- # Convert variables to space-separated strings.
1437
- _list_escape_for_shell("${c_compile_flags} " c_compile_flags)
1438
- _list_escape_for_shell("${link_flags} " link_flags )
1439
-
1440
1416
# Set compilation and link flags.
1441
- set_property (TARGET "${target} " APPEND_STRING PROPERTY
1442
- COMPILE_FLAGS " ${c_compile_flags} " )
1443
- set_property (TARGET "${target} " APPEND_STRING PROPERTY
1444
- LINK_FLAGS " ${link_flags} " )
1445
- set_property (TARGET "${target} " APPEND PROPERTY LINK_LIBRARIES ${link_libraries} )
1446
- swift_target_link_search_directories("${target} " "${library_search_directories} " )
1417
+ target_compile_options (${target} PRIVATE
1418
+ ${c_compile_flags} )
1419
+ target_link_options (${target} PRIVATE
1420
+ ${link_flags} )
1421
+ if (${SWIFTLIB_SINGLE_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
1422
+ target_link_options (${target} PRIVATE
1423
+ "LINKER:-compatibility_version,1" )
1424
+ if (SWIFT_COMPILER_VERSION)
1425
+ target_link_options (${target} PRIVATE
1426
+ "LINKER:-current_version,${SWIFT_COMPILER_VERSION} " )
1427
+ endif ()
1428
+ # Include LLVM Bitcode slices for iOS, Watch OS, and Apple TV OS device libraries.
1429
+ if (SWIFT_EMBED_BITCODE_SECTION AND NOT SWIFTLIB_SINGLE_DONT_EMBED_BITCODE)
1430
+ if (${SWIFTLIB_SINGLE_SDK} MATCHES "(I|TV|WATCH)OS" )
1431
+ target_link_options (${target} PRIVATE
1432
+ "LINKER:-bitcode_bundle"
1433
+ $<$<BOOL :SWIFT_EMBED_BITCODE_SECTION_HIDE_SYMBOLS>:"LINKER:-bitcode_hide_symbols" >
1434
+ "LINKER:-lto_library,${LLVM_LIBRARY_DIR} /libLTO.dylib" )
1435
+ endif ()
1436
+ endif ()
1437
+ endif ()
1438
+ target_link_libraries (${target} PRIVATE
1439
+ ${link_libraries} )
1440
+ target_link_directories (${target} PRIVATE
1441
+ ${library_search_directories} )
1447
1442
1448
1443
# Adjust the linked libraries for windows targets. On Windows, the link is
1449
1444
# performed against the import library, and the runtime uses the dll. Not
@@ -1493,8 +1488,8 @@ function(_add_swift_library_single target name)
1493
1488
endif ()
1494
1489
1495
1490
if (target_static)
1496
- set_property ( TARGET " ${target_static} " APPEND_STRING PROPERTY
1497
- COMPILE_FLAGS " ${c_compile_flags} " )
1491
+ target_link_options ( ${target_static} PRIVATE
1492
+ ${c_compile_flags} )
1498
1493
# FIXME: The fallback paths here are going to be dynamic libraries.
1499
1494
1500
1495
if (SWIFTLIB_INSTALL_WITH_SHARED)
@@ -1506,7 +1501,8 @@ function(_add_swift_library_single target name)
1506
1501
"${search_base_dir} /${SWIFTLIB_SINGLE_SUBDIR} "
1507
1502
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH} /../lib/swift/${SWIFTLIB_SINGLE_SUBDIR} "
1508
1503
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH} /../lib/swift/${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK} _LIB_SUBDIR}" )
1509
- swift_target_link_search_directories("${target_static} " "${library_search_directories} " )
1504
+ target_link_directories (${target_static} PRIVATE
1505
+ ${library_search_directories} )
1510
1506
target_link_libraries ("${target_static} " PRIVATE
1511
1507
${SWIFTLIB_SINGLE_PRIVATE_LINK_LIBRARIES} )
1512
1508
endif ()
@@ -2600,16 +2596,14 @@ function(_add_swift_executable_single name)
2600
2596
${SWIFTEXE_SINGLE_DEPENDS} )
2601
2597
llvm_update_compile_flags("${name} " )
2602
2598
2603
- # Convert variables to space-separated strings.
2604
- _list_escape_for_shell("${c_compile_flags} " c_compile_flags)
2605
- _list_escape_for_shell("${link_flags} " link_flags )
2606
-
2607
- set_property (TARGET ${name} APPEND_STRING PROPERTY
2608
- COMPILE_FLAGS " ${c_compile_flags} " )
2609
- swift_target_link_search_directories("${name} " "${library_search_directories} " )
2610
- set_property (TARGET ${name} APPEND_STRING PROPERTY
2611
- LINK_FLAGS " ${link_flags} " )
2612
- set_property (TARGET ${name} APPEND PROPERTY LINK_LIBRARIES ${link_libraries} )
2599
+ target_compile_options (${name} PRIVATE
2600
+ ${c_compile_flags} )
2601
+ target_link_directories (${name} PRIVATE
2602
+ ${library_search_directories} )
2603
+ target_link_options (${name} PRIVATE
2604
+ ${link_flags} )
2605
+ target_link_libraries (${name} PRIVATE
2606
+ ${link_libraries} )
2613
2607
if (SWIFT_PARALLEL_LINK_JOBS)
2614
2608
set_property (TARGET ${name} PROPERTY JOB_POOL_LINK swift_link_job_pool)
2615
2609
endif ()
0 commit comments