diff options
author | Alexander Neundorf <neundorf@kde.org> | 2007-05-24 15:27:51 (GMT) |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2007-05-24 15:27:51 (GMT) |
commit | 7d7aba292c09170fc9f145d68644e1ff6d158eec (patch) | |
tree | 6b50a27fb13d788c4b977ea199c6311ceea04854 /Tests/TryCompile/CMakeLists.txt | |
parent | 8fb8a44f5f1de4c659cc4b4cfe060e91b1e48b9c (diff) | |
download | CMake-7d7aba292c09170fc9f145d68644e1ff6d158eec.zip CMake-7d7aba292c09170fc9f145d68644e1ff6d158eec.tar.gz CMake-7d7aba292c09170fc9f145d68644e1ff6d158eec.tar.bz2 |
ENH: add two simple tests for TRY_RUN()
STYLE: create a new base class cmCoreTryCompile, from which
cmTryCompileCommand and cmTryRunCommand are derived, so there are no public
static functions with lots of arguments anymore
Alex
Diffstat (limited to 'Tests/TryCompile/CMakeLists.txt')
-rw-r--r-- | Tests/TryCompile/CMakeLists.txt | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index a9a0883..0de616f 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -61,8 +61,7 @@ IF (CMAKE_ANSI_FOR_SCOPE) MESSAGE("Compiler supports ansi for") ELSE(CMAKE_ANSI_FOR_SCOPE) MESSAGE("Compiler does not support ansi for scope") -ENDIF(CMAKE_ANSI_FOR_SCOPE) - +ENDIF(CMAKE_ANSI_FOR_SCOPE) MESSAGE("use the module now") INCLUDE(${CMAKE_ROOT}/Modules/TestForANSIForScope.cmake) @@ -73,3 +72,32 @@ ELSE(CMAKE_ANSI_FOR_SCOPE) ENDIF(CMAKE_ANSI_FOR_SCOPE) ADD_EXECUTABLE(TryCompile pass.c) + +###################################### + +# now two tests for TRY_RUN + +# try to run a file that should compile and run without error +TRY_RUN(SHOULD_RUN SHOULD_COMPILE + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/exit_success.c + OUTPUT_VARIABLE TRY_OUT) +IF(NOT SHOULD_COMPILE) + MESSAGE(SEND_ERROR "exit_success failed compiling: ${TRY_OUT}") +ENDIF(NOT SHOULD_COMPILE) +IF(NOT "${SHOULD_RUN}" STREQUAL "0") + MESSAGE(SEND_ERROR "exit_success failed running with exit code ${SHOULD_RUN}") +ENDIF(NOT "${SHOULD_RUN}" STREQUAL "0") + +# try to run a file that should compile and run, but return an error +TRY_RUN(SHOULD_EXIT_WITH_ERROR SHOULD_COMPILE + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/exit_with_error.c + OUTPUT_VARIABLE TRY_OUT) +IF(NOT SHOULD_COMPILE) + MESSAGE(STATUS " exit_with_error failed compiling: ${TRY_OUT}") +ENDIF(NOT SHOULD_COMPILE) +IF("${SHOULD_EXIT_WITH_ERROR}" STREQUAL "0") + MESSAGE(SEND_ERROR " exit_with_error passed with exit code ${SHOULD_EXIT_WITH_ERROR}") +ENDIF("${SHOULD_EXIT_WITH_ERROR}" STREQUAL "0") + |