summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesSwift.cmake
blob: 8edff2c621abeb684227b795cb2097d696fc301b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cmake_policy(SET CMP0157 NEW)
enable_language(Swift)
include(CheckSourceCompiles)

set(Swift 1) # test that this is tolerated

check_source_compiles(Swift "baz()" SHOULD_FAIL)

if(SHOULD_FAIL)
  message(SEND_ERROR "invalid Swift source didn't fail.")
endif()

check_source_compiles(Swift "print(\"Hello, CMake\")" SHOULD_BUILD)
if(NOT SHOULD_BUILD)
  message(SEND_ERROR "Test failed for valid Swift source.")
endif()