Skip to content

Commit 5083132

Browse files
committed
cmake: extract version string and add PrintVersion.cmake
Add a helper to allow us to programatically extract the Swift version string during the build. This is particularly useful for injection into the packaging stages.
1 parent 91d2a1c commit 5083132

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,7 @@ endif()
304304
set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
305305
"Build Swift with code coverage instrumenting enabled [FALSE, NOT-MERGED, MERGED]")
306306

307-
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
308-
# can be reused when a new version of Swift comes out (assuming the user hasn't
309-
# manually set it as part of their own CMake configuration).
310-
set(SWIFT_VERSION_MAJOR 5)
311-
set(SWIFT_VERSION_MINOR 9)
312-
set(SWIFT_VERSION "${SWIFT_VERSION_MAJOR}.${SWIFT_VERSION_MINOR}")
307+
include(cmake/SwiftVerison.cmake)
313308

314309
set(SWIFT_VENDOR "" CACHE STRING
315310
"The vendor name of the Swift compiler")

cmake/PrintVersion.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include(SwiftVersion.cmake)
2+
message(${SWIFT_VERSION})

cmake/SwiftVersion.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
2+
# can be reused when a new version of Swift comes out (assuming the user hasn't
3+
# manually set it as part of their own CMake configuration).
4+
set(SWIFT_VERSION_MAJOR 5)
5+
set(SWIFT_VERSION_MINOR 9)
6+
set(SWIFT_VERSION "${SWIFT_VERSION_MAJOR}.${SWIFT_VERSION_MINOR}")

0 commit comments

Comments
 (0)