Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Valijson to version 0.6. #1721

Merged
merged 2 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions src/Valijson/valijson/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ xcode/valijson.xcodeproj/project.xcworkspace
xcode/valijson.xcodeproj/project.xcworkspace/xcuserdata
xcode/valijson.xcodeproj/xcuserdata
doc/html
.idea
cmake-build-*
CMakeFiles/
4 changes: 2 additions & 2 deletions src/Valijson/valijson/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ before_install:
- export POCO_OPTS="$POCO_OPTS -DENABLE_MONGODB=off -DENABLE_NET=off -DENABLE_NETSSL=off -DENABLE_PAGECOMPILER=off"
- export POCO_OPTS="$POCO_OPTS -DENABLE_PAGECOMPILER_FILE2PAGE=off -DENABLE_PDF=off -DENABLE_UTIL=off -DENABLE_XML=off -DENABLE_ZIP=off"
- cmake -D CMAKE_CXX_COMPILER=`which ${CXX_COMPILER}` -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" -DCMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS" $POCO_OPTS ..
- sudo make install
- sudo make -j 4 install
- wget -O curlpp-0.8.1.tar.gz https://github.com/jpbarrette/curlpp/archive/v0.8.1.tar.gz
- tar -xf curlpp-0.8.1.tar.gz
- cd curlpp-0.8.1
- mkdir cmake_build
- cd cmake_build
- cmake -D CMAKE_CXX_COMPILER=`which ${CXX_COMPILER}` -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" -DCMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS" ..
- sudo make install
- sudo make -j 4 install
- popd

script:
Expand Down
6 changes: 6 additions & 0 deletions src/Valijson/valijson/Authors
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ Pierre Lamot, pierre.lamot@yahoo.fr

drewxa (github username), bo.ro.da@mail.ru
Adapter for Poco JSON parser

Jordan Bayles (jophba), jophba@chromium.org
JsonCpp owner

Matt Young (matty0ung), <mfsy@yahoo.com>
Adapter for Boost.JSON parser library
122 changes: 89 additions & 33 deletions src/Valijson/valijson/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,33 @@ option(valijson_INSTALL_HEADERS "Install valijson headers." FALSE)
option(valijson_BUILD_EXAMPLES "Build valijson examples." FALSE)
option(valijson_BUILD_TESTS "Build valijson test suite." TRUE)
option(valijson_EXCLUDE_BOOST "Exclude Boost when building test suite." FALSE)
option(valijson_USE_EXCEPTIONS "Use exceptions in valijson and included libs." TRUE)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
if(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
else()
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(!COMPILER_SUPPORTS_CXX11)
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()

# Suppress boost warnings that aren't relevant to the test suite
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_BIND_GLOBAL_PLACEHOLDERS")

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
endif()

add_library(valijson INTERFACE)
# create alias, so that user could always write target_link_libraries(... ValiJSON::valijson)
# despite of valijson target is imported or not
add_library(ValiJSON::valijson ALIAS valijson)

include(GNUInstallDirs)
target_include_directories(valijson INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

if(valijson_INSTALL_HEADERS)
install(DIRECTORY include/ DESTINATION include)
Expand All @@ -18,29 +43,27 @@ if(NOT valijson_BUILD_TESTS AND NOT valijson_BUILD_EXAMPLES)
return()
endif()

SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if(valijson_USE_EXCEPTIONS)
add_definitions(-DVALIJSON_USE_EXCEPTIONS=1)
else()
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
add_definitions(-D_HAS_EXCEPTIONS=0)
add_definitions(-DBOOST_NO_EXCEPTIONS)
add_definitions(-DJSON_USE_EXCEPTION=0)
add_definitions(-DVALIJSON_USE_EXCEPTIONS=0)
endif()

find_package(curlpp)
find_package(Poco OPTIONAL_COMPONENTS JSON)
find_package(Qt5Core)

# jsoncpp library
add_library(jsoncpp
thirdparty/jsoncpp-0.9.4/src/lib_json/json_reader.cpp
thirdparty/jsoncpp-0.9.4/src/lib_json/json_value.cpp
thirdparty/jsoncpp-0.9.4/src/lib_json/json_writer.cpp
thirdparty/jsoncpp-1.9.4/src/lib_json/json_reader.cpp
thirdparty/jsoncpp-1.9.4/src/lib_json/json_value.cpp
thirdparty/jsoncpp-1.9.4/src/lib_json/json_writer.cpp
)

target_include_directories(jsoncpp SYSTEM PRIVATE thirdparty/jsoncpp-0.9.4/include)
set_target_properties(jsoncpp PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/thirdparty/jsoncpp-0.9.4)
target_include_directories(jsoncpp SYSTEM PRIVATE thirdparty/jsoncpp-1.9.4/include)
set_target_properties(jsoncpp PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/thirdparty/jsoncpp-1.9.4)

add_library(json11
thirdparty/json11-ec4e452/json11.cpp
Expand All @@ -51,10 +74,10 @@ set_target_properties(json11 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINAR

# Not all of these are required for examples build it doesn't hurt to include them
include_directories(include SYSTEM
thirdparty/gtest-1.7.0/include
thirdparty/gtest-1.11.0/include
thirdparty/json11-ec4e452
thirdparty/jsoncpp-0.9.4/include
thirdparty/rapidjson-1.1.0/include
thirdparty/jsoncpp-1.9.4/include
thirdparty/rapidjson-48fbd8c/include
thirdparty/picojson-1.3.0
thirdparty/nlohmann-json-3.1.2
)
Expand All @@ -66,11 +89,14 @@ if(valijson_BUILD_TESTS)

# Build local gtest
set(gtest_force_shared_crt ON)
add_subdirectory(thirdparty/gtest-1.7.0)
option(BUILD_GMOCK FALSE)
option(INSTALL_GTEST FALSE)
add_subdirectory(thirdparty/gtest-1.11.0)

set(TEST_SOURCES
tests/test_adapter_comparison.cpp
tests/test_fetch_document_callback.cpp
tests/test_fetch_urn_document_callback.cpp
tests/test_fetch_absolute_uri_document_callback.cpp
tests/test_json_pointer.cpp
tests/test_json11_adapter.cpp
tests/test_jsoncpp_adapter.cpp
Expand All @@ -82,42 +108,68 @@ if(valijson_BUILD_TESTS)
tests/test_validator.cpp
)

set(TEST_LIBS gtest gtest_main jsoncpp json11)

if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
list(APPEND TEST_SOURCES tests/test_boost_json_adapter.cpp)
list(APPEND TEST_SOURCES tests/test_property_tree_adapter.cpp)
endif()

if(Poco_FOUND)
include_directories(${Poco_INCLUDE_DIRS})
list(APPEND TEST_SOURCES tests/test_poco_json_adapter.cpp)
list(APPEND TEST_LIBS ${Poco_Foundation_LIBRARIES} ${Poco_JSON_LIBRARIES})
endif()

if(Qt5Core_FOUND)
include_directories(${Qt5Core_INCLUDE_DIRS})
list(APPEND TEST_LIBS Qt5::Core)
list(APPEND TEST_SOURCES tests/test_qtjson_adapter.cpp)
endif()

# Unit tests executable
add_executable(test_suite ${TEST_SOURCES})
if(NOT valijson_USE_EXCEPTIONS)
if(MSVC)
if(CMAKE_CXX_FLAGS MATCHES "/EHsc ")
string(REPLACE "/EHsc" "/EHs-c-" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
target_compile_options(test_suite PUBLIC /EHs-c-)
endif()
else()
target_compile_options(test_suite PUBLIC -fno-exceptions)
endif()
endif()

if(NOT MSVC)
set_target_properties(test_suite PROPERTIES COMPILE_FLAGS " -pedantic -Werror -Wshadow -Wunused")
endif()

# Definition for using picojson
set_target_properties(test_suite PROPERTIES COMPILE_DEFINITIONS "PICOJSON_USE_INT64")

set(TEST_LIBS gtest gtest_main jsoncpp json11)

if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
list(APPEND TEST_SOURCES tests/test_property_tree_adapter.cpp)
add_definitions(-DBOOST_ALL_DYN_LINK)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
target_compile_definitions(test_suite PRIVATE "VALIJSON_BUILD_PROPERTY_TREE_ADAPTER")
target_compile_definitions(test_suite PRIVATE "VALIJSON_BUILD_BOOST_ADAPTERS")
endif()

if(Poco_FOUND)
include_directories(${Poco_INCLUDE_DIRS})
list(APPEND TEST_SOURCES tests/test_poco_json_adapter.cpp)
list(APPEND TEST_LIBS ${Poco_Foundation_LIBRARIES} ${Poco_JSON_LIBRARIES})
target_compile_definitions(test_suite PRIVATE "VALIJSON_BUILD_POCO_ADAPTER")
endif()

if(Qt5Core_FOUND)
include_directories(${Qt5Core_INCLUDE_DIRS})
list(APPEND TEST_SOURCES tests/test_qtjson_adapter.cpp)
list(APPEND TEST_LIBS Qt5::Core)
target_compile_definitions(test_suite PRIVATE "VALIJSON_BUILD_QT_ADAPTER")
endif()

target_link_libraries(test_suite ${TEST_LIBS} ${Boost_LIBRARIES})
endif()

if(valijson_BUILD_EXAMPLES)
find_package(curlpp)
include_directories(SYSTEM)

add_executable(custom_schema
Expand All @@ -144,14 +196,18 @@ if(valijson_BUILD_EXAMPLES)
examples/json_pointers.cpp
)

add_executable(remote_resolution_local_file
examples/remote_resolution_local_file.cpp
)

if(curlpp_FOUND)
include_directories(${curlpp_INCLUDE_DIR})

add_executable(remote_resolution
examples/remote_resolution.cpp
add_executable(remote_resolution_url
examples/remote_resolution_url.cpp
)

target_link_libraries(remote_resolution curl ${curlpp_LIBRARIES})
target_link_libraries(remote_resolution_url curl ${curlpp_LIBRARIES})
endif()

target_link_libraries(custom_schema ${Boost_LIBRARIES})
Expand Down
Loading