CMakeLists.txt 144 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
include(${CMAKE_CURRENT_SOURCE_DIR}/CheckSwift.cmake)
26

27
# Fake a user home directory to avoid polluting the real one.
28 29 30 31 32
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.
33 34
# But provide original ENV{HOME} value in ENV{CTEST_REAL_HOME} for tests that
# need access to the real HOME directory.
35 36 37
if(NOT DEFINED ENV{CTEST_REAL_HOME})
  set(ENV{CTEST_REAL_HOME} \"\$ENV{HOME}\")
endif()
38
set(ENV{HOME} \"${TEST_HOME}\")
39
")
40
endif()
41

42 43 44 45 46 47 48 49 50 51 52 53
# 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()

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

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

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

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

79 80 81 82
  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()
83
  endif()
84

85
  set(MAKE_IS_GNU )
86 87
  if(CMAKE_MAKE_PROGRAM MATCHES make)
    execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} no_such_target --version
88 89 90 91 92 93 94 95 96 97
      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
98
      CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR
99
      CMAKE_GENERATOR MATCHES "Visual Studio|Xcode|Borland")
100 101 102 103 104
    set(MAKE_SUPPORTS_SPACES 1)
  else()
    set(MAKE_SUPPORTS_SPACES 0)
  endif()

105 106 107 108 109 110 111 112 113 114 115
  # 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()

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

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

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

143 144 145 146 147 148
  if(RPMBUILD_EXECUTABLE)
    set(CPACK_BINARY_RPM ON)
  else()
    set(CPACK_BINARY_RPM OFF)
  endif()

149
  # Look for dpkg to use for tests.
150 151 152 153 154 155 156 157
  find_program(DPKG_EXECUTABLE NAMES dpkg)

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

Alex Turbov's avatar
Alex Turbov committed
158 159 160 161 162 163 164 165 166
  # Look for NuGet to use for tests.
  find_program(NUGET_EXECUTABLE NAMES NuGet nuget)

  if(NUGET_EXECUTABLE)
    set(CPACK_BINARY_NUGET ON)
  else()
    set(CPACK_BINARY_NUGET OFF)
  endif()

167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
  if(WIN32)
    # Macro to search for available Windows CE SDKs in the windows Registry
    macro(select_wince_sdk selected_reg selected_sdk)
      if(CMAKE_HOST_WIN32)
        execute_process(COMMAND reg QUERY "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs"
                    OUTPUT_VARIABLE sdk_reg
                    ERROR_VARIABLE my_err)
        string(REGEX REPLACE "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Wow6432Node\\\\Microsoft\\\\Windows CE Tools\\\\SDKs\\\\"  ";" sdk_list "${sdk_reg}")
        list(LENGTH sdk_list sdk_list_len)
        if (${sdk_list_len} GREATER 1)
          list(GET sdk_list 1 _sdk) # The first entry is always empty due to the regex replace above
          string(STRIP ${_sdk} _sdk) # Make sure there is no newline in the SDK name
        endif()
        # Build a key to be used by get_filename_component that is pointing to the SDK directory
        set(_reg "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs\\${_sdk}]")
        # Set return values
        set(${selected_reg} ${_reg})
        set(${selected_sdk} ${_sdk})
      endif(CMAKE_HOST_WIN32)
    endmacro(select_wince_sdk)

    set(reg_vs10 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]")
    set(reg_vs11 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;InstallDir]")
    set(reg_vs12 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0;InstallDir]")
    set(reg_vs14 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0;InstallDir]")
    set(reg_ws80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]")
    set(reg_ws81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]")
    set(reg_ws10_0 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0\\Setup\\Build Tools for Windows 10;srcPath]")
    set(reg_wp80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.0;InstallationFolder]")
    set(reg_wp81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.1;InstallationFolder]")
    select_wince_sdk(reg_wince wince_sdk)
    set(reg_tegra "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;sdkRoot]")
    set(reg_nasm "[HKEY_CURRENT_USER\\SOFTWARE\\nasm]")
    foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra nasm)
      get_filename_component(r "${reg_${reg}}" ABSOLUTE)
      if(IS_DIRECTORY "${r}" AND NOT "${r}" STREQUAL "/registry")
        set(${reg} 1)
      else()
        set(${reg} 0)
      endif()
    endforeach()
  endif()

210 211 212
  #---------------------------------------------------------------------------
  # Add tests below here.

213 214
  if(NOT CMake_TEST_EXTERNAL_CMAKE)
    add_subdirectory(CMakeLib)
jdavidberger's avatar
jdavidberger committed
215

216
    add_subdirectory(CMakeServerLib)
217
  endif()
218 219
  add_subdirectory(CMakeOnly)
  add_subdirectory(RunCMake)
220

221
  add_subdirectory(FindPackageModeMakefileTest)
222

223
  # Collect a list of all test build directories.
224
  set(TEST_BUILD_DIRS)
225

226
  # Should the long tests be run?
227
  option(CMAKE_RUN_LONG_TESTS
228
    "Should the long tests be run (such as Bootstrap)." ON)
229
  mark_as_advanced(CMAKE_RUN_LONG_TESTS)
230

231 232
  if (CMAKE_RUN_LONG_TESTS)
    option(CTEST_TEST_CTEST
233
      "Should the tests that run a full sub ctest process be run?"
234
      OFF)
235
    mark_as_advanced(CTEST_TEST_CTEST)
236
  endif ()
237

238 239 240 241
  # Should tests that use CVS be run?
  #
  set(do_cvs_tests 0)

242 243
  if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake)
    find_package(CVS QUIET)
244
  else()
245
    find_program(CVS_EXECUTABLE NAMES cvs)
246
  endif()
247

248 249
  if(CVS_EXECUTABLE)
    set(do_cvs_tests 1)
250
  endif()
251

252 253 254
  if(do_cvs_tests AND NOT UNIX)
    if("${CVS_EXECUTABLE}" MATCHES "cygwin")
      set(do_cvs_tests 0)
255 256
    endif()
  endif()
257

258 259 260 261 262 263 264 265 266 267 268
  # 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.
  #
269
  option(CTEST_TEST_CPACK
270 271
    "Should the tests that use '--build-target package' be run?"
    ON)
272 273
  mark_as_advanced(CTEST_TEST_CPACK)
  set(CTEST_TEST_OSX_ARCH 0)
274
  set(CMake_TEST_XCODE_VERSION 0)
275 276
  if(APPLE)
    execute_process(
277 278 279 280
      COMMAND sw_vers -productVersion
      OUTPUT_VARIABLE OSX_VERSION
      OUTPUT_STRIP_TRAILING_WHITESPACE
      )
281
    if(OSX_VERSION VERSION_LESS 10.4)
282 283 284
      message(STATUS "Forcing CTEST_TEST_CPACK=OFF on OSX < 10.4")
      message(STATUS "OSX_VERSION='${OSX_VERSION}'")
      set(CTEST_TEST_CPACK OFF)
285
    else()
286
      set(CTEST_TEST_OSX_ARCH 1)
287
    endif()
288 289 290 291 292 293 294 295 296 297 298
    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()
299 300 301 302
    if(NOT CMake_TEST_XCODE_VERSION VERSION_LESS 10)
      # Since Xcode 10 we do not have two supported architectures for the host.
      set(CTEST_TEST_OSX_ARCH 0)
    endif()
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
    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()
326
  endif()
327

328 329
  # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value,
  # whichever is greater.
330 331 332
  set(CMAKE_LONG_TEST_TIMEOUT 1500)
  if(CTEST_TEST_TIMEOUT)
    set(CMAKE_LONG_TEST_TIMEOUT ${CTEST_TEST_TIMEOUT})
333
  endif()
334 335
  if(CMAKE_LONG_TEST_TIMEOUT LESS 1500)
    set(CMAKE_LONG_TEST_TIMEOUT 1500)
336
  endif()
337

338
  add_test(NAME CMake.Copyright
339
    COMMAND ${CMAKE_CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake)
340

341
  # add a bunch of standard build-and-test style tests
Ken Martin's avatar
Ken Martin committed
342 343
  ADD_TEST_MACRO(CommandLineTest CommandLineTest)
  ADD_TEST_MACRO(FindPackageTest FindPackageTest)
Bill Hoffman's avatar
Bill Hoffman committed
344
  ADD_TEST_MACRO(FindModulesExecuteAll FindModulesExecuteAll)
Ken Martin's avatar
Ken Martin committed
345 346 347 348
  ADD_TEST_MACRO(StringFileTest StringFileTest)
  ADD_TEST_MACRO(TryCompile TryCompile)
  ADD_TEST_MACRO(SystemInformation SystemInformation)
  ADD_TEST_MACRO(MathTest MathTest)
349
  ADD_TEST_MACRO(CompileFeatures CompileFeatures)
350
  ADD_TEST_MACRO(CMakeCommands.target_compile_features)
351

352
  if(CMake_TEST_RESOURCES)
353
    ADD_TEST_MACRO(VSResource VSResource)
354 355 356
    if (CMAKE_GENERATOR MATCHES "Ninja")
      add_test_macro(VSResourceNinjaForceRSP VSResourceNinjaForceRSP)
    endif ()
357
  endif()
358
  ADD_TEST_MACRO(MSManifest MSManifest)
Ken Martin's avatar
Ken Martin committed
359 360
  ADD_TEST_MACRO(Simple Simple)
  ADD_TEST_MACRO(PreOrder PreOrder)
361
  ADD_TEST_MACRO(MissingSourceFile MissingSourceFile)
362
  set_tests_properties(MissingSourceFile PROPERTIES
363
    PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file:[ \r\n]*DoesNotExist/MissingSourceFile.c")
364 365 366 367 368
  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")
369
        set(CMake_TEST_XCODE_SWIFT 1)
370
      endif()
371 372
    endif()
  endif()
373 374 375 376 377 378
  if(CMAKE_Swift_COMPILER OR CMake_TEST_XCODE_SWIFT)
    ADD_TEST_MACRO(SwiftOnly SwiftOnly)
    if(CMake_TEST_XCODE_SWIFT)
      ADD_TEST_MACRO(SwiftMix SwiftMix)
    endif()
  endif()
379
  if(CMAKE_Fortran_COMPILER)
380
    ADD_TEST_MACRO(FortranOnly FortranOnly)
381
  endif()
382 383 384 385 386 387
  # 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.
388 389
  if(CMAKE_Fortran_COMPILER OR CMAKE_TEST_CMAKE_ADD_FORTRAN)
    set(CMAKE_SKIP_VSGNUFortran FALSE)
390 391
    # disable test for apple builds using ifort if they are building
    # more than one architecture, as ifort does not support that.
392 393 394 395 396 397 398 399
    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)
400
        AND (CMAKE_Fortran_COMPILER MATCHES ifort))
401 402 403 404
      message(STATUS "Skip VSGNUFortran for ifort and lsb compilers")
      set(CMAKE_SKIP_VSGNUFortran TRUE)
    endif()
    if(NOT CMAKE_SKIP_VSGNUFortran)
405
      ADD_TEST_MACRO(VSGNUFortran ${CMAKE_CMAKE_COMMAND} -P runtest.cmake)
406 407
    endif()
  endif()
408

409
  if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])")
410
    ADD_TEST_MACRO(CSharpOnly CSharpOnly)
411
    ADD_TEST_MACRO(CSharpLinkToCxx CSharpLinkToCxx)
412
    ADD_TEST_MACRO(CSharpLinkFromCxx CSharpLinkFromCxx)
413
  endif()
414

Ken Martin's avatar
Ken Martin committed
415 416
  ADD_TEST_MACRO(COnly COnly)
  ADD_TEST_MACRO(CxxOnly CxxOnly)
417
  ADD_TEST_MACRO(CxxSubdirC CxxSubdirC)
418
  ADD_TEST_MACRO(IPO COnly/COnly)
419
  ADD_TEST_MACRO(OutDir runtime/OutDir)
420
  ADD_TEST_MACRO(OutName exe.OutName.exe)
Brad King's avatar
Brad King committed
421
  ADD_TEST_MACRO(ObjectLibrary UseCshared)
Ken Martin's avatar
Ken Martin committed
422 423
  ADD_TEST_MACRO(NewlineArgs NewlineArgs)
  ADD_TEST_MACRO(SetLang SetLang)
424
  ADD_TEST_MACRO(EmptyProperty EmptyProperty)
425
  ADD_TEST_MACRO(ExternalOBJ ExternalOBJ)
426 427 428
  if(NOT CMake_TEST_EXTERNAL_CMAKE)
    ADD_TEST_MACRO(LoadCommand LoadedCommand)
  endif()
429
  ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory)
430
  ADD_TEST_MACRO(LinkLanguage LinkLanguage)
431 432
  ADD_TEST_MACRO(LinkLine LinkLine)
  ADD_TEST_MACRO(MacroTest miniMacroTest)
433
  ADD_TEST_MACRO(FunctionTest miniFunctionTest)
434
  ADD_TEST_MACRO(ReturnTest ReturnTest)
435
  ADD_TEST_MACRO(Properties Properties)
Alexander Neundorf's avatar
 
Alexander Neundorf committed
436
  ADD_TEST_MACRO(Assembler HelloAsm)
Alexander Neundorf's avatar
 
Alexander Neundorf committed
437
  ADD_TEST_MACRO(SourceGroups SourceGroups)
438
  ADD_TEST_MACRO(Preprocess Preprocess)
439
  set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
440
  ADD_TEST_MACRO(ExportImport ExportImport)
Brad King's avatar
Brad King committed
441
  ADD_TEST_MACRO(Unset Unset)
442
  ADD_TEST_MACRO(PolicyScope PolicyScope)
443
  ADD_TEST_MACRO(EmptyLibrary EmptyLibrary)
444
  ADD_TEST_MACRO(CompileDefinitions CompileDefinitions)
445 446 447
  if(CMAKE_Fortran_COMPILER)
    set(CompileOptions_BUILD_OPTIONS -DTEST_FORTRAN=1)
  endif()
448
  ADD_TEST_MACRO(CompileOptions CompileOptions)
449
  ADD_TEST_MACRO(CompatibleInterface CompatibleInterface)
450
  ADD_TEST_MACRO(AliasTarget AliasTarget)
451
  ADD_TEST_MACRO(StagingPrefix StagingPrefix)
452
  ADD_TEST_MACRO(ImportedSameName ImportedSameName)
453
  ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary)
454 455 456 457
  if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
    set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
    ADD_TEST_MACRO(ConfigSources ConfigSources)
  endif()
458
  ADD_TEST_MACRO(SourcesProperty SourcesProperty)
459
  ADD_TEST_MACRO(SourceFileProperty SourceFileProperty)
460 461 462
  if (NOT CMAKE_GENERATOR STREQUAL "Xcode")
    ADD_TEST_MACRO(SourceFileIncludeDirProperty SourceFileIncludeDirProperty)
  endif()
463
  if(CMAKE_CXX_COMPILER_ID STREQUAL GNU
464
      AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
465 466 467
    set(runCxxDialectTest 1)
  endif()
  if(CMAKE_CXX_COMPILER_ID STREQUAL Clang
468
        AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4 AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
469 470 471 472 473 474 475
    if(NOT APPLE OR POLICY CMP0025)
      set(runCxxDialectTest 1)
    endif()
  endif()
  if(runCxxDialectTest)
    ADD_TEST_MACRO(CxxDialect CxxDialect)
  endif()
476
  set_tests_properties(EmptyLibrary PROPERTIES
477
    PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test")
478
  ADD_TEST_MACRO(CrossCompile CrossCompile)
479
  set_tests_properties(CrossCompile PROPERTIES
480
    PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode")
481
  if("${CMAKE_GENERATOR}" MATCHES "Make")
482
    ADD_TEST_MACRO(Policy0002 Policy0002)
483
  endif()
484
  if(CTEST_TEST_OSX_ARCH)
485
    ADD_TEST_MACRO(Architecture Architecture)
486
    set_tests_properties(Architecture PROPERTIES
487
      PASS_REGULAR_EXPRESSION "(file is not of required architecture|does not match cputype|not the architecture being linked)")
488
  endif()
489

490
  list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX})
491

492 493 494 495
  if(NOT DEFINED CMake_TEST_Qt4)
    set(CMake_TEST_Qt4 1)
  endif()
  if(CMake_TEST_Qt4 AND NOT QT4_FOUND)
496
    find_package(Qt4 QUIET)
497
  endif()
498

499
  if(CMake_TEST_Qt4 AND QT4_FOUND)
500 501 502 503
    # 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.
504 505 506
    include(CheckCXXSourceCompiles)
    set(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}")
    set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
507

508 509
    set(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES})
    set(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES})
510 511 512 513

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

514 515 516
    set(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}")
    set(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}")
  endif()
517

518
  # run test for BundleUtilities on supported platforms/compilers
519
  if(MSVC OR
520
     MINGW OR
521 522
     CMAKE_SYSTEM_NAME MATCHES "Linux" OR
     CMAKE_SYSTEM_NAME MATCHES "Darwin")
523
  if(NOT "${CMAKE_GENERATOR}" STREQUAL "Watcom WMake")
524

525
    add_test(BundleUtilities ${CMAKE_CTEST_COMMAND}
526 527 528
      --build-and-test
      "${CMake_SOURCE_DIR}/Tests/BundleUtilities"
      "${CMake_BINARY_DIR}/Tests/BundleUtilities"
529
      ${build_generator_args}
530
      --build-project BundleUtilities
531
      --build-options ${build_options}
532
      )
533
    list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleUtilities")
534 535 536

    # run test for DeployQt4 on supported platforms/compilers (which depends on BundleUtilities)
    # this test also depends on the existence of the standard qtiff plugin
537
    if(QT4_WORKS AND QT_QTSQL_FOUND)
538
      add_test(Qt4Deploy ${CMAKE_CTEST_COMMAND}
539 540 541
        --build-and-test
        "${CMake_SOURCE_DIR}/Tests/Qt4Deploy"
        "${CMake_BINARY_DIR}/Tests/Qt4Deploy"
542
        ${build_generator_args}
543
        --build-project Qt4Deploy
544
        --build-options ${build_options}
545
        -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
546
        -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
547
        )
548
      list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Deploy")
549 550
    endif()

551 552
  endif()
  endif()
553

554 555 556 557
  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"
558
    "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake" @ONLY)
559
  add_test(CMakeBuildTest ${CMAKE_CMAKE_COMMAND} -P
560
    "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake")
561
  list(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR})
562
  # now do it again for a project that has two project commands
563 564 565 566
  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"
567
    "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake" @ONLY)
568
  add_test(CMakeDoubleProject ${CMAKE_CMAKE_COMMAND} -P
569
    "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake")
570
  list(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR})
571

Brad King's avatar
Brad King committed
572 573
  ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize)

574 575 576 577 578 579 580 581 582 583 584
  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()

585 586 587 588
  add_test(Module.ExternalData ${CMAKE_CTEST_COMMAND}
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/Module/ExternalData"
    "${CMake_BINARY_DIR}/Tests/Module/ExternalData"
589
    ${build_generator_args}
590
    --build-project ExternalDataTest
591
    --build-noclean
592
    --force-new-ctest-process
593 594
    --build-options ${build_options}
      -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES}
595 596 597 598
    --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
    )
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData")

599
  ADD_TEST_MACRO(Module.FindDependency FindDependency)
600

601 602
  ADD_TEST_MACRO(Module.WriteCompilerDetectionHeader WriteCompilerDetectionHeader)

603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619
  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_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()

620 621 622 623 624 625 626 627 628 629
  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)
630
    add_test(Visibility ${CMAKE_CTEST_COMMAND}
631
      --build-and-test
632 633
      "${CMake_SOURCE_DIR}/Tests/Visibility"
      "${CMake_BINARY_DIR}/Tests/Visibility"
634
      ${build_generator_args}
635
      --build-project Visibility
636 637 638
      --build-options ${build_options}
    )
    list(APPEND TEST_BUILD_DIRS
639
      "${CMake_BINARY_DIR}/Tests/Visibility"
640 641 642
    )
  endif()

643
  add_test(LinkFlags-prepare
644 645 646 647
    ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/LinkFlags"
    "${CMake_BINARY_DIR}/Tests/LinkFlags"
648
    ${build_generator_args}
649 650
    --build-project LinkFlags
    --build-target LinkFlags
651 652
    --build-options ${build_options}
      -DTEST_CONFIG=\${CTEST_CONFIGURATION_TYPE}
653
    )
654
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkFlags")
655

656 657
  macro(ADD_LINK_FLAGS_TEST name depends)
    add_test(LinkFlags-${name}
658 659 660
      ${CMAKE_CMAKE_COMMAND} --build "${CMake_BINARY_DIR}/Tests/LinkFlags"
      --target LinkFlags_${name} --config \${CTEST_CONFIGURATION_TYPE}
      )
661
    set_tests_properties(LinkFlags-${name} PROPERTIES
662
      PASS_REGULAR_EXPRESSION "BADFLAG" DEPENDS LinkFlags-${depends})
663
  endmacro()
664 665
  ADD_LINK_FLAGS_TEST(lib prepare)
  ADD_LINK_FLAGS_TEST(dll lib)
666 667
  ADD_LINK_FLAGS_TEST(mod dll)
  ADD_LINK_FLAGS_TEST(exe mod)
668 669
  ADD_LINK_FLAGS_TEST(lib_config exe)
  ADD_LINK_FLAGS_TEST(dll_config lib_config)
670 671 672 673 674 675 676 677 678 679
  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)
680

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

687
    # check which generators we have
688 689
    execute_process(COMMAND ${CMAKE_CMAKE_COMMAND} --help
      OUTPUT_VARIABLE cmakeOutput ERROR_VARIABLE cmakeOutput)
690

691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716
    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)
717

718
  endif()
719

720
  # test for correct sub-project generation
721 722
  # not implemented in Xcode or Ninja
  if(NOT CMAKE_GENERATOR MATCHES "Xcode|Ninja")
723 724
    # run cmake and configure all of SubProject
    # but only build the independent executable car
725
    add_test(SubProject ${CMAKE_CTEST_COMMAND}
726 727 728 729
      --build-and-test
      "${CMake_SOURCE_DIR}/Tests/SubProject"
      "${CMake_BINARY_DIR}/Tests/SubProject"
      --build-project SubProject
730
      ${build_generator_args}
731
      --build-target car
732
      --build-options ${build_options}
733 734
      --test-command car
      )
735

736 737 738 739 740
    # 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
741
    if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
742
      set(SubProject-Stage2_BUILD_MAKEPROGRAM
743
        --build-makeprogram ${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
744 745
        )
    endif()
746
    add_test(SubProject-Stage2  ${CMAKE_CTEST_COMMAND}
747
      --build-and-test
748 749
      "${CMake_SOURCE_DIR}/Tests/SubProject/foo"
      "${CMake_BINARY_DIR}/Tests/SubProject/foo"
750
      --build-generator ${CMAKE_GENERATOR}
751
      --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}"
752
      --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
753
      ${SubProject-Stage2_BUILD_MAKEPROGRAM}
754
      --build-nocmake
755 756
      --build-project foo
      --build-target foo
757
      --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubProject/foo"
758
      --build-options ${build_options}
759 760
      --test-command foo
      )
761 762
    set_tests_properties ( SubProject-Stage2 PROPERTIES DEPENDS SubProject)
    list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubProject")
763
  endif()
764

765 766
  # macro to add a test that will build a nightly release
  # of CMake for given platform using the release scripts
767 768 769 770
  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"
771
      "cd ${_TEST_DIR}
772
${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script}
773
${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGHTLY_RELEASES}'
774
    ")
775 776 777
    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})
778 779
    endif()
  endmacro()
780
  if(CMake_BUILD_NIGHTLY_RELEASES)
781 782
    ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin32
      win32_release.cmake)
783 784
    ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin64
      win64_release.cmake)
785
    ADD_NIGHTLY_BUILD_TEST(CMakeNightlyOSX
786
      osx_release.cmake)
787 788
    ADD_NIGHTLY_BUILD_TEST(CMakeNightlyLinux64
      linux64_release.cmake)
789
    set_property(TEST CMakeNightlyWin64 PROPERTY DEPENDS CMakeNightlyWin32)
790
  endif()
791

792
  # add tests with more complex invocations
793
  add_test(Framework ${CMAKE_CTEST_COMMAND}
794 795 796 797
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/Framework"
    "${CMake_BINARY_DIR}/Tests/Framework"
    --build-two-config
798
    ${build_generator_args}
799
    --build-project Framework
800
    --build-options ${build_options}
801 802
    "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/Framework/Install"
    --test-command bar)
803
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Framework")
804

805
  add_test(TargetName ${CMAKE_CTEST_COMMAND}
806 807 808 809
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/TargetName"
    "${CMake_BINARY_DIR}/Tests/TargetName"
    --build-two-config
810
    ${build_generator_args}
811
    --build-project TargetName
812
    --build-options ${build_options}
813
    --test-command ${CMAKE_CMAKE_COMMAND} -E compare_files
814 815
    ${CMake_SOURCE_DIR}/Tests/TargetName/scripts/hello_world
    ${CMake_BINARY_DIR}/Tests/TargetName/scripts/hello_world)
816
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TargetName")
817

818
  add_test(LibName ${CMAKE_CTEST_COMMAND}
819 820 821 822
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/LibName"
    "${CMake_BINARY_DIR}/Tests/LibName"
    --build-two-config
823
    ${build_generator_args}
824
    --build-project LibName
825
    --build-exe-dir "${CMake_BINARY_DIR}/Tests/LibName/lib"
826
    --build-options ${build_options}
827 828
    --test-command foobar
    )
829
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LibName")
830

831
  add_test(CustComDepend ${CMAKE_CTEST_COMMAND}
832 833 834 835
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/CustComDepend"
    "${CMake_BINARY_DIR}/Tests/CustComDepend"
    --build-two-config
836
    ${build_generator_args}
837
    --build-project CustComDepend
838
    --build-exe-dir "${CMake_BINARY_DIR}/Tests/CustComDepend/bin"
839
    --build-options ${build_options}
840 841
    --test-command foo bar.c
    )
842
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustComDepend")
843

844
  add_test(ArgumentExpansion  ${CMAKE_CTEST_COMMAND}
Ben Boeckel's avatar
Ben Boeckel committed
845 846 847
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/ArgumentExpansion"
    "${CMake_BINARY_DIR}/Tests/ArgumentExpansion"
848
    ${build_generator_args}
Ben Boeckel's avatar
Ben Boeckel committed
849 850
    --build-project ArgumentExpansion
    --build-exe-dir "${CMake_BINARY_DIR}/Tests/ArgumentExpansion/bin"
851
    --build-options ${build_options}
Ben Boeckel's avatar
Ben Boeckel committed
852
    )
853
  set_tests_properties(ArgumentExpansion PROPERTIES
854
    FAIL_REGULAR_EXPRESSION "Unexpected: ")
855
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ArgumentExpansion")
Ben Boeckel's avatar
Ben Boeckel committed
856

857 858
  add_test(GeneratorExpression
    ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
Brad King's avatar
Brad King committed
859 860 861
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/GeneratorExpression"
    "${CMake_BINARY_DIR}/Tests/GeneratorExpression"
862
    ${build_generator_args}
Brad King's avatar
Brad King committed
863
    --build-project GeneratorExpression
864 865
    --build-options ${build_options}
      -DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE}
866
    --test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
Brad King's avatar
Brad King committed
867 868 869
    )
  list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/GeneratorExpression")

870
  add_test(CustomCommand  ${CMAKE_CTEST_COMMAND}
871 872 873 874
    --build-and-test
    "${CMake_SOURCE_DIR}/Tests/CustomCommand"
    "${CMake_BINARY_DIR}/Tests/CustomCommand"
    --build-two-config
875
    ${build_generator_args}