diff --git a/CMakeLists.txt b/CMakeLists.txt index ff4428eee..7858527a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,9 +18,7 @@ option(JSONTOOLKIT_INSTALL "Install the JSON Toolkit library" ON) option(JSONTOOLKIT_ADDRESS_SANITIZER "Build JSON Toolkit with an address sanitizer" OFF) option(JSONTOOLKIT_UNDEFINED_SANITIZER "Build JSON Toolkit with an undefined behavior sanitizer" OFF) -set(NOA_GOOGLETEST ${JSONTOOLKIT_TESTS} CACHE BOOL "GoogleTest") -set(NOA_GOOGLEBENCHMARK ${JSONTOOLKIT_BENCHMARK} CACHE BOOL "GoogleBenchmark") -add_subdirectory(vendor/noa) +find_package(Noa REQUIRED) if(JSONTOOLKIT_INSTALL) include(GNUInstallDirs) diff --git a/DEPENDENCIES b/DEPENDENCIES index 1c722d3dc..4c006256e 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,5 +1,5 @@ vendorpull https://github.com/sourcemeta/vendorpull 70342aaf458e6cb80baeb5b718901075fc42ede6 -noa https://github.com/sourcemeta/noa 4fe72e795c684035712bc7ac38d96e84f62ff414 +noa https://github.com/sourcemeta/noa 75ac6ef239d0167beeb69e5dc49695ed3ea2d63a jsontestsuite https://github.com/nst/JSONTestSuite d64aefb55228d9584d3e5b2433f720ea8fd00c82 jsonschema-2020-12 https://github.com/json-schema-org/json-schema-spec 769daad75a9553562333a8937a187741cb708c72 jsonschema-2019-09 https://github.com/json-schema-org/json-schema-spec 41014ea723120ce70b314d72f863c6929d9f3cfd diff --git a/cmake/FindNoa.cmake b/cmake/FindNoa.cmake new file mode 100644 index 000000000..8e1fc3b8d --- /dev/null +++ b/cmake/FindNoa.cmake @@ -0,0 +1,12 @@ +if(NOT Noa_FOUND) + if(JSONTOOLKIT_INSTALL) + set(NOA_INSTALL ON CACHE BOOL "enable Noa installation") + else() + set(NOA_INSTALL OFF CACHE BOOL "disable Noa installation") + endif() + + set(NOA_GOOGLETEST ${JSONTOOLKIT_TESTS} CACHE BOOL "GoogleTest") + set(NOA_GOOGLEBENCHMARK ${JSONTOOLKIT_BENCHMARK} CACHE BOOL "GoogleBenchmark") + add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/noa") + set(Noa_FOUND ON) +endif() diff --git a/vendor/noa/CMakeLists.txt b/vendor/noa/CMakeLists.txt index 6705d15e0..a2dd5e34a 100644 --- a/vendor/noa/CMakeLists.txt +++ b/vendor/noa/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) project(noa VERSION 0.0.0 LANGUAGES CXX - DESCRIPTION "The swiss-army knife for JSON programming in C++") + DESCRIPTION "A set of re-usable and opinionated utilities for Sourcemeta projects") list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") include(noa) @@ -12,6 +12,7 @@ option(NOA_GOOGLETEST "Build the Google Test library" ON) option(NOA_GOOGLEBENCHMARK "Build the Google Benchmark library" ON) option(NOA_TESTS "Build the Noa tests" OFF) option(NOA_BENCHMARK "Build the Noa benchmarks" OFF) +option(NOA_DOCS "Build the Noa docs" OFF) option(NOA_INSTALL "Install the Noa library" ON) option(NOA_ADDRESS_SANITIZER "Build Noa with an address sanitizer" OFF) option(NOA_UNDEFINED_SANITIZER "Build Noa with an undefined behavior sanitizer" OFF) @@ -56,6 +57,11 @@ elseif(NOA_UNDEFINED_SANITIZER) noa_sanitizer(TYPE undefined) endif() +if(NOA_DOCS) + noa_target_doxygen(CONFIG "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/website") +endif() + if(PROJECT_IS_TOP_LEVEL) noa_target_clang_format(SOURCES benchmark/*.h benchmark/*.cc diff --git a/vendor/noa/benchmark/CMakeLists.txt b/vendor/noa/benchmark/CMakeLists.txt deleted file mode 100644 index d9ed6cc87..000000000 --- a/vendor/noa/benchmark/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -set(BENCHMARK_SOURCES) - -if(NOA_REGEX) - list(APPEND BENCHMARK_SOURCES regex.cc) -endif() - -if(BENCHMARK_SOURCES) - noa_googlebenchmark(NAMESPACE sourcemeta PROJECT noa - FOLDER "Noa" SOURCES ${BENCHMARK_SOURCES}) - - target_compile_definitions(sourcemeta_noa_benchmark - PRIVATE CURRENT_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}") - - if(NOA_REGEX) - target_link_libraries(sourcemeta_noa_benchmark - PRIVATE sourcemeta::noa::regex) - endif() - - add_custom_target(benchmark_all - COMMAND sourcemeta_noa_benchmark - DEPENDS sourcemeta_noa_benchmark - COMMENT "Running benchmark...") - add_custom_target(benchmark_json - COMMAND sourcemeta_noa_benchmark - --benchmark_format=json - --benchmark_out="${PROJECT_BINARY_DIR}/benchmark.json" - DEPENDS sourcemeta_noa_benchmark - COMMENT "Running benchmark...") -else() - add_custom_target(benchmark_all VERBATIM - COMMAND "${CMAKE_COMMAND}" -E echo "Nothing to benchmark" - COMMAND "${CMAKE_COMMAND}" -E false) - add_custom_target(benchmark_json VERBATIM - COMMAND "${CMAKE_COMMAND}" -E echo "Nothing to benchmark" - COMMAND "${CMAKE_COMMAND}" -E false) -endif() diff --git a/vendor/noa/benchmark/regex.cc b/vendor/noa/benchmark/regex.cc deleted file mode 100644 index 7cfdbfaad..000000000 --- a/vendor/noa/benchmark/regex.cc +++ /dev/null @@ -1,37 +0,0 @@ -#include - -#include // assert -#include // std::string - -#include - -#define BENCHMARK_REGEX(name, pattern, input) \ - static void name(benchmark::State &state) { \ - const auto regex{sourcemeta::noa::to_regex(pattern)}; \ - assert(regex.has_value()); \ - for (auto _ : state) { \ - auto result{ \ - sourcemeta::noa::matches(regex.value(), input)}; \ - assert(result); \ - benchmark::DoNotOptimize(result); \ - } \ - } \ - BENCHMARK(name); - -BENCHMARK_REGEX(Regex_Lower_S_Or_Upper_S_Asterisk, "[\\s\\S]*", "foo") -BENCHMARK_REGEX(Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar, "^[\\s\\S]*$", - "foo") -BENCHMARK_REGEX(Regex_Period_Asterisk, ".*", "foo") -BENCHMARK_REGEX(Regex_Group_Period_Asterisk_Group, "(.*)", "foo") -BENCHMARK_REGEX(Regex_Period_Plus, ".+", "foo") -BENCHMARK_REGEX(Regex_Period, ".", "foo") -BENCHMARK_REGEX(Regex_Caret_Period_Plus_Dollar, "^.+$", "foo") -BENCHMARK_REGEX(Regex_Caret_Group_Period_Plus_Group_Dollar, "^(.+)$", "foo") -BENCHMARK_REGEX(Regex_Caret_Period_Asterisk_Dollar, "^.*$", "foo") -BENCHMARK_REGEX(Regex_Caret_Group_Period_Asterisk_Group_Dollar, "^(.*)$", "foo") -BENCHMARK_REGEX(Regex_Caret_X_Hyphen, "^x-", "x-foo") -BENCHMARK_REGEX(Regex_Period_Md_Dollar, "\\.md$", "foo.md") -BENCHMARK_REGEX(Regex_Caret_Slash_Period_Asterisk, "^/.*", "/foo/bar") -BENCHMARK_REGEX(Regex_Caret_Period_Range_Dollar, "^.{1,256}$", "foobar") -// As a stress test, it is supposed to have O(2^n) complexity -BENCHMARK_REGEX(Regex_Nested_Backtrack, "^(x+x+)+y$", "xxxxxxxxxxxxxxxxy") diff --git a/vendor/noa/vendor/boost-regex.mask b/vendor/noa/vendor/boost-regex.mask deleted file mode 100644 index 1b1154ae3..000000000 --- a/vendor/noa/vendor/boost-regex.mask +++ /dev/null @@ -1,12 +0,0 @@ -build/ -doc/ -example/ -meta/ -performance/ -src/ -test/ -tools/ -CMakeLists.txt -index.html -README.md -readme.txt diff --git a/vendor/noa/vendor/googlebenchmark.mask b/vendor/noa/vendor/googlebenchmark.mask deleted file mode 100644 index 9ccea5b38..000000000 --- a/vendor/noa/vendor/googlebenchmark.mask +++ /dev/null @@ -1,22 +0,0 @@ -.github/ -bazel/ -bindings/ -docs/ -test/ -tools/ -AUTHORS -BUILD.bazel -CONTRIBUTING.md -CONTRIBUTORS -MODULE.bazel -WORKSPACE -WORKSPACE.bzlmod -_config.yml -appveyor.yml -pyproject.toml -setup.py -.clang-format -.clang-tidy -.pre-commit-config.yaml -.ycm_extra_conf.py -README.md