Skip to content

Commit a91d745

Browse files
committed
prepare for conan
1 parent 5f8b1b8 commit a91d745

File tree

4 files changed

+192
-68
lines changed

4 files changed

+192
-68
lines changed

CHANGELOG.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
6+
## [1.0.0] - 2025-11-01
7+
8+
### Added
9+
10+
- Initial Conan package release for Conan 2.0
11+
- C++20 client library (`influxdb-cpp-rest`) for InfluxDB
12+
- C wrapper library (`influx-c-rest`) providing a C API over the asynchronous C++ API
13+
- Support for InfluxDB 1.x (tested with InfluxDB 1.8+)
14+
- Synchronous and asynchronous (batched) insertion APIs
15+
- Query API support
16+
- Basic authentication support
17+
- CMake integration via `find_package(influxdb-cpp-rest)`
18+
19+
### Technical Details
20+
21+
- **C++ Standard**: Requires C++20 or later
22+
- Minimum compiler versions:
23+
- GCC 11+
24+
- Clang 14+
25+
- MSVC 2019+ (19.29+) with `/std:c++20` or later
26+
- **InfluxDB Compatibility**: Supports InfluxDB 1.x (tested with v1.8+)
27+
- **Libraries Included**:
28+
- `influxdb-cpp-rest`: Static C++ library providing the core functionality
29+
- `influx-c-rest`: Shared C wrapper library for C interoperability
30+
- **Dependencies**:
31+
- cpprestsdk/2.10.19 (HTTP client)
32+
- rxcpp/4.1.1 (Reactive Extensions for asynchronous operations)
33+
34+
### Notes
35+
36+
- This package replaces the legacy C++03 version available as [`v0.0.1-legacy`](https://github.com/d-led/influxdb-cpp-rest/releases/tag/v0.0.1-legacy)
37+
- The modern C++20 version provides improved performance, type safety, and modern C++ features
38+
- The C wrapper (`influx-c-rest`) enables integration from C projects while maintaining the performance benefits of the underlying C++ implementation
39+
40+
---
41+
42+
## Legacy Versions
43+
44+
### [0.0.1-legacy] - Legacy Release
45+
46+
- Legacy C++03 compatible version
47+
- Available as a GitHub release tag
48+
- Not available as a Conan package
49+
50+
[1.0.0]: https://github.com/d-led/influxdb-cpp-rest/releases/tag/v1.0.0
51+
[0.0.1-legacy]: https://github.com/d-led/influxdb-cpp-rest/releases/tag/v0.0.1-legacy
52+
53+
---
54+
55+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
56+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

CMakeLists.txt

Lines changed: 79 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -169,32 +169,65 @@ target_link_libraries(influxdb-cpp-rest
169169
PUBLIC
170170
${CONAN_LIBS}
171171
)
172-
# Workaround: Conan OpenSSL CMakeDeps doesn't set include directories
173-
if(TARGET OpenSSL::SSL)
174-
# Read openssl package folder from the data file
175-
file(GLOB _OPENSSL_DATA_FILES "${CMAKE_BINARY_DIR}/OpenSSL-*-data.cmake")
176-
if(_OPENSSL_DATA_FILES)
177-
list(GET _OPENSSL_DATA_FILES 0 _OPENSSL_DATA_FILE)
178-
message(STATUS "Found OpenSSL data file: ${_OPENSSL_DATA_FILE}")
179-
file(READ "${_OPENSSL_DATA_FILE}" _OPENSSL_DATA_CONTENT)
180-
string(REGEX MATCH "set\\(openssl_PACKAGE_FOLDER_RELEASE \"([^\"]+)\"\\)" _MATCH "${_OPENSSL_DATA_CONTENT}")
181-
if(_MATCH)
182-
string(REGEX REPLACE ".*openssl_PACKAGE_FOLDER_RELEASE \"([^\"]+)\".*" "\\1" OPENSSL_PKG_FOLDER "${_MATCH}")
183-
set(OPENSSL_INCLUDE_DIR "${OPENSSL_PKG_FOLDER}/include")
184-
message(STATUS "OpenSSL pkg folder: ${OPENSSL_PKG_FOLDER}, include: ${OPENSSL_INCLUDE_DIR}")
185-
if(EXISTS "${OPENSSL_INCLUDE_DIR}")
186-
set_target_properties(OpenSSL::SSL OpenSSL::Crypto PROPERTIES
187-
INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}"
188-
)
189-
message(STATUS "Set OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}")
190-
else()
191-
message(WARNING "OpenSSL include dir does not exist: ${OPENSSL_INCLUDE_DIR}")
172+
# Workaround: Ensure OpenSSL include directories are available
173+
# Boost (via cpprestsdk) requires OpenSSL headers, but Conan's OpenSSL CMakeDeps
174+
# might not properly set INTERFACE_INCLUDE_DIRECTORIES
175+
if(TARGET OpenSSL::SSL AND USE_CONAN)
176+
# Find OpenSSL include directory - try multiple methods
177+
set(_OPENSSL_INCLUDE_DIR "")
178+
179+
# Method 1: Check CMAKE_PREFIX_PATH (set by Conan generators)
180+
foreach(_PREFIX_PATH ${CMAKE_PREFIX_PATH})
181+
set(_POSSIBLE_INCLUDE "${_PREFIX_PATH}/include")
182+
if(EXISTS "${_POSSIBLE_INCLUDE}/openssl/ssl.h")
183+
set(_OPENSSL_INCLUDE_DIR "${_POSSIBLE_INCLUDE}")
184+
message(STATUS "Found OpenSSL includes via CMAKE_PREFIX_PATH: ${_OPENSSL_INCLUDE_DIR}")
185+
break()
186+
endif()
187+
endforeach()
188+
189+
# Method 2: Read from Conan's generator data files
190+
if(NOT _OPENSSL_INCLUDE_DIR)
191+
file(GLOB _OPENSSL_DATA_FILES
192+
"${CMAKE_BINARY_DIR}/OpenSSL-*-data.cmake"
193+
"${CMAKE_BINARY_DIR}/generators/OpenSSL-*-data.cmake"
194+
"${CMAKE_BINARY_DIR}/build/Release/generators/OpenSSL-*-data.cmake"
195+
"${CMAKE_BINARY_DIR}/build/${CMAKE_BUILD_TYPE}/generators/OpenSSL-*-data.cmake"
196+
)
197+
if(_OPENSSL_DATA_FILES)
198+
list(GET _OPENSSL_DATA_FILES 0 _OPENSSL_DATA_FILE)
199+
file(READ "${_OPENSSL_DATA_FILE}" _OPENSSL_DATA_CONTENT)
200+
# Match both lowercase and mixed case variants
201+
string(REGEX MATCH "set\\([Oo]pen[Ss][Ss][Ll]_PACKAGE_FOLDER_RELEASE \"([^\"]+)\"\\)" _MATCH "${_OPENSSL_DATA_CONTENT}")
202+
if(_MATCH)
203+
string(REGEX REPLACE ".*PACKAGE_FOLDER_RELEASE \"([^\"]+)\".*" "\\1" _OPENSSL_PKG_FOLDER "${_MATCH}")
204+
set(_OPENSSL_INCLUDE_DIR "${_OPENSSL_PKG_FOLDER}/include")
205+
message(STATUS "Found OpenSSL includes via data file: ${_OPENSSL_INCLUDE_DIR}")
192206
endif()
193-
else()
194-
message(WARNING "Could not extract OpenSSL package folder from data file")
195207
endif()
208+
endif()
209+
210+
# Method 3: Use find_path to search in known locations
211+
if(NOT _OPENSSL_INCLUDE_DIR)
212+
find_path(_OPENSSL_INCLUDE_DIR
213+
NAMES openssl/ssl.h
214+
PATHS ${CMAKE_PREFIX_PATH}
215+
PATH_SUFFIXES include
216+
NO_DEFAULT_PATH
217+
)
218+
if(_OPENSSL_INCLUDE_DIR)
219+
message(STATUS "Found OpenSSL includes via find_path: ${_OPENSSL_INCLUDE_DIR}")
220+
endif()
221+
endif()
222+
223+
# Add the include directory directly to our target
224+
# This is critical because Boost's ASIO SSL tries to include openssl headers directly
225+
if(_OPENSSL_INCLUDE_DIR AND EXISTS "${_OPENSSL_INCLUDE_DIR}")
226+
target_include_directories(influxdb-cpp-rest PRIVATE "${_OPENSSL_INCLUDE_DIR}")
227+
message(STATUS "Added OpenSSL include directory to influxdb-cpp-rest: ${_OPENSSL_INCLUDE_DIR}")
196228
else()
197-
message(WARNING "Could not find OpenSSL data file")
229+
message(WARNING "Could not find OpenSSL include directory - compilation may fail")
230+
message(WARNING "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
198231
endif()
199232
endif()
200233

@@ -343,33 +376,35 @@ if(BUILD_TESTING)
343376
endif()
344377
endif()
345378

346-
# Enable testing
347-
enable_testing()
379+
# Enable testing and register tests (only if BUILD_TESTING is ON)
380+
if(BUILD_TESTING)
381+
enable_testing()
348382

349-
# Register tests with CTest
350-
add_test(NAME test-influxdb-cpp-rest COMMAND ${CMAKE_BINARY_DIR}/bin/test-influxdb-cpp-rest)
351-
add_test(NAME test-influx-c-rest COMMAND ${CMAKE_BINARY_DIR}/bin/test-influx-c-rest)
352-
add_test(NAME test-influxdb-cpp-auth COMMAND ${CMAKE_BINARY_DIR}/bin/test-influxdb-cpp-auth)
383+
# Register tests with CTest
384+
add_test(NAME test-influxdb-cpp-rest COMMAND ${CMAKE_BINARY_DIR}/bin/test-influxdb-cpp-rest)
385+
add_test(NAME test-influx-c-rest COMMAND ${CMAKE_BINARY_DIR}/bin/test-influx-c-rest)
386+
add_test(NAME test-influxdb-cpp-auth COMMAND ${CMAKE_BINARY_DIR}/bin/test-influxdb-cpp-auth)
353387

354-
# Set output directories for executables - match influx-c-rest DLL location
355-
if(CMAKE_CONFIGURATION_TYPES)
356-
# Multi-config generator (Visual Studio, Xcode)
357-
set_target_properties(test-influxdb-cpp-rest test-influx-c-rest test-influxdb-cpp-auth
358-
PROPERTIES
359-
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>"
360-
)
361-
else()
362-
# Single-config generator
363-
if(CMAKE_BUILD_TYPE)
388+
# Set output directories for executables - match influx-c-rest DLL location
389+
if(CMAKE_CONFIGURATION_TYPES)
390+
# Multi-config generator (Visual Studio, Xcode)
364391
set_target_properties(test-influxdb-cpp-rest test-influx-c-rest test-influxdb-cpp-auth
365392
PROPERTIES
366-
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}"
393+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>"
367394
)
368395
else()
369-
set_target_properties(test-influxdb-cpp-rest test-influx-c-rest test-influxdb-cpp-auth
370-
PROPERTIES
371-
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
372-
)
396+
# Single-config generator
397+
if(CMAKE_BUILD_TYPE)
398+
set_target_properties(test-influxdb-cpp-rest test-influx-c-rest test-influxdb-cpp-auth
399+
PROPERTIES
400+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}"
401+
)
402+
else()
403+
set_target_properties(test-influxdb-cpp-rest test-influx-c-rest test-influxdb-cpp-auth
404+
PROPERTIES
405+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
406+
)
407+
endif()
373408
endif()
374409
endif()
375410

conanfile.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from conan import ConanFile
2-
from conan.tools.cmake import CMake, cmake_layout
3-
from conan.tools.files import copy
2+
from conan.tools.cmake import CMake, cmake_layout, CMakeDeps, CMakeToolchain
43

54

65
class InfluxdbCppRestConan(ConanFile):
@@ -14,7 +13,9 @@ class InfluxdbCppRestConan(ConanFile):
1413
settings = "os", "compiler", "build_type", "arch"
1514
options = {"shared": [True, False], "fPIC": [True, False]}
1615
default_options = {"shared": False, "fPIC": True}
17-
generators = "CMakeDeps", "CMakeToolchain"
16+
17+
# Export source files needed for building
18+
exports_sources = "CMakeLists.txt", "src/*"
1819

1920
def config_options(self):
2021
if self.settings.os == "Windows":
@@ -25,23 +26,43 @@ def configure(self):
2526
self.options["cpprestsdk"].shared = True
2627

2728
def requirements(self):
28-
self.requires("cpprestsdk/2.10.19") # Latest stable version
29-
self.requires("rxcpp/4.1.1") # Latest stable version
29+
self.requires("cpprestsdk/2.10.19")
30+
self.requires("rxcpp/4.1.1")
3031

3132
def build_requirements(self):
3233
# Only for tests - not linked to the library
3334
self.test_requires("catch2/3.11.0")
3435

35-
# Don't use cmake_layout when consuming dependencies - it creates nested build directories
36-
# def layout(self):
37-
# cmake_layout(self)
36+
def layout(self):
37+
cmake_layout(self)
38+
39+
def generate(self):
40+
deps = CMakeDeps(self)
41+
deps.generate()
42+
tc = CMakeToolchain(self)
43+
tc.generate()
3844

3945
def build(self):
4046
cmake = CMake(self)
41-
cmake.configure()
47+
# Disable tests and demo for packaging
48+
cmake.configure(variables={"BUILD_TESTING": "OFF", "BUILD_DEMO": "OFF"})
4249
cmake.build()
4350

4451
def package(self):
4552
cmake = CMake(self)
4653
cmake.install()
4754

55+
def package_info(self):
56+
self.cpp_info.set_property("cmake_file_name", "influxdb-cpp-rest")
57+
self.cpp_info.set_property("cmake_target_name", "influxdb-cpp-rest::influxdb-cpp-rest")
58+
59+
# Libraries to link
60+
self.cpp_info.libs = ["influxdb-cpp-rest"]
61+
62+
# Include directories
63+
self.cpp_info.includedirs = ["include"]
64+
65+
# System dependencies (if any)
66+
if self.settings.os == "Linux":
67+
self.cpp_info.system_libs = ["pthread"]
68+

scripts/tag-version.sh

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@ bump_version() {
107107
# Update version in all files
108108
update_version_files() {
109109
local new_version="$1"
110-
local sed_in_place
111-
112-
if [[ "$(uname)" == "Darwin" ]]; then
113-
sed_in_place="sed -i ''"
114-
else
115-
sed_in_place="sed -i"
116-
fi
117110

118111
if [ "$DRY_RUN" = true ]; then
119112
echo "[DRY RUN] Would update versions to: ${new_version}"
@@ -141,13 +134,21 @@ update_version_files() {
141134

142135
# Update conanfile.py
143136
if [ -f "${CONANFILE}" ]; then
144-
$sed_in_place "s/version = \"[^\"]*\"/version = \"${new_version}\"/" "${CONANFILE}"
137+
if [[ "$(uname)" == "Darwin" ]]; then
138+
sed -i '' "s/version = \"[^\"]*\"/version = \"${new_version}\"/" "${CONANFILE}"
139+
else
140+
sed -i "s/version = \"[^\"]*\"/version = \"${new_version}\"/" "${CONANFILE}"
141+
fi
145142
echo "✓ Updated ${CONANFILE} to version ${new_version}"
146143
fi
147144

148145
# Update CMakeLists.txt (project VERSION)
149146
if [ -f "${CMAKELISTS}" ]; then
150-
$sed_in_place -E "s/VERSION [0-9]+\\.[0-9]+\\.[0-9]+(-rc[0-9]+)?/VERSION ${new_version}/" "${CMAKELISTS}"
147+
if [[ "$(uname)" == "Darwin" ]]; then
148+
sed -i '' -E "s/VERSION [0-9]+\\.[0-9]+\\.[0-9]+(-rc[0-9]+)?/VERSION ${new_version}/" "${CMAKELISTS}"
149+
else
150+
sed -i -E "s/VERSION [0-9]+\\.[0-9]+\\.[0-9]+(-rc[0-9]+)?/VERSION ${new_version}/" "${CMAKELISTS}"
151+
fi
151152
echo "✓ Updated ${CMAKELISTS} to version ${new_version}"
152153
fi
153154
}
@@ -389,10 +390,9 @@ main() {
389390
# Update all version files
390391
update_version_files "$NEW_VERSION"
391392

392-
# Commit version changes
393-
commit_version_changes "$NEW_VERSION"
394-
395393
if [ "$DRY_RUN" = true ]; then
394+
echo ""
395+
commit_version_changes "$NEW_VERSION"
396396
echo ""
397397
create_tag "$NEW_VERSION"
398398
if [ "$PUSH" = true ]; then
@@ -404,9 +404,13 @@ main() {
404404
exit 0
405405
fi
406406

407-
# Create git tag
407+
# Ask for confirmation to commit and tag
408408
if [ "$YES" = true ]; then
409409
# Auto-confirm, skip prompt
410+
# Commit version changes
411+
commit_version_changes "$NEW_VERSION"
412+
413+
# Create git tag
410414
create_tag "$NEW_VERSION"
411415

412416
# Push tag if --push flag was set
@@ -415,16 +419,22 @@ main() {
415419
push_tag "$NEW_VERSION"
416420
echo ""
417421
echo "✓ Version bumped to ${NEW_VERSION}"
422+
echo "✓ Changes committed"
418423
echo "✓ Git tag v${NEW_VERSION} created and pushed"
419424
else
420425
echo ""
421426
echo "✓ Version bumped to ${NEW_VERSION}"
427+
echo "✓ Changes committed"
422428
echo "✓ Git tag v${NEW_VERSION} created"
423429
fi
424430
else
425-
read -p "Create git tag v${NEW_VERSION}? (y/N) " -n 1 -r
431+
read -p "Commit and tag v${NEW_VERSION}? (y/N) " -n 1 -r
426432
echo
427433
if [[ $REPLY =~ ^[Yy]$ ]]; then
434+
# Commit version changes
435+
commit_version_changes "$NEW_VERSION"
436+
437+
# Create git tag
428438
create_tag "$NEW_VERSION"
429439

430440
# Push tag if --push flag was set
@@ -433,14 +443,16 @@ main() {
433443
push_tag "$NEW_VERSION"
434444
echo ""
435445
echo "✓ Version bumped to ${NEW_VERSION}"
446+
echo "✓ Changes committed"
436447
echo "✓ Git tag v${NEW_VERSION} created and pushed"
437448
else
438449
echo ""
439450
echo "✓ Version bumped to ${NEW_VERSION}"
451+
echo "✓ Changes committed"
440452
echo "✓ Git tag v${NEW_VERSION} created"
441453
fi
442454
else
443-
echo "Tag creation cancelled. Version updated in files only."
455+
echo "Cancelled. Version updated in files only."
444456
fi
445457
fi
446458
}

0 commit comments

Comments
 (0)