@@ -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)
@@ -1450,17 +1430,32 @@ function(_add_swift_library_single target name)
1450
1430
set (PLIST_INFO_BUILD_VERSION)
1451
1431
endif ()
1452
1432
1453
- # Convert variables to space-separated strings.
1454
- _list_escape_for_shell("${c_compile_flags} " c_compile_flags)
1455
- _list_escape_for_shell("${link_flags} " link_flags )
1456
-
1457
1433
# Set compilation and link flags.
1458
- set_property (TARGET "${target} " APPEND_STRING PROPERTY
1459
- COMPILE_FLAGS " ${c_compile_flags} " )
1460
- set_property (TARGET "${target} " APPEND_STRING PROPERTY
1461
- LINK_FLAGS " ${link_flags} " )
1462
- set_property (TARGET "${target} " APPEND PROPERTY LINK_LIBRARIES ${link_libraries} )
1463
- swift_target_link_search_directories("${target} " "${library_search_directories} " )
1434
+ target_compile_options (${target} PRIVATE
1435
+ ${c_compile_flags} )
1436
+ target_link_options (${target} PRIVATE
1437
+ ${link_flags} )
1438
+ if (${SWIFTLIB_SINGLE_SDK} IN_LIST SWIFT_APPLE_PLATFORMS)
1439
+ target_link_options (${target} PRIVATE
1440
+ "LINKER:-compatibility_version,1" )
1441
+ if (SWIFT_COMPILER_VERSION)
1442
+ target_link_options (${target} PRIVATE
1443
+ "LINKER:-current_version,${SWIFT_COMPILER_VERSION} " )
1444
+ endif ()
1445
+ # Include LLVM Bitcode slices for iOS, Watch OS, and Apple TV OS device libraries.
1446
+ if (SWIFT_EMBED_BITCODE_SECTION AND NOT SWIFTLIB_SINGLE_DONT_EMBED_BITCODE)
1447
+ if (${SWIFTLIB_SINGLE_SDK} MATCHES "(I|TV|WATCH)OS" )
1448
+ target_link_options (${target} PRIVATE
1449
+ "LINKER:-bitcode_bundle"
1450
+ $<$<BOOL :SWIFT_EMBED_BITCODE_SECTION_HIDE_SYMBOLS>:"LINKER:-bitcode_hide_symbols" >
1451
+ "LINKER:-lto_library,${LLVM_LIBRARY_DIR} /libLTO.dylib" )
1452
+ endif ()
1453
+ endif ()
1454
+ endif ()
1455
+ target_link_libraries (${target} PRIVATE
1456
+ ${link_libraries} )
1457
+ target_link_directories (${target} PRIVATE
1458
+ ${library_search_directories} )
1464
1459
1465
1460
# Adjust the linked libraries for windows targets. On Windows, the link is
1466
1461
# performed against the import library, and the runtime uses the dll. Not
@@ -1510,8 +1505,8 @@ function(_add_swift_library_single target name)
1510
1505
endif ()
1511
1506
1512
1507
if (target_static)
1513
- set_property ( TARGET " ${target_static} " APPEND_STRING PROPERTY
1514
- COMPILE_FLAGS " ${c_compile_flags} " )
1508
+ target_link_options ( ${target_static} PRIVATE
1509
+ ${c_compile_flags} )
1515
1510
# FIXME: The fallback paths here are going to be dynamic libraries.
1516
1511
1517
1512
if (SWIFTLIB_INSTALL_WITH_SHARED)
@@ -1523,7 +1518,8 @@ function(_add_swift_library_single target name)
1523
1518
"${search_base_dir} /${SWIFTLIB_SINGLE_SUBDIR} "
1524
1519
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH} /../lib/swift/${SWIFTLIB_SINGLE_SUBDIR} "
1525
1520
"${SWIFT_NATIVE_SWIFT_TOOLS_PATH} /../lib/swift/${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK} _LIB_SUBDIR}" )
1526
- swift_target_link_search_directories("${target_static} " "${library_search_directories} " )
1521
+ target_link_directories (${target_static} PRIVATE
1522
+ ${library_search_directories} )
1527
1523
target_link_libraries ("${target_static} " PRIVATE
1528
1524
${SWIFTLIB_SINGLE_PRIVATE_LINK_LIBRARIES} )
1529
1525
endif ()
@@ -2624,16 +2620,14 @@ function(_add_swift_executable_single name)
2624
2620
${SWIFTEXE_SINGLE_DEPENDS} )
2625
2621
llvm_update_compile_flags("${name} " )
2626
2622
2627
- # Convert variables to space-separated strings.
2628
- _list_escape_for_shell("${c_compile_flags} " c_compile_flags)
2629
- _list_escape_for_shell("${link_flags} " link_flags )
2630
-
2631
- set_property (TARGET ${name} APPEND_STRING PROPERTY
2632
- COMPILE_FLAGS " ${c_compile_flags} " )
2633
- swift_target_link_search_directories("${name} " "${library_search_directories} " )
2634
- set_property (TARGET ${name} APPEND_STRING PROPERTY
2635
- LINK_FLAGS " ${link_flags} " )
2636
- set_property (TARGET ${name} APPEND PROPERTY LINK_LIBRARIES ${link_libraries} )
2623
+ target_compile_options (${name} PRIVATE
2624
+ ${c_compile_flags} )
2625
+ target_link_directories (${name} PRIVATE
2626
+ ${library_search_directories} )
2627
+ target_link_options (${name} PRIVATE
2628
+ ${link_flags} )
2629
+ target_link_libraries (${name} PRIVATE
2630
+ ${link_libraries} )
2637
2631
if (SWIFT_PARALLEL_LINK_JOBS)
2638
2632
set_property (TARGET ${name} PROPERTY JOB_POOL_LINK swift_link_job_pool)
2639
2633
endif ()
0 commit comments