Skip to content

Commit 56b3a9f

Browse files
committed
[CMake] Manually Set swift-version
CMAKE_Swift_LANGUAGE_VERSION isn't supported until CMake 3.16 which isn't generally released yet. For anything less, pass in -swift-version 4.2 with add_compile_options.
1 parent ed61206 commit 56b3a9f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ cmake_minimum_required(VERSION 3.15.1)
1111
project(SwiftPM LANGUAGES C Swift)
1212

1313
set(CMAKE_Swift_LANGUAGE_VERSION 4.2)
14+
if(CMAKE_VERSION VERSION_LESS 3.16)
15+
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-swift-version$<SEMICOLON>4.2>)
16+
endif()
17+
1418
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
1519

1620
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

0 commit comments

Comments
 (0)