CheckSourceCompilesSwift.cmake 417 B

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