Skip to content

Commit a8c8508

Browse files
committed
Restructure Foundation into Sources/Foundation
This moves the Foundation sources from `Foundation` into a subdirectory in `Sources`. This reflects the traditional directory structure for Frameworks.
1 parent 24cb3bb commit a8c8508

File tree

139 files changed

+32
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+32
-41
lines changed

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ enable_testing()
1717
# Cache the variable to allow the user to alter the configuration.
1818
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" CACHE
1919
STRING "MSVC Runtime Library")
20+
2021
if(CMAKE_VERSION VERSION_LESS 3.16.0)
2122
if(NOT (CMAKE_SYSTEM_NAME STREQUAL Windows OR CMAKE_SYSTEM_NAME STREQUAL Darwin))
2223
set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG "-Xlinker -rpath -Xlinker ")
2324
set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG_SEP ":")
2425
endif()
26+
# Workaround for CMake 3.15 which doesn't link libraries properly on Windows
27+
set(CMAKE_LINK_LIBRARY_FLAG "-l")
2528
endif()
2629

2730
option(BUILD_SHARED_LIBS "build shared libraries" ON)
@@ -45,7 +48,6 @@ target_include_directories(CoreFoundation PRIVATE
4548
${CMAKE_CURRENT_BINARY_DIR}/CoreFoundation.framework/Headers)
4649

4750
add_subdirectory(Sources)
48-
add_subdirectory(Foundation)
4951
add_subdirectory(Tools)
5052
if(ENABLE_TESTING)
5153
find_package(XCTest CONFIG REQUIRED)

Sources/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
add_subdirectory(UUID)
2+
add_subdirectory(Foundation)
23
add_subdirectory(FoundationNetworking)
34
add_subdirectory(FoundationXML)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Foundation/CMakeLists.txt Sources/Foundation/CMakeLists.txt

+26-38
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
2-
if(CMAKE_VERSION VERSION_LESS 3.16)
3-
set(CMAKE_LINK_LIBRARY_FLAG "-l")
4-
endif()
5-
61
add_library(Foundation
72
AffineTransform.swift
83
Array.swift
@@ -33,7 +28,7 @@ add_library(Foundation
3328
FileManager.swift
3429
FileManager+POSIX.swift
3530
FileManager+Win32.swift
36-
FileManager_XDG.swift
31+
FileManager+XDG.swift
3732
Formatter.swift
3833
FoundationErrors.swift
3934
Host.swift
@@ -139,50 +134,43 @@ add_library(Foundation
139134
target_compile_definitions(Foundation PRIVATE
140135
DEPLOYMENT_RUNTIME_SWIFT)
141136
target_compile_options(Foundation PUBLIC
137+
$<$<BOOL:${ENABLE_TESTING}>:-enable-testing>
142138
"SHELL:-Xcc -F${CMAKE_BINARY_DIR}")
143-
if(CMAKE_SYSTEM_NAME STREQUAL Windows AND CMAKE_VERSION VERSION_LESS 3.16)
144-
# Work around for CMake 15 which doesn't link in the resource file
145-
# target properly
146-
add_dependencies(Foundation CoreFoundationResources)
147-
target_link_options(Foundation PRIVATE $<TARGET_OBJECTS:CoreFoundationResources>)
148-
endif()
149-
if(ENABLE_TESTING)
150-
target_compile_options(Foundation PRIVATE
151-
-enable-testing)
152-
endif()
153-
target_link_libraries(Foundation PRIVATE
154-
CoreFoundation
155-
uuid)
156-
target_link_libraries(Foundation PUBLIC
157-
swiftDispatch)
158-
159-
# TODO(compnerd) properly propogate `BUILD_RPATH` to the target using CMake
160-
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
161-
target_link_options(Foundation PRIVATE
162-
"SHELL:-Xlinker -rpath -Xlinker $<TARGET_FILE_DIR:swiftDispatch>")
163-
endif()
164-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
165-
target_link_libraries(Foundation PRIVATE
166-
CoreFoundationResources)
167-
target_link_libraries(Foundation PRIVATE
168-
Ole32
169-
Shell32
170-
pathcch)
171-
endif()
139+
target_link_libraries(Foundation
140+
PRIVATE
141+
$<$<PLATFORM_ID:Windows>:CoreFoundationResources>
142+
$<$<PLATFORM_ID:Windows>:Ole32>
143+
$<$<PLATFORM_ID:Windows>:Shell32>
144+
$<$<PLATFORM_ID:Windows>:pathcch>
145+
CoreFoundation
146+
uuid
147+
PUBLIC
148+
swiftDispatch)
172149
set_target_properties(Foundation PROPERTIES
173150
INSTALL_RPATH "$ORIGIN"
174151
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift
175152
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift)
176153

154+
if(CMAKE_SYSTEM_NAME STREQUAL Windows AND CMAKE_VERSION VERSION_LESS 3.16)
155+
# Workaround for CMake 3.15 which doesn't link in the resource file target
156+
# properly
157+
add_dependencies(Foundation CoreFoundationResources)
158+
target_link_options(Foundation PRIVATE $<TARGET_OBJECTS:CoreFoundationResources>)
177159

160+
# Workaround for CMake 3.15 which doesn't handle `-rpath` properly
161+
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
162+
target_link_options(Foundation PRIVATE
163+
"SHELL:-Xlinker -rpath -Xlinker $<TARGET_FILE_DIR:swiftDispatch>")
164+
endif()
165+
endif()
178166

179-
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS
180-
Foundation FoundationNetworking)
181-
get_swift_host_arch(swift_arch)
167+
168+
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS Foundation)
182169
install(TARGETS Foundation
183170
ARCHIVE DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>
184171
LIBRARY DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>
185172
RUNTIME DESTINATION bin)
173+
get_swift_host_arch(swift_arch)
186174
install(FILES
187175
${CMAKE_BINARY_DIR}/swift/Foundation.swiftdoc
188176
${CMAKE_BINARY_DIR}/swift/Foundation.swiftmodule
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Sources/FoundationNetworking/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_library(FoundationNetworking
2-
../../Foundation/Boxing.swift
2+
../Foundation/Boxing.swift
33
HTTPCookie.swift
44
HTTPCookieStorage.swift
55
NSURLRequest.swift

Tests/Foundation/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ add_executable(TestFoundation
33
HTTPServer.swift
44
Imports.swift
55
FTPServer.swift
6-
../../Foundation/ProgressFraction.swift
6+
../../Sources/Foundation/ProgressFraction.swift
77
Utilities.swift
88
FixtureValues.swift)
99

0 commit comments

Comments
 (0)