diff --git a/CMakeLists.txt b/CMakeLists.txt index dce992f..2da3c4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ if(NOT TARGET json-hpp) endif() # and one for the validator -add_library(json-schema-validator SHARED +add_library(json-schema-validator src/json-schema-draft4.json.cpp src/json-uri.cpp src/json-validator.cpp) @@ -49,9 +49,11 @@ endif() target_link_libraries(json-schema-validator PUBLIC json-hpp) -target_compile_definitions(json-schema-validator - PRIVATE - -DJSON_SCHEMA_VALIDATOR_EXPORTS) +if(BUILD_SHARED_LIBS) + target_compile_definitions(json-schema-validator + PRIVATE + -DJSON_SCHEMA_VALIDATOR_EXPORTS) +endif() # regex with boost if gcc < 4.9 - default is std::regex if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") diff --git a/README.md b/README.md index c604c0d..ac55838 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,16 @@ enable_testing() # if you want to inherit tests add_subdirectory(path-to-this-project json-schema-validator) ``` +### Building a shared library + +By default a static library is built. Shared libraries are generated by using +the `BUILD_SHARED_LIBS`-cmake variable: + +In your initial call to cmake simply add: +```bash +cmake -DBUILD_SHARED_LIBS=ON +``` + ## Code See also `app/json-schema-validate.cpp`.