CMakeLists.txt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. enable_testing()
  2. # MUST do this before including IDNA
  3. # because it will otherwise poison GTest with BUILD_GMOCK=OFF
  4. find_package(GTest CONFIG REQUIRED COMPONENTS gtest gmock)
  5. find_package(jsoncpp REQUIRED)
  6. find_package(CURL REQUIRED)
  7. # ICU Components Reference:
  8. # https://cmake.org/cmake/help/latest/module/FindICU.html
  9. # ICU components = data, i18n, io, le, lx, test, tu and uc.
  10. find_package(ICU 77.1 COMPONENTS uc i18n)
  11. FetchContent_Declare(
  12. IDNA
  13. GIT_REPOSITORY https://github.com/ada-url/idna.git
  14. GIT_TAG 0.5.0
  15. )
  16. FetchContent_MakeAvailable(IDNA)
  17. FetchContent_Declare(
  18. json_schema_test_suite
  19. GIT_REPOSITORY https://github.com/json-schema-org/JSON-Schema-Test-Suite.git
  20. GIT_TAG Test-JSON-Schema-Acceptance-1.037
  21. )
  22. FetchContent_MakeAvailable(json_schema_test_suite)
  23. include(GoogleTest)
  24. add_executable(annotation_test annotation_test.cxx)
  25. target_link_libraries(annotation_test GTest::gtest GTest::gmock jsoncpp_lib)
  26. gtest_discover_tests(annotation_test)
  27. add_executable(extension_test extension_test.cxx)
  28. target_link_libraries(extension_test GTest::gtest GTest::gmock jsoncpp_lib)
  29. gtest_discover_tests(extension_test)
  30. add_executable(selfvalidate_test selfvalidate_test.cxx)
  31. target_compile_definitions(selfvalidate_test PUBLIC JVALIDATE_USE_EXCEPTIONS)
  32. if (${json_schema_test_suite_POPULATED})
  33. target_compile_definitions(selfvalidate_test
  34. PUBLIC
  35. JVALIDATE_JSON_SCHEMA_TEST_SUITE_DIR="${json_schema_test_suite_SOURCE_DIR}"
  36. )
  37. endif()
  38. target_link_libraries(selfvalidate_test GTest::gtest GTest::gmock jsoncpp_lib CURL::libcurl)
  39. if (ICU_FOUND)
  40. target_link_libraries(selfvalidate_test ICU::uc ICU::i18n)
  41. endif()
  42. if (IDNA_POPULATED)
  43. target_link_libraries(selfvalidate_test ada-idna)
  44. endif()
  45. string(
  46. JOIN ":"
  47. SelfValidateTest_Unsupported
  48. "*optional_content"
  49. "*optional_*ecmascript_regex"
  50. "*optional_zeroTerminatedFloats"
  51. )
  52. if (NOT ${ICU_FOUND})
  53. string(
  54. APPEND SelfValidateTest_Unsupported
  55. ":*optional_non_bmp_regex"
  56. )
  57. endif()
  58. set(SelfValidateTest_Unsupported_Suites "")
  59. set(SelfValidateTest_Unsupported_Cases "*leap second")
  60. if (NOT ${IDNA_POPULATED})
  61. string(
  62. APPEND SelfValidateTest_Unsupported
  63. ":*optional_*iri*"
  64. ":*optional_*idn*"
  65. ":*optional_*uri_template*"
  66. )
  67. string(
  68. APPEND SelfValidateTest_Unsupported_Suites
  69. ":*punycode*"
  70. ":*puny-code"
  71. )
  72. string(
  73. APPEND SelfValidateTest_Unsupported_Cases
  74. ":*punycode*"
  75. ":*puny-code"
  76. )
  77. endif()
  78. gtest_discover_tests(selfvalidate_test
  79. EXTRA_ARGS --json_suite_filter=-${SelfValidateTest_Unsupported_Suites}
  80. --json_case_filter=-${SelfValidateTest_Unsupported_Cases}
  81. TEST_FILTER -${SelfValidateTest_Unsupported})