Skip to content

Commit cd2a7b3

Browse files
committed
CMake: Set language version across supplemental libs
The Swift language version appears in the Swift interface and impacts how the interface is handled by the compiler when importing the module. The version only appears if it is set, which means that downstream projects setting the version explicitly may interpret the swift interface file differently. This also factors the setting out into a separate file, which is used to set the C++ standard and Swift language version since it is the same across these libraries at this time. If this assumption changes, we can refactor as necessary and this structure shouldn't be seen as enforcement. Finally, this patch moves setting the language version and standard variables before the languages are enabled. This ensures that the try-compile applies the appropriate flags when verifying that the compiler works.
1 parent 16ce6b8 commit cd2a7b3

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

Runtimes/Supplemental/Distributed/CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ list(APPEND CMAKE_MODULE_PATH
1313
"${CMAKE_SOURCE_DIR}/../cmake/modules"
1414
"${CMAKE_SOURCE_DIR}/../../cmake/modules")
1515

16+
include(LanguageVersions)
1617
include(SwiftProjectVersion)
1718
project(SwiftDistributed
1819
LANGUAGES C CXX Swift
@@ -22,17 +23,10 @@ if(NOT PROJECT_IS_TOP_LEVEL)
2223
message(SEND_ERROR "Swift Distributed must build as a standalone project")
2324
endif()
2425

25-
set(CMAKE_Swift_LANGUAGE_VERSION 5)
26-
2726
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
2827

2928
set(CMAKE_C_VISIBILITY_PRESET "hidden")
30-
31-
set(CMAKE_CXX_EXTENSIONS NO)
32-
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
33-
set(CMAKE_CXX_STANDARD_REQUIRED YES)
3429
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
35-
3630
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
3731

3832
set(${PROJECT_NAME}_SWIFTC_SOURCE_DIR

Runtimes/Supplemental/Observation/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ list(APPEND CMAKE_MODULE_PATH
1313
"${CMAKE_SOURCE_DIR}/../cmake/modules"
1414
"${CMAKE_SOURCE_DIR}/../../cmake/modules")
1515

16+
include(LanguageVersions)
1617
include(SwiftProjectVersion)
1718
project(SwiftObservation
1819
LANGUAGES Swift CXX
@@ -22,9 +23,6 @@ if(NOT PROJECT_IS_TOP_LEVEL)
2223
message(SEND_ERROR "Swift Observation must build as a standalone project")
2324
endif()
2425

25-
set(CMAKE_CXX_STANDARD 17)
26-
set(CMAKE_CXX_STANDARD_REQUIRED YES)
27-
set(CMAKE_CXX_EXTENSIONS NO)
2826
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
2927

3028
set(${PROJECT_NAME}_SWIFTC_SOURCE_DIR

Runtimes/Supplemental/StringProcessing/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ list(APPEND CMAKE_MODULE_PATH
1414
"${CMAKE_SOURCE_DIR}/../cmake/modules"
1515
"${CMAKE_SOURCE_DIR}/../../cmake/modules")
1616

17+
include(LanguageVersions)
1718
include(SwiftProjectVersion)
1819
project(SwiftStringProcessing
1920
LANGUAGES Swift C

Runtimes/Supplemental/Synchronization/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ list(APPEND CMAKE_MODULE_PATH
1313
"${CMAKE_SOURCE_DIR}/../cmake/modules"
1414
"${CMAKE_SOURCE_DIR}/../../cmake/modules")
1515

16+
include(LanguageVersions)
1617
include(SwiftProjectVersion)
1718
project(SwiftSynchronization
1819
LANGUAGES Swift

Runtimes/Supplemental/Volatile/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ list(APPEND CMAKE_MODULE_PATH
1313
"${CMAKE_SOURCE_DIR}/../cmake/modules"
1414
"${CMAKE_SOURCE_DIR}/../../cmake/modules")
1515

16+
include(LanguageVersions)
1617
include(SwiftProjectVersion)
1718
project(SwiftVolatile
1819
LANGUAGES Swift
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set(CMAKE_Swift_LANGUAGE_VERSION 5)
2+
3+
set(CMAKE_CXX_STANDARD 17)
4+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
5+
set(CMAKE_CXX_EXTENSIONS NO)

0 commit comments

Comments
 (0)