Update readme remove example
This commit is contained in:
parent
6777732b91
commit
04ef7daac7
19
README.md
19
README.md
@ -105,23 +105,12 @@ In your initial call to cmake simply add:
|
||||
cmake [..] -DBUILD_SHARED_LIBS=ON [..]
|
||||
```
|
||||
|
||||
## Providing access to nlohmann-json
|
||||
## nlohmann-json integration
|
||||
|
||||
The CMake-file of this libraries tries several ways to ultimately include
|
||||
`nlohmann/json.hpp`
|
||||
As nlohmann-json is a dependency, this library tries find it.
|
||||
|
||||
During the cmake-configurate-step there are 3 tries done trying to
|
||||
access nlohmann-json:
|
||||
|
||||
1. link with a nlohmann_json::nlohmann_json-target,
|
||||
2. find the nlohmann_json-cmake-package and link with nlohmann_json::nlohmann_json-target or
|
||||
3. find path to `nlohmann/json.hpp`.
|
||||
|
||||
1 is there to make it work when this project is added as
|
||||
a sub-directory (via `add_subdirectory()`), 2 and 3 can be
|
||||
assisted by setting the `nlohmann_json_DIR`-variable.
|
||||
|
||||
For 1 there is an example of you to do in example/cmake-submodule.
|
||||
The cmake-configuration first checks if nlohmann-json is available as an cmake-target. This may happen, because it is used as a submodule in a super-project which already provides and uses nlohmann-json.
|
||||
Otherwise, it calls `find_package` for nlohmann-json and requires that library to be installed on the system.
|
||||
|
||||
### Building with Hunter package manager
|
||||
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
project(simple-json-validator-as-submodule-test)
|
||||
|
||||
# absolute-path
|
||||
set(PATH_TO_NLOHMANN_JSON_REPO $ENV{HOME}/devel/upstream/json)
|
||||
|
||||
# build shared library
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
|
||||
# JSON library
|
||||
option(JSON_BuildTests OFF)
|
||||
add_subdirectory(${PATH_TO_NLOHMANN_JSON_REPO}
|
||||
json-binary-dir
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
# JSON SCHEMA VALIDATOR library
|
||||
option(BUILD_TESTS OFF)
|
||||
add_subdirectory(../..
|
||||
json-validator-binary-dir
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
add_executable(validate validate.cpp)
|
||||
target_link_libraries(validate nlohmann_json_schema_validator)
|
||||
@ -1,20 +0,0 @@
|
||||
#include <nlohmann/json-schema.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
nlohmann::json schema_json{{"type", "number"}};
|
||||
nlohmann::json_schema::json_validator validator;
|
||||
|
||||
validator.set_root_schema(schema_json);
|
||||
|
||||
validator.validate(1);
|
||||
try {
|
||||
validator.validate("\"1\"");
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << "expected exception: " << e.what() << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user