CMakeLists.txt 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 ada-idna 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 ada-idna 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 ada-idna jsoncpp_lib CURL::libcurl)
  39. if (ICU_FOUND)
  40. target_link_libraries(annotation_test ICU::uc ICU::i18n)
  41. target_link_libraries(extension_test ICU::uc ICU::i18n)
  42. target_link_libraries(selfvalidate_test ICU::uc ICU::i18n)
  43. endif()
  44. string(
  45. JOIN ":"
  46. SelfValidateTest_Unsupported
  47. "*optional_content"
  48. "*optional_*ecmascript_regex"
  49. "*optional_zeroTerminatedFloats"
  50. )
  51. if (NOT ${ICU_FOUND})
  52. string(
  53. JOIN ":"
  54. SelfValidateTest_Unsupported
  55. ${SelfValidateTest_Unsupported}
  56. "*optional_non_bmp_regex"
  57. )
  58. endif()
  59. set(SelfValidateTest_Unsupported_Cases "*leap second")
  60. gtest_discover_tests(selfvalidate_test
  61. EXTRA_ARGS --json_case_filter=-${SelfValidateTest_Unsupported_Cases}
  62. TEST_FILTER -${SelfValidateTest_Unsupported})