Skip to content

Commit 22ff7ce

Browse files
committed
Addressed more comments
1 parent e776427 commit 22ff7ce

File tree

7 files changed

+62
-101
lines changed

7 files changed

+62
-101
lines changed

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ else()
6464
GIT_REPOSITORY https://github.com/apple/swift-collections.git
6565
GIT_TAG release/1.1)
6666
endif()
67-
FetchContent_MakeAvailable(SwiftCollections SwiftFoundationICU)
67+
FetchContent_MakeAvailable(SwiftFoundationICU SwiftCollections)
68+
69+
list(APPEND CMAKE_MODULE_PATH ${SwiftFoundation_SOURCE_DIR}/cmake/modules)
6870

6971
# Availability Macros (only applies to FoundationEssentials and FoundationInternationalization)
7072
set(_SwiftFoundation_availability_macros)
@@ -82,8 +84,7 @@ list(APPEND _SwiftFoundation_availability_macros
8284
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPredicateRegex 0.3:macOS 10000, iOS 10000, tvOS 10000, watchOS 10000\">"
8385
"SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPredicateRegex 0.4:macOS 10000, iOS 10000, tvOS 10000, watchOS 10000\">")
8486

85-
list(APPEND CMAKE_MODULE_PATH ${SwiftFoundation_SOURCE_DIR}/cmake/modules)
86-
include(SwiftSupport)
87+
include(SwiftFoundationSwiftSupport)
8788

8889
add_subdirectory(Sources)
8990
add_subdirectory(cmake/modules)

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ let package = Package(
5959
exact: "0.0.8"),
6060
.package(
6161
url: "https://github.com/apple/swift-syntax.git",
62-
from: "510.0.0")
62+
from: "600.0.0-latest")
6363
],
6464
targets: [
6565
// Foundation (umbrella)

Sources/FoundationEssentials/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,4 @@ set_target_properties(FoundationEssentials PROPERTIES
7474
INSTALL_RPATH "$ORIGIN")
7575

7676
set_property(GLOBAL APPEND PROPERTY SWIFT_FOUNDATION_EXPORTS FoundationEssentials)
77-
_install_target(FoundationEssentials)
77+
_swift_foundation_install_target(FoundationEssentials)

Sources/FoundationInternationalization/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ set_target_properties(FoundationInternationalization PROPERTIES
4343
INSTALL_RPATH "$ORIGIN")
4444

4545
set_property(GLOBAL APPEND PROPERTY SWIFT_FOUNDATION_EXPORTS FoundationInternationalization)
46-
_install_target(FoundationInternationalization)
46+
_swift_foundation_install_target(FoundationInternationalization)

Sources/FoundationMacros/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if(NOT SwiftSyntax_FOUND)
1919
# If building at desk, check out and link against the SwiftSyntax repo's targets
2020
FetchContent_Declare(SwiftSyntax
2121
GIT_REPOSITORY https://github.com/apple/swift-syntax.git
22-
GIT_TAG 510.0.0)
22+
GIT_TAG 4c6cc0a3b9e8f14b3ae2307c5ccae4de6167ac2c) # 600.0.0-prerelease-2024-06-12
2323
FetchContent_MakeAvailable(SwiftSyntax)
2424
endif()
2525

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Returns the os name in a variable
2+
#
3+
# Usage:
4+
# get_swift_host_os(result_var_name)
5+
#
6+
#
7+
# Sets ${result_var_name} with the converted OS name derived from
8+
# CMAKE_SYSTEM_NAME.
9+
function(get_swift_host_os result_var_name)
10+
set(${result_var_name} ${SWIFT_SYSTEM_NAME} PARENT_SCOPE)
11+
endfunction()
12+
13+
function(_swift_foundation_install_target module)
14+
get_swift_host_os(swift_os)
15+
get_target_property(type ${module} TYPE)
16+
17+
if(type STREQUAL STATIC_LIBRARY)
18+
set(swift swift_static)
19+
else()
20+
set(swift swift)
21+
endif()
22+
23+
install(TARGETS ${module}
24+
ARCHIVE DESTINATION lib/${swift}/${swift_os}
25+
LIBRARY DESTINATION lib/${swift}/${swift_os}
26+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
27+
if(type STREQUAL EXECUTABLE)
28+
return()
29+
endif()
30+
31+
get_target_property(module_name ${module} Swift_MODULE_NAME)
32+
if(NOT module_name)
33+
set(module_name ${module})
34+
endif()
35+
36+
if(NOT SwiftFoundation_MODULE_TRIPLE)
37+
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)
38+
if(CMAKE_Swift_COMPILER_TARGET)
39+
list(APPEND module_triple_command -target ${CMAKE_Swift_COMPILER_TARGET})
40+
endif()
41+
execute_process(COMMAND ${module_triple_command} OUTPUT_VARIABLE target_info_json)
42+
string(JSON module_triple GET "${target_info_json}" "target" "moduleTriple")
43+
set(SwiftFoundation_MODULE_TRIPLE "${module_triple}" CACHE STRING "swift module triple used for installed swiftmodule and swiftinterface files")
44+
mark_as_advanced(SwiftFoundation_MODULE_TRIPLE)
45+
endif()
46+
47+
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftdoc
48+
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule
49+
RENAME ${SwiftFoundation_MODULE_TRIPLE}.swiftdoc)
50+
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftmodule
51+
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule
52+
RENAME ${SwiftFoundation_MODULE_TRIPLE}.swiftmodule)
53+
54+
endfunction()

cmake/modules/SwiftSupport.cmake

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)