Skip to content

Commit eca7824

Browse files
authored
Added option to enable CMake Install (swiftlang#2907)
Since SwiftPM does its own installation using the bootstrap script, it hides the CMake install target to only be enabled on Windows which doesn't use the bootstrap script. But when bootstrapping using CMake on non Windows platforms, it would be nice to be able to enable them.
1 parent b6e556a commit eca7824

File tree

20 files changed

+28
-24
lines changed

20 files changed

+28
-24
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ else()
3030
endif()
3131
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
3232

33-
option(BUILD_SHARED_LIBS "Build shared libraryes by default" YES)
33+
option(BUILD_SHARED_LIBS "Build shared libraries by default" YES)
34+
35+
string(COMPARE EQUAL ${CMAKE_SYSTEM_NAME} Windows CMAKE_INSTALL_DEFAULT)
36+
option(USE_CMAKE_INSTALL
37+
"Install build products using cmake's install() instead of the bootstrap script's install()"
38+
${CMAKE_INSTALL_DEFAULT})
3439

3540
find_package(TSC CONFIG REQUIRED)
3641

Sources/Build/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ target_link_libraries(Build PRIVATE
2727
set_target_properties(Build PROPERTIES
2828
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
2929

30-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
30+
if(USE_CMAKE_INSTALL)
3131
install(TARGETS Build
3232
ARCHIVE DESTINATION lib
3333
LIBRARY DESTINATION lib

Sources/Commands/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ endif()
3939
set_target_properties(Commands PROPERTIES
4040
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
4141

42-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
42+
if(USE_CMAKE_INSTALL)
4343
install(TARGETS Commands
4444
ARCHIVE DESTINATION lib
4545
LIBRARY DESTINATION lib

Sources/LLBuildManifest/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ target_link_libraries(LLBuildManifest PUBLIC
2121
set_target_properties(LLBuildManifest PROPERTIES
2222
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
2323

24-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
24+
if(USE_CMAKE_INSTALL)
2525
install(TARGETS LLBuildManifest
2626
ARCHIVE DESTINATION lib
2727
LIBRARY DESTINATION lib

Sources/PackageGraph/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ target_link_libraries(PackageGraph PUBLIC
2727
set_target_properties(PackageGraph PROPERTIES
2828
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
2929

30-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
30+
if(USE_CMAKE_INSTALL)
3131
install(TARGETS PackageGraph
3232
ARCHIVE DESTINATION lib
3333
LIBRARY DESTINATION lib

Sources/PackageLoading/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ target_link_libraries(PackageLoading PUBLIC
2727
set_target_properties(PackageLoading PROPERTIES
2828
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
2929

30-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
30+
if(USE_CMAKE_INSTALL)
3131
install(TARGETS PackageLoading
3232
ARCHIVE DESTINATION lib
3333
LIBRARY DESTINATION lib

Sources/PackageModel/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ target_link_libraries(PackageModel PUBLIC
2525
set_target_properties(PackageModel PROPERTIES
2626
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
2727

28-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
28+
if(USE_CMAKE_INSTALL)
2929
install(TARGETS PackageModel
3030
ARCHIVE DESTINATION lib
3131
LIBRARY DESTINATION lib

Sources/SPMBuildCore/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ target_link_libraries(SPMBuildCore PUBLIC
2121
PackageGraph)
2222

2323

24-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
24+
if(USE_CMAKE_INSTALL)
2525
install(TARGETS SPMBuildCore
2626
ARCHIVE DESTINATION lib
2727
LIBRARY DESTINATION lib

Sources/SPMLLBuild/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ target_link_libraries(SPMLLBuild PUBLIC
1616
TSCUtility
1717
llbuildSwift)
1818

19-
20-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
19+
if(USE_CMAKE_INSTALL)
2120
install(TARGETS SPMLLBuild
2221
ARCHIVE DESTINATION lib
2322
LIBRARY DESTINATION lib

Sources/SourceControl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ target_link_libraries(SourceControl PUBLIC
2121
set_target_properties(SourceControl PROPERTIES
2222
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
2323

24-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
24+
if(USE_CMAKE_INSTALL)
2525
install(TARGETS SourceControl
2626
ARCHIVE DESTINATION lib
2727
LIBRARY DESTINATION lib

Sources/Workspace/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ target_link_libraries(Workspace PUBLIC
2929
set_target_properties(Workspace PROPERTIES
3030
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
3131

32-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
32+
if(USE_CMAKE_INSTALL)
3333
install(TARGETS Workspace
3434
ARCHIVE DESTINATION lib
3535
LIBRARY DESTINATION lib

Sources/XCBuildSupport/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ target_link_libraries(XCBuildSupport PUBLIC
2323
set_target_properties(XCBuildSupport PROPERTIES
2424
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
2525

26-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
27-
install(TARGETS XCBuildSupport
26+
if(USE_CMAKE_INSTALL)
27+
install(TARGETS XCBuildSupport
2828
ARCHIVE DESTINATION lib
2929
LIBRARY DESTINATION lib
3030
RUNTIME DESTINATION bin)

Sources/Xcodeproj/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ target_link_libraries(Xcodeproj PUBLIC
2121
set_target_properties(Xcodeproj PROPERTIES
2222
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
2323

24-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
24+
if(USE_CMAKE_INSTALL)
2525
install(TARGETS Xcodeproj
2626
ARCHIVE DESTINATION lib
2727
LIBRARY DESTINATION lib

Sources/swift-build/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ add_executable(swift-build
1111
target_link_libraries(swift-build PRIVATE
1212
Commands)
1313

14-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
15-
install(TARGETS swift-build
16-
DESTINATION bin)
14+
if(USE_CMAKE_INSTALL)
15+
install(TARGETS swift-build
16+
DESTINATION bin)
1717
endif()

Sources/swift-package/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ add_executable(swift-package
1111
target_link_libraries(swift-package PRIVATE
1212
Commands)
1313

14-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
14+
if(USE_CMAKE_INSTALL)
1515
install(TARGETS swift-package
1616
RUNTIME DESTINATION bin)
1717
endif()

Sources/swift-run/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ add_executable(swift-run
1111
target_link_libraries(swift-run PRIVATE
1212
Commands)
1313

14-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
14+
if(USE_CMAKE_INSTALL)
1515
install(TARGETS swift-run
1616
RUNTIME DESTINATION bin)
1717
endif()

Sources/swift-test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ add_executable(swift-test
1111
target_link_libraries(swift-test PRIVATE
1212
Commands)
1313

14-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
14+
if(USE_CMAKE_INSTALL)
1515
install(TARGETS swift-test
1616
RUNTIME DESTINATION bin)
1717
endif()

swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ set_target_properties(TSCBasic PROPERTIES
6565
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
6666

6767

68-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
68+
if(USE_CMAKE_INSTALL)
6969
install(TARGETS TSCBasic
7070
ARCHIVE DESTINATION lib
7171
LIBRARY DESTINATION lib

swift-tools-support-core/Sources/TSCLibc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set_target_properties(TSCLibc PROPERTIES
2020
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
2121

2222

23-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
23+
if(USE_CMAKE_INSTALL)
2424
install(TARGETS TSCLibc
2525
ARCHIVE DESTINATION lib
2626
LIBRARY DESTINATION lib

swift-tools-support-core/Sources/TSCUtility/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ endif()
5252
set_target_properties(TSCUtility PROPERTIES
5353
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
5454

55-
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
55+
if(USE_CMAKE_INSTALL)
5656
install(TARGETS TSCUtility
5757
ARCHIVE DESTINATION lib
5858
LIBRARY DESTINATION lib

0 commit comments

Comments
 (0)