CMakeLists.txt 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. # This directory contains tests that run CMake to configure a project
  2. # but do not actually build anything. To add a test:
  3. #
  4. # 1.) Add a subdirectory named for the test.
  5. #
  6. # 2.) Call add_RunCMake_test and pass the test directory name.
  7. #
  8. # 3.) Create a RunCMakeTest.cmake script in the directory containing
  9. # include(RunCMake)
  10. # run_cmake(SubTest1)
  11. # ...
  12. # run_cmake(SubTestN)
  13. # where SubTest1..SubTestN are sub-test names each corresponding to
  14. # an independent CMake run and project configuration.
  15. #
  16. # 3.) Create a CMakeLists.txt file in the directory containing
  17. # cmake_minimum_required(...)
  18. # project(${RunCMake_TEST} NONE) # or languages needed
  19. # include(${RunCMake_TEST}.cmake)
  20. # where "${RunCMake_TEST}" is literal. A value for RunCMake_TEST
  21. # will be passed to CMake by the run_cmake macro when running each
  22. # sub-test.
  23. #
  24. # 4.) Create a <SubTest>.cmake file for each sub-test named above
  25. # containing the actual test code. Optionally create files
  26. # containing expected test results:
  27. # <SubTest>-result.txt = Process result expected if not "0"
  28. # <SubTest>-stdout.txt = Regex matching expected stdout content
  29. # <SubTest>-stderr.txt = Regex matching expected stderr content
  30. # <SubTest>-check.cmake = Custom result check
  31. # Note that trailing newlines will be stripped from actual and expected test
  32. # output before matching against the stdout and stderr expressions.
  33. # The code in <SubTest>-check.cmake may use variables
  34. # RunCMake_TEST_SOURCE_DIR = Top of test source tree
  35. # RunCMake_TEST_BINARY_DIR = Top of test binary tree
  36. # and an failure must store a message in RunCMake_TEST_FAILED.
  37. macro(add_RunCMake_test test)
  38. add_test(RunCMake.${test} ${CMAKE_CMAKE_COMMAND}
  39. -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR}
  40. -DRunCMake_GENERATOR=${CMAKE_TEST_GENERATOR}
  41. -DRunCMake_GENERATOR_TOOLSET=${CMAKE_TEST_GENERATOR_TOOLSET}
  42. -DRunCMake_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${test}
  43. -DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${test}
  44. ${${test}_ARGS}
  45. -P "${CMAKE_CURRENT_SOURCE_DIR}/${test}/RunCMakeTest.cmake"
  46. )
  47. endmacro()
  48. if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 3)
  49. set(GeneratorToolset_ARGS -DXCODE_BELOW_3=1)
  50. endif()
  51. add_RunCMake_test(CMP0019)
  52. add_RunCMake_test(CMP0022)
  53. add_RunCMake_test(CMP0026)
  54. add_RunCMake_test(CMP0027)
  55. add_RunCMake_test(CMP0028)
  56. add_RunCMake_test(CMP0037)
  57. add_RunCMake_test(CMP0038)
  58. add_RunCMake_test(CMP0039)
  59. add_RunCMake_test(CMP0040)
  60. add_RunCMake_test(CMP0041)
  61. if(CMAKE_SYSTEM_NAME MATCHES Darwin AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
  62. add_RunCMake_test(CMP0042)
  63. endif()
  64. add_RunCMake_test(CTest)
  65. if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles")
  66. add_RunCMake_test(CompilerChange)
  67. endif()
  68. add_RunCMake_test(CompilerNotFound)
  69. add_RunCMake_test(Configure)
  70. add_RunCMake_test(DisallowedCommands)
  71. add_RunCMake_test(ExternalData)
  72. add_RunCMake_test(FPHSA)
  73. add_RunCMake_test(GeneratorExpression)
  74. add_RunCMake_test(GeneratorToolset)
  75. add_RunCMake_test(TargetPropertyGeneratorExpressions)
  76. add_RunCMake_test(Languages)
  77. add_RunCMake_test(ObjectLibrary)
  78. if(NOT WIN32)
  79. add_RunCMake_test(PositionIndependentCode)
  80. set(SKIP_VISIBILITY 0)
  81. if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 4.2)
  82. set(SKIP_VISIBILITY 1)
  83. endif()
  84. if (CMAKE_CXX_COMPILER_ID MATCHES Watcom
  85. OR CMAKE_SYSTEM_NAME MATCHES IRIX64
  86. OR CMAKE_CXX_COMPILER_ID MATCHES HP
  87. OR CMAKE_CXX_COMPILER_ID MATCHES XL
  88. OR CMAKE_CXX_COMPILER_ID MATCHES SunPro)
  89. set(SKIP_VISIBILITY 1)
  90. endif()
  91. if (NOT SKIP_VISIBILITY)
  92. add_RunCMake_test(VisibilityPreset)
  93. endif()
  94. endif()
  95. if (QT4_FOUND)
  96. set(CompatibleInterface_ARGS -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE})
  97. endif()
  98. add_RunCMake_test(CompatibleInterface)
  99. add_RunCMake_test(Syntax)
  100. add_RunCMake_test(add_dependencies)
  101. add_RunCMake_test(build_command)
  102. add_RunCMake_test(export)
  103. add_RunCMake_test(cmake_minimum_required)
  104. add_RunCMake_test(find_package)
  105. add_RunCMake_test(get_filename_component)
  106. add_RunCMake_test(if)
  107. add_RunCMake_test(include)
  108. add_RunCMake_test(include_directories)
  109. add_RunCMake_test(list)
  110. add_RunCMake_test(message)
  111. add_RunCMake_test(string)
  112. add_RunCMake_test(try_compile)
  113. add_RunCMake_test(set)
  114. add_RunCMake_test(variable_watch)
  115. add_RunCMake_test(CMP0004)
  116. add_RunCMake_test(TargetPolicies)
  117. add_RunCMake_test(alias_targets)
  118. add_RunCMake_test(interface_library)
  119. add_RunCMake_test(no_install_prefix)
  120. find_package(Qt4 QUIET)
  121. find_package(Qt5Core QUIET)
  122. if (QT4_FOUND AND Qt5Core_FOUND AND NOT Qt5Core_VERSION VERSION_LESS 5.1.0)
  123. add_RunCMake_test(IncompatibleQt)
  124. endif()
  125. if (QT4_FOUND)
  126. set(ObsoleteQtMacros_ARGS -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE})
  127. add_RunCMake_test(ObsoleteQtMacros)
  128. endif()
  129. if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]")
  130. add_RunCMake_test(include_external_msproject)
  131. add_RunCMake_test(SolutionGlobalSections)
  132. endif()
  133. add_RunCMake_test(File_Generate)
  134. add_RunCMake_test(ExportWithoutLanguage)
  135. add_RunCMake_test(target_link_libraries)
  136. add_RunCMake_test(CheckModules)