[cmake-commits] alex committed CMakeLists.txt 1.9 1.10 exit_success.c
1.1 1.2 exit_with_error.c 1.1 1.2
cmake-commits at cmake.org
cmake-commits at cmake.org
Fri Jun 1 11:16:32 EDT 2007
Update of /cvsroot/CMake/CMake/Tests/TryCompile
In directory public:/mounts/ram/cvs-serv6882/Tests/TryCompile
Modified Files:
CMakeLists.txt exit_success.c exit_with_error.c
Log Message:
ENH: improve TRY_RUN() for crosscompiling: instead of just failing, it now
creates two cache variables, one for the RUN_RESULT, one for the RUN_OUTPUT
(if required), which can be set or preset by the user. It has now also two
new arguments: RUN_OUTPUT_VARIABLE and COMPILE_OUTPUT_VARIABLE (the old
OUTPUT_VARIABLE merges both), so if only COMPILE_OUTPUT_VARIABLE is used the
run time output of the TRY_RUN is unused and the user doesn't have to care
about the output when crosscompiling. This is now used in FindThreads.cmake,
CheckC/CXXSourceRuns.cmake and TestBigEndian.cmake, which used the output
only for the logfile (compile output is still there). Test/TryCompile/ now
also tests the behaviour of OUTPUT_VARIABLE, RUN_OUTPUT_VARIABLE and
COMPILE_OUTPUT_VARIABLE.
Alex
Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/TryCompile/CMakeLists.txt,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- CMakeLists.txt 24 May 2007 16:06:59 -0000 1.9
+++ CMakeLists.txt 1 Jun 2007 15:16:29 -0000 1.10
@@ -87,6 +87,8 @@
# now two tests for TRY_RUN
# try to run a file that should compile and run without error
+# also check that OUTPUT_VARIABLE contains both the compile output
+# and the run output
TRY_RUN(SHOULD_RUN SHOULD_COMPILE
${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
${TryCompile_SOURCE_DIR}/exit_success.c
@@ -97,16 +99,39 @@
IF(NOT "${SHOULD_RUN}" STREQUAL "0")
MESSAGE(SEND_ERROR "exit_success failed running with exit code ${SHOULD_RUN}")
ENDIF(NOT "${SHOULD_RUN}" STREQUAL "0")
+# check the compile output for the filename
+IF(NOT "${TRY_OUT}" MATCHES "exit_success")
+ MESSAGE(SEND_ERROR " TRY_OUT didn't contain \"exit_success\": \"${TRY_OUT}\"")
+ENDIF(NOT "${TRY_OUT}" MATCHES "exit_success")
+# check the run output
+IF(NOT "${TRY_OUT}" MATCHES "hello world")
+ MESSAGE(SEND_ERROR " TRY_OUT didn't contain \"hello world\": \"${TRY_OUT}\"")
+ENDIF(NOT "${TRY_OUT}" MATCHES "hello world")
+
# 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)
+ COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT
+ RUN_OUTPUT_VARIABLE RUN_OUTPUT)
+
IF(NOT SHOULD_COMPILE)
- MESSAGE(STATUS " exit_with_error failed compiling: ${TRY_OUT}")
+ MESSAGE(STATUS " exit_with_error failed compiling: ${COMPILE_OUTPUT}")
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")
+# check the compile output, it should contain the filename
+IF(NOT "${COMPILE_OUTPUT}" MATCHES "exit_with_error")
+ MESSAGE(SEND_ERROR " COMPILE_OUT didn't contain \"exit_with_error\": \"${COMPILE_OUTPUT}\"")
+ENDIF(NOT "${COMPILE_OUTPUT}" MATCHES "exit_with_error")
+#... but not the run time output
+IF("${COMPILE_OUTPUT}" MATCHES "hello world")
+ MESSAGE(SEND_ERROR " COMPILE_OUT contains the run output: \"${COMPILE_OUTPUT}\"")
+ENDIF("${COMPILE_OUTPUT}" MATCHES "hello world")
+# check the run output, it should stdout
+IF(NOT "${RUN_OUTPUT}" MATCHES "hello world")
+ MESSAGE(SEND_ERROR " RUN_OUTPUT didn't contain \"hello world\": \"${RUN_OUTPUT}\"")
+ENDIF(NOT "${RUN_OUTPUT}" MATCHES "hello world")
Index: exit_with_error.c
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/TryCompile/exit_with_error.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- exit_with_error.c 24 May 2007 15:27:51 -0000 1.1
+++ exit_with_error.c 1 Jun 2007 15:16:29 -0000 1.2
@@ -1,4 +1,7 @@
+#include <stdio.h>
+
int main()
{
+ printf("hello world\n");
return -1;
}
Index: exit_success.c
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/TryCompile/exit_success.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- exit_success.c 24 May 2007 15:27:51 -0000 1.1
+++ exit_success.c 1 Jun 2007 15:16:29 -0000 1.2
@@ -1,4 +1,7 @@
+#include <stdio.h>
+
int main()
{
+ printf("hello world\n");
return 0;
}
More information about the Cmake-commits
mailing list