diff --git a/.gitignore b/.gitignore index 9682782fa..626b66cc0 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,119 @@ compile_commands.json # temps /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 \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index fd8bcf2b2..c6b228dc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,12 +40,6 @@ foreach(pold "") # Currently Empty endif() 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. if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES) 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}") 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/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_EXAMPLE "Compile JsonCpp example" 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(BUILD_OBJECT_LIBS "Build jsoncpp_lib as a object library." ON) + +option(JSONCPP_BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." OFF) # Adhere to GNU filesystem layout conventions 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") configure_file("${PROJECT_SOURCE_DIR}/version.in" @@ -120,9 +111,6 @@ macro(use_compilation_warning_as_error) endif() endmacro() -# Include our configuration header -include_directories(${jsoncpp_SOURCE_DIR}/include) - if(MSVC) # Only enabled in debug because some old versions of VS STL generate # unreachable code warning when compiled in release configuration. @@ -179,22 +167,6 @@ if(JSONCPP_WITH_PKGCONFIG_SUPPORT) DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") 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) enable_testing() @@ -204,9 +176,6 @@ endif() # Build the different applications add_subdirectory(src) -#install the includes -add_subdirectory(include) - #install the example if(JSONCPP_WITH_EXAMPLE) add_subdirectory(example) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 230d1bd7b..f6ebb581d 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,27 +1,6 @@ #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_compile_options(-Wall -Wextra) -elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - add_definitions( - -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}) +add_subdirectory(readFromStream/) +add_subdirectory(readFromString/) +add_subdirectory(streamWrite/) +add_subdirectory(stringWrite/) \ No newline at end of file diff --git a/example/readFromStream/CMakeLists.txt b/example/readFromStream/CMakeLists.txt new file mode 100644 index 000000000..77524d2bf --- /dev/null +++ b/example/readFromStream/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(readFromStream readFromStream.cpp) +target_link_libraries(readFromStream PRIVATE jsoncpp::framework) \ No newline at end of file diff --git a/example/readFromString/CMakeLists.txt b/example/readFromString/CMakeLists.txt new file mode 100644 index 000000000..b8352e612 --- /dev/null +++ b/example/readFromString/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(readFromString readFromString.cpp) +target_link_libraries(readFromString PRIVATE jsoncpp::framework) \ No newline at end of file diff --git a/example/streamWrite/CMakeLists.txt b/example/streamWrite/CMakeLists.txt new file mode 100644 index 000000000..e82d17941 --- /dev/null +++ b/example/streamWrite/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(streamWrite streamWrite.cpp) +target_link_libraries(streamWrite PRIVATE jsoncpp::framework) \ No newline at end of file diff --git a/example/stringWrite/CMakeLists.txt b/example/stringWrite/CMakeLists.txt new file mode 100644 index 000000000..a1f80ccdb --- /dev/null +++ b/example/stringWrite/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(stringWrite stringWrite.cpp) +target_link_libraries(stringWrite PRIVATE jsoncpp::framework) \ No newline at end of file diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index dc40d95e8..139597f9c 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,5 +1,2 @@ -file(GLOB INCLUDE_FILES "json/*.h") -install(FILES - ${INCLUDE_FILES} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json) + diff --git a/src/jsontestrunner/CMakeLists.txt b/src/jsontestrunner/CMakeLists.txt index 1fc71ea87..3c8a18bf3 100644 --- a/src/jsontestrunner/CMakeLists.txt +++ b/src/jsontestrunner/CMakeLists.txt @@ -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 - find_package(Python3 COMPONENTS Interpreter) - # Set variables for backwards compatibility with cmake < 3.12.0 - set(PYTHONINTERP_FOUND ${Python3_Interpreter_FOUND}) - set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) -else() - set(Python_ADDITIONAL_VERSIONS 3.8) - find_package(PythonInterp 3) -endif() - -add_executable(jsontestrunner_exe - main.cpp -) +# The new Python3 module is much more robust than the previous PythonInterp +find_package(Python3 COMPONENTS Interpreter) +# Set variables for backwards compatibility with cmake < 3.12.0 +set(PYTHONINTERP_FOUND ${Python3_Interpreter_FOUND}) +set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) -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() +add_executable(jsontestrunner_exe main.cpp) +target_link_libraries(jsontestrunner_exe PRIVATE jsoncpp::framework) set_target_properties(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe) if(PYTHONINTERP_FOUND) # Run end to end parser/writer tests - set(TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../test) - set(RUNJSONTESTS_PATH ${TEST_DIR}/runjsontests.py) + set(RUNJSONTESTS_PATH ${JSONCPP_ROOT_DIR}/test/runjsontests.py) # Run unit tests in post-build # (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?) add_custom_target(jsoncpp_readerwriter_tests - "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $ "${TEST_DIR}/data" + "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $ "${JSONCPP_ROOT_DIR}/test/data" DEPENDS jsontestrunner_exe jsoncpp_test ) 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 add_test(NAME jsoncpp_readerwriter - COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $ "${TEST_DIR}/data" - WORKING_DIRECTORY "${TEST_DIR}/data" + COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $ "${JSONCPP_ROOT_DIR}/test/data" + WORKING_DIRECTORY "${JSONCPP_ROOT_DIR}/test/data" ) add_test(NAME jsoncpp_readerwriter_json_checker - COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" --with-json-checker $ "${TEST_DIR}/data" - WORKING_DIRECTORY "${TEST_DIR}/data" + COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" --with-json-checker $ "${JSONCPP_ROOT_DIR}/test/data" + WORKING_DIRECTORY "${JSONCPP_ROOT_DIR}/test/data" ) endif() diff --git a/src/lib_json/CMakeLists.txt b/src/lib_json/CMakeLists.txt index 3cf66eb34..59daf9d59 100644 --- a/src/lib_json/CMakeLists.txt +++ b/src/lib_json/CMakeLists.txt @@ -25,41 +25,11 @@ if(NOT (HAVE_CLOCALE AND HAVE_LCONV_SIZE AND HAVE_DECIMAL_POINT AND HAVE_LOCALEC 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. # 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 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_alignof # Alignment control alignof, as defined in N2341. #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. ) +# 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. -if(BUILD_SHARED_LIBS) - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) - add_compile_definitions(JSON_DLL_BUILD) - else() - add_definitions(-DJSON_DLL_BUILD) - endif() - - set(SHARED_LIB ${PROJECT_NAME}_lib) - add_library(${SHARED_LIB} SHARED ${PUBLIC_HEADERS} ${JSONCPP_SOURCES}) - set_target_properties(${SHARED_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(${SHARED_LIB} PROPERTIES INSTALL_RPATH "@loader_path/.") - endif() - - target_compile_features(${SHARED_LIB} PUBLIC ${REQUIRED_FEATURES}) +# Property: OBJECT - target_include_directories(${SHARED_LIB} PUBLIC - $ - $ - $ - ) - 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() +add_library(jsoncpp.framework.object OBJECT + json_reader.cpp + json_value.cpp + json_writer.cpp + ) - set_target_properties(${STATIC_LIB} PROPERTIES - OUTPUT_NAME jsoncpp${STATIC_SUFFIX} - VERSION ${PROJECT_VERSION} - ) +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}) - # Set library's runtime search path on OSX - if(APPLE) - set_target_properties(${STATIC_LIB} PROPERTIES INSTALL_RPATH "@loader_path/.") - endif() +target_compile_features(jsoncpp.framework.object PUBLIC ${REQUIRED_FEATURES}) +target_include_directories(jsoncpp.framework.object PUBLIC $) - target_compile_features(${STATIC_LIB} PUBLIC ${REQUIRED_FEATURES}) - target_include_directories(${STATIC_LIB} PUBLIC - $ - $ - $ - ) +if (JSONCPP_BUILD_SHARED_LIBS) - list(APPEND CMAKE_TARGETS ${STATIC_LIB}) -endif() + # CMake link shared library on Windows + # Ref: https://stackoverflow.com/a/41618677 + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) -if(BUILD_OBJECT_LIBS) - set(OBJECT_LIB ${PROJECT_NAME}_object) - add_library(${OBJECT_LIB} OBJECT ${PUBLIC_HEADERS} ${JSONCPP_SOURCES}) + # 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. - set_target_properties(${OBJECT_LIB} PROPERTIES - OUTPUT_NAME jsoncpp - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_SOVERSION} - POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} - ) + # Property: SHARED, POSITION_INDEPENDENT_CODE + add_library(jsoncpp.framework SHARED $) - # Set library's runtime search path on OSX - if(APPLE) - set_target_properties(${OBJECT_LIB} PROPERTIES INSTALL_RPATH "@loader_path/.") - endif() + # Needed for legacy code + target_compile_definitions(jsoncpp.framework PUBLIC JSON_DLL_BUILD) + target_compile_definitions(jsoncpp.framework PUBLIC JSON_DLL) - target_compile_features(${OBJECT_LIB} PUBLIC ${REQUIRED_FEATURES}) +else () - target_include_directories(${OBJECT_LIB} PUBLIC - $ - $ - $ - ) + add_library(jsoncpp.framework STATIC $) - list(APPEND CMAKE_TARGETS ${OBJECT_LIB}) -endif() +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} -) +add_library(jsoncpp::framework ALIAS jsoncpp.framework) +set_target_properties(jsoncpp.framework PROPERTIES CXX_STANDARD 11) +set_target_properties(jsoncpp.framework PROPERTIES CXX_EXTENSIONS OFF) +set_target_properties(jsoncpp.framework PROPERTIES CXX_STANDARD_REQUIRED ON) +set_target_properties(jsoncpp.framework PROPERTIES VERSION ${PROJECT_VERSION}) +set_target_properties(jsoncpp.framework PROPERTIES SOVERSION ${PROJECT_SOVERSION}) +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 $) \ No newline at end of file diff --git a/src/test_lib_json/CMakeLists.txt b/src/test_lib_json/CMakeLists.txt index 1c3fce913..eefc98a9c 100644 --- a/src/test_lib_json/CMakeLists.txt +++ b/src/test_lib_json/CMakeLists.txt @@ -1,39 +1,26 @@ # vim: et ts=4 sts=4 sw=4 tw=0 add_executable(jsoncpp_test - jsontest.cpp - jsontest.h - fuzz.cpp - fuzz.h - main.cpp -) + jsontest.cpp + jsontest.h + fuzz.cpp + fuzz.h + main.cpp) - -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() +target_link_libraries(jsoncpp_test PRIVATE jsoncpp::framework) # another way to solve issue #90 #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 add_test(NAME jsoncpp_test - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -) + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) set_target_properties(jsoncpp_test PROPERTIES OUTPUT_NAME jsoncpp_test) # Run unit tests in post-build # (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?) -if(JSONCPP_WITH_POST_BUILD_UNITTEST) +if (JSONCPP_WITH_POST_BUILD_UNITTEST) add_custom_command(TARGET jsoncpp_test - POST_BUILD - COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ - ) -endif() + POST_BUILD + COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $) +endif ()