CMakeLists.txt 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. string(
  40. JOIN ":"
  41. SelfValidateTest_Unsupported
  42. "*optional_content"
  43. "*optional_*ecmascript_regex"
  44. "*optional_zeroTerminatedFloats"
  45. )
  46. set(SelfValidateTest_Unsupported_Suites "")
  47. set(SelfValidateTest_Unsupported_Cases "*leap second")
  48. if (ICU_FOUND)
  49. target_link_libraries(selfvalidate_test ICU::uc ICU::i18n)
  50. else()
  51. string(
  52. APPEND SelfValidateTest_Unsupported
  53. ":*optional_non_bmp_regex"
  54. )
  55. endif()
  56. if (IDNA_POPULATED)
  57. target_link_libraries(selfvalidate_test ada-idna)
  58. else()
  59. string(
  60. APPEND SelfValidateTest_Unsupported
  61. ":*optional_*iri*"
  62. ":*optional_*idn*"
  63. ":*optional_*uri_template*"
  64. )
  65. string(
  66. APPEND SelfValidateTest_Unsupported_Suites
  67. ":*punycode*"
  68. ":*puny-code"
  69. )
  70. string(
  71. APPEND SelfValidateTest_Unsupported_Cases
  72. ":*punycode*"
  73. ":*puny-code"
  74. )
  75. endif()
  76. gtest_discover_tests(selfvalidate_test
  77. EXTRA_ARGS --json_suite_filter=-${SelfValidateTest_Unsupported_Suites}
  78. --json_case_filter=-${SelfValidateTest_Unsupported_Cases}
  79. TEST_FILTER -${SelfValidateTest_Unsupported})