pboettch / json-schema-validator

JSON schema validator for JSON for Modern C++
Other
469 stars 135 forks source link

Cmake clean up #193

Closed vrince closed 1 year ago

vrince commented 2 years ago

This is a draft of cmake simplification following the discussion from #185

note: It's maybe too big of a move as I see a lot of effort have been put in a couple of years ago to make json-schema-validator works with find-package and this MR goes completely in the other direction.

The goal of this MR is to make CMake process dead simple and make usage of this library really easy to help adoption. Bottom line the following cmake is all it needs to use both json-schema-validator and appropriate version of nlohmann_json for people starting from scratch :

cmake_minimum_required(VERSION 3.16)
include(FetchContent)

project(stand-alone VERSION 1.0.0 LANGUAGES CXX)

set(JSON_VALIDATOR_BUILD_EXAMPLES OFF)
set(JSON_VALIDATOR_BUILD_TESTS OFF)

FetchContent_Declare(json_schema_validator 
GIT_REPOSITORY https://github.com/vrince/json-schema-validator
GIT_TAG 379cf8c2b4ad49fe3a21e926ffdf543b9e9da8df)
FetchContent_MakeAvailable(json_schema_validator)

add_executable(stand-alone stand-alone.cpp)
target_link_libraries(stand-alone nlohmann_json_schema_validator)

This is just an example once merged the GIT_TAG will make more sense...

This MR also contains:

vrince commented 2 years ago

@pboettch here is a draft of FetchContent move ... still some stuff to clean on the test side since there is a test to check if find_package(...) works and I remove everything export-related (feeling a little bad about that .... sorry).

vrince commented 2 years ago

Contemplating to set JSON_VALIDATOR_BUILD_EXAMPLES and JSON_VALIDATOR_BUILD_TESTS off by default document then for internal developers.

pboettch commented 2 years ago

Beautiful so far.

pboettch commented 2 years ago

This will supersede #162 and #185, right?

vrince commented 2 years ago

@pboettch being at it ... making it a c++11 project and dropping the regex boost gcc 4.9 thing?

pboettch commented 2 years ago

@pboettch being at it ... making it a c++11 project and dropping the regex boost gcc 4.9 thing?

Making in C++11 OK, but not dropping the boost-regex-thing ftm. Or in a separate PR. I have one project with gcc-4.9 I'd need to check before.

SamVanheer commented 2 years ago

It might be worth keeping Boost regex support since std::regex has pretty poor performance: https://stackoverflow.com/questions/70583395/why-is-stdregex-notoriously-much-slower-than-other-regular-expression-librarie

I'd suggest reworking the CMake setup logic to allow users to provide Boost as an existing target or by providing the config file. Using NOT TARGET Boost::regex before using find_package will probably suffice. This also implies using Boost::regex instead of Boost_* variables.

Making the use of Boost regex possible on any platform would also be good.

vrince commented 2 years ago

Guys this is unfinished business my goal was to simplify integration into other projects using CMake Fetch content (with it does in its current state) but then it crashed on me for some reason when I use it. So I used another lib to do json schema validation. Not sure I'll devote the time needed to finalize this MR.

pboettch commented 2 years ago

Yeah, sorry for not having continued until now. Time is going by so fast.

What crash did you observe?

pboettch commented 1 year ago

All PRs have been closed due to me changing the main-branch to main. Please reissue your pull-request to that branch. Sorry and thanks.

nine commented 1 year ago

This pull request is quite promising. @pboettch do you need any help to finalize the integration?

LecrisUT commented 1 year ago

Consider #262 for a more complete implementation