Skip to content

Commit a30b955

Browse files
committed
Addressed review comments and updated dependency URLs
1 parent 8a542c6 commit a30b955

File tree

8 files changed

+67
-113
lines changed

8 files changed

+67
-113
lines changed

CMakeLists.txt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,26 @@ if (_SwiftFoundationICU_SourceDIR)
5353
SOURCE_DIR ${_SwiftFoundationICU_SourceDIR})
5454
else()
5555
FetchContent_Declare(SwiftFoundationICU
56-
GIT_REPOSITORY https://github.com/iCharlesHu/swift-foundation-icu.git
57-
GIT_TAG charles/cmake-support)
56+
GIT_REPOSITORY https://github.com/apple/swift-foundation-icu.git
57+
GIT_TAG 0.0.8)
5858
endif()
59-
FetchContent_MakeAvailable(SwiftFoundationICU)
6059

6160
if (_SwiftFoundation_SourceDIR)
6261
FetchContent_Declare(SwiftFoundation
6362
SOURCE_DIR ${_SwiftFoundation_SourceDIR})
6463
else()
6564
FetchContent_Declare(SwiftFoundation
66-
GIT_REPOSITORY https://github.com/iCharlesHu/swift-foundation.git
67-
GIT_TAG charles/cmake-support)
65+
GIT_REPOSITORY https://github.com/apple/swift-foundation.git
66+
GIT_TAG main)
6867
endif()
69-
FetchContent_MakeAvailable(SwiftFoundation)
68+
FetchContent_MakeAvailable(SwiftFoundationICU SwiftFoundation)
7069

7170
# System dependencies (fail fast if dependencies are missing)
7271
find_package(LibXml2 REQUIRED)
7372
find_package(CURL REQUIRED)
7473
find_package(dispatch CONFIG REQUIRED)
7574

7675
# Common build flags (_CFURLSessionInterface, _CFXMLInterface, CoreFoundation)
77-
set(_Foundation_common_build_flags)
7876
list(APPEND _Foundation_common_build_flags
7977
"-DDEPLOYMENT_RUNTIME_SWIFT"
8078
"-DCF_BUILDING_CF"
@@ -112,7 +110,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android")
112110
"-I/usr/lib/swift") # dispatch
113111
endif()
114112

115-
include(SwiftSupport)
113+
include(FoundationSwiftSupport)
116114

117115
add_subdirectory(Sources)
118116
add_subdirectory(cmake/modules)

Sources/Foundation/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,4 @@ target_link_libraries(Foundation PUBLIC
165165
swiftDispatch)
166166

167167
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS Foundation)
168-
_install_target(Foundation)
168+
_foundation_install_target(Foundation)

Sources/FoundationNetworking/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,13 @@ target_compile_options(FoundationNetworking PRIVATE
5151

5252
target_link_libraries(FoundationNetworking
5353
PRIVATE
54-
Foundation
5554
CoreFoundation
5655
_CFURLSessionInterface
5756
PUBLIC
58-
FoundationEssentials)
57+
Foundation)
5958

6059
set_target_properties(FoundationNetworking PROPERTIES
6160
INSTALL_RPATH "$ORIGIN")
6261

6362
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationNetworking)
64-
_install_target(FoundationNetworking)
63+
_foundation_install_target(FoundationNetworking)

Sources/FoundationXML/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ target_compile_options(FoundationXML PRIVATE
2626

2727
target_link_libraries(FoundationXML
2828
PRIVATE
29-
Foundation
3029
CoreFoundation
3130
_CFXMLInterface
3231
PUBLIC
33-
FoundationEssentials)
32+
Foundation)
3433

3534
set_target_properties(FoundationXML PROPERTIES
3635
INSTALL_RPATH "$ORIGIN")
3736

3837
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationXML)
39-
_install_target(FoundationXML)
38+
_foundation_install_target(FoundationXML)

Sources/_CFURLSessionInterface/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ target_include_directories(_CFURLSessionInterface
1818
PUBLIC
1919
include
2020
PRIVATE
21-
../CoreFoundation/internalInclude
22-
../CoreFoundation/include)
21+
../CoreFoundation/internalInclude)
2322

2423
target_precompile_headers(_CFURLSessionInterface PRIVATE ${CMAKE_SOURCE_DIR}/Sources/CoreFoundation/internalInclude/CoreFoundation_Prefix.h)
2524

Sources/_CFXMLInterface/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ target_include_directories(_CFXMLInterface
1919
include
2020
PRIVATE
2121
../CoreFoundation/internalInclude
22-
../CoreFoundation/include
2322
/usr/include/libxml2/)
2423

2524
target_compile_options(_CFXMLInterface PRIVATE
@@ -32,4 +31,4 @@ target_link_libraries(_CFXMLInterface PRIVATE
3231

3332
if(NOT BUILD_SHARED_LIBS)
3433
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS _CFXMLInterface)
35-
endif()
34+
endif()
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(_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)