diff options
Diffstat (limited to 'Tests/TryCompile')
-rw-r--r-- | Tests/TryCompile/CMakeLists.txt | 18 | ||||
-rw-r--r-- | Tests/TryCompile/fail2a.c | 1 | ||||
-rw-r--r-- | Tests/TryCompile/fail2b.c | 1 | ||||
-rw-r--r-- | Tests/TryCompile/pass2a.c | 2 | ||||
-rw-r--r-- | Tests/TryCompile/pass2b.cxx | 1 |
5 files changed, 23 insertions, 0 deletions
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index b6b66d8..4540fd0 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -71,6 +71,24 @@ if(SHOULD_FAIL) message(SEND_ERROR "Should fail passed ${TRY_OUT}") endif() +# try to compile two files that should compile +try_compile(SHOULD_PASS + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + SOURCES ${TryCompile_SOURCE_DIR}/pass2a.c ${TryCompile_SOURCE_DIR}/pass2b.cxx + OUTPUT_VARIABLE TRY_OUT) +if(NOT SHOULD_PASS) + message(SEND_ERROR "should pass failed ${TRY_OUT}") +endif() + +# try to compile two files that should not compile +try_compile(SHOULD_FAIL + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + SOURCES ${TryCompile_SOURCE_DIR}/fail2a.c ${TryCompile_SOURCE_DIR}/fail2b.c + OUTPUT_VARIABLE TRY_OUT) +if(SHOULD_FAIL) + message(SEND_ERROR "Should fail passed ${TRY_OUT}") +endif() + if(NOT SHOULD_FAIL) if(SHOULD_PASS) message("All Tests passed, ignore all previous output.") diff --git a/Tests/TryCompile/fail2a.c b/Tests/TryCompile/fail2a.c new file mode 100644 index 0000000..78f2de1 --- /dev/null +++ b/Tests/TryCompile/fail2a.c @@ -0,0 +1 @@ +int main(void) { return 0; } diff --git a/Tests/TryCompile/fail2b.c b/Tests/TryCompile/fail2b.c new file mode 100644 index 0000000..5ee809c --- /dev/null +++ b/Tests/TryCompile/fail2b.c @@ -0,0 +1 @@ +does_not_compile diff --git a/Tests/TryCompile/pass2a.c b/Tests/TryCompile/pass2a.c new file mode 100644 index 0000000..bbfe6d5 --- /dev/null +++ b/Tests/TryCompile/pass2a.c @@ -0,0 +1,2 @@ +extern int pass2b(void); +int main() { return pass2b(); } diff --git a/Tests/TryCompile/pass2b.cxx b/Tests/TryCompile/pass2b.cxx new file mode 100644 index 0000000..4c539e2 --- /dev/null +++ b/Tests/TryCompile/pass2b.cxx @@ -0,0 +1 @@ +extern "C" int pass2b(void) { return 0; } |