Updated formatting of documentation plus a little reorganization.
[cmake.git] / Tests / CommandLineTest / CMakeLists.txt
blobe01a4c702671bd326b8ae1f6907b94859116d06f
1 cmake_minimum_required (VERSION 2.6)
2 PROJECT(CommandLineTest)
4 GET_FILENAME_COMPONENT(CMAKE_BIN_DIR ${CMAKE_COMMAND} PATH)
5 FIND_PROGRAM(DUMP_DOC_EXE NAMES DumpDocumentation PATHS ${CMAKE_BIN_DIR})
6 MACRO(EXEC_CMAKE_COMMAND CMAKE_ARGS)
7   EXEC_PROGRAM("${CMAKE_COMMAND}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET)
8   IF(${RET})
9     MESSAGE(SEND_ERROR "CMake command failed with arguments \"${CMAKE_ARGS}\"")
10   ENDIF(${RET})
11 ENDMACRO(EXEC_CMAKE_COMMAND)
13 EXEC_CMAKE_COMMAND("-E chdir \"${CMAKE_CURRENT_SOURCE_DIR}\" \"${CMAKE_COMMAND}\" -E echo \"Hello World\"")
14 EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -L ${CommandLineTest_SOURCE_DIR}\"")
15 EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LA ${CommandLineTest_SOURCE_DIR}\"")
16 EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LH ${CommandLineTest_SOURCE_DIR}\"")
17 EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LAH ${CommandLineTest_SOURCE_DIR}\"")
18 EXEC_CMAKE_COMMAND("--help")
19 EXEC_CMAKE_COMMAND("--help-command-list")
20 EXEC_CMAKE_COMMAND("--help add_executable")
21 EXEC_CMAKE_COMMAND("--help-command add_executable")
22 EXEC_CMAKE_COMMAND("--help-full \"${CMAKE_CURRENT_BINARY_DIR}/cmake.txt\"")
23 EXEC_CMAKE_COMMAND("--help-man \"${CMAKE_CURRENT_BINARY_DIR}/cmake.man\"")
24 EXEC_CMAKE_COMMAND("--help-html \"${CMAKE_CURRENT_BINARY_DIR}/cmake.html\"")
25 EXEC_CMAKE_COMMAND("--copyright \"${CMAKE_CURRENT_BINARY_DIR}/Copyright.txt\"")
26 EXEC_CMAKE_COMMAND("--version \"${CMAKE_CURRENT_BINARY_DIR}/version.txt\"")
28 IF(DUMP_DOC_EXE)
29   EXEC_PROGRAM(${DUMP_DOC_EXE} ARGS "--all-for-coverage \"${CMAKE_CURRENT_BINARY_DIR}/all_for_coverage.txt\"" RETURN_VALUE RET)
30   IF(${RET})
31     MESSAGE(SEND_ERROR "DumpDoc command failed ")
32   ENDIF(${RET})
33 ELSE(DUMP_DOC_EXE)
34   MESSAGE(SEND_ERROR "Cannot find DumpDocumentation executable.")
35 ENDIF(DUMP_DOC_EXE)
37 ADD_EXECUTABLE(CommandLineTest CommandLineTest.cxx)
39 GET_FILENAME_COMPONENT(CMAKE_COMMAND_PATH "${CMAKE_COMMAND}" PATH)
40 SET(CTEST_COMMAND "${CMAKE_COMMAND_PATH}/ctest")
41 MACRO(EXEC_CTEST_COMMAND CMAKE_ARGS)
42   EXEC_PROGRAM("${CTEST_COMMAND}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET)
43   IF(${RET})
44     MESSAGE(SEND_ERROR "CTest command failed with arguments \"${CMAKE_ARGS}\"")
45   ENDIF(${RET})
46 ENDMACRO(EXEC_CTEST_COMMAND)
47 MACRO(EXEC_CTEST_COMMAND_WITH_DIR DIR CMAKE_ARGS)
48   EXEC_PROGRAM("${CTEST_COMMAND}" "${DIR}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET)
49   IF(${RET})
50     MESSAGE(SEND_ERROR "CTest command failed with arguments \"${CMAKE_ARGS}\"")
51   ENDIF(${RET})
52 ENDMACRO(EXEC_CTEST_COMMAND_WITH_DIR)
54 EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.."  "-N")
55 EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.."  "-R complex -N")
56 EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.."  "-E Simple -N")
57 EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.."  "-E Simple -N")
58 EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.."  "-N -I -10")
59 EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.."  "-N -I 10-")
60 EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.."  "-N -I 3,4")
61 EXEC_CTEST_COMMAND("--help")
62 EXEC_CTEST_COMMAND("--copyright")
63 EXEC_CTEST_COMMAND("--help-full \"${CMAKE_CURRENT_BINARY_DIR}/ctest.txt\"")
64 EXEC_CTEST_COMMAND("--help-man \"${CMAKE_CURRENT_BINARY_DIR}/ctest.man\"")
65 EXEC_CTEST_COMMAND("--help-html \"${CMAKE_CURRENT_BINARY_DIR}/ctest.html\"")
66 EXEC_CTEST_COMMAND("--version")
68 IF(THIS_SHOULD_BE_SET)
69   MESSAGE(STATUS "***************************")
70   MESSAGE(STATUS "PreLoad.cmake works fine.")
71   MESSAGE(STATUS "***************************")
72 ELSE(THIS_SHOULD_BE_SET)
73   MESSAGE("***************************")
74   MESSAGE(FATAL_ERROR "PreLoad.cmake does not work.")
75 ENDIF(THIS_SHOULD_BE_SET)
77 IF(DEFINED ENV{TEST_ENVIRONMENT_VARIABLE_NOTSET})
78   MESSAGE(SEND_ERROR "Environment variable definition test broken!")
79 ENDIF(DEFINED ENV{TEST_ENVIRONMENT_VARIABLE_NOTSET})
81 SET(ENV{TEST_ENVIRONMENT_VARIABLE} "Environment variable set")
82 IF("$ENV{TEST_ENVIRONMENT_VARIABLE}" STREQUAL "Environment variable set")
83   MESSAGE(STATUS "Environment variable set to: $ENV{TEST_ENVIRONMENT_VARIABLE}")
84   IF(NOT DEFINED ENV{TEST_ENVIRONMENT_VARIABLE})
85     MESSAGE(SEND_ERROR "Environment variable definition test failed!")
86   ENDIF(NOT DEFINED ENV{TEST_ENVIRONMENT_VARIABLE})
87 ELSE("$ENV{TEST_ENVIRONMENT_VARIABLE}" STREQUAL "Environment variable set")
88   MESSAGE(SEND_ERROR "Environment variable setting is broken")
89 ENDIF("$ENV{TEST_ENVIRONMENT_VARIABLE}" STREQUAL "Environment variable set")