CheckCSourceCompiles.cmake 369 B

123456789101112131415
  1. enable_language (C)
  2. include(CheckSourceCompiles)
  3. set(C 1) # test that this is tolerated
  4. check_source_compiles(C "I don't build" SHOULD_FAIL)
  5. if(SHOULD_FAIL)
  6. message(SEND_ERROR "invalid C source didn't fail.")
  7. endif()
  8. check_source_compiles(C "int main() {return 0;}" SHOULD_BUILD)
  9. if(NOT SHOULD_BUILD)
  10. message(SEND_ERROR "Test fail for valid C source.")
  11. endif()