Skip to content

Commit

Permalink
Replace curl with cpr (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
offa committed Jan 28, 2023
1 parent bdb4859 commit 4f1f45e
Show file tree
Hide file tree
Showing 15 changed files with 440 additions and 925 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

find_package(Threads REQUIRED)
find_package(CURL REQUIRED MODULE)
find_package(cpr REQUIRED)

if (INFLUXCXX_WITH_BOOST)
# Fixes warning when using boost from brew
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ InfluxDB C++ client library
- C++17 compiler

__Dependencies__
- CURL (required)
- [cpr](https://github.com/libcpr/cpr) (required)
- boost 1.66+ (optional – see [Transports](#transports))

### Generic
Expand Down Expand Up @@ -124,7 +124,7 @@ List of supported transport is following:

| Name | Dependency | URI protocol | Sample URI |
| ----------- |:-----------:|:--------------:| -------------------------------------:|
| HTTP | cURL<sup>i)</sup> | `http`/`https` | `http://localhost:8086?db=<db>` |
| HTTP | cpr<sup>i)</sup> | `http`/`https` | `http://localhost:8086?db=<db>` |
| TCP | boost | `tcp` | `tcp://localhost:8094` |
| UDP | boost | `udp` | `udp://localhost:8094` |
| Unix socket | boost | `unix` | `unix:///tmp/telegraf.sock` |
Expand Down
2 changes: 1 addition & 1 deletion cmake/InfluxDBConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include(CMakeFindDependencyMacro)
if(InfluxDB_WITH_BOOST)
find_dependency(Boost COMPONENTS system REQUIRED)
endif()
find_dependency(CURL REQUIRED)
find_dependency(cpr REQUIRED)
find_dependency(Threads REQUIRED)

if(NOT TARGET InfluxData::InfluxDB)
Expand Down
8 changes: 3 additions & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class InfluxdbCxxConan(ConanFile):
"system": False,
"boost": True,
"boost:shared": True,
"libcurl:shared": True
}
exports = ["LICENSE"]
exports_sources = ("CMakeLists.txt", "src/*", "include/*", "test/*",
Expand Down Expand Up @@ -54,10 +53,9 @@ def set_version(self):
f"Project version from CMakeLists.txt: '{self.version}'")

def requirements(self):
if not self.options.system:
self.requires("libcurl/7.84.0")
if self.options.boost:
self.requires("boost/1.79.0")
self.requires("cpr/1.9.3")
if not self.options.system and self.options.boost:
self.requires("boost/1.81.0")
if self.options.tests:
self.requires("catch2/3.3.0")
self.requires("trompeloeil/43")
Expand Down
2 changes: 1 addition & 1 deletion script/ci_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -ex

apt-get update
apt-get install -y python3-pip libcurl4-openssl-dev
apt-get install -y python3-pip
pip3 install -U conan

mkdir -p build && cd build
Expand Down
5 changes: 4 additions & 1 deletion script/ci_testdeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ cp -r script/include_library/* ${BASEPATH}/

cd /tmp/influx-test-${PID}/
mkdir build && cd build
cmake "$@" ..

conan install -g cmake_paths -g cmake_find_package cpr/1.9.3@

cmake -DCMAKE_TOOLCHAIN_FILE=./conan_paths.cmake "$@" ..
cmake --build . -j

#cleanup
Expand Down
28 changes: 17 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ set(INTERNAL_INCLUDE_DIRS
${PROJECT_BINARY_DIR}/src
)

add_library(InfluxDB-Http OBJECT HTTP.cxx)
target_include_directories(InfluxDB-Http PRIVATE ${INTERNAL_INCLUDE_DIRS})
target_include_directories(InfluxDB-Http SYSTEM PUBLIC $<TARGET_PROPERTY:CURL::libcurl,INTERFACE_INCLUDE_DIRECTORIES>)


add_library(InfluxDB-BoostSupport OBJECT
$<$<NOT:$<BOOL:${INFLUXCXX_WITH_BOOST}>>:NoBoostSupport.cxx>
Expand All @@ -30,17 +26,27 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_
set_source_files_properties(UDP.cxx TCP.cxx UnixSocket.cxx PROPERTIES COMPILE_OPTIONS "-Wno-null-dereference")
endif()

add_library(InfluxDB-Internal OBJECT LineProtocol.cxx)
add_library(InfluxDB-Internal OBJECT LineProtocol.cxx HTTP.cxx)
target_include_directories(InfluxDB-Internal PRIVATE ${INTERNAL_INCLUDE_DIRS})
target_link_libraries(InfluxDB-Internal PUBLIC cpr::cpr)


add_library(InfluxDB-Core OBJECT
InfluxDB.cxx
Point.cxx
InfluxDBFactory.cxx
Proxy.cxx
)
target_include_directories(InfluxDB-Core PUBLIC
${PROJECT_SOURCE_DIR}/include
${PROJECT_BINARY_DIR}/src
)
target_link_libraries(InfluxDB-Core PRIVATE cpr::cpr)


add_library(InfluxDB
InfluxDB.cxx
Point.cxx
InfluxDBFactory.cxx
Proxy.cxx
$<TARGET_OBJECTS:InfluxDB-Core>
$<TARGET_OBJECTS:InfluxDB-Internal>
$<TARGET_OBJECTS:InfluxDB-Http>
$<TARGET_OBJECTS:InfluxDB-BoostSupport>
)
add_library(InfluxData::InfluxDB ALIAS InfluxDB)
Expand Down Expand Up @@ -76,7 +82,7 @@ target_include_directories(InfluxDB
# Link targets
target_link_libraries(InfluxDB
PRIVATE
CURL::libcurl
cpr::cpr
Threads::Threads
$<$<BOOL:${INFLUXCXX_WITH_BOOST}>:Boost::boost>
$<$<BOOL:${INFLUXCXX_WITH_BOOST}>:Boost::system>
Expand Down
Loading

0 comments on commit 4f1f45e

Please sign in to comment.