blob: 8a4b4f4a8168be001d904869d7db28c1de565b49 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
cmake_minimum_required (VERSION 2.6)
project(CommandLineTest)
get_filename_component(CMAKE_BIN_DIR ${CMAKE_COMMAND} PATH)
macro(EXEC_CMAKE_COMMAND CMAKE_ARGS)
exec_program("${CMAKE_COMMAND}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET)
if(${RET})
message(SEND_ERROR "CMake command failed with arguments \"${CMAKE_ARGS}\"")
endif(${RET})
endmacro(EXEC_CMAKE_COMMAND)
EXEC_CMAKE_COMMAND("-E chdir \"${CMAKE_CURRENT_SOURCE_DIR}\" \"${CMAKE_COMMAND}\" -E echo \"Hello World\"")
EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -L ${CommandLineTest_SOURCE_DIR}\"")
EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LA ${CommandLineTest_SOURCE_DIR}\"")
EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LH ${CommandLineTest_SOURCE_DIR}\"")
EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LAH ${CommandLineTest_SOURCE_DIR}\"")
EXEC_CMAKE_COMMAND("--help")
EXEC_CMAKE_COMMAND("--help-command-list")
EXEC_CMAKE_COMMAND("--help add_executable")
EXEC_CMAKE_COMMAND("--help-command add_executable")
EXEC_CMAKE_COMMAND("--help-full \"${CMAKE_CURRENT_BINARY_DIR}/cmake.txt\"")
EXEC_CMAKE_COMMAND("--help-man \"${CMAKE_CURRENT_BINARY_DIR}/cmake.man\"")
EXEC_CMAKE_COMMAND("--help-html \"${CMAKE_CURRENT_BINARY_DIR}/cmake.html\"")
EXEC_CMAKE_COMMAND("--copyright \"${CMAKE_CURRENT_BINARY_DIR}/Copyright.txt\"")
EXEC_CMAKE_COMMAND("--version \"${CMAKE_CURRENT_BINARY_DIR}/version.txt\"")
add_executable(CommandLineTest CommandLineTest.cxx)
get_filename_component(CMAKE_COMMAND_PATH "${CMAKE_COMMAND}" PATH)
set(CTEST_COMMAND "${CMAKE_COMMAND_PATH}/ctest")
macro(EXEC_CTEST_COMMAND CMAKE_ARGS)
exec_program("${CTEST_COMMAND}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET)
if(${RET})
message(SEND_ERROR "CTest command failed with arguments \"${CMAKE_ARGS}\"")
endif(${RET})
endmacro(EXEC_CTEST_COMMAND)
macro(EXEC_CTEST_COMMAND_WITH_DIR DIR CMAKE_ARGS)
exec_program("${CTEST_COMMAND}" "${DIR}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET)
if(${RET})
message(SEND_ERROR "CTest command failed with arguments \"${CMAKE_ARGS}\"")
endif(${RET})
endmacro(EXEC_CTEST_COMMAND_WITH_DIR)
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N")
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-R complex -N")
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-E Simple -N")
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-E Simple -N")
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N -I -10")
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N -I 10-")
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N -I 3,4")
EXEC_CTEST_COMMAND("--help")
EXEC_CTEST_COMMAND("--copyright")
EXEC_CTEST_COMMAND("--help-full \"${CMAKE_CURRENT_BINARY_DIR}/ctest.txt\"")
EXEC_CTEST_COMMAND("--help-man \"${CMAKE_CURRENT_BINARY_DIR}/ctest.man\"")
EXEC_CTEST_COMMAND("--help-html \"${CMAKE_CURRENT_BINARY_DIR}/ctest.html\"")
EXEC_CTEST_COMMAND("--version")
if(THIS_SHOULD_BE_SET)
message(STATUS "***************************")
message(STATUS "PreLoad.cmake works fine.")
message(STATUS "***************************")
else(THIS_SHOULD_BE_SET)
message("***************************")
message(FATAL_ERROR "PreLoad.cmake does not work.")
endif(THIS_SHOULD_BE_SET)
if(DEFINED ENV{TEST_ENVIRONMENT_VARIABLE_NOTSET})
message(SEND_ERROR "Environment variable definition test broken!")
endif(DEFINED ENV{TEST_ENVIRONMENT_VARIABLE_NOTSET})
set(ENV{TEST_ENVIRONMENT_VARIABLE} "Environment variable set")
if("$ENV{TEST_ENVIRONMENT_VARIABLE}" STREQUAL "Environment variable set")
message(STATUS "Environment variable set to: $ENV{TEST_ENVIRONMENT_VARIABLE}")
if(NOT DEFINED ENV{TEST_ENVIRONMENT_VARIABLE})
message(SEND_ERROR "Environment variable definition test failed!")
endif(NOT DEFINED ENV{TEST_ENVIRONMENT_VARIABLE})
else("$ENV{TEST_ENVIRONMENT_VARIABLE}" STREQUAL "Environment variable set")
message(SEND_ERROR "Environment variable setting is broken")
endif("$ENV{TEST_ENVIRONMENT_VARIABLE}" STREQUAL "Environment variable set")
|