cmake/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake

16 lines
409 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(CheckCSourceRuns)
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_runs("int main() {return 2;}" SHOULD_FAIL)
2021-09-14 00:13:48 +02:00
if(SHOULD_FAIL)
2022-11-16 20:14:03 +01:00
message(SEND_ERROR "check_c_source_runs succeeded, but should have failed.")
2021-09-14 00:13:48 +02:00
endif()
2022-11-16 20:14:03 +01:00
check_c_source_runs("int main() {return 0;}" SHOULD_RUN)
2021-09-14 00:13:48 +02:00
if(NOT SHOULD_RUN)
2022-11-16 20:14:03 +01:00
message(SEND_ERROR "check_c_source_runs failed for valid C executable.")
2021-09-14 00:13:48 +02:00
endif()