CheckSourceCompilesSwift.cmake 387 B

123456789101112131415
  1. enable_language(Swift)
  2. include(CheckSourceCompiles)
  3. set(Swift 1) # test that this is tolerated
  4. check_source_compiles(Swift "baz()" SHOULD_FAIL)
  5. if(SHOULD_FAIL)
  6. message(SEND_ERROR "invalid Swift source didn't fail.")
  7. endif()
  8. check_source_compiles(Swift "print(\"Hello, CMake\")" SHOULD_BUILD)
  9. if(NOT SHOULD_BUILD)
  10. message(SEND_ERROR "Test failed for valid Swift source.")
  11. endif()