CMakeLists.txt 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. cmake_minimum_required(VERSION 3.5)
  2. project(TestCustomFailureMessage LANGUAGES NONE)
  3. include(CTest)
  4. add_test(NAME FindPython.CustomFailureMessage.Interpreter COMMAND
  5. ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
  6. --build-and-test
  7. "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check"
  8. "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Interpreter"
  9. ${build_generator_args}
  10. --build-project TestCustomFailureMessage.Check
  11. --build-options "-DCHECK_COMPONENTS=Interpreter"
  12. "-DPython3_EXECUTABLE=/not/found/interpreter"
  13. --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
  14. )
  15. set_tests_properties(FindPython.CustomFailureMessage.Interpreter PROPERTIES
  16. PASS_REGULAR_EXPRESSION "Reason given by package:.+Interpreter: Cannot run the interpreter")
  17. add_test(NAME FindPython.CustomFailureMessage.Library COMMAND
  18. ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
  19. --build-and-test
  20. "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check"
  21. "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Library"
  22. ${build_generator_args}
  23. --build-project TestCustomFailureMessage.Check
  24. --build-options "-DCHECK_COMPONENTS=Development"
  25. "-DPython3_LIBRARY=/not/found/library"
  26. --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
  27. )
  28. set_tests_properties(FindPython.CustomFailureMessage.Library PROPERTIES
  29. PASS_REGULAR_EXPRESSION "Reason given by package:.+Development: Cannot find the library")
  30. add_test(NAME FindPython.CustomFailureMessage.Include COMMAND
  31. ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
  32. --build-and-test
  33. "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check"
  34. "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Include"
  35. ${build_generator_args}
  36. --build-project TestCustomFailureMessage.Check
  37. --build-options "-DCHECK_COMPONENTS=Development"
  38. "-DPython3_INCLUDE_DIR=/not/found/include"
  39. --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
  40. )
  41. set_tests_properties(FindPython.CustomFailureMessage.Include PROPERTIES
  42. PASS_REGULAR_EXPRESSION "Reason given by package:.+Development: Cannot find the directory")
  43. add_test(NAME FindPython.CustomFailureMessage.Multiple COMMAND
  44. ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
  45. --build-and-test
  46. "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check"
  47. "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/Multiple"
  48. ${build_generator_args}
  49. --build-project TestCustomFailureMessage.Check
  50. --build-options "-DCHECK_COMPONENTS=Interpreter;Development"
  51. "-DPython3_EXECUTABLE=/not/found/interpreter"
  52. "-DPython3_LIBRARY=/not/found/library"
  53. --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
  54. )
  55. set_tests_properties(FindPython.CustomFailureMessage.Multiple PROPERTIES
  56. PASS_REGULAR_EXPRESSION "Reason given by package:.+Interpreter: Cannot run the interpreter.+Development: Cannot find the library")
  57. if (CMake_TEST_FindPython_NumPy)
  58. add_test(NAME FindPython.CustomFailureMessage.NumPy COMMAND
  59. ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
  60. --build-and-test
  61. "${CMake_SOURCE_DIR}/Tests/FindPython/CustomFailureMessage/Check"
  62. "${CMake_BINARY_DIR}/Tests/FindPython/CustomFailureMessage/NumPy"
  63. ${build_generator_args}
  64. --build-project TestCustomFailureMessage.Check
  65. --build-options "-DCHECK_COMPONENTS=Interpreter;Development;NumPy"
  66. "-DPython3_NumPy_INCLUDE_DIR=/not/found/numpy/include"
  67. --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
  68. )
  69. set_tests_properties(FindPython.CustomFailureMessage.NumPy PROPERTIES
  70. PASS_REGULAR_EXPRESSION "Reason given by package:.+NumPy: Cannot find the directory")
  71. endif()