mirror of
https://github.com/apple/swift-crypto
synced 2026-11-22 04:30:39 +00:00
Build the CMake targets in the Swift 6 language mode (#501)
### Motivation: `Package.swift` uses tools version 6.2 and declares no `swiftLanguageModes`, so SwiftPM builds Swift Crypto in the Swift 6 language mode. The CMake build passes no `-swift-version`, so the compiler falls back to the Swift 5 language mode. The two build systems compile the same sources in different language modes. ### Modifications: - Set `CMAKE_Swift_LANGUAGE_VERSION` to 6 after the swift-asn1 `FetchContent` block, so swift-asn1 keeps its own language mode when CMake fetches it. - Raise the minimum CMake version to 3.16, the release that added `Swift_LANGUAGE_VERSION`. - Remove the branch that set Windows output directories for CMake versions before 3.16. ### Result: CMake builds Swift Crypto in the Swift 6 language mode, as SwiftPM does.
This commit is contained in:
1 parent
32adcc5038
commit
281a92df6c
1 file changed
+6
-8
+6
-8
@@ -12,7 +12,7 @@
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
cmake_minimum_required(VERSION 3.15.1)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
if(POLICY CMP0157)
|
||||
cmake_policy(SET CMP0157 NEW)
|
||||
@@ -25,13 +25,8 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
||||
|
||||
include(SwiftSupport)
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 3.16 AND CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
else()
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
endif()
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
|
||||
|
||||
@@ -79,5 +74,8 @@ if(NOT SwiftASN1_FOUND)
|
||||
FetchContent_MakeAvailable(ASN1)
|
||||
endif()
|
||||
|
||||
# Set after vending swift-asn1 so its targets keep their own language mode.
|
||||
set(CMAKE_Swift_LANGUAGE_VERSION 6)
|
||||
|
||||
add_subdirectory(Sources)
|
||||
add_subdirectory(cmake/modules)
|
||||
Reference in new issue
Block a user