CMakeLists.txt 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 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_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${test}
  42. -DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${test}
  43. -P "${CMAKE_CURRENT_SOURCE_DIR}/${test}/RunCMakeTest.cmake"
  44. )
  45. endmacro()
  46. add_RunCMake_test(CMP0019)
  47. add_RunCMake_test(GeneratorExpression)
  48. add_RunCMake_test(TargetPropertyGeneratorExpressions)
  49. add_RunCMake_test(Languages)
  50. add_RunCMake_test(ObjectLibrary)
  51. if(NOT WIN32)
  52. add_RunCMake_test(PositionIndependentCode)
  53. endif()
  54. add_RunCMake_test(CompatibleInterface)
  55. add_RunCMake_test(build_command)
  56. add_RunCMake_test(find_package)
  57. add_RunCMake_test(include)
  58. add_RunCMake_test(include_directories)
  59. add_RunCMake_test(list)
  60. add_RunCMake_test(CMP0004)
  61. if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]")
  62. add_RunCMake_test(include_external_msproject)
  63. add_RunCMake_test(SolutionGlobalSections)
  64. endif()