GetPropertyTest.cmake.in 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake")
  2. get_property(FOO_BRIEF GLOBAL PROPERTY FOO BRIEF_DOCS)
  3. get_property(FOO_FULL GLOBAL PROPERTY FOO FULL_DOCS)
  4. if (NOT FOO_BRIEF STREQUAL "NOTFOUND")
  5. message(SEND_ERROR "property FOO has BRIEF_DOCS set to '${FOO_BRIEF}'")
  6. endif ()
  7. if (NOT FOO_FULL STREQUAL "NOTFOUND")
  8. message(SEND_ERROR "property FOO has FULL_DOCS set to '${FOO_FULL}'")
  9. endif ()
  10. set(test_var alpha)
  11. get_property(result VARIABLE PROPERTY test_var)
  12. if(NOT result STREQUAL "alpha")
  13. message(SEND_ERROR "bad value of VARIABLE PROPERTY test_var: got '${result}' instead of 'alpha'")
  14. endif()
  15. include("@CMAKE_CURRENT_SOURCE_DIR@/../RegexEscapeString.cmake")
  16. REGEX_ESCAPE_STRING(CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@")
  17. set(Missing-Argument-RESULT 1)
  18. set(Missing-Argument-STDERR ".*CMake Error at (${CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/)?GetProperty-Missing-Argument.cmake:1 \\(get_property\\):.*get_property called with incorrect number of arguments.*")
  19. check_cmake_test(GetProperty
  20. Missing-Argument
  21. )
  22. set(Bad-Scope-RESULT 1)
  23. set(Bad-Scope-STDERR ".*CMake Error at (${CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/)?GetProperty-Bad-Scope.cmake:1 \\(get_property\\):.*get_property given invalid scope FOO\\..*")
  24. check_cmake_test(GetProperty
  25. Bad-Scope
  26. )
  27. set(Bad-Argument-RESULT 1)
  28. set(Bad-Argument-STDERR ".*CMake Error at (${CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/)?GetProperty-Bad-Argument.cmake:1 \\(get_property\\):.*get_property given invalid argument \"FOO\"\\..*")
  29. check_cmake_test(GetProperty
  30. Bad-Argument
  31. )
  32. set(No-Property-RESULT 1)
  33. set(No-Property-STDERR ".*CMake Error at (${CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/)?GetProperty-No-Property.cmake:1 \\(get_property\\):.*get_property not given a PROPERTY <name> argument\\..*")
  34. check_cmake_test(GetProperty
  35. No-Property
  36. )
  37. set(Global-Name-RESULT 1)
  38. set(Global-Name-STDERR ".*CMake Error at (${CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/)?GetProperty-Global-Name.cmake:1 \\(get_property\\):.*get_property given name for GLOBAL scope\\..*")
  39. check_cmake_test(GetProperty
  40. Global-Name
  41. )
  42. set(Bad-Directory-RESULT 1)
  43. set(Bad-Directory-STDERR ".*CMake Error at (${CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/)?GetProperty-Bad-Directory.cmake:1 \\(get_property\\):.*get_property DIRECTORY scope provided but requested directory was not.*found\\..*")
  44. check_cmake_test(GetProperty
  45. Bad-Directory
  46. )
  47. set(No-Target-RESULT 1)
  48. set(No-Target-STDERR ".*CMake Error at (${CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/)?GetProperty-No-Target.cmake:1 \\(get_property\\):.*get_property not given name for TARGET scope\\..*")
  49. check_cmake_test(GetProperty
  50. No-Target
  51. )
  52. set(Bad-Target-RESULT 1)
  53. set(Bad-Target-STDERR ".*CMake Error at (${CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/)?GetProperty-Bad-Target.cmake:1 \\(get_property\\):.*get_property could not find TARGET FOO\\..*")
  54. check_cmake_test(GetProperty
  55. Bad-Target
  56. )
  57. set(No-Source-RESULT 1)
  58. set(No-Source-STDERR ".*CMake Error at (${CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/)?GetProperty-No-Source.cmake:1 \\(get_property\\):.*get_property not given name for SOURCE scope\\..*")
  59. check_cmake_test(GetProperty
  60. No-Source
  61. )
  62. set(No-Test-RESULT 1)
  63. set(No-Test-STDERR ".*CMake Error at (${CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/)?GetProperty-No-Test.cmake:1 \\(get_property\\):.*get_property not given name for TEST scope\\..*")
  64. check_cmake_test(GetProperty
  65. No-Test
  66. )
  67. set(Bad-Test-RESULT 1)
  68. set(Bad-Test-STDERR ".*CMake Error at (${CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/)?GetProperty-Bad-Test.cmake:1 \\(get_property\\):.*get_property given TEST name that does not exist: FOO.*")
  69. check_cmake_test(GetProperty
  70. Bad-Test
  71. )
  72. set(Variable-Name-RESULT 1)
  73. set(Variable-Name-STDERR ".*CMake Error at (${CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/)?GetProperty-Variable-Name.cmake:1 \\(get_property\\):.*get_property given name for VARIABLE scope\\..*")
  74. check_cmake_test(GetProperty
  75. Variable-Name
  76. )
  77. set(No-Cache-RESULT 1)
  78. set(No-Cache-STDERR ".*CMake Error at (${CTEST_ESCAPED_CMAKE_CURRENT_SOURCE_DIR}/)?GetProperty-No-Cache.cmake:1 \\(get_property\\):.*get_property not given name for CACHE scope\\..*")
  79. check_cmake_test(GetProperty
  80. No-Cache
  81. )