Updates will be applied on October 27th between 12pm - 12:45pm EDT (UTC-0400). Gitlab may be slow during the maintenance window.

CMakeLists.txt 133 KB
Newer Older
Ken Martin's avatar
Ken Martin committed
1
2
# a macro for tests that have a simple format where the name matches the
# directory and project
3
4
5
6
macro(ADD_TEST_MACRO NAME)
  if(${ARGC} GREATER 1)
    set(_test_command --test-command ${ARGN})
  endif()
7
8
  string(REPLACE "." "/" dir "${NAME}")
  string(REGEX REPLACE "[^.]*\\." "" proj "${NAME}")
9
  add_test(NAME "${NAME}" COMMAND "${CMAKE_CTEST_COMMAND}"
Ken Martin's avatar
Ken Martin committed
10
    --build-and-test
11
12
    "${CMake_SOURCE_DIR}/Tests/${dir}"
    "${CMake_BINARY_DIR}/Tests/${dir}"
Ken Martin's avatar
Ken Martin committed
13
    --build-two-config
14
    ${build_generator_args}
15
    --build-project ${proj}
16
    ${${NAME}_CTEST_OPTIONS}
17
    --build-options ${build_options}
18
    ${${NAME}_BUILD_OPTIONS}
19
20
    ${_test_command})
  unset(_test_command)
21
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}")
22
endmacro()
Ken Martin's avatar
Ken Martin committed
23

24
include(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake)
25

26
# Fake a user home directory to avoid polluting the real one.
27
28
29
30
31
if(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME)
  set(TEST_HOME "${CMake_BINARY_DIR}/Tests/CMakeFiles/TestHome")
  file(MAKE_DIRECTORY "${TEST_HOME}")
  file(WRITE "${TEST_HOME}/.cvspass" ":pserver:anoncvs@www.cmake.org:/cvsroot/KWSys A\n")
  set(TEST_HOME_ENV_CODE "# Fake a user home directory to avoid polluting the real one.
32
33
# But provide original ENV{HOME} value in ENV{CTEST_REAL_HOME} for tests that
# need access to the real HOME directory.
34
35
36
if(NOT DEFINED ENV{CTEST_REAL_HOME})
  set(ENV{CTEST_REAL_HOME} \"\$ENV{HOME}\")
endif()
37
set(ENV{HOME} \"${TEST_HOME}\")
38
")
39
endif()
40

41
42
43
44
45
46
47
48
49
50
51
52
# 3.9 or later provides a definitive answer to whether we are multi-config
# through a global property. Prior to 3.9, CMAKE_CONFIGURATION_TYPES being set
# is assumed to mean multi-config, but developers might modify it so it is
# technically not as reliable.
if(NOT CMAKE_VERSION VERSION_LESS 3.9)
  get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
elseif(CMAKE_CONFIGURATION_TYPES)
  set(_isMultiConfig True)
else()
  set(_isMultiConfig False)
endif()

53
# Choose a default configuration for CTest tests.
54
set(CTestTest_CONFIG Debug)
55
if(NOT _isMultiConfig AND CMAKE_BUILD_TYPE)
56
57
  set(CTestTest_CONFIG ${CMAKE_BUILD_TYPE})
endif()
58

59
configure_file(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in
60
               ${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake @ONLY)
61

62
# Testing
63
if(BUILD_TESTING)
64
  set(CMake_TEST_DEVENV "")
65
66
  if(CMAKE_VS_DEVENV_COMMAND)
    set(CMake_TEST_DEVENV "${CMAKE_VS_DEVENV_COMMAND}")
67
  elseif(CMAKE_GENERATOR MATCHES "Visual Studio 9 " AND
68
69
70
71
      NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]")
    set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}")
  endif()

72
  if(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode")
73
    set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "")
74
  else()
75
    set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
76
  endif()
77

78
79
80
81
  if(NOT CMake_TEST_EXTERNAL_CMAKE)
    if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_GENERATOR}" MATCHES Ninja AND NOT WIN32))
      set(TEST_CompileCommandOutput 1)
    endif()
82
  endif()
83

84
  set(MAKE_IS_GNU )
85
86
  if(CMAKE_MAKE_PROGRAM MATCHES make)
    execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} no_such_target --version
87
88
89
90
91
92
93
94
95
96
      RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out)
    if("${res}" STREQUAL "0")
      if("${out}" MATCHES "GNU")
        set(MAKE_IS_GNU 1)
      endif()
    endif()
  endif()

  # some old versions of make simply cannot handle spaces in paths
  if (MAKE_IS_GNU OR
97
      CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR
98
      CMAKE_GENERATOR MATCHES "Visual Studio|Xcode|Borland")
99
100
101
102
103
    set(MAKE_SUPPORTS_SPACES 1)
  else()
    set(MAKE_SUPPORTS_SPACES 0)
  endif()

104
105
106
107
108
109
110
111
112
113
114
  # assume no resources building to test
  set(CMake_TEST_RESOURCES FALSE)
  # for windows and cygwin assume we have resources
  if(WIN32 OR CYGWIN)
    set(CMake_TEST_RESOURCES TRUE)
  endif()
  # for borland and watcom there is no resource support
  if(WATCOM OR BORLAND)
    set(CMake_TEST_RESOURCES FALSE)
  endif()

115
  set(build_generator_args
116
    --build-generator ${CMAKE_GENERATOR}
117
    )
118
119
120
121
122
  if(CMAKE_GENERATOR_PLATFORM)
    list(APPEND build_generator_args
      --build-generator-platform ${CMAKE_GENERATOR_PLATFORM}
      )
  endif()
123
  if(CMAKE_GENERATOR_TOOLSET)
124
    list(APPEND build_generator_args
125
      --build-generator-toolset ${CMAKE_GENERATOR_TOOLSET}
126
127
      )
  endif()
128

129
  set(build_options)
130
131
  if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
    list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
132
  endif()
133

134
135
  # Look for rpmbuild to use for tests.
  # The tool does not work with spaces in the path.
136
  if(NOT CMAKE_CURRENT_BINARY_DIR MATCHES " ")
137
138
139
140
141
    find_program(RPMBUILD_EXECUTABLE NAMES rpmbuild)
  else()
    set(RPMBUILD_EXECUTABLE "RPMBUILD_EXECUTABLE-NOTFOUND")
  endif()

142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
  if(RPMBUILD_EXECUTABLE)
    set(CPACK_BINARY_RPM ON)
  else()
    set(CPACK_BINARY_RPM OFF)
  endif()

  # Look for rpmbuild to use for tests.
  # The tool does not work with spaces in the path.
  find_program(DPKG_EXECUTABLE NAMES dpkg)

  if(DPKG_EXECUTABLE)
    set(CPACK_BINARY_DEB ON)
  else()
    set(CPACK_BINARY_DEB OFF)
  endif()

158
159
160
  #---------------------------------------------------------------------------
  # Add tests below here.

161
162
  if(NOT CMake_TEST_EXTERNAL_CMAKE)
    add_subdirectory(CMakeLib)
jdavidberger's avatar
jdavidberger committed
163

164
    add_subdirectory(CMakeServerLib)
165
  endif()
166
167
  add_subdirectory(CMakeOnly)
  add_subdirectory(RunCMake)
168

169
  add_subdirectory(FindPackageModeMakefileTest)
170

171
  # Collect a list of all test build directories.
172
  set(TEST_BUILD_DIRS)
173

174
  # Should the long tests be run?
175
  option(CMAKE_RUN_LONG_TESTS
176
    "Should the long tests be run (such as Bootstrap)." ON)
177
  mark_as_advanced(CMAKE_RUN_LONG_TESTS)
178

179
180
  if (CMAKE_RUN_LONG_TESTS)
    option(CTEST_TEST_CTEST
181
      "Should the tests that run a full sub ctest process be run?"
182
      OFF)
183
    mark_as_advanced(CTEST_TEST_CTEST)
184
  endif ()
185

186
187
188
189
  # Should tests that use CVS be run?
  #
  set(do_cvs_tests 0)

190
191
  if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake)
    find_package(CVS QUIET)
192
  else()
193
    find_program(CVS_EXECUTABLE NAMES cvs)
194
  endif()
195

196
197
  if(CVS_EXECUTABLE)
    set(do_cvs_tests 1)
198
  endif()
199

200
201
202
  if(do_cvs_tests AND NOT UNIX)
    if("${CVS_EXECUTABLE}" MATCHES "cygwin")
      set(do_cvs_tests 0)
203
204
    endif()
  endif()
205

206
207
208
209
210
211
212
213
214
215
216
  # Should CPack tests be run? By default, yes, but...
  #
  # Disable packaging test on Apple 10.3 and below. PackageMaker starts
  # DiskManagementTool as root and disowns it
  # (http://lists.apple.com/archives/installer-dev/2005/Jul/msg00005.html).
  # It is left holding open pipe handles and preventing ProcessUNIX from
  # detecting end-of-data even after its immediate child exits. Then
  # the test hangs until it times out and is killed. This is a
  # well-known bug in kwsys process execution that I would love to get
  # time to fix.
  #
217
  option(CTEST_TEST_CPACK
218
219
    "Should the tests that use '--build-target package' be run?"
    ON)
220
221
  mark_as_advanced(CTEST_TEST_CPACK)
  set(CTEST_TEST_OSX_ARCH 0)
222
  set(CMake_TEST_XCODE_VERSION 0)
223
224
  if(APPLE)
    execute_process(
225
226
227
228
      COMMAND sw_vers -productVersion
      OUTPUT_VARIABLE OSX_VERSION
      OUTPUT_STRIP_TRAILING_WHITESPACE
      )
229
    if(OSX_VERSION VERSION_LESS 10.4)
230
231
232
      message(STATUS "Forcing CTEST_TEST_CPACK=OFF on OSX < 10.4")
      message(STATUS "OSX_VERSION='${OSX_VERSION}'")
      set(CTEST_TEST_CPACK OFF)
233
    else()
234
      set(CTEST_TEST_OSX_ARCH 1)
235
    endif()
236
237
238
239
240
241
242
243
244
245
246
    if(XCODE_VERSION)
      set(CMake_TEST_XCODE_VERSION "${XCODE_VERSION}")
    else()
      execute_process(
        COMMAND xcodebuild -version
        OUTPUT_VARIABLE _version ERROR_VARIABLE _version
        )
      if(_version MATCHES "^Xcode ([0-9]+(\\.[0-9]+)*)")
        set(CMake_TEST_XCODE_VERSION "${CMAKE_MATCH_1}")
      endif()
    endif()
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
    if(CMAKE_OSX_SYSROOT)
      execute_process(
        COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version ProductName
        OUTPUT_VARIABLE _stdout
        OUTPUT_STRIP_TRAILING_WHITESPACE
        ERROR_VARIABLE _stderr
        RESULT_VARIABLE _failed
        )
      if(NOT _failed)
        set(CMAKE_OSX_SDKPRODUCT "${_stdout}")
      endif()

      execute_process(
        COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion
        OUTPUT_VARIABLE _stdout
        OUTPUT_STRIP_TRAILING_WHITESPACE
        ERROR_VARIABLE _stderr
        RESULT_VARIABLE _failed
        )
      if(NOT _failed)
        set(CMAKE_OSX_SDKVERSION "${_stdout}")
      endif()
    endif()
270
  endif()
271

272
273
  # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value,
  # whichever is greater.
274
275
276
  set(CMAKE_LONG_TEST_TIMEOUT 1500)
  if(CTEST_TEST_TIMEOUT)
    set(CMAKE_LONG_TEST_TIMEOUT ${CTEST_TEST_TIMEOUT})
277
  endif()
278
279
  if(CMAKE_LONG_TEST_TIMEOUT LESS 1500)
    set(CMAKE_LONG_TEST_TIMEOUT 1500)
280
  endif()
281

282
  add_test(NAME CMake.Copyright
283
    COMMAND ${CMAKE_CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake)
284

285
  # add a bunch of standard build-and-test style tests
Ken Martin's avatar
Ken Martin committed
286
287
  ADD_TEST_MACRO(CommandLineTest CommandLineTest)
  ADD_TEST_MACRO(FindPackageTest FindPackageTest)
Bill Hoffman's avatar
Bill Hoffman committed
288
  ADD_TEST_MACRO(FindModulesExecuteAll FindModulesExecuteAll)
Ken Martin's avatar
Ken Martin committed
289
290
291
292
  ADD_TEST_MACRO(StringFileTest StringFileTest)
  ADD_TEST_MACRO(TryCompile TryCompile)
  ADD_TEST_MACRO(SystemInformation SystemInformation)
  ADD_TEST_MACRO(MathTest MathTest)
293
  ADD_TEST_MACRO(CompileFeatures CompileFeatures)
294
  ADD_TEST_MACRO(CMakeCommands.target_compile_features)
295

296
  if(CMake_TEST_RESOURCES)
297
    ADD_TEST_MACRO(VSResource VSResource)
298
299
300
    if (CMAKE_GENERATOR MATCHES "Ninja")
      add_test_macro(VSResourceNinjaForceRSP VSResourceNinjaForceRSP)
    endif ()
301
  endif()
302
  ADD_TEST_MACRO(MSManifest MSManifest)
Ken Martin's avatar
Ken Martin committed
303
304
  ADD_TEST_MACRO(Simple Simple)
  ADD_TEST_MACRO(PreOrder PreOrder)
305
  ADD_TEST_MACRO(MissingSourceFile MissingSourceFile)
306
  set_tests_properties(MissingSourceFile PROPERTIES
307
    PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file:[ \r\n]*DoesNotExist/MissingSourceFile.c")
308
309
310
311
312
313
314
315
  if(CMake_TEST_XCODE_VERSION AND CMAKE_OSX_SDKVERSION AND CMAKE_OSX_SDKPRODUCT)
    if((NOT CMake_TEST_XCODE_VERSION VERSION_LESS 6.1) AND
       ((NOT CMAKE_OSX_SDKPRODUCT STREQUAL "Mac OS X") OR
        (NOT CMAKE_OSX_SDKVERSION VERSION_LESS 10.10)))
      if(CMAKE_GENERATOR STREQUAL "Xcode")
        ADD_TEST_MACRO(SwiftMix SwiftMix)
        ADD_TEST_MACRO(SwiftOnly SwiftOnly)
      endif()
316
317
    endif()
  endif()
318
  if(CMAKE_Fortran_COMPILER)
319
    ADD_TEST_MACRO(FortranOnly FortranOnly)
320
  endif()
321
322
323
324
325
326
  # test Visual Studio GNU Fortran mixing with cmake_add_fortran_subdirectory
  # run this project if we have a working fortran compiler or
  # the test is enabled with CMAKE_TEST_CMAKE_ADD_FORTRAN cache variable.
  # If you enable the test, CMake should find the MinGW fortran install,
  # or in some cases you might need to set the PATH so that cmake can find
  # the gfortran from mingw.
327
328
  if(CMAKE_Fortran_COMPILER OR CMAKE_TEST_CMAKE_ADD_FORTRAN)
    set(CMAKE_SKIP_VSGNUFortran FALSE)
329
330
    # disable test for apple builds using ifort if they are building
    # more than one architecture, as ifort does not support that.
331
332
333
334
335
336
337
338
    if(APPLE AND (CMAKE_Fortran_COMPILER MATCHES ifort))
      list(LENGTH CMAKE_OSX_ARCHITECTURES len)
      if("${len}" GREATER 1)
        message(STATUS "Skip VSGNUFortran for ifort dual cpu mac build")
        set(CMAKE_SKIP_VSGNUFortran TRUE)
      endif()
    endif()
    if((CMAKE_C_COMPILER MATCHES lsb)
339
        AND (CMAKE_Fortran_COMPILER MATCHES ifort))
340
341
342
343
      message(STATUS "Skip VSGNUFortran for ifort and lsb compilers")
      set(CMAKE_SKIP_VSGNUFortran TRUE)
    endif()
    if(NOT CMAKE_SKIP_VSGNUFortran)
344
      ADD_TEST_MACRO(VSGNUFortran ${CMAKE_CMAKE_COMMAND} -P runtest.cmake)
345
346
    endif()
  endif()
347

348
  if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])")
349
    ADD_TEST_MACRO(CSharpOnly CSharpOnly)
350
    ADD_TEST_MACRO(CSharpLinkToCxx CSharpLinkToCxx)
351
    ADD_TEST_MACRO(CSharpLinkFromCxx CSharpLinkFromCxx)
352
  endif()
353

Ken Martin's avatar
Ken Martin committed
354
355
  ADD_TEST_MACRO(COnly COnly)
  ADD_TEST_MACRO(CxxOnly CxxOnly)
356
  ADD_TEST_MACRO(CxxSubdirC CxxSubdirC)
357
  ADD_TEST_MACRO(IPO COnly/COnly)
358
  ADD_TEST_MACRO(OutDir runtime/OutDir)
Brad King's avatar
Brad King committed
359
  ADD_TEST_MACRO(ObjectLibrary UseCshared)
Ken Martin's avatar
Ken Martin committed
360
361
  ADD_TEST_MACRO(NewlineArgs NewlineArgs)
  ADD_TEST_MACRO(SetLang SetLang)
362
  ADD_TEST_MACRO(EmptyProperty EmptyProperty)
363
  ADD_TEST_MACRO(ExternalOBJ ExternalOBJ)
364
365
366
  if(NOT CMake_TEST_EXTERNAL_CMAKE)
    ADD_TEST_MACRO(LoadCommand LoadedCommand)
  endif()
367
  ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory)
368
  ADD_TEST_MACRO(LinkLanguage LinkLanguage)
369
370
  ADD_TEST_MACRO(LinkLine LinkLine)
  ADD_TEST_MACRO(MacroTest miniMacroTest)
371
  ADD_TEST_MACRO(FunctionTest miniFunctionTest)
372
  ADD_TEST_MACRO(ReturnTest ReturnTest)
373
  ADD_TEST_MACRO(Properties Properties)
Alexander Neundorf's avatar
   
Alexander Neundorf committed
374
  ADD_TEST_MACRO(Assembler HelloAsm)
Alexander Neundorf's avatar
   
Alexander Neundorf committed
375
  ADD_TEST_MACRO(SourceGroups SourceGroups)
376
  ADD_TEST_MACRO(Preprocess Preprocess)
377
  set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
378
  ADD_TEST_MACRO(ExportImport ExportImport)
Brad King's avatar
Brad King committed
379
  ADD_TEST_MACRO(Unset Unset)
380
  ADD_TEST_MACRO(PolicyScope PolicyScope)
381
  ADD_TEST_MACRO(EmptyLibrary EmptyLibrary)
382
  ADD_TEST_MACRO(CompileDefinitions CompileDefinitions)
383
  ADD_TEST_MACRO(CompileOptions CompileOptions)
384
  ADD_TEST_MACRO(CompatibleInterface CompatibleInterface)
385
  ADD_TEST_MACRO(AliasTarget AliasTarget)
386
  ADD_TEST_MACRO(StagingPrefix StagingPrefix)
387
  ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary)
388
389
390
391
  if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
    set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
    ADD_TEST_MACRO(ConfigSources ConfigSources)
  endif()
392
  ADD_TEST_MACRO(SourcesProperty SourcesProperty)
393
  ADD_TEST_MACRO(SourceFileProperty SourceFileProperty)
394
395
396
  if (NOT CMAKE_GENERATOR STREQUAL "Xcode")
    ADD_TEST_MACRO(SourceFileIncludeDirProperty SourceFileIncludeDirProperty)
  endif()
397
  if(CMAKE_CXX_COMPILER_ID STREQUAL GNU
398
      AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
399
400
401
    set(runCxxDialectTest 1)
  endif()
  if(CMAKE_CXX_COMPILER_ID STREQUAL Clang
402
        AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
403
404
405
406
407
408
409
    if(NOT APPLE OR POLICY CMP0025)
      set(runCxxDialectTest 1)
    endif()
  endif()
  if(runCxxDialectTest)
    ADD_TEST_MACRO(CxxDialect CxxDialect)
  endif()
410
  set_tests_properties(EmptyLibrary PROPERTIES
411
    PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test")
412
  ADD_TEST_MACRO(CrossCompile CrossCompile)
413
  set_tests_properties(CrossCompile PROPERTIES
414
    PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode")
415
  if("${CMAKE_GENERATOR}" MATCHES "Make")
416
    ADD_TEST_MACRO(Policy0002 Policy0002)
417
  endif()
418
  if(CTEST_TEST_OSX_ARCH)
419
    ADD_TEST_MACRO(Architecture Architecture)
420
    set_tests_properties(Architecture PROPERTIES
421
      PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked)")
422
  endif()
423

424
  list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX})
425

426
427
428
429
  if(NOT DEFINED CMake_TEST_Qt4)
    set(CMake_TEST_Qt4 1)
  endif()
  if(CMake_TEST_Qt4 AND NOT QT4_FOUND)
430
    find_package(Qt4 QUIET)
431
  endif()
432

433
  if(CMake_TEST_Qt4 AND QT4_FOUND)
434
435
436
437
    # test whether the Qt4 which has been found works, on some machines
    # which run nightly builds there were errors like "wrong file format"
    # for libQtCore.so. So first check it works, and only if it does add
    # the automoc test.
438
439
440
    include(CheckCXXSourceCompiles)
    set(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}")
    set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
441

442
443
    set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES})
    set(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES})
444
445
446
447

    CHECK_CXX_SOURCE_COMPILES("#include <QCoreApplication>\n int main() {return (qApp == 0 ? 0 : 1); }\n"
                              QT4_WORKS)

448
449
450
    set(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}")
    set(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
  endif()
451

452
  # run test for BundleUtilities on supported platforms/compilers
453
  if(MSVC OR
454
     MINGW OR
455
456
     CMAKE_SYSTEM_NAME MATCHES "Linux" OR
     CMAKE_SYSTEM_NAME MATCHES "Darwin")
457
  if(NOT "${CMAKE_GENERATOR}" STREQUAL "Watcom WMake")
458

459
    add_test(BundleUtilities ${CMAKE_CTEST_COMMAND}
460
461
462
      --build-and-test
      "${CMake_SOURCE_DIR}/Tests/BundleUtilities"
      "${CMake_BINARY_DIR}/Tests/BundleUtilities"
463
      ${build_generator_args}
464
      --build-project BundleUtilities
465
      --build-options ${build_options}
466
      )
467
    list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleUtilities")
468
469
470

    # run test for DeployQt4 on supported platforms/compilers (which depends on BundleUtilities)
    # this test also depends on the existence of the standard qtiff plugin
471
    if(QT4_WORKS AND QT_QTSQL_FOUND)
472
      add_test(Qt4Deploy ${CMAKE_CTEST_COMMAND}
473
474
475
        --build-and-test
        "${CMake_SOURCE_DIR}/Tests/Qt4Deploy"
        "${CMake_BINARY_DIR}/Tests/Qt4Deploy"
476
        ${build_generator_args}
477
        --build-project Qt4Deploy
478
        --build-options ${build_options}
479
        -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
480
        -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
481
        )
482
      list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Deploy")
483
484
    endif()

485
486
  endif()
  endif()
487

488
489
490
491
  set(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/COnly")
  set(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/CMakeBuildCOnly")
  set(CMAKE_BUILD_TEST_EXE COnly)
  configure_file("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in"
492
    "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake" @ONLY)
493
  add_test(CMakeBuildTest ${CMAKE_CMAKE_COMMAND} -P
494
    "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake")
495
  list(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR})
496
  # now do it again for a project that has two project commands
497
498
499
500
  set(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/DoubleProject")
  set(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/DoubleProject")
  set(CMAKE_BUILD_TEST_EXE just_silly)
  configure_file("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in"
501
    "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake" @ONLY)
502
  add_test(CMakeDoubleProject ${CMAKE_CMAKE_COMMAND} -P
503
    "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake")
504
  list(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR})
505

Brad King's avatar
Brad King committed
506
507
  ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize)

508
509
510
511
512
513
514
515
516
517
518
  set(Module.CheckIPOSupported-C_BUILD_OPTIONS -DCMake_TEST_IPO_WORKS_C=${CMake_TEST_IPO_WORKS_C})
  ADD_TEST_MACRO(Module.CheckIPOSupported-C CheckIPOSupported-C)

  set(Module.CheckIPOSupported-CXX_BUILD_OPTIONS -DCMake_TEST_IPO_WORKS_CXX=${CMake_TEST_IPO_WORKS_CXX})
  ADD_TEST_MACRO(Module.CheckIPOSupported-CXX CheckIPOSupported-CXX)

  if(CMAKE_Fortran_COMPILER)
    set(Module.CheckIPOSupported-Fortran_BUILD_OPTIONS -DCMake_TEST_IPO_WORKS_Fortran=${CMake_TEST_IPO_WORKS_Fortran})
    ADD_TEST_MACRO(Module.CheckIPOSupported-Fortran CheckIPOSupported-Fortran)
  endif()

519
520
521
522
  add_test(Module.ExternalData ${CMAKE_CTEST_COMMAND}
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/Module/ExternalData"
    "${CMake_BINARY_DIR}/Tests/Module/ExternalData"
523
    ${build_generator_args}
524
    --build-project ExternalDataTest
525
    --build-noclean
526
    --force-new-ctest-process
527
528
    --build-options ${build_options}
      -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES}
529
530
531
532
    --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
    )
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData")

533
  ADD_TEST_MACRO(Module.FindDependency FindDependency)
534

535
536
  ADD_TEST_MACRO(Module.WriteCompilerDetectionHeader WriteCompilerDetectionHeader)

537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
  if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
    include(CheckCXXCompilerFlag)
    check_cxx_compiler_flag(-fPIE run_pic_test)
  else()
    if (CMAKE_CXX_COMPILER_ID MATCHES "PGI"
        OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale"
        OR CMAKE_SYSTEM_NAME MATCHES "IRIX64"
        OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
      set(run_pic_test 0)
    else()
      set(run_pic_test 1)
    endif()
  endif()

  if (run_pic_test)
    ADD_TEST_MACRO(PositionIndependentTargets PositionIndependentTargets)
  endif()

555
556
557
558
559
560
561
562
563
564
  if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") AND
    (NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 4.2) AND
    (CMAKE_SYSTEM_NAME MATCHES "Linux"))

    include(CheckCXXCompilerFlag)
    check_cxx_compiler_flag(
      -fvisibility-inlines-hidden run_inlines_hidden_test)
  endif()

  if(run_inlines_hidden_test)
565
    add_test(Visibility ${CMAKE_CTEST_COMMAND}
566
      --build-and-test
567
568
      "${CMake_SOURCE_DIR}/Tests/Visibility"
      "${CMake_BINARY_DIR}/Tests/Visibility"
569
      ${build_generator_args}
570
      --build-project Visibility
571
572
573
      --build-options ${build_options}
    )
    list(APPEND TEST_BUILD_DIRS
574
      "${CMake_BINARY_DIR}/Tests/Visibility"
575
576
577
    )
  endif()

578
  add_test(LinkFlags-prepare
579
580
581
582
    ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/LinkFlags"
    "${CMake_BINARY_DIR}/Tests/LinkFlags"
583
    ${build_generator_args}
584
585
    --build-project LinkFlags
    --build-target LinkFlags
586
587
    --build-options ${build_options}
      -DTEST_CONFIG=\${CTEST_CONFIGURATION_TYPE}
588
    )
589
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkFlags")
590

591
592
  macro(ADD_LINK_FLAGS_TEST name depends)
    add_test(LinkFlags-${name}
593
594
595
      ${CMAKE_CMAKE_COMMAND} --build "${CMake_BINARY_DIR}/Tests/LinkFlags"
      --target LinkFlags_${name} --config \${CTEST_CONFIGURATION_TYPE}
      )
596
    set_tests_properties(LinkFlags-${name} PROPERTIES
597
      PASS_REGULAR_EXPRESSION "BADFLAG" DEPENDS LinkFlags-${depends})
598
  endmacro()
599
600
  ADD_LINK_FLAGS_TEST(lib prepare)
  ADD_LINK_FLAGS_TEST(dll lib)
601
602
  ADD_LINK_FLAGS_TEST(mod dll)
  ADD_LINK_FLAGS_TEST(exe mod)
603
604
  ADD_LINK_FLAGS_TEST(lib_config exe)
  ADD_LINK_FLAGS_TEST(dll_config lib_config)
605
606
607
608
609
610
611
612
613
614
  ADD_LINK_FLAGS_TEST(mod_config dll_config)
  ADD_LINK_FLAGS_TEST(exe_config mod_config)
  ADD_LINK_FLAGS_TEST(lib_flags exe_config)
  ADD_LINK_FLAGS_TEST(dll_flags lib_flags)
  ADD_LINK_FLAGS_TEST(mod_flags dll_flags)
  ADD_LINK_FLAGS_TEST(exe_flags mod_flags)
  ADD_LINK_FLAGS_TEST(lib_flags_config exe_flags)
  ADD_LINK_FLAGS_TEST(dll_flags_config lib_flags_config)
  ADD_LINK_FLAGS_TEST(mod_flags_config dll_flags_config)
  ADD_LINK_FLAGS_TEST(exe_flags_config mod_flags_config)
615

616
  # If we are running right now with a Unix Makefiles or Ninja based generator,
617
  # build the "Simple" test with the ExtraGenerators, if available
618
  # This doesn't test whether the generated project files work (unfortunately),
619
  # mainly it tests that cmake doesn't crash when generating these project files.
620
621
  if(${CMAKE_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_GENERATOR} MATCHES "Ninja")

622
    # check which generators we have
623
624
    execute_process(COMMAND ${CMAKE_CMAKE_COMMAND} --help
      OUTPUT_VARIABLE cmakeOutput ERROR_VARIABLE cmakeOutput)
625

626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
    set(extraGenerators
      "CodeBlocks"
      "CodeLite"
      "Eclipse CDT4"
      "Kate"
      "Sublime Text 2")

    foreach(extraGenerator ${extraGenerators})
      if ("${cmakeOutput}" MATCHES "${extraGenerator} - ${CMAKE_GENERATOR}")
        set(extraGeneratorTestName "Simple_${extraGenerator}Generator")
        string(REPLACE " " "" extraGeneratorTestName ${extraGeneratorTestName})

        add_test(${extraGeneratorTestName} ${CMAKE_CTEST_COMMAND}
          --build-and-test
          "${CMake_SOURCE_DIR}/Tests/Simple"
          "${CMake_BINARY_DIR}/Tests/${extraGeneratorTestName}"
          --build-two-config
          --build-generator "${extraGenerator} - ${CMAKE_GENERATOR}"
          --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}"
          --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
          --build-project Simple
          --build-options ${build_options}
          --test-command Simple)
        list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${extraGeneratorTestName}")
      endif ()
    endforeach(extraGenerator)
652

653
  endif()
654

655
  # test for correct sub-project generation
656
657
  # not implemented in Xcode or Ninja
  if(NOT CMAKE_GENERATOR MATCHES "Xcode|Ninja")
658
659
    # run cmake and configure all of SubProject
    # but only build the independent executable car
660
    add_test(SubProject ${CMAKE_CTEST_COMMAND}
661
662
663
664
      --build-and-test
      "${CMake_SOURCE_DIR}/Tests/SubProject"
      "${CMake_BINARY_DIR}/Tests/SubProject"
      --build-project SubProject
665
      ${build_generator_args}
666
      --build-target car
667
      --build-options ${build_options}
668
669
      --test-command car
      )
670

671
672
673
674
675
    # For stage 2, do not run cmake again.
    # Then build the foo sub project which should build
    # the bar library which should be referenced because
    # foo links to the static library bar, but bar is not
    # directly in the foo sub project
676
    if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
677
      set(SubProject-Stage2_BUILD_MAKEPROGRAM
678
        --build-makeprogram ${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
679
680
        )
    endif()
681
    add_test(SubProject-Stage2  ${CMAKE_CTEST_COMMAND}
682
      --build-and-test
683
684
      "${CMake_SOURCE_DIR}/Tests/SubProject/foo"
      "${CMake_BINARY_DIR}/Tests/SubProject/foo"
685
      --build-generator ${CMAKE_GENERATOR}
686
      --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}"
687
      --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
688
      ${SubProject-Stage2_BUILD_MAKEPROGRAM}
689
      --build-nocmake
690
691
      --build-project foo
      --build-target foo
692
      --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubProject/foo"
693
      --build-options ${build_options}
694
695
      --test-command foo
      )
696
697
    set_tests_properties ( SubProject-Stage2 PROPERTIES DEPENDS SubProject)
    list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubProject")
698
  endif()
699

700
701
  # macro to add a test that will build a nightly release
  # of CMake for given platform using the release scripts
702
703
704
705
  macro(ADD_NIGHTLY_BUILD_TEST name script)
    set(_TEST_DIR "${CMake_BINARY_DIR}/Tests/${name}")
    file(MAKE_DIRECTORY "${_TEST_DIR}")
    file(WRITE "${_TEST_DIR}/nightly-cmake.sh"
706
      "cd ${_TEST_DIR}
707
${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script}
708
${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake
709
    ")
710
711
712
    add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh)
    if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY)
      set_tests_properties (${name} PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
713
714
    endif()
  endmacro()
715
  if(CMAKE_BUILD_NIGHTLY_RELEASES)
716
717
    ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin32
      win32_release.cmake)
718
719
    ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin64
      win64_release.cmake)
720
    ADD_NIGHTLY_BUILD_TEST(CMakeNightlyOSX
721
      osx_release.cmake)
722
723
    ADD_NIGHTLY_BUILD_TEST(CMakeNightlyLinux64
      linux64_release.cmake)
724
    set_property(TEST CMakeNightlyWin64 PROPERTY DEPENDS CMakeNightlyWin32)
725
  endif()
726

727
  # add tests with more complex invocations
728
  add_test(Framework ${CMAKE_CTEST_COMMAND}
729
730
731
732
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/Framework"
    "${CMake_BINARY_DIR}/Tests/Framework"
    --build-two-config
733
    ${build_generator_args}
734
    --build-project Framework
735
    --build-options ${build_options}
736
737
    "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/Framework/Install"
    --test-command bar)
738
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Framework")
739

740
  add_test(TargetName ${CMAKE_CTEST_COMMAND}
741
742
743
744
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/TargetName"
    "${CMake_BINARY_DIR}/Tests/TargetName"
    --build-two-config
745
    ${build_generator_args}
746
    --build-project TargetName
747
    --build-options ${build_options}
748
    --test-command ${CMAKE_CMAKE_COMMAND} -E compare_files
749
750
    ${CMake_SOURCE_DIR}/Tests/TargetName/scripts/hello_world
    ${CMake_BINARY_DIR}/Tests/TargetName/scripts/hello_world)
751
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TargetName")
752

753
  add_test(LibName ${CMAKE_CTEST_COMMAND}
754
755
756
757
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/LibName"
    "${CMake_BINARY_DIR}/Tests/LibName"
    --build-two-config
758
    ${build_generator_args}
759
    --build-project LibName
760
    --build-exe-dir "${CMake_BINARY_DIR}/Tests/LibName/lib"
761
    --build-options ${build_options}
762
763
    --test-command foobar
    )
764
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LibName")
765

766
  add_test(CustComDepend ${CMAKE_CTEST_COMMAND}
767
768
769
770
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/CustComDepend"
    "${CMake_BINARY_DIR}/Tests/CustComDepend"
    --build-two-config
771
    ${build_generator_args}
772
    --build-project CustComDepend
773
    --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustComDepend/bin"
774
    --build-options ${build_options}
775
776
    --test-command foo bar.c
    )
777
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustComDepend")
778

779
  add_test(ArgumentExpansion  ${CMAKE_CTEST_COMMAND}
Ben Boeckel's avatar
Ben Boeckel committed
780
781
782
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/ArgumentExpansion"
    "${CMake_BINARY_DIR}/Tests/ArgumentExpansion"
783
    ${build_generator_args}
Ben Boeckel's avatar
Ben Boeckel committed
784
785
    --build-project ArgumentExpansion
    --build-exe-dir "${CMake_BINARY_DIR}/Tests/ArgumentExpansion/bin"
786
    --build-options ${build_options}
Ben Boeckel's avatar
Ben Boeckel committed
787
    )
788
  set_tests_properties(ArgumentExpansion PROPERTIES
789
    FAIL_REGULAR_EXPRESSION "Unexpected: ")
790
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ArgumentExpansion")
Ben Boeckel's avatar
Ben Boeckel committed
791

792
793
  add_test(GeneratorExpression
    ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
Brad King's avatar
Brad King committed
794
795
796
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/GeneratorExpression"
    "${CMake_BINARY_DIR}/Tests/GeneratorExpression"
797
    ${build_generator_args}
Brad King's avatar
Brad King committed
798
    --build-project GeneratorExpression
799
800
    --build-options ${build_options}
      -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE}
801
    --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
Brad King's avatar
Brad King committed
802
803
804
    )
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/GeneratorExpression")

805
  add_test(CustomCommand  ${CMAKE_CTEST_COMMAND}
806
807
808
809
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/CustomCommand"
    "${CMake_BINARY_DIR}/Tests/CustomCommand"
    --build-two-config
810
    ${build_generator_args}
811
812
    --build-project CustomCommand
    --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommand/bin"
813
    --build-options ${build_options}
814
815
    --test-command CustomCommand
    )
816
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommand")
817

818
819
  ADD_TEST_MACRO(CustomCommandByproducts CustomCommandByproducts)

820
821
  ADD_TEST_MACRO(CommandLength CommandLength)

822
823
  ADD_TEST_MACRO(EmptyDepends ${CMAKE_CTEST_COMMAND})

824
  add_test(CustomCommandWorkingDirectory  ${CMAKE_CTEST_COMMAND}
825
826
827
828
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/CustomCommandWorkingDirectory"
    "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory"
    --build-two-config
829
    ${build_generator_args}
830
    --build-project TestWorkingDir
831
    --build-options ${build_options}
832
833
    --test-command working
    )
834
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory")
835

836
  add_test(OutOfSource ${CMAKE_CTEST_COMMAND}
837
838
839
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/OutOfSource"
    "${CMake_BINARY_DIR}/Tests/OutOfSource"
840
    ${build_generator_args}
841
842
    --build-project OutOfSource
    --build-two-config
843
    --build-options ${build_options}
844
845
    --test-command
    "${CMake_BINARY_DIR}/Tests/OutOfSource/SubDir/OutOfSourceSubdir/simple")
846
847
848
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfSource")
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfSourceDeep")
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfBinary")
849

850
  add_test(BuildDepends ${CMAKE_CTEST_COMMAND}
851
852
853
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/BuildDepends"
    "${CMake_BINARY_DIR}/Tests/BuildDepends"
854
    ${build_generator_args}
855
    --build-project BuildDepends
856
    --build-options ${build_options}
857
    )
858
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BuildDepends")
859

860
  set(SimpleInstallInstallDir
861
    "${CMake_BINARY_DIR}/Tests/SimpleInstall/InstallDirectory")
862
  add_test(SimpleInstall ${CMAKE_CTEST_COMMAND}
863
864
865
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/SimpleInstall"
    "${CMake_BINARY_DIR}/Tests/SimpleInstall"
866
    ${build_generator_args}
867
868
    --build-project TestSimpleInstall
    --build-two-config
869
    --build-options ${build_options}
870
    "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}"
871
    "-DCTEST_TEST_CPACK:BOOL=${CTEST_TEST_CPACK}"
872
    --test-command   ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExe)
873
874
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstall")
  add_test(SimpleInstall-Stage2 ${CMAKE_CTEST_COMMAND}
875
876
877
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/SimpleInstallS2"
    "${CMake_BINARY_DIR}/Tests/SimpleInstallS2"
878
    ${build_generator_args}
879
880
    --build-project TestSimpleInstall
    --build-two-config
881
    --build-options ${build_options}
882
883
    "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}"
    "-DSTAGE2:BOOL=1"
884
    --test-command   ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExeS2)
885
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstallS2")
886

887
888
889
890
891
892
893
894
895
896
897
898
899
  set(MissingInstallInstallDir
    "${CMake_BINARY_DIR}/Tests/MissingInstall/InstallDirectory")
  add_test(MissingInstall ${CMAKE_CTEST_COMMAND}
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/MissingInstall"
    "${CMake_BINARY_DIR}/Tests/MissingInstall"
    ${build_generator_args}
    --build-project TestMissingInstall
    --build-two-config
    --build-options ${build_options}
    "-DCMAKE_INSTALL_PREFIX:PATH=${MissingInstallInstallDir}")
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MissingInstall")

900
901
902
903
  # By default, run the CPackComponents test if the CTEST_TEST_CPACK
  # option is ON:
  #
  set(CTEST_RUN_CPackComponents ${CTEST_TEST_CPACK})
904
  set(CTEST_package_X11_TEST ${CTEST_TEST_CPACK})
905
  set(CTEST_RUN_CPackComponentsForAll ${CTEST_TEST_CPACK})
906
  set(CTEST_RUN_CPackComponentsPrefix ${CTEST_TEST_CPACK})
907