Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: selectively convert modules to static linking in CMake #8268

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ let package = Package(
name: "CoreCommands",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
"Basics",
"Build",
"PackageLoading",
Expand All @@ -509,9 +510,11 @@ let package = Package(
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "OrderedCollections", package: "swift-collections"),
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
"Basics",
"Build",
"CoreCommands",
"LLBuildManifest",
"PackageGraph",
"PackageModelSyntax",
"SourceControl",
Expand Down Expand Up @@ -594,7 +597,7 @@ let package = Package(
.executableTarget(
/** The main executable provided by SwiftPM */
name: "swift-package",
dependencies: ["Basics", "Commands"],
dependencies: ["Commands"],
exclude: ["CMakeLists.txt"]
),
.executableTarget(
Expand Down
9 changes: 3 additions & 6 deletions Sources/CoreCommands/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

add_library(CoreCommands
add_library(CoreCommands STATIC
BuildSystemSupport.swift
SwiftCommandState.swift
SwiftCommandObservabilityHandler.swift
Expand All @@ -16,6 +16,8 @@ target_link_libraries(CoreCommands PUBLIC
Basics
Build
PackageGraph
PackageModel
PackageLoading
TSCBasic
TSCUtility
Workspace
Expand All @@ -26,8 +28,3 @@ target_link_libraries(CoreCommands PRIVATE
# NOTE(compnerd) workaround for CMake not setting up include flags yet
set_target_properties(CoreCommands PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

install(TARGETS CoreCommands
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
8 changes: 1 addition & 7 deletions Sources/DriverSupport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

add_library(DriverSupport
add_library(DriverSupport STATIC
DriverSupportUtils.swift
SPMSwiftDriverExecutor.swift)
# NOTE(compnerd) workaround for CMake not setting up include flags yet
Expand All @@ -16,9 +16,3 @@ target_link_libraries(DriverSupport PUBLIC
Basics
PackageModel
SwiftDriver)

install(TARGETS DriverSupport
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
set_property(GLOBAL APPEND PROPERTY SwiftPM_EXPORTS DriverSupport)
6 changes: 1 addition & 5 deletions Sources/PackageModelSyntax/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

add_library(PackageModelSyntax
add_library(PackageModelSyntax STATIC
AddPackageDependency.swift
AddProduct.swift
AddTarget.swift
Expand Down Expand Up @@ -37,8 +37,4 @@ target_link_libraries(PackageModelSyntax PUBLIC
set_target_properties(PackageModelSyntax PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

install(TARGETS PackageModelSyntax
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
set_property(GLOBAL APPEND PROPERTY SwiftPM_EXPORTS PackageModelSyntax)
7 changes: 1 addition & 6 deletions Sources/SwiftSDKCommand/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# See http://swift.org/LICENSE.txt for license information
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors

add_library(SwiftSDKCommand
add_library(SwiftSDKCommand STATIC
Configuration/ConfigurationSubcommand.swift
Configuration/DeprecatedSwiftSDKConfigurationCommand.swift
Configuration/ResetConfiguration.swift
Expand All @@ -27,8 +27,3 @@ target_link_libraries(SwiftSDKCommand PUBLIC
# NOTE(compnerd) workaround for CMake not setting up include flags yet
set_target_properties(SwiftSDKCommand PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

install(TARGETS SwiftSDKCommand
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
3 changes: 1 addition & 2 deletions Sources/swift-package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
add_executable(swift-package
Entrypoint.swift)
target_link_libraries(swift-package PRIVATE
Commands
TSCBasic)
Commands)

target_compile_options(swift-package PRIVATE
-parse-as-library)
Expand Down