summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2020-09-14 17:26:43 (GMT)
committerRobert Maynard <robert.maynard@kitware.com>2020-09-23 16:28:37 (GMT)
commit357e2ef429b5245de4f2f5fc7ba7b8089d90bb1c (patch)
tree77b39aa9c625e80699a3998be433cde4f5dc9d88 /Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake
parent10ae907de07c26820a765c6a516d1f4baa46161d (diff)
downloadCMake-357e2ef429b5245de4f2f5fc7ba7b8089d90bb1c.zip
CMake-357e2ef429b5245de4f2f5fc7ba7b8089d90bb1c.tar.gz
CMake-357e2ef429b5245de4f2f5fc7ba7b8089d90bb1c.tar.bz2
CheckSoureRuns: Add a unified way to check if a source runs
Diffstat (limited to 'Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake')
-rw-r--r--Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake13
1 files changed, 13 insertions, 0 deletions
diff --git a/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake
new file mode 100644
index 0000000..3029ac2
--- /dev/null
+++ b/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake
@@ -0,0 +1,13 @@
+
+enable_language (C)
+include(CheckSourceRuns)
+
+check_source_runs(C "int main() {return 2;}" SHOULD_FAIL)
+if(SHOULD_FAIL)
+ message(SEND_ERROR "C check_source_runs succeeded, but should have failed.")
+endif()
+
+check_source_runs(C "int main() {return 0;}" SHOULD_RUN)
+if(NOT SHOULD_RUN)
+ message(SEND_ERROR "C check_source_runs failed for valid C executable.")
+endif()