Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesSwift.cmake
raw| 1 | cmake_policy(SET CMP0157 NEW) |
| 2 | enable_language(Swift) |
| 3 | include(CheckSourceCompiles) |
| 4 | |
| 5 | set(Swift 1) # test that this is tolerated |
| 6 | |
| 7 | check_source_compiles(Swift "baz()" SHOULD_FAIL) |
| 8 | |
| 9 | if(SHOULD_FAIL) |
| 10 | message(SEND_ERROR "invalid Swift source didn't fail.") |
| 11 | endif() |
| 12 | |
| 13 | check_source_compiles(Swift "print(\"Hello, CMake\")" SHOULD_BUILD) |
| 14 | if(NOT SHOULD_BUILD) |
| 15 | message(SEND_ERROR "Test failed for valid Swift source.") |
| 16 | endif() |