CMakeLists.txt 3.65 KB
Newer Older
1 2 3 4 5 6 7 8 9
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Test.cmake.in
               ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake @ONLY)

macro(add_CMakeOnly_test test)
  add_test(CMakeOnly.${test} ${CMAKE_CMAKE_COMMAND}
    -DTEST=${test}
    -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake
    )
endmacro()
10

11
add_CMakeOnly_test(LinkInterfaceLoop)
12 13 14 15 16 17 18 19
# If a bug is introduced in CMake that causes an infinite loop while
# analyzing LinkInterfaceLoop then don't let the test run too long.
# Use an option to customize it so that the timeout can be extended
# on busy machines.
if(NOT DEFINED CMake_TEST_CMakeOnly.LinkInterfaceLoop_TIMEOUT)
  set(CMake_TEST_CMakeOnly.LinkInterfaceLoop_TIMEOUT 90)
endif()
set_property(TEST CMakeOnly.LinkInterfaceLoop PROPERTY TIMEOUT ${CMake_TEST_CMakeOnly.LinkInterfaceLoop_TIMEOUT})
20

21 22 23
add_CMakeOnly_test(CheckSymbolExists)

add_CMakeOnly_test(CheckCXXSymbolExists)
24

25 26
add_CMakeOnly_test(CheckCXXCompilerFlag)

Brad King's avatar
Brad King committed
27 28
add_CMakeOnly_test(CheckLanguage)

29 30
add_CMakeOnly_test(CheckStructHasMember)

31 32
add_CMakeOnly_test(CompilerIdC)
add_CMakeOnly_test(CompilerIdCXX)
33 34 35 36 37 38

if(CMAKE_OBJC_COMPILER)
  add_CMakeOnly_test(CompilerIdOBJC)
  add_CMakeOnly_test(CheckOBJCCompilerFlag)
endif()

39 40 41 42 43
if(CMAKE_OBJCXX_COMPILER)
  add_CMakeOnly_test(CompilerIdOBJCXX)
  add_CMakeOnly_test(CheckOBJCXXCompilerFlag)
endif()

44 45 46
if(CMAKE_Fortran_COMPILER)
  add_CMakeOnly_test(CompilerIdFortran)
endif()
47
if(CMAKE_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])")
48 49
  add_CMakeOnly_test(CompilerIdCSharp)
endif()
50

51 52 53 54 55
add_test(CMakeOnly.AllFindModules ${CMAKE_CMAKE_COMMAND}
  -DTEST=AllFindModules
  -DCMAKE_ARGS=-DCMake_TEST_CMakeOnly.AllFindModules_NO_VERSION=${CMake_TEST_CMakeOnly.AllFindModules_NO_VERSION}
  -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake
  )
56

57 58
add_CMakeOnly_test(SelectLibraryConfigurations)

59
add_CMakeOnly_test(TargetScope)
60

61
add_CMakeOnly_test(find_library)
62
add_CMakeOnly_test(find_path)
63

64 65 66 67 68
add_test(CMakeOnly.ProjectInclude ${CMAKE_CMAKE_COMMAND}
  -DTEST=ProjectInclude
  -DCMAKE_ARGS=-DCMAKE_PROJECT_ProjectInclude_INCLUDE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectInclude/include.cmake
  -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake
  )
69

70 71 72 73 74 75
add_test(CMakeOnly.ProjectIncludeAny ${CMAKE_CMAKE_COMMAND}
  -DTEST=ProjectIncludeAny
  -DCMAKE_ARGS=-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectInclude/include.cmake
  -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake
  )

76 77
add_test(CMakeOnly.ProjectIncludeBefore ${CMAKE_CMAKE_COMMAND}
  -DTEST=ProjectIncludeBefore
78 79 80 81 82 83
  -DCMAKE_ARGS=-DCMAKE_PROJECT_ProjectInclude_INCLUDE_BEFORE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectIncludeBefore/include.cmake
  -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake
  )

add_test(CMakeOnly.ProjectIncludeBeforeAny ${CMAKE_CMAKE_COMMAND}
  -DTEST=ProjectIncludeBeforeAny
84 85 86 87
  -DCMAKE_ARGS=-DCMAKE_PROJECT_INCLUDE_BEFORE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectIncludeBefore/include.cmake
  -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake
  )

88
include(CMakeParseArguments)
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103

function(add_major_test module)
  cmake_parse_arguments(MAJOR_TEST "NOLANG" "VERSION_VAR" "VERSIONS" ${ARGN})
  foreach (_version IN LISTS MAJOR_TEST_VERSIONS)
    add_test(CMakeOnly.MajorVersionSelection-${module}_${_version}
      ${CMAKE_CMAKE_COMMAND}
        -DTEST=MajorVersionSelection-${module}_${_version}
        -DTEST_SOURCE=MajorVersionSelection
        "-DCMAKE_ARGS=-DMAJOR_TEST_MODULE=${module};-DMAJOR_TEST_VERSION=${_version};-DMAJOR_TEST_NO_LANGUAGES=${MAJOR_TEST_NOLANG};-DMAJOR_TEST_VERSION_VAR=${MAJOR_TEST_VERSION_VAR}"
        -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake
      )
  endforeach ()
endfunction()

add_major_test(PythonLibs VERSIONS 2 3 VERSION_VAR PYTHONLIBS_VERSION_STRING)
104
add_major_test(PythonInterp NOLANG VERSIONS 3 VERSION_VAR PYTHON_VERSION_STRING)
105
add_major_test(Qt VERSIONS 3 4 VERSION_VAR QT_VERSION_STRING)