Skip to content

Commit 7be5a73

Browse files
committed
Add modulemaps that work for statically compiled Foundation
The static libraries need to link against additional dependencies, which are listed in the newly added modulemaps
1 parent 514c9e9 commit 7be5a73

File tree

4 files changed

+34
-10
lines changed

4 files changed

+34
-10
lines changed

CMakeLists.txt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,39 +62,44 @@ if(ENABLE_TESTING)
6262
add_subdirectory(Tests)
6363
endif()
6464

65+
set(swift_lib_dir "lib/swift")
66+
6567
if(NOT BUILD_SHARED_LIBS)
68+
set(swift_lib_dir "lib/swift_static")
69+
6670
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS
6771
CoreFoundation CFXMLInterface CFURLSessionInterface)
6872
install(TARGETS CoreFoundation CFXMLInterface CFURLSessionInterface
69-
DESTINATION lib/swift_static/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>)
73+
DESTINATION ${swift_lib_dir}/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>)
7074
endif()
75+
7176
# TODO(compnerd) install as a Framework as that is how swift actually is built
7277
install(DIRECTORY
7378
${CMAKE_CURRENT_BINARY_DIR}/CoreFoundation.framework/Headers/
7479
DESTINATION
75-
lib/swift/CoreFoundation
80+
${swift_lib_dir}/CoreFoundation
7681
FILES_MATCHING PATTERN "*.h")
7782
install(FILES
78-
CoreFoundation/Base.subproj/module.map
83+
CoreFoundation/Base.subproj/$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:static/>module.map
7984
DESTINATION
80-
lib/swift/CoreFoundation)
85+
${swift_lib_dir}/CoreFoundation)
8186
install(DIRECTORY
8287
${CMAKE_CURRENT_BINARY_DIR}/CFURLSessionInterface.framework/Headers/
8388
DESTINATION
84-
lib/swift/CFURLSessionInterface
89+
${swift_lib_dir}/CFURLSessionInterface
8590
FILES_MATCHING PATTERN "*.h")
8691
install(FILES
87-
CoreFoundation/URL.subproj/module.map
92+
CoreFoundation/URL.subproj/$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:static/>module.map
8893
DESTINATION
89-
lib/swift/CFURLSessionInterface)
94+
${swift_lib_dir}/CFURLSessionInterface)
9095
install(DIRECTORY
9196
${CMAKE_CURRENT_BINARY_DIR}/CFXMLInterface.framework/Headers/
9297
DESTINATION
93-
lib/swift/CFXMLInterface
98+
${swift_lib_dir}/CFXMLInterface
9499
FILES_MATCHING PATTERN "*.h")
95100
install(FILES
96-
CoreFoundation/Parsing.subproj/module.map
101+
CoreFoundation/Parsing.subproj/$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:static/>module.map
97102
DESTINATION
98-
lib/swift/CFXMLInterface)
103+
${swift_lib_dir}/CFXMLInterface)
99104

100105
add_subdirectory(cmake/modules)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module CoreFoundation [extern_c] [system] {
2+
umbrella header "CoreFoundation.h"
3+
explicit module CFPlugInCOM { header "CFPlugInCOM.h" }
4+
5+
link "CoreFoundation"
6+
link "uuid"
7+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module CFXMLInterface [extern_c] [system] {
2+
umbrella header "CFXMLInterface.h"
3+
4+
link "CFXMLInterface"
5+
link "xml2"
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module CFURLSessionInterface [extern_c] [system] {
2+
umbrella header "CFURLSessionInterface.h"
3+
4+
link "CFURLSessionInterface"
5+
link "curl"
6+
}

0 commit comments

Comments
 (0)