Merge bd5bc9a5ac
into 42e892d96e
This commit is contained in:
commit
2e7b1f8bae
116
.gitignore
vendored
116
.gitignore
vendored
@ -55,3 +55,119 @@ compile_commands.json
|
|||||||
|
|
||||||
# temps
|
# temps
|
||||||
/version
|
/version
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/intellij
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij
|
||||||
|
|
||||||
|
### Intellij ###
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/usage.statistics.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
.idea/**
|
||||||
|
|
||||||
|
# AWS User-specific
|
||||||
|
.idea/**/aws.xml
|
||||||
|
|
||||||
|
# Generated files
|
||||||
|
.idea/**/contentModel.xml
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# Gradle and Maven with auto-import
|
||||||
|
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||||
|
# since they will be recreated, and may cause churn. Uncomment if using
|
||||||
|
# auto-import.
|
||||||
|
# .idea/artifacts
|
||||||
|
# .idea/compiler.xml
|
||||||
|
# .idea/jarRepositories.xml
|
||||||
|
# .idea/modules.xml
|
||||||
|
# .idea/*.iml
|
||||||
|
# .idea/modules
|
||||||
|
# *.iml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-*/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# SonarLint plugin
|
||||||
|
.idea/sonarlint/
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# Android studio 3.1+ serialized cache file
|
||||||
|
.idea/caches/build_file_checksums.ser
|
||||||
|
|
||||||
|
### Intellij Patch ###
|
||||||
|
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||||
|
|
||||||
|
# *.iml
|
||||||
|
# modules.xml
|
||||||
|
# .idea/misc.xml
|
||||||
|
# *.ipr
|
||||||
|
|
||||||
|
# Sonarlint plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/7973-sonarlint
|
||||||
|
.idea/**/sonarlint/
|
||||||
|
|
||||||
|
# SonarQube Plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
|
||||||
|
.idea/**/sonarIssues.xml
|
||||||
|
|
||||||
|
# Markdown Navigator plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
|
||||||
|
.idea/**/markdown-navigator.xml
|
||||||
|
.idea/**/markdown-navigator-enh.xml
|
||||||
|
.idea/**/markdown-navigator/
|
||||||
|
|
||||||
|
# Cache file creation bug
|
||||||
|
# See https://youtrack.jetbrains.com/issue/JBR-2257
|
||||||
|
.idea/$CACHE_FILE$
|
||||||
|
|
||||||
|
# CodeStream plugin
|
||||||
|
# https://plugins.jetbrains.com/plugin/12206-codestream
|
||||||
|
.idea/codestream.xml
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/intellij
|
@ -40,12 +40,6 @@ foreach(pold "") # Currently Empty
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Build the library with C++11 standard support, independent from other including
|
|
||||||
# software which may use a different CXX_STANDARD or CMAKE_CXX_STANDARD.
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
|
|
||||||
# Ensure that CMAKE_BUILD_TYPE has a value specified for single configuration generators.
|
# Ensure that CMAKE_BUILD_TYPE has a value specified for single configuration generators.
|
||||||
if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
|
if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
|
||||||
set(CMAKE_BUILD_TYPE Release CACHE STRING
|
set(CMAKE_BUILD_TYPE Release CACHE STRING
|
||||||
@ -78,6 +72,9 @@ project(jsoncpp
|
|||||||
message(STATUS "JsonCpp Version: ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
message(STATUS "JsonCpp Version: ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
||||||
set(PROJECT_SOVERSION 25)
|
set(PROJECT_SOVERSION 25)
|
||||||
|
|
||||||
|
# Defines the project root to be used throughout all scripts.
|
||||||
|
set(JSONCPP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInSourceBuilds.cmake)
|
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInSourceBuilds.cmake)
|
||||||
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInBuildInstalls.cmake)
|
include(${CMAKE_CURRENT_SOURCE_DIR}/include/PreventInBuildInstalls.cmake)
|
||||||
|
|
||||||
@ -89,18 +86,12 @@ option(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON)
|
|||||||
option(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" ON)
|
option(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" ON)
|
||||||
option(JSONCPP_WITH_EXAMPLE "Compile JsonCpp example" OFF)
|
option(JSONCPP_WITH_EXAMPLE "Compile JsonCpp example" OFF)
|
||||||
option(JSONCPP_STATIC_WINDOWS_RUNTIME "Use static (MT/MTd) Windows runtime" OFF)
|
option(JSONCPP_STATIC_WINDOWS_RUNTIME "Use static (MT/MTd) Windows runtime" OFF)
|
||||||
option(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." ON)
|
|
||||||
option(BUILD_STATIC_LIBS "Build jsoncpp_lib as a static library." ON)
|
option(JSONCPP_BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." OFF)
|
||||||
option(BUILD_OBJECT_LIBS "Build jsoncpp_lib as a object library." ON)
|
|
||||||
|
|
||||||
# Adhere to GNU filesystem layout conventions
|
# Adhere to GNU filesystem layout conventions
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH "Archive output dir.")
|
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE PATH "Library output dir.")
|
|
||||||
set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" CACHE PATH "PDB (MSVC debug symbol)output dir.")
|
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Executable/dll output dir.")
|
|
||||||
|
|
||||||
set(JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL")
|
set(JSONCPP_USE_SECURE_MEMORY "0" CACHE STRING "-D...=1 to use memory-wiping allocator for STL")
|
||||||
|
|
||||||
configure_file("${PROJECT_SOURCE_DIR}/version.in"
|
configure_file("${PROJECT_SOURCE_DIR}/version.in"
|
||||||
@ -120,9 +111,6 @@ macro(use_compilation_warning_as_error)
|
|||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
# Include our configuration header
|
|
||||||
include_directories(${jsoncpp_SOURCE_DIR}/include)
|
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# Only enabled in debug because some old versions of VS STL generate
|
# Only enabled in debug because some old versions of VS STL generate
|
||||||
# unreachable code warning when compiled in release configuration.
|
# unreachable code warning when compiled in release configuration.
|
||||||
@ -179,22 +167,6 @@ if(JSONCPP_WITH_PKGCONFIG_SUPPORT)
|
|||||||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(JSONCPP_WITH_CMAKE_PACKAGE)
|
|
||||||
include(CMakePackageConfigHelpers)
|
|
||||||
install(EXPORT jsoncpp
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp
|
|
||||||
FILE jsoncpp-targets.cmake)
|
|
||||||
configure_package_config_file(jsoncppConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfig.cmake
|
|
||||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp)
|
|
||||||
|
|
||||||
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake"
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
COMPATIBILITY SameMajorVersion)
|
|
||||||
install(FILES
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfigVersion.cmake ${CMAKE_CURRENT_BINARY_DIR}/jsoncppConfig.cmake
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/jsoncpp-namespaced-targets.cmake
|
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/jsoncpp)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(JSONCPP_WITH_TESTS)
|
if(JSONCPP_WITH_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
@ -204,9 +176,6 @@ endif()
|
|||||||
# Build the different applications
|
# Build the different applications
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
#install the includes
|
|
||||||
add_subdirectory(include)
|
|
||||||
|
|
||||||
#install the example
|
#install the example
|
||||||
if(JSONCPP_WITH_EXAMPLE)
|
if(JSONCPP_WITH_EXAMPLE)
|
||||||
add_subdirectory(example)
|
add_subdirectory(example)
|
||||||
|
@ -1,27 +1,6 @@
|
|||||||
#vim: et ts =4 sts = 4 sw = 4 tw = 0
|
#vim: et ts =4 sts = 4 sw = 4 tw = 0
|
||||||
set(EXAMPLES
|
|
||||||
readFromString
|
|
||||||
readFromStream
|
|
||||||
stringWrite
|
|
||||||
streamWrite
|
|
||||||
)
|
|
||||||
add_definitions(-D_GLIBCXX_USE_CXX11_ABI)
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
add_subdirectory(readFromStream/)
|
||||||
add_compile_options(-Wall -Wextra)
|
add_subdirectory(readFromString/)
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
add_subdirectory(streamWrite/)
|
||||||
add_definitions(
|
add_subdirectory(stringWrite/)
|
||||||
-D_SCL_SECURE_NO_WARNINGS
|
|
||||||
-D_CRT_SECURE_NO_WARNINGS
|
|
||||||
-D_WIN32_WINNT=0x601
|
|
||||||
-D_WINSOCK_DEPRECATED_NO_WARNINGS
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach(example ${EXAMPLES})
|
|
||||||
add_executable(${example} ${example}/${example}.cpp)
|
|
||||||
target_include_directories(${example} PUBLIC ${CMAKE_SOURCE_DIR}/include)
|
|
||||||
target_link_libraries(${example} jsoncpp_lib)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
add_custom_target(examples ALL DEPENDS ${EXAMPLES})
|
|
2
example/readFromStream/CMakeLists.txt
Normal file
2
example/readFromStream/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
add_executable(readFromStream readFromStream.cpp)
|
||||||
|
target_link_libraries(readFromStream PRIVATE jsoncpp::framework)
|
2
example/readFromString/CMakeLists.txt
Normal file
2
example/readFromString/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
add_executable(readFromString readFromString.cpp)
|
||||||
|
target_link_libraries(readFromString PRIVATE jsoncpp::framework)
|
2
example/streamWrite/CMakeLists.txt
Normal file
2
example/streamWrite/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
add_executable(streamWrite streamWrite.cpp)
|
||||||
|
target_link_libraries(streamWrite PRIVATE jsoncpp::framework)
|
2
example/stringWrite/CMakeLists.txt
Normal file
2
example/stringWrite/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
add_executable(stringWrite stringWrite.cpp)
|
||||||
|
target_link_libraries(stringWrite PRIVATE jsoncpp::framework)
|
@ -1,5 +1,2 @@
|
|||||||
file(GLOB INCLUDE_FILES "json/*.h")
|
|
||||||
install(FILES
|
|
||||||
${INCLUDE_FILES}
|
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json)
|
|
||||||
|
|
||||||
|
@ -1,51 +1,33 @@
|
|||||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
|
|
||||||
# The new Python3 module is much more robust than the previous PythonInterp
|
# The new Python3 module is much more robust than the previous PythonInterp
|
||||||
find_package(Python3 COMPONENTS Interpreter)
|
find_package(Python3 COMPONENTS Interpreter)
|
||||||
# Set variables for backwards compatibility with cmake < 3.12.0
|
# Set variables for backwards compatibility with cmake < 3.12.0
|
||||||
set(PYTHONINTERP_FOUND ${Python3_Interpreter_FOUND})
|
set(PYTHONINTERP_FOUND ${Python3_Interpreter_FOUND})
|
||||||
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
|
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
|
||||||
else()
|
|
||||||
set(Python_ADDITIONAL_VERSIONS 3.8)
|
|
||||||
find_package(PythonInterp 3)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable(jsontestrunner_exe
|
add_executable(jsontestrunner_exe main.cpp)
|
||||||
main.cpp
|
target_link_libraries(jsontestrunner_exe PRIVATE jsoncpp::framework)
|
||||||
)
|
|
||||||
|
|
||||||
if(BUILD_SHARED_LIBS)
|
|
||||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
|
|
||||||
add_compile_definitions( JSON_DLL )
|
|
||||||
else()
|
|
||||||
add_definitions(-DJSON_DLL)
|
|
||||||
endif()
|
|
||||||
target_link_libraries(jsontestrunner_exe jsoncpp_lib)
|
|
||||||
else()
|
|
||||||
target_link_libraries(jsontestrunner_exe jsoncpp_static)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe)
|
set_target_properties(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe)
|
||||||
|
|
||||||
if(PYTHONINTERP_FOUND)
|
if(PYTHONINTERP_FOUND)
|
||||||
# Run end to end parser/writer tests
|
# Run end to end parser/writer tests
|
||||||
set(TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../test)
|
set(RUNJSONTESTS_PATH ${JSONCPP_ROOT_DIR}/test/runjsontests.py)
|
||||||
set(RUNJSONTESTS_PATH ${TEST_DIR}/runjsontests.py)
|
|
||||||
|
|
||||||
# Run unit tests in post-build
|
# Run unit tests in post-build
|
||||||
# (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?)
|
# (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?)
|
||||||
add_custom_target(jsoncpp_readerwriter_tests
|
add_custom_target(jsoncpp_readerwriter_tests
|
||||||
"${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $<TARGET_FILE:jsontestrunner_exe> "${TEST_DIR}/data"
|
"${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $<TARGET_FILE:jsontestrunner_exe> "${JSONCPP_ROOT_DIR}/test/data"
|
||||||
DEPENDS jsontestrunner_exe jsoncpp_test
|
DEPENDS jsontestrunner_exe jsoncpp_test
|
||||||
)
|
)
|
||||||
add_custom_target(jsoncpp_check DEPENDS jsoncpp_readerwriter_tests)
|
add_custom_target(jsoncpp_check DEPENDS jsoncpp_readerwriter_tests)
|
||||||
|
|
||||||
## Create tests for dashboard submission, allows easy review of CI results https://my.cdash.org/index.php?project=jsoncpp
|
## Create tests for dashboard submission, allows easy review of CI results https://my.cdash.org/index.php?project=jsoncpp
|
||||||
add_test(NAME jsoncpp_readerwriter
|
add_test(NAME jsoncpp_readerwriter
|
||||||
COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $<TARGET_FILE:jsontestrunner_exe> "${TEST_DIR}/data"
|
COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $<TARGET_FILE:jsontestrunner_exe> "${JSONCPP_ROOT_DIR}/test/data"
|
||||||
WORKING_DIRECTORY "${TEST_DIR}/data"
|
WORKING_DIRECTORY "${JSONCPP_ROOT_DIR}/test/data"
|
||||||
)
|
)
|
||||||
add_test(NAME jsoncpp_readerwriter_json_checker
|
add_test(NAME jsoncpp_readerwriter_json_checker
|
||||||
COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" --with-json-checker $<TARGET_FILE:jsontestrunner_exe> "${TEST_DIR}/data"
|
COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" --with-json-checker $<TARGET_FILE:jsontestrunner_exe> "${JSONCPP_ROOT_DIR}/test/data"
|
||||||
WORKING_DIRECTORY "${TEST_DIR}/data"
|
WORKING_DIRECTORY "${JSONCPP_ROOT_DIR}/test/data"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
@ -25,41 +25,11 @@ if(NOT (HAVE_CLOCALE AND HAVE_LCONV_SIZE AND HAVE_DECIMAL_POINT AND HAVE_LOCALEC
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(JSONCPP_INCLUDE_DIR ../../include)
|
|
||||||
|
|
||||||
set(PUBLIC_HEADERS
|
|
||||||
${JSONCPP_INCLUDE_DIR}/json/config.h
|
|
||||||
${JSONCPP_INCLUDE_DIR}/json/forwards.h
|
|
||||||
${JSONCPP_INCLUDE_DIR}/json/json_features.h
|
|
||||||
${JSONCPP_INCLUDE_DIR}/json/value.h
|
|
||||||
${JSONCPP_INCLUDE_DIR}/json/reader.h
|
|
||||||
${JSONCPP_INCLUDE_DIR}/json/version.h
|
|
||||||
${JSONCPP_INCLUDE_DIR}/json/writer.h
|
|
||||||
${JSONCPP_INCLUDE_DIR}/json/assertions.h
|
|
||||||
)
|
|
||||||
|
|
||||||
source_group("Public API" FILES ${PUBLIC_HEADERS})
|
|
||||||
|
|
||||||
set(JSONCPP_SOURCES
|
|
||||||
json_tool.h
|
|
||||||
json_reader.cpp
|
|
||||||
json_valueiterator.inl
|
|
||||||
json_value.cpp
|
|
||||||
json_writer.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
# Install instructions for this target
|
|
||||||
if(JSONCPP_WITH_CMAKE_PACKAGE)
|
|
||||||
set(INSTALL_EXPORT EXPORT jsoncpp)
|
|
||||||
else()
|
|
||||||
set(INSTALL_EXPORT)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Specify compiler features required when compiling a given target.
|
# Specify compiler features required when compiling a given target.
|
||||||
# See https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#prop_gbl:CMAKE_CXX_KNOWN_FEATURES
|
# See https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html#prop_gbl:CMAKE_CXX_KNOWN_FEATURES
|
||||||
# for complete list of features available
|
# for complete list of features available
|
||||||
list(APPEND REQUIRED_FEATURES
|
list(APPEND REQUIRED_FEATURES
|
||||||
cxx_std_11 # Compiler mode is aware of C++ 11.
|
|
||||||
#MSVC 1900 cxx_alignas # Alignment control alignas, as defined in N2341.
|
#MSVC 1900 cxx_alignas # Alignment control alignas, as defined in N2341.
|
||||||
#MSVC 1900 cxx_alignof # Alignment control alignof, as defined in N2341.
|
#MSVC 1900 cxx_alignof # Alignment control alignof, as defined in N2341.
|
||||||
#MSVC 1900 cxx_attributes # Generic attributes, as defined in N2761.
|
#MSVC 1900 cxx_attributes # Generic attributes, as defined in N2761.
|
||||||
@ -105,104 +75,62 @@ list(APPEND REQUIRED_FEATURES
|
|||||||
cxx_variadic_templates # Variadic templates, as defined in N2242.
|
cxx_variadic_templates # Variadic templates, as defined in N2242.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# The OBJECT's can be used to compile the sources in the list given to add_library
|
||||||
|
# to object files, but then neither archiving them into a static library nor
|
||||||
|
# linking them into a shared object. The use of object libraries is
|
||||||
|
# particularly useful if one needs to create both static and shared libraries
|
||||||
|
# in one go.
|
||||||
|
|
||||||
|
# Property: OBJECT
|
||||||
|
|
||||||
|
|
||||||
|
add_library(jsoncpp.framework.object OBJECT
|
||||||
|
json_reader.cpp
|
||||||
|
json_value.cpp
|
||||||
|
json_writer.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(jsoncpp.framework.object PROPERTIES CXX_STANDARD 11)
|
||||||
|
set_target_properties(jsoncpp.framework.object PROPERTIES CXX_EXTENSIONS OFF)
|
||||||
|
set_target_properties(jsoncpp.framework.object PROPERTIES CXX_STANDARD_REQUIRED ON)
|
||||||
|
set_target_properties(jsoncpp.framework.object PROPERTIES VERSION ${PROJECT_VERSION})
|
||||||
|
set_target_properties(jsoncpp.framework.object PROPERTIES SOVERSION ${PROJECT_SOVERSION})
|
||||||
|
|
||||||
|
target_compile_features(jsoncpp.framework.object PUBLIC ${REQUIRED_FEATURES})
|
||||||
|
target_include_directories(jsoncpp.framework.object PUBLIC $<BUILD_INTERFACE:${JSONCPP_ROOT_DIR}/include>)
|
||||||
|
|
||||||
|
|
||||||
|
if (JSONCPP_BUILD_SHARED_LIBS)
|
||||||
|
|
||||||
|
# CMake link shared library on Windows
|
||||||
|
# Ref: https://stackoverflow.com/a/41618677
|
||||||
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
||||||
|
|
||||||
|
# The POSITION_INDEPENDENT_CODE property determines whether position independent executables or
|
||||||
|
# shared libraries will be created. This property is True by default for SHARED and MODULE library
|
||||||
|
# targets and False otherwise.
|
||||||
|
|
||||||
|
# Property: SHARED, POSITION_INDEPENDENT_CODE
|
||||||
|
add_library(jsoncpp.framework SHARED $<TARGET_OBJECTS:jsoncpp.framework.object>)
|
||||||
|
|
||||||
|
# Needed for legacy code
|
||||||
|
target_compile_definitions(jsoncpp.framework PUBLIC JSON_DLL_BUILD)
|
||||||
|
target_compile_definitions(jsoncpp.framework PUBLIC JSON_DLL)
|
||||||
|
|
||||||
if(BUILD_SHARED_LIBS)
|
|
||||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
|
|
||||||
add_compile_definitions(JSON_DLL_BUILD)
|
|
||||||
else ()
|
else ()
|
||||||
add_definitions(-DJSON_DLL_BUILD)
|
|
||||||
|
add_library(jsoncpp.framework STATIC $<TARGET_OBJECTS:jsoncpp.framework.object>)
|
||||||
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(SHARED_LIB ${PROJECT_NAME}_lib)
|
add_library(jsoncpp::framework ALIAS jsoncpp.framework)
|
||||||
add_library(${SHARED_LIB} SHARED ${PUBLIC_HEADERS} ${JSONCPP_SOURCES})
|
set_target_properties(jsoncpp.framework PROPERTIES CXX_STANDARD 11)
|
||||||
set_target_properties(${SHARED_LIB} PROPERTIES
|
set_target_properties(jsoncpp.framework PROPERTIES CXX_EXTENSIONS OFF)
|
||||||
OUTPUT_NAME jsoncpp
|
set_target_properties(jsoncpp.framework PROPERTIES CXX_STANDARD_REQUIRED ON)
|
||||||
VERSION ${PROJECT_VERSION}
|
set_target_properties(jsoncpp.framework PROPERTIES VERSION ${PROJECT_VERSION})
|
||||||
SOVERSION ${PROJECT_SOVERSION}
|
set_target_properties(jsoncpp.framework PROPERTIES SOVERSION ${PROJECT_SOVERSION})
|
||||||
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Set library's runtime search path on OSX
|
|
||||||
if(APPLE)
|
|
||||||
set_target_properties(${SHARED_LIB} PROPERTIES INSTALL_RPATH "@loader_path/.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_compile_features(${SHARED_LIB} PUBLIC ${REQUIRED_FEATURES})
|
|
||||||
|
|
||||||
target_include_directories(${SHARED_LIB} PUBLIC
|
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
|
|
||||||
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/json>
|
|
||||||
)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_TARGETS ${SHARED_LIB})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_STATIC_LIBS)
|
|
||||||
set(STATIC_LIB ${PROJECT_NAME}_static)
|
|
||||||
add_library(${STATIC_LIB} STATIC ${PUBLIC_HEADERS} ${JSONCPP_SOURCES})
|
|
||||||
|
|
||||||
# avoid name clashes on windows as the shared import lib is also named jsoncpp.lib
|
|
||||||
if(NOT DEFINED STATIC_SUFFIX AND BUILD_SHARED_LIBS)
|
|
||||||
if (MSVC)
|
|
||||||
set(STATIC_SUFFIX "_static")
|
|
||||||
else()
|
|
||||||
set(STATIC_SUFFIX "")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(${STATIC_LIB} PROPERTIES
|
|
||||||
OUTPUT_NAME jsoncpp${STATIC_SUFFIX}
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Set library's runtime search path on OSX
|
|
||||||
if(APPLE)
|
|
||||||
set_target_properties(${STATIC_LIB} PROPERTIES INSTALL_RPATH "@loader_path/.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_compile_features(${STATIC_LIB} PUBLIC ${REQUIRED_FEATURES})
|
|
||||||
|
|
||||||
target_include_directories(${STATIC_LIB} PUBLIC
|
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
|
|
||||||
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/json>
|
|
||||||
)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_TARGETS ${STATIC_LIB})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_OBJECT_LIBS)
|
|
||||||
set(OBJECT_LIB ${PROJECT_NAME}_object)
|
|
||||||
add_library(${OBJECT_LIB} OBJECT ${PUBLIC_HEADERS} ${JSONCPP_SOURCES})
|
|
||||||
|
|
||||||
set_target_properties(${OBJECT_LIB} PROPERTIES
|
|
||||||
OUTPUT_NAME jsoncpp
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
SOVERSION ${PROJECT_SOVERSION}
|
|
||||||
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Set library's runtime search path on OSX
|
|
||||||
if(APPLE)
|
|
||||||
set_target_properties(${OBJECT_LIB} PROPERTIES INSTALL_RPATH "@loader_path/.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_compile_features(${OBJECT_LIB} PUBLIC ${REQUIRED_FEATURES})
|
|
||||||
|
|
||||||
target_include_directories(${OBJECT_LIB} PUBLIC
|
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/${JSONCPP_INCLUDE_DIR}>
|
|
||||||
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/json>
|
|
||||||
)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_TARGETS ${OBJECT_LIB})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(TARGETS ${CMAKE_TARGETS} ${INSTALL_EXPORT}
|
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
||||||
OBJECTS DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
target_compile_features(jsoncpp.framework PUBLIC ${REQUIRED_FEATURES})
|
||||||
|
# It is necessary to repeat these instructions again, in case of not doing it, the executables
|
||||||
|
# will be unable to locate the Headers needed to perform the linking
|
||||||
|
target_include_directories(jsoncpp.framework PUBLIC $<BUILD_INTERFACE:${JSONCPP_ROOT_DIR}/include>)
|
@ -5,28 +5,16 @@ add_executable(jsoncpp_test
|
|||||||
jsontest.h
|
jsontest.h
|
||||||
fuzz.cpp
|
fuzz.cpp
|
||||||
fuzz.h
|
fuzz.h
|
||||||
main.cpp
|
main.cpp)
|
||||||
)
|
|
||||||
|
|
||||||
|
target_link_libraries(jsoncpp_test PRIVATE jsoncpp::framework)
|
||||||
if(BUILD_SHARED_LIBS)
|
|
||||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
|
|
||||||
add_compile_definitions( JSON_DLL )
|
|
||||||
else()
|
|
||||||
add_definitions( -DJSON_DLL )
|
|
||||||
endif()
|
|
||||||
target_link_libraries(jsoncpp_test jsoncpp_lib)
|
|
||||||
else()
|
|
||||||
target_link_libraries(jsoncpp_test jsoncpp_static)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# another way to solve issue #90
|
# another way to solve issue #90
|
||||||
#set_target_properties(jsoncpp_test PROPERTIES COMPILE_FLAGS -ffloat-store)
|
#set_target_properties(jsoncpp_test PROPERTIES COMPILE_FLAGS -ffloat-store)
|
||||||
|
|
||||||
## Create tests for dashboard submission, allows easy review of CI results https://my.cdash.org/index.php?project=jsoncpp
|
## Create tests for dashboard submission, allows easy review of CI results https://my.cdash.org/index.php?project=jsoncpp
|
||||||
add_test(NAME jsoncpp_test
|
add_test(NAME jsoncpp_test
|
||||||
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:jsoncpp_test>
|
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:jsoncpp_test>)
|
||||||
)
|
|
||||||
set_target_properties(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test)
|
set_target_properties(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test)
|
||||||
|
|
||||||
# Run unit tests in post-build
|
# Run unit tests in post-build
|
||||||
@ -34,6 +22,5 @@ set_target_properties(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test)
|
|||||||
if (JSONCPP_WITH_POST_BUILD_UNITTEST)
|
if (JSONCPP_WITH_POST_BUILD_UNITTEST)
|
||||||
add_custom_command(TARGET jsoncpp_test
|
add_custom_command(TARGET jsoncpp_test
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:jsoncpp_test>
|
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:jsoncpp_test>)
|
||||||
)
|
|
||||||
endif ()
|
endif ()
|
||||||
|
Loading…
Reference in New Issue
Block a user