diff options
author | Brad King <brad.king@kitware.com> | 2013-07-09 19:26:15 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-07-15 13:16:36 (GMT) |
commit | c28715b16c7a71cd8ea0416277cc87ee9bc8eaa1 (patch) | |
tree | 5ac7556cea734d652fd2499d1c0323fc9419d5e3 /Tests/TryCompile/CMakeLists.txt | |
parent | 448a67714825a6d3018a6974153de6771080a8e6 (diff) | |
download | CMake-c28715b16c7a71cd8ea0416277cc87ee9bc8eaa1.zip CMake-c28715b16c7a71cd8ea0416277cc87ee9bc8eaa1.tar.gz CMake-c28715b16c7a71cd8ea0416277cc87ee9bc8eaa1.tar.bz2 |
try_compile: Add COPY_FILE_ERROR option to capture failure
When the COPY_FILE operation fails optionally capture the error message
with a COPY_FILE_ERROR option instead of reporting the error
immediately. This gives callers a chance to do something else or report
the error.
Teach the RunCMake.try_compile test to cover bad argument combinations
involving COPY_FILE_ERROR. Teach the TryCompile test to cover the case
of a COPY_FILE error message captured by COPY_FILE_ERROR.
Diffstat (limited to 'Tests/TryCompile/CMakeLists.txt')
-rw-r--r-- | Tests/TryCompile/CMakeLists.txt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 4540fd0..173929b 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -44,6 +44,23 @@ else() file(REMOVE "${TryCompile_BINARY_DIR}/CopyOfPass") endif() +# try to compile a file that should compile +# also check that COPY_FILE_ERROR works +file(WRITE ${TryCompile_BINARY_DIR}/invalid "") +try_compile(SHOULD_PASS + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/pass.c + OUTPUT_VARIABLE TRY_OUT + COPY_FILE ${TryCompile_BINARY_DIR}/invalid/path + COPY_FILE_ERROR _captured + ) +if(NOT SHOULD_PASS) + message(SEND_ERROR "should pass failed ${TRY_OUT}") +endif() +if(NOT _captured MATCHES "Cannot copy output executable.*/invalid/path") + message(SEND_ERROR "COPY_FILE_ERROR did not capture expected message") +endif() + # try to compile a file that should not compile try_compile(SHOULD_FAIL ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp |