diff options
author | Brad King <brad.king@kitware.com> | 2013-07-15 13:31:01 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-07-15 13:31:01 (GMT) |
commit | 88f4ec0dd5a1e181ca3dc35992755930599f2e3f (patch) | |
tree | 3032ef95b560826fb003c17ce44f9aa1c9da1aa9 /Tests | |
parent | 0d41e9ea3566716f3e6b3db4ad8403c418c7f5e4 (diff) | |
parent | 290857bb03a4ce2f42df751c319769ff5863dd73 (diff) | |
download | CMake-88f4ec0dd5a1e181ca3dc35992755930599f2e3f.zip CMake-88f4ec0dd5a1e181ca3dc35992755930599f2e3f.tar.gz CMake-88f4ec0dd5a1e181ca3dc35992755930599f2e3f.tar.bz2 |
Merge topic 'try_compile-escape-flags'
290857b try_compile: Escape CMAKE_<lang>_FLAGS in test projects (#14268)
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/TryCompile/CMakeLists.txt | 18 | ||||
-rw-r--r-- | Tests/TryCompile/testdef.c | 4 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 4540fd0..7b25e84 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -89,6 +89,24 @@ if(SHOULD_FAIL) message(SEND_ERROR "Should fail passed ${TRY_OUT}") endif() +# try to compile a file that should compile +set(_c_flags "${CMAKE_C_FLAGS}") +if(CMAKE_GENERATOR STREQUAL "Visual Studio 6") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D \"TESTDEF\"") +elseif(WATCOM) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -dTESTDEF") +else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \"-DTESTDEF\"") +endif() +try_compile(SHOULD_PASS + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/testdef.c + OUTPUT_VARIABLE TRY_OUT) +if(NOT SHOULD_PASS) + message(SEND_ERROR "should pass failed ${TRY_OUT}") +endif() +set(CMAKE_C_FLAGS "${_c_flags}") + if(NOT SHOULD_FAIL) if(SHOULD_PASS) message("All Tests passed, ignore all previous output.") diff --git a/Tests/TryCompile/testdef.c b/Tests/TryCompile/testdef.c new file mode 100644 index 0000000..5401e71 --- /dev/null +++ b/Tests/TryCompile/testdef.c @@ -0,0 +1,4 @@ +#ifndef TESTDEF +# error "TESTDEF should be defined!" +#endif +int main(void) { return 0; } |