[ppconsul] remove conflict with json11 (#6967)

* [ppconsol] remove conflict with json11
This commit is contained in:
Phil Christensen 2019-06-22 23:30:45 -07:00 committed by GitHub
parent f3db66b403
commit 17b8cd9d05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 119 additions and 40 deletions

View File

@ -1,3 +1,3 @@
Source: json11
Version: 2017-06-20-1
Version: 2017-06-20-2
Description: json11 is a tiny JSON library for C++11, providing JSON parsing and serialization.

View File

@ -0,0 +1,14 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 819c36f..847489e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,6 +52,6 @@ if (JSON11_BUILD_TESTS)
target_link_libraries(json11_test json11)
endif()
-install(TARGETS json11 DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE})
-install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/json11.hpp" DESTINATION include/${CMAKE_LIBRARY_ARCHITECTURE})
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/json11.pc" DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig)
+install(TARGETS json11 DESTINATION lib)
+install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/json11.hpp" DESTINATION include)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/json11.pc" DESTINATION lib/pkgconfig)

View File

@ -0,0 +1,25 @@
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
if(NOT JSON11_FIND_COMPONENTS)
set(JSON11_FIND_COMPONENTS json11 json11)
if(JSON11_FIND_REQUIRED)
set(JSON11_FIND_REQUIRED_json11 TRUE)
endif()
set(JSON11_FOUND TRUE)
endif()
set(JSON11_INCLUDE_DIRS ${_DIR}/../../include)
set(JSON11_LIBRARIES)
if (EXISTS ${_DIR}/../../lib/libjson11.a)
list(APPEND JSON11_LIBRARIES optimized ${_DIR}/../../lib/libjson11.a)
endif()
if (EXISTS ${_DIR}/../../debug/lib/libjson11.a)
list(APPEND JSON11_LIBRARIES debug ${_DIR}/../../debug/lib/libjson11.a)
endif()
if (EXISTS ${_DIR}/../../lib/json11.lib)
list(APPEND JSON11_LIBRARIES optimized ${_DIR}/../../lib/json11.lib)
endif()
if (EXISTS ${_DIR}/../../debug/lib/json11.lib)
list(APPEND JSON11_LIBRARIES debug ${_DIR}/../../debug/lib/json11.lib)
endif()

View File

@ -8,6 +8,7 @@ vcpkg_from_github(
REF ec4e45219af1d7cde3d58b49ed762376fccf1ace
SHA512 2129e048d8dee027dc1ba789d9901e017b7d698465e15236802ef68639161e1cc7c8665d5f50079333801717fd41ffbe2cb90fa2165b9a85629e8ced8f2b3cd8
HEAD_REF master
PATCHES destination.patch
)
vcpkg_configure_cmake(
@ -20,6 +21,8 @@ vcpkg_configure_cmake(
vcpkg_install_cmake()
vcpkg_copy_pdbs()
file(INSTALL ${CURRENT_PORT_DIR}/json11-config.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/json11)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
# Handle copyright

View File

@ -1,5 +1,5 @@
Source: ppconsul
Version: 0.3
Version: 0.3-1
Homepage: https://github.com/oliora/ppconsul
Description: A C++ client library for Consul. Consul is a distributed tool for discovering and configuring services in your infrastructure.
Build-Depends: boost-core, boost-variant, curl[openssl]
Build-Depends: boost-core, boost-variant, curl[openssl], json11

View File

@ -1,8 +1,17 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 92e4698..002981e 100644
index 92e4698..aa643aa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,6 +75,8 @@ else ()
@@ -52,6 +52,8 @@ endif()
enable_testing()
+find_package(json11 REQUIRED)
+
if (${USE_CPPNETLIB})
find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS thread filesystem system date_time chrono regex)
@@ -75,6 +77,8 @@ else ()
set (CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${CURL_ROOT}/lib")
endif ()
find_package(CURL REQUIRED)
@ -11,19 +20,30 @@ index 92e4698..002981e 100644
endif ()
set(LIBB64_DIR "${PROJECT_SOURCE_DIR}/ext/b64")
@@ -89,7 +91,6 @@ endif()
@@ -87,9 +91,7 @@ if (WIN32 AND NOT BUILD_STATIC_LIB)
message(FATAL_ERROR "Building Ppconsul as dynamic library on Windows is not supported, see https://github.com/oliora/ppconsul/issues/25")
endif()
add_subdirectory(ext/json11)
-add_subdirectory(ext/json11)
add_subdirectory(src)
-add_subdirectory(tests)
install(
DIRECTORY "${HEADERS_DIR}"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8e24aab..beaac68 100644
index d747100..966c7e2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -85,7 +85,10 @@ if (${USE_CPPNETLIB})
@@ -78,7 +78,7 @@ target_include_directories(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME}
PRIVATE
- json11
+ ${JSON11_LIBRARIES}
${Boost_LIBRARIES}
)
@@ -87,7 +87,10 @@ if (${USE_CPPNETLIB})
target_link_libraries(${PROJECT_NAME} PRIVATE ${CPPNETLIB_LIBRARIES})
else ()
target_include_directories(${PROJECT_NAME} PRIVATE ${CURL_INCLUDE_DIR})
@ -35,3 +55,16 @@ index 8e24aab..beaac68 100644
endif ()
source_group(${PROJECT_NAME} FILES ${SOURCES})
diff --git a/src/s11n.h b/src/s11n.h
index 962a1ac..6ab7f3b 100644
--- a/src/s11n.h
+++ b/src/s11n.h
@@ -6,7 +6,7 @@
#include "ppconsul/config.h"
#include "ppconsul/error.h"
-#include <json11/json11.hpp>
+#include <json11.hpp>
#include <vector>
#include <set>
#include <map>

View File

@ -9,6 +9,10 @@ vcpkg_from_github(
PATCHES "cmake_build.patch"
)
# Force the use of the vcpkg installed versions
file(REMOVE_RECURSE ${SOURCE_PATH}/ext/json11)
file(REMOVE_RECURSE ${SOURCE_PATH}/ext/catch)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA