1 PROJECT(CommandLineTest)
3 GET_FILENAME_COMPONENT(CMAKE_BIN_DIR ${CMAKE_COMMAND} PATH)
4 FIND_PROGRAM(DUMP_DOC_EXE NAMES DumpDocumentation PATHS ${CMAKE_BIN_DIR})
5 MACRO(EXEC_CMAKE_COMMAND CMAKE_ARGS)
6 EXEC_PROGRAM("${CMAKE_COMMAND}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET)
8 MESSAGE(SEND_ERROR "CMake command failed with arguments \"${CMAKE_ARGS}\"")
10 ENDMACRO(EXEC_CMAKE_COMMAND)
12 EXEC_CMAKE_COMMAND("-E chdir \"${CMAKE_CURRENT_SOURCE_DIR}\" \"${CMAKE_COMMAND}\" -E echo \"Hello World\"")
13 EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -L ${CommandLineTest_SOURCE_DIR}\"")
14 EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LA ${CommandLineTest_SOURCE_DIR}\"")
15 EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LH ${CommandLineTest_SOURCE_DIR}\"")
16 EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LAH ${CommandLineTest_SOURCE_DIR}\"")
17 EXEC_CMAKE_COMMAND("--help")
18 EXEC_CMAKE_COMMAND("--help-command-list")
19 EXEC_CMAKE_COMMAND("--help ADD_EXECUTABLE")
20 EXEC_CMAKE_COMMAND("--help-command ADD_EXECUTABLE")
21 EXEC_CMAKE_COMMAND("--help-full \"${CMAKE_CURRENT_BINARY_DIR}/cmake.txt\"")
22 EXEC_CMAKE_COMMAND("--help-man \"${CMAKE_CURRENT_BINARY_DIR}/cmake.man\"")
23 EXEC_CMAKE_COMMAND("--help-html \"${CMAKE_CURRENT_BINARY_DIR}/cmake.html\"")
24 EXEC_CMAKE_COMMAND("--copyright \"${CMAKE_CURRENT_BINARY_DIR}/Copyright.txt\"")
25 EXEC_CMAKE_COMMAND("--version \"${CMAKE_CURRENT_BINARY_DIR}/version.txt\"")
28 EXEC_PROGRAM(${DUMP_DOC_EXE} ARGS "--all-for-coverage \"${CMAKE_CURRENT_BINARY_DIR}/all_for_coverage.txt\"" RETURN_VALUE RET)
30 MESSAGE(SEND_ERROR "DumpDoc command failed ")
33 MESSAGE(SEND_ERROR "Cannot find DumpDocumentation executable.")
36 ADD_EXECUTABLE(CommandLineTest CommandLineTest.cxx)
38 GET_FILENAME_COMPONENT(CMAKE_COMMAND_PATH "${CMAKE_COMMAND}" PATH)
39 SET(CTEST_COMMAND "${CMAKE_COMMAND_PATH}/ctest")
40 MACRO(EXEC_CTEST_COMMAND CMAKE_ARGS)
41 EXEC_PROGRAM("${CTEST_COMMAND}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET)
43 MESSAGE(SEND_ERROR "CTest command failed with arguments \"${CMAKE_ARGS}\"")
45 ENDMACRO(EXEC_CTEST_COMMAND)
46 MACRO(EXEC_CTEST_COMMAND_WITH_DIR DIR CMAKE_ARGS)
47 EXEC_PROGRAM("${CTEST_COMMAND}" "${DIR}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET)
49 MESSAGE(SEND_ERROR "CTest command failed with arguments \"${CMAKE_ARGS}\"")
51 ENDMACRO(EXEC_CTEST_COMMAND_WITH_DIR)
53 EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N")
54 EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-R complex -N")
55 EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-E Simple -N")
56 EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-E Simple -N")
57 EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N -I -10")
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 3,4")
60 EXEC_CTEST_COMMAND("--help")
61 EXEC_CTEST_COMMAND("--copyright")
62 EXEC_CTEST_COMMAND("--help-full \"${CMAKE_CURRENT_BINARY_DIR}/ctest.txt\"")
63 EXEC_CTEST_COMMAND("--help-man \"${CMAKE_CURRENT_BINARY_DIR}/ctest.man\"")
64 EXEC_CTEST_COMMAND("--help-html \"${CMAKE_CURRENT_BINARY_DIR}/ctest.html\"")
65 EXEC_CTEST_COMMAND("--version")
67 IF(THIS_SHOULD_BE_SET)
68 MESSAGE(STATUS "***************************")
69 MESSAGE(STATUS "PreLoad.cmake works fine.")
70 MESSAGE(STATUS "***************************")
71 ELSE(THIS_SHOULD_BE_SET)
72 MESSAGE("***************************")
73 MESSAGE(FATAL_ERROR "PreLoad.cmake does not work.")
74 ENDIF(THIS_SHOULD_BE_SET)