Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 103 additions & 54 deletions example/client-cpp-example/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,23 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/thrift/include)
# Add cpp-client include directory
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client/include)

FIND_PACKAGE(OpenSSL REQUIRED)
IF(OpenSSL_FOUND)
MESSAGE(STATUS "OpenSSL found: ${OPENSSL_VERSION}")
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
# =========================
# SSL option (default OFF)
# =========================
option(WITH_SSL "Build with SSL support" OFF)

IF(WITH_SSL)
FIND_PACKAGE(OpenSSL REQUIRED)
IF(OpenSSL_FOUND)
MESSAGE(STATUS "OpenSSL found: ${OPENSSL_VERSION}")
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
ADD_DEFINITIONS(-DWITH_SSL=1)
ELSE()
MESSAGE(FATAL_ERROR "OpenSSL not found, but WITH_SSL is enabled")
ENDIF()
ELSE()
MESSAGE(FATAL_ERROR "OpenSSL not found")
MESSAGE(STATUS "Building without SSL support")
ADD_DEFINITIONS(-DWITH_SSL=0)
ENDIF()

FIND_PACKAGE(Boost REQUIRED)
Expand All @@ -50,53 +61,91 @@ ADD_EXECUTABLE(TableModelSessionExample TableModelSessionExample.cpp)
ADD_EXECUTABLE(MultiSvrNodeClient MultiSvrNodeClient.cpp)

IF(MSVC)
TARGET_LINK_LIBRARIES(SessionExample
iotdb_session
"${CMAKE_SOURCE_DIR}/thrift/lib/Release/thriftmd.lib"
OpenSSL::SSL
OpenSSL::Crypto
)
TARGET_LINK_LIBRARIES(AlignedTimeseriesSessionExample
iotdb_session
"${CMAKE_SOURCE_DIR}/thrift/lib/Release/thriftmd.lib"
OpenSSL::SSL
OpenSSL::Crypto
)
TARGET_LINK_LIBRARIES(TableModelSessionExample
iotdb_session
"${CMAKE_SOURCE_DIR}/thrift/lib/Release/thriftmd.lib"
OpenSSL::SSL
OpenSSL::Crypto
)
TARGET_LINK_LIBRARIES(MultiSvrNodeClient
iotdb_session
"${CMAKE_SOURCE_DIR}/thrift/lib/Release/thriftmd.lib"
OpenSSL::SSL
OpenSSL::Crypto
)
IF(WITH_SSL)
TARGET_LINK_LIBRARIES(SessionExample
iotdb_session
"${CMAKE_SOURCE_DIR}/thrift/lib/Release/thriftmd.lib"
OpenSSL::SSL
OpenSSL::Crypto
)
TARGET_LINK_LIBRARIES(AlignedTimeseriesSessionExample
iotdb_session
"${CMAKE_SOURCE_DIR}/thrift/lib/Release/thriftmd.lib"
OpenSSL::SSL
OpenSSL::Crypto
)
TARGET_LINK_LIBRARIES(TableModelSessionExample
iotdb_session
"${CMAKE_SOURCE_DIR}/thrift/lib/Release/thriftmd.lib"
OpenSSL::SSL
OpenSSL::Crypto
)
TARGET_LINK_LIBRARIES(MultiSvrNodeClient
iotdb_session
"${CMAKE_SOURCE_DIR}/thrift/lib/Release/thriftmd.lib"
OpenSSL::SSL
OpenSSL::Crypto
)
ELSE()
TARGET_LINK_LIBRARIES(SessionExample
iotdb_session
"${CMAKE_SOURCE_DIR}/thrift/lib/Release/thriftmd.lib"
)
TARGET_LINK_LIBRARIES(AlignedTimeseriesSessionExample
iotdb_session
"${CMAKE_SOURCE_DIR}/thrift/lib/Release/thriftmd.lib"
)
TARGET_LINK_LIBRARIES(TableModelSessionExample
iotdb_session
"${CMAKE_SOURCE_DIR}/thrift/lib/Release/thriftmd.lib"
)
TARGET_LINK_LIBRARIES(MultiSvrNodeClient
iotdb_session
"${CMAKE_SOURCE_DIR}/thrift/lib/Release/thriftmd.lib"
)
ENDIF()
ELSE()
TARGET_LINK_LIBRARIES(SessionExample
iotdb_session
pthread
OpenSSL::SSL
OpenSSL::Crypto
)
TARGET_LINK_LIBRARIES(AlignedTimeseriesSessionExample
iotdb_session
pthread
OpenSSL::SSL
OpenSSL::Crypto
)
TARGET_LINK_LIBRARIES(TableModelSessionExample
iotdb_session
pthread
OpenSSL::SSL
OpenSSL::Crypto
)
TARGET_LINK_LIBRARIES(MultiSvrNodeClient
iotdb_session
pthread
OpenSSL::SSL
OpenSSL::Crypto
)
ENDIF()
IF(WITH_SSL)
TARGET_LINK_LIBRARIES(SessionExample
iotdb_session
pthread
OpenSSL::SSL
OpenSSL::Crypto
)
TARGET_LINK_LIBRARIES(AlignedTimeseriesSessionExample
iotdb_session
pthread
OpenSSL::SSL
OpenSSL::Crypto
)
TARGET_LINK_LIBRARIES(TableModelSessionExample
iotdb_session
pthread
OpenSSL::SSL
OpenSSL::Crypto
)
TARGET_LINK_LIBRARIES(MultiSvrNodeClient
iotdb_session
pthread
OpenSSL::SSL
OpenSSL::Crypto
)
ELSE()
TARGET_LINK_LIBRARIES(SessionExample
iotdb_session
pthread
)
TARGET_LINK_LIBRARIES(AlignedTimeseriesSessionExample
iotdb_session
pthread
)
TARGET_LINK_LIBRARIES(TableModelSessionExample
iotdb_session
pthread
)
TARGET_LINK_LIBRARIES(MultiSvrNodeClient
iotdb_session
pthread
)
ENDIF()
ENDIF()
3 changes: 3 additions & 0 deletions iotdb-client/client-cpp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<cmake.root.dir>${project.build.directory}/dependency/cmake/</cmake.root.dir>
<thrift.exec.absolute.path>${project.build.directory}/thrift/bin/${thrift.executable}</thrift.exec.absolute.path>
<maven.test.skip>${ctest.skip.tests}</maven.test.skip>
<with.ssl>false</with.ssl>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -217,6 +218,7 @@
<targetPath>${project.build.directory}/build/main</targetPath>
<options>
<option>-DBOOST_INCLUDEDIR=${boost.include.dir}</option>
<option>-DWITH_SSL=${with.ssl}</option>
</options>
</configuration>
</execution>
Expand All @@ -233,6 +235,7 @@
<targetPath>${project.build.directory}/build/test</targetPath>
<options>
<option>-DBOOST_INCLUDEDIR=${boost.include.dir}</option>
<option>-DWITH_SSL=${with.ssl}</option>
</options>
</configuration>
</execution>
Expand Down
50 changes: 35 additions & 15 deletions iotdb-client/client-cpp/src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,23 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -g -O2 ")
# Add Thrift include directory
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/../../thrift/include)

# Find OpenSSL Library
FIND_PACKAGE(OpenSSL REQUIRED)
IF(OpenSSL_FOUND)
MESSAGE(STATUS "OpenSSL found: ${OPENSSL_VERSION}")
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
# =========================
# SSL option (default OFF)
# =========================
option(WITH_SSL "Build with SSL support" OFF)

IF(WITH_SSL)
FIND_PACKAGE(OpenSSL REQUIRED)
IF(OpenSSL_FOUND)
MESSAGE(STATUS "OpenSSL found: ${OPENSSL_VERSION}")
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
ADD_DEFINITIONS(-DWITH_SSL=1)
ELSE()
MESSAGE(FATAL_ERROR "OpenSSL not found, but WITH_SSL is enabled")
ENDIF()
ELSE()
MESSAGE(FATAL_ERROR "OpenSSL not found")
MESSAGE(STATUS "Building without SSL support")
ADD_DEFINITIONS(-DWITH_SSL=0)
ENDIF()

# Add Boost include path for MacOS
Expand All @@ -51,8 +61,8 @@ ELSE()
ENDIF()

IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT MSVC)
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
add_link_options(-fsanitize=address)
#add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
#add_link_options(-fsanitize=address)
ENDIF()

# Add the generated source files to the sources for the library.
Expand All @@ -63,10 +73,20 @@ ELSE()
ADD_LIBRARY(iotdb_session SHARED ${SESSION_SRCS})
ENDIF()

# Link with Thrift static library
target_link_libraries(iotdb_session
PUBLIC
OpenSSL::SSL
OpenSSL::Crypto
${THRIFT_STATIC_LIB}
)
# =========================
# Link libraries (SSL optional)
# =========================
IF(WITH_SSL)
target_link_libraries(iotdb_session
PUBLIC
OpenSSL::SSL
OpenSSL::Crypto
${THRIFT_STATIC_LIB}
)
ELSE()
target_link_libraries(iotdb_session
PUBLIC
${THRIFT_STATIC_LIB}
)
ENDIF()

Loading