Skip to content

Commit 98ff863

Browse files
authored
Add modulemaps that work for statically compiled Foundation (#2850)
* 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 * Move swift_lib_dir definition into separate block
1 parent 38b6914 commit 98ff863

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

CMakeLists.txt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,33 +68,39 @@ if(NOT BUILD_SHARED_LIBS)
6868
install(TARGETS CoreFoundation CFXMLInterface CFURLSessionInterface
6969
DESTINATION lib/swift_static/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>)
7070
endif()
71+
72+
set(swift_lib_dir "lib/swift")
73+
if(NOT BUILD_SHARED_LIBS)
74+
set(swift_lib_dir "lib/swift_static")
75+
endif()
76+
7177
# TODO(compnerd) install as a Framework as that is how swift actually is built
7278
install(DIRECTORY
7379
${CMAKE_CURRENT_BINARY_DIR}/CoreFoundation.framework/Headers/
7480
DESTINATION
75-
lib/swift/CoreFoundation
81+
${swift_lib_dir}/CoreFoundation
7682
FILES_MATCHING PATTERN "*.h")
7783
install(FILES
78-
CoreFoundation/Base.subproj/module.map
84+
CoreFoundation/Base.subproj/$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:static/>module.map
7985
DESTINATION
80-
lib/swift/CoreFoundation)
86+
${swift_lib_dir}/CoreFoundation)
8187
install(DIRECTORY
8288
${CMAKE_CURRENT_BINARY_DIR}/CFURLSessionInterface.framework/Headers/
8389
DESTINATION
84-
lib/swift/CFURLSessionInterface
90+
${swift_lib_dir}/CFURLSessionInterface
8591
FILES_MATCHING PATTERN "*.h")
8692
install(FILES
87-
CoreFoundation/URL.subproj/module.map
93+
CoreFoundation/URL.subproj/$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:static/>module.map
8894
DESTINATION
89-
lib/swift/CFURLSessionInterface)
95+
${swift_lib_dir}/CFURLSessionInterface)
9096
install(DIRECTORY
9197
${CMAKE_CURRENT_BINARY_DIR}/CFXMLInterface.framework/Headers/
9298
DESTINATION
93-
lib/swift/CFXMLInterface
99+
${swift_lib_dir}/CFXMLInterface
94100
FILES_MATCHING PATTERN "*.h")
95101
install(FILES
96-
CoreFoundation/Parsing.subproj/module.map
102+
CoreFoundation/Parsing.subproj/$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:static/>module.map
97103
DESTINATION
98-
lib/swift/CFXMLInterface)
104+
${swift_lib_dir}/CFXMLInterface)
99105

100106
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)