[cmake-commits] alex committed CMakeLists.txt 1.7 1.8 exit_success.c
NONE 1.1 exit_with_error.c NONE 1.1
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu May 24 11:27:53 EDT 2007
Update of /cvsroot/CMake/CMake/Tests/TryCompile
In directory public:/mounts/ram/cvs-serv14675/Tests/TryCompile
Modified Files:
CMakeLists.txt
Added Files:
exit_success.c exit_with_error.c
Log Message:
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
Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/TryCompile/CMakeLists.txt,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CMakeLists.txt 31 Jan 2007 19:00:44 -0000 1.7
+++ CMakeLists.txt 24 May 2007 15:27:51 -0000 1.8
@@ -61,8 +61,7 @@
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 @@
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")
+
--- NEW FILE: exit_with_error.c ---
int main()
{
return -1;
}
--- NEW FILE: exit_success.c ---
int main()
{
return 0;
}
More information about the Cmake-commits
mailing list