diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2019-11-06 22:55:48 (GMT) |
---|---|---|
committer | Cristian Adam <cristian.adam@gmail.com> | 2019-11-09 10:25:32 (GMT) |
commit | 7447aa4b340420b0d55bc17bdd9ca1422b1806cf (patch) | |
tree | fb6c81fc7dea4897f7b954edb6fd0c5b9af47e25 /Tests/TryCompile | |
parent | ef86e8991b6b9b2d4b25f98a95ba950f9ba19485 (diff) | |
download | CMake-7447aa4b340420b0d55bc17bdd9ca1422b1806cf.zip CMake-7447aa4b340420b0d55bc17bdd9ca1422b1806cf.tar.gz CMake-7447aa4b340420b0d55bc17bdd9ca1422b1806cf.tar.bz2 |
ObjC: Add try_compile support
Fixes: #19920
Diffstat (limited to 'Tests/TryCompile')
-rw-r--r-- | Tests/TryCompile/CMakeLists.txt | 19 | ||||
-rw-r--r-- | Tests/TryCompile/fail.m | 1 | ||||
-rw-r--r-- | Tests/TryCompile/pass.m | 4 |
3 files changed, 24 insertions, 0 deletions
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 498e556..9ec9b70 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -365,6 +365,25 @@ if (APPLE) TEST_ASSERT(SIMPLE_OBJCXX_RUN_SHOULD_WORK "CHECK_OBJCXX_SOURCE_RUNS() failed, but should have succeeded") TEST_FAIL(OBJCXX_RUN_SHOULD_FAIL "CHECK_OBJCXX_SOURCE_RUNS() succeeds, but should have failed") TEST_ASSERT(OBJCXX_RUN_SHOULD_WORK "CHECK_OBJCXX_SOURCE_RUNS() failed, but should have succeeded") + + # try to compile a file that should compile + try_compile(SHOULD_PASS + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/pass.m + OUTPUT_VARIABLE TRY_OUT) + if(NOT SHOULD_PASS) + message(SEND_ERROR "should pass failed ${TRY_OUT}") + endif() + + # try to compile a file that should not compile + try_compile(SHOULD_FAIL + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/fail.m + OUTPUT_VARIABLE TRY_OUT) + if(SHOULD_FAIL) + message(SEND_ERROR "Should fail passed ${TRY_OUT}") + endif() + endif() ####################################################################### diff --git a/Tests/TryCompile/fail.m b/Tests/TryCompile/fail.m new file mode 100644 index 0000000..b915ebe --- /dev/null +++ b/Tests/TryCompile/fail.m @@ -0,0 +1 @@ +asdflkjasdlj diff --git a/Tests/TryCompile/pass.m b/Tests/TryCompile/pass.m new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/TryCompile/pass.m @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} |