Integrate JSON libs (#9145)

* Add nlohmann json (Release 3.10.4) as submodule

* Move nlohmann_json lib to json folder, add json_schema validator lib as submodule

* Move BUILD_SHARED_LIBS flag to a separete scope

* Add export of nlohmann_json_schema_validator

* Fix build

* set folder thirdparty

* link lib to offline_transformations and benchmark_app

* suppress shadowing names warning in nlohmann_json lib

* fix include in benchmark_app

* Resolve review comments: add json subdirs to samples cmake

* Fix static build

* Proper json integration

* removed cpp_samples_deps component

Co-authored-by: Ivan Tikhonov <ivan.tikhonov@intel.com>
This commit is contained in:
Ilya Lavrenov
2021-12-12 20:40:41 +03:00
committed by GitHub
parent 75ac2d4b7d
commit 9e519946f0
11 changed files with 59 additions and 13 deletions

27
thirdparty/json/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,27 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# suppress shadowing names warning
set(JSON_SystemInclude ON CACHE BOOL "" FORCE)
add_subdirectory(nlohmann_json EXCLUDE_FROM_ALL)
set(BUILD_SHARED_LIBS OFF)
set(JSON_VALIDATOR_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(JSON_VALIDATOR_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(nlohmann_json_schema_validator EXCLUDE_FROM_ALL)
set_target_properties(nlohmann_json_schema_validator PROPERTIES FOLDER thirdparty)
# WA for CentOS with gcc < 4.9: override defitions to remove boost usage
set_property(TARGET nlohmann_json_schema_validator PROPERTY COMPILE_DEFINITIONS "")
set_property(TARGET nlohmann_json_schema_validator PROPERTY INTERFACE_LINK_LIBRARIES nlohmann_json)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
target_compile_definitions(nlohmann_json_schema_validator PRIVATE JSON_SCHEMA_NO_REGEX)
target_compile_options(nlohmann_json_schema_validator PRIVATE -Wno-missing-field-initializers -Wno-shadow)
endif()
# WA for nlohmann_json_schema_validator:
# nlohmann_json must be in the same export set of nlohmann_json_schema_validator targets
install(TARGETS nlohmann_json EXPORT nlohmann_json_schema_validatorTargets
ARCHIVE DESTINATION lib EXCLUDE_FROM_ALL)