Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake
raw| 1 | |
| 2 | enable_language (C) |
| 3 | include(CheckCSourceCompiles) |
| 4 | |
| 5 | set(C 1) # test that this is tolerated |
| 6 | |
| 7 | check_c_source_compiles("I don't build" SHOULD_FAIL) |
| 8 | if(SHOULD_FAIL) |
| 9 | message(SEND_ERROR "invalid C source didn't fail.") |
| 10 | endif() |
| 11 | |
| 12 | check_c_source_compiles("int main() {return 0;}" SHOULD_BUILD) |
| 13 | if(NOT SHOULD_BUILD) |
| 14 | message(SEND_ERROR "Test fail for valid C source.") |
| 15 | endif() |