@@ -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 ()
199232endif ()
200233
@@ -343,33 +376,35 @@ if(BUILD_TESTING)
343376 endif ()
344377endif ()
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 ()
374409endif ()
375410
0 commit comments