cmake/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake

16 lines
370 B
CMake
Raw Normal View History

2021-09-14 00:13:48 +02:00
enable_language (C)
2022-11-16 20:14:03 +01:00
include(CheckCSourceCompiles)
2021-09-14 00:13:48 +02:00
set(C 1) # test that this is tolerated
2022-11-16 20:14:03 +01:00
check_c_source_compiles("I don't build" SHOULD_FAIL)
2021-09-14 00:13:48 +02:00
if(SHOULD_FAIL)
message(SEND_ERROR "invalid C source didn't fail.")
endif()
2022-11-16 20:14:03 +01:00
check_c_source_compiles("int main() {return 0;}" SHOULD_BUILD)
2021-09-14 00:13:48 +02:00
if(NOT SHOULD_BUILD)
message(SEND_ERROR "Test fail for valid C source.")
endif()