summaryrefslogtreecommitdiff
path: root/Tests/CMakeTests/GetPrerequisitesTest.cmake.in
blob: daf467bcca9d6e85764b882e396aacbcd18cad46 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Test of the functions in the CMake Modules file:
#
include(GetPrerequisites)

set(CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@")
set(CMAKE_CONFIGURATION_TYPES "@CMAKE_CONFIGURATION_TYPES@")
set(CMAKE_EXECUTABLE_SUFFIX "@CMAKE_EXECUTABLE_SUFFIX@")


message(STATUS "=============================================================================")
message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
message(STATUS "")
message(STATUS "CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}'")
message(STATUS "CMAKE_CONFIGURATION_TYPES='${CMAKE_CONFIGURATION_TYPES}'")
message(STATUS "CMAKE_EXECUTABLE_SUFFIX='${CMAKE_EXECUTABLE_SUFFIX}'")
message(STATUS "CTEST_CONFIGURATION_TYPE='${CTEST_CONFIGURATION_TYPE}'")
message(STATUS "")


function(stresstest_list_prerequisites file)
  message(STATUS "=============================================================================")
  message(STATUS "stresstest_list_prerequisites file='${file}'")
  message(STATUS "")

  get_filename_component(file_full "${file}" ABSOLUTE)

  message(STATUS "list_prerequisites '${file_full}' 0 0 0")
  list_prerequisites("${file_full}" 0 0 0)
  message(STATUS "")

  message(STATUS "list_prerequisites '${file_full}' 0 0 1")
  list_prerequisites("${file_full}" 0 0 1)
  message(STATUS "")

  message(STATUS "list_prerequisites '${file_full}' 0 1 0")
  list_prerequisites("${file_full}" 0 1 0)
  message(STATUS "")

  message(STATUS "list_prerequisites '${file_full}' 0 1 1")
  list_prerequisites("${file_full}" 0 1 1)
  message(STATUS "")

  message(STATUS "list_prerequisites '${file_full}' 1 0 0")
  list_prerequisites("${file_full}" 1 0 0)
  message(STATUS "")

  message(STATUS "list_prerequisites '${file_full}' 1 0 1")
  list_prerequisites("${file_full}" 1 0 1)
  message(STATUS "")

  message(STATUS "list_prerequisites '${file_full}' 1 1 0")
  list_prerequisites("${file_full}" 1 1 0)
  message(STATUS "")

  message(STATUS "list_prerequisites '${file_full}' 1 1 1")
  list_prerequisites("${file_full}" 1 1 1)
  message(STATUS "")

  message(STATUS "=============================================================================")
  message(STATUS "")
endfunction(stresstest_list_prerequisites)


function(test_cmake_executables)
  message(STATUS "=============================================================================")
  message(STATUS "Loop over all executable files in the same directory with CMake")
  message(STATUS "")

  get_filename_component(cmake_bin_dir "${CMAKE_COMMAND}" PATH)
  list_prerequisites_by_glob(GLOB "${cmake_bin_dir}/*" 0 0 1)
endfunction(test_cmake_executables)


message(STATUS "=============================================================================")
message(STATUS "Simplest test - list all the direct prerequisites of CMake itself")
message(STATUS "")
list_prerequisites("${CMAKE_COMMAND}" 0 0 1)
message(STATUS "")

message(STATUS "=============================================================================")
string(LENGTH "$ENV{PATH}" PATH_LENGTH_BEGIN)
message(STATUS "Begin PATH length is: ${PATH_LENGTH_BEGIN}")
message(STATUS "")


# Leave the code for these tests in here, but turn them off by default... they
# take longer than they're worth during development...
#
set(do_testdefaults 0)
if(do_testdefaults)
  message(STATUS "=============================================================================")
  message(STATUS "Test default argument values to list_prerequisites function...")
  message(STATUS "")
  list_prerequisites("${CMAKE_COMMAND}")
  message(STATUS "")
endif(do_testdefaults)


set(do_stresstest 0)
if(do_stresstest)
  message(STATUS "=============================================================================")
  message(STATUS "stresstest_list_prerequisites with CMake itself...")
  message(STATUS "")
  stresstest_list_prerequisites("${CMAKE_COMMAND}")
  message(STATUS "")
endif(do_stresstest)


test_cmake_executables()


message(STATUS "=============================================================================")
message(STATUS "Test overriding 'gp_tool' with bogus value")
message(STATUS "")
set(gp_tool "bogus")
list_prerequisites("${CMAKE_COMMAND}" 0 0 0)
set(gp_tool)
message(STATUS "")


message(STATUS "=============================================================================")
message(STATUS "Test overriding 'gp_tool' with value unlikely to be found")
message(STATUS "")
if(APPLE)
  set(gp_tool "dumpbin")
else()
  set(gp_tool "otool")
endif()
set(gp_cmd "gp_cmd-NOTFOUND")
list_prerequisites("${CMAKE_COMMAND}" 0 0 0)
set(gp_cmd)
set(gp_tool)
message(STATUS "")


message(STATUS "=============================================================================")
message(STATUS "All variables: (Make sure functions/macros are not leaving stuff around...")
message(STATUS "                Only variables predefined by CMake and defined in this")
message(STATUS "                test script file should be listed here...)")
message(STATUS "")
get_cmake_property(vs VARIABLES)
foreach(v ${vs})
  message(STATUS "${v}='${${v}}'")
endforeach(v)
message(STATUS "")

message(STATUS "=============================================================================")
string(LENGTH "$ENV{PATH}" PATH_LENGTH_END)
message(STATUS "Final PATH length is: ${PATH_LENGTH_END}")

if(PATH_LENGTH_END GREATER ${PATH_LENGTH_BEGIN})
    message(FATAL_ERROR "list_prerequisties is endlessly appending the path of gp_tool to the PATH.")
endif()
message(STATUS "")


message(STATUS "=============================================================================")
message(STATUS "End of test")
message(STATUS "")