Skip to content
Merged
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
24 changes: 7 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,22 @@
*.a

# cmake output
*.cmake
*.build
*.xcodeproj
CMakeFiles
CMakeCache.txt
CTestTestfile.cmake
CMakeScripts
Makefile
cmake_install.cmake
cmake_uninstall.cmake
cassandra-config-version.cmake
cassandra-config.cmake
cassandra-targets.cmake
install_manifest.txt

# build files
build/
Testing/
build
Testing
Debug
demo/cql_demo
test/unit_tests/cql_test

# external deps
ext/bin
ext/lib
ext/src
ext/share
ext/include
ext/ssl
ext/tmp

# editor
*.swp
*~
Expand Down
150 changes: 59 additions & 91 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.0)
cmake_minimum_required(VERSION 2.6.4)
set(PROJECT_NAME_STR cql)
# Alias for project name used in unit tests
set(CQL_DRIVER_PROJECT_NAME ${PROJECT_NAME_STR})
Expand All @@ -7,11 +7,10 @@ project(${PROJECT_NAME_STR} C CXX)
#-------------------
# The version number
#-------------------

set (cassandra_VERSION_MAJOR 0)
set (cassandra_VERSION_MINOR 7)
set (cassandra_VERSION_PATCH 0)
set (cassandra_VERSION_STRING ${cassandra_VERSION_MAJOR}.${cassandra_VERSION_MINOR}.${cassandra_VERSION_PATCH})
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 7)
set(PROJECT_VERSION_PATCH 0)
set(PROJECT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})

# todo: add version header

Expand All @@ -28,43 +27,33 @@ set(CMAKE_MODULE_PATH ${EXT_PREFIX})
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)

include(openssl)
include(zlib)
set(LIBS ${LIBS} ${openssl_STATIC_LIBRARIES} )
set(LIBS ${LIBS} ${zlib_STATIC_LIBRARIES} )
else()
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_STATIC_RUNTIME OFF)

find_package(OpenSSL REQUIRED)
set(LIBS ${LIBS} ${OPENSSL_LIBRARIES} )

find_package(ZLIB REQUIRED)
set(LIBS ${LIBS} ${ZLIB_LIBRARIES} )
# Disable boost auto linking feature
# it prevents visual studio from simultaneously building
# static and shared version of driver
# needed by boost to link dynamically
# this is a noop on platforms other than windows
add_definitions(-DBOOST_ALL_DYN_LINK)
add_definitions(-DBOOST_ALL_NO_LIB)
endif()

# Boost
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.54.0 COMPONENTS atomic system thread unit_test_framework date_time REQUIRED)
find_package(Boost 1.41.0 COMPONENTS system thread unit_test_framework date_time program_options REQUIRED)
set(LIBS ${LIBS} ${Boost_LIBRARIES})

find_package(OpenSSL REQUIRED)
set(LIBS ${LIBS} ${OPENSSL_LIBRARIES})

find_package(ZLIB REQUIRED)
set(LIBS ${LIBS} ${ZLIB_LIBRARIES})

# Threading
find_package(Threads REQUIRED)
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})

# -------------------------------------------------------------
# Find libCDS library
# -------------------------------------------------------------
# Allow access to custom FindLIBCDS module
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")

find_package(LIBCDS REQUIRED)

set(LIBS ${LIBS} ${LIBCDS_LIBRARIES})
set(INCLUDES ${INCLUDES} ${LIBCDS_INCLUDE_DIRS})
# -------------------------------------------------------------

# Build up the include path's
set(INCLUDES ${INCLUDES} ${OPENSSL_INCLUDE_DIR} )
set(INCLUDES ${INCLUDES} ${ZLIB_INCLUDE_DIR} )
Expand All @@ -73,22 +62,14 @@ set(INCLUDES ${INCLUDES} ${Boost_INCLUDE_DIRS} )
set(PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
set(INCLUDES ${INCLUDES} ${PROJECT_INCLUDE_DIR})


# disable boost auto linking feature
# it prevents visual studio from simultaneously building
# static and shared version of driver
# needed by boost to link dynamically
add_definitions(-DBOOST_ALL_DYN_LINK)
add_definitions(-DBOOST_ALL_NO_LIB)

set(MULTICORE_CORES_NUMBER "3" CACHE STRING "Number of cores (for multicore compilation)")
option(MULTICORE_COMPILATION "Enable multicore compilation" OFF)

if(MULTICORE_COMPILATION)
# MULTICORE BUILD
# by default we use 3 cores
if(MSVC)
add_definitions("/MP${MULTICORE_CORES_NUMBER}")
add_definitions("/MP${MULTICORE_CORES_NUMBER}")
endif()
# on linux platform this parameter is named -j e.g. -j 5
# but should be passed to MAKE program not to compiler!
Expand All @@ -109,11 +90,14 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
else()
# GCC specific compiler options
# I disabled long-long warning because boost generates about 50 such warnings
# -std=c++0x, -fno-strict-aliasing :: required by libcds
set(PLATFORM_DEPENDENT_COMPILER_OPTIONS "-fPIC -Wall -pedantic -std=c++0x -Wno-long-long -fno-strict-aliasing")
set(PLATFORM_DEPENDENT_COMPILER_OPTIONS "-fPIC -Wall -pedantic -Wno-long-long -fno-strict-aliasing")
endif()


# add_custom_target (AppDependencies ALL
# DEPENDS ${APP_DEPENDENCIES}
# COMMENT "Installing any missing dependencies.")

#-------------------
# Cassandra static and shared
#-------------------
Expand All @@ -130,73 +114,63 @@ include_directories(${INCLUDES})
# we must add header files as dependencies (if header
# changes project must be recompiled, right).
file(GLOB INC_FILES
${PROJECT_SOURCE_DIR}/include/cql/*.hpp )
file(GLOB INC_EXCEPTION_FILES
${PROJECT_SOURCE_DIR}/include/cql/exceptions/*.hpp )
${PROJECT_SOURCE_DIR}/include/cql/*.hpp )

file(GLOB INC_FILES_EXCEPTIONS
${PROJECT_SOURCE_DIR}/include/cql/exceptions/*.hpp )

file(GLOB INC_FILES_INTERNAL
${PROJECT_SOURCE_DIR}/include/cql/internal/*.hpp )

file(GLOB INC_FILES_LOCKFREE
${PROJECT_SOURCE_DIR}/include/cql/lockfree/*.hpp )

file(GLOB INC_FILES_POLICIES
${PROJECT_SOURCE_DIR}/include/cql/policies/*.hpp )

file(GLOB SRC_FILES
${PROJECT_SOURCE_DIR}/src/cql/*.cpp)

file(GLOB SRC_EXCEPTION_FILES
file(GLOB SRC_FILES_EXCEPTIONS
${PROJECT_SOURCE_DIR}/src/cql/exceptions/*.cpp )

file(GLOB SRC_FILES_INTERNAL
${PROJECT_SOURCE_DIR}/src/cql/internal/*.cpp )

file(GLOB SRC_FILES_LOCKFREE
${PROJECT_SOURCE_DIR}/src/cql/lockfree/*.cpp )

file(GLOB SRC_FILES_POLICIES
${PROJECT_SOURCE_DIR}/src/cql/policies/*.cpp )

source_group("Source Files" FILES ${SRC_FILES})
source_group("Source Files\\Internal" FILES ${SRC_FILES_INTERNAL})
source_group("Source Files\\Exceptions" FILES ${SRC_EXCEPTION_FILES})
source_group("Source Files\\Lock Free" FILES ${SRC_FILES_LOCKFREE})
source_group("Source Files\\Exceptions" FILES ${SRC_FILES_EXCEPTIONS})
source_group("Source Files\\Policies" FILES ${SRC_FILES_POLICIES})

source_group("Header Files" FILES ${INC_FILES})
source_group("Header Files\\Internal" FILES ${INC_FILES_INTERNAL})
source_group("Header Files\\Exceptions" FILES ${INC_EXCEPTION_FILES})
source_group("Header Files\\Lock Free" FILES ${INC_FILES_LOCKFREE})
source_group("Header Files\\Exceptions" FILES ${INC_FILES_EXCEPTIONS})
source_group("Header Files\\Policies" FILES ${INC_FILES_POLICIES})

set(ALL_SOURCE_FILES
${SRC_FILES} ${SRC_FILES_INTERNAL} ${SRC_EXCEPTION_FILES} ${SRC_FILES_LOCKFREE} ${SRC_FILES_POLICIES}
${INC_FILES} ${INC_FILES_INTERNAL} ${INC_EXCEPTION_FILES} ${INC_FILES_LOCKFREE} ${INC_FILES_POLICIES})
set(ALL_SOURCE_FILES
${SRC_FILES} ${SRC_FILES_INTERNAL} ${SRC_FILES_EXCEPTIONS} ${SRC_FILES_POLICIES}
${INC_FILES} ${INC_FILES_INTERNAL} ${INC_FILES_EXCEPTIONS} ${INC_FILES_POLICIES})

# build dynamic and static version of library

# !!!! DYNAMIC TARGET CURRENTY DISABLED (TOO SPEED UP COMPILATION)
# add_library(${PROJECT_LIB_NAME} SHARED ${ALL_SOURCE_FILES})
add_library(${PROJECT_LIB_NAME} SHARED ${ALL_SOURCE_FILES})

set(PROJECT_LIB_NAME_STATIC "${PROJECT_LIB_NAME}_static")
add_library(${PROJECT_LIB_NAME_STATIC} STATIC ${ALL_SOURCE_FILES})

#target_link_libraries(${PROJECT_LIB_NAME} ${LIBS})
target_link_libraries(${PROJECT_LIB_NAME} ${LIBS})
target_link_libraries(${PROJECT_LIB_NAME_STATIC} ${LIBS})

#set_target_properties(${PROJECT_LIB_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_LIB_NAME})
#set_target_properties(${PROJECT_LIB_NAME} PROPERTIES VERSION ${cassandra_VERSION_STRING} SOVERSION ${cassandra_VERSION_MAJOR})
set_target_properties(${PROJECT_LIB_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_LIB_NAME})
set_target_properties(${PROJECT_LIB_NAME} PROPERTIES VERSION ${PROJECT_VERSION_STRING} SOVERSION ${PROJECT_VERSION_MAJOR})

set_target_properties(${PROJECT_LIB_NAME_STATIC} PROPERTIES OUTPUT_NAME ${PROJECT_LIB_NAME_STATIC})
set_target_properties(${PROJECT_LIB_NAME_STATIC} PROPERTIES VERSION ${cassandra_VERSION_STRING} SOVERSION ${cassandra_VERSION_MAJOR})
set_target_properties(${PROJECT_LIB_NAME_STATIC} PROPERTIES VERSION ${PROJECT_VERSION_STRING} SOVERSION ${PROJECT_VERSION_MAJOR})

set(PROJECT_COMPILER_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_DEPENDENT_COMPILER_OPTIONS}")

#set_property(
# TARGET ${PROJECT_LIB_NAME}
# APPEND PROPERTY COMPILE_FLAGS ${PROJECT_COMPILER_FLAGS})
set_property(
TARGET ${PROJECT_LIB_NAME}
APPEND PROPERTY COMPILE_FLAGS ${PROJECT_COMPILER_FLAGS})

set_property(
TARGET ${PROJECT_LIB_NAME_STATIC}
Expand All @@ -206,23 +180,26 @@ set_property(
# install target
#-------------------

file(GLOB INSTALL_HEADERS "${PROJECT_INCLUDE_DIR}/cql/*.hpp")

# Where to put headers
set(INSTALL_HEADERS_DIR "${CMAKE_INSTALL_PREFIX}/include/cql")
install(FILES ${INSTALL_HEADERS} DESTINATION "${INSTALL_HEADERS_DIR}")
install(FILES ${INC_FILES} DESTINATION "${INSTALL_HEADERS_DIR}")
install(FILES ${INC_FILES_EXCEPTIONS} DESTINATION "${INSTALL_HEADERS_DIR}/exceptions")
install(FILES ${INC_FILES_POLICIES} DESTINATION "${INSTALL_HEADERS_DIR}/policies")

# Where to put libraries
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
# For windows only
set(INSTALL_DLL_DIR "${CMAKE_INSTALL_PREFIX}/bin")

#install(TARGETS ${PROJECT_LIB_NAME_STATIC} ${PROJECT_LIB_NAME}
install(TARGETS ${PROJECT_LIB_NAME_STATIC}
RUNTIME DESTINATION ${INSTALL_DLL_DIR} # for dll files
LIBRARY DESTINATION ${INSTALL_LIB_DIR} # for shared library
ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) # for static library
install(TARGETS ${PROJECT_LIB_NAME}
RUNTIME DESTINATION ${INSTALL_DLL_DIR} # for dll files
LIBRARY DESTINATION ${INSTALL_LIB_DIR} # for shared library
ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) # for static library

install(TARGETS ${PROJECT_LIB_NAME_STATIC}
RUNTIME DESTINATION ${INSTALL_DLL_DIR} # for dll files
LIBRARY DESTINATION ${INSTALL_LIB_DIR} # for shared library
ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) # for static library

#-------------------
# uninstall target
Expand All @@ -236,23 +213,14 @@ configure_file(
add_custom_target(UNINSTALL
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)


#-------------------
# Boost unit tests
#-------------------

add_subdirectory(extra/ccm_bridge)
add_subdirectory(test/unit_tests)
# add_subdirectory(extra/ccm_bridge)
# add_subdirectory(test/unit_tests)

#-------------------
# the demo program
#-------------------

add_subdirectory(demo)

#-------------------
# test libcds
#-------------------

# Exclude demo from CMAKE build system
# add_subdirectory(test/libcds_demo)
Binary file removed Demo_cql
Binary file not shown.
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,41 +55,39 @@ In addition to the sample code below there is a fully functional [demo](https://
#include <cql/cql_cluster.hpp>
#include <cql/cql_builder.hpp>
#include <cql/cql_result.hpp>
#include <cds/gc/hp.h>

int
main(int argc, char**)
{
using namespace cql;
using boost::shared_ptr;
// Boilerplate: initialize cql with 512 hazard pointers.
cql_initialize(512);

// initialize cql
cql_initialize();
cql_thread_infrastructure_t cql_ti;

// Suppose you have the Cassandra cluster at 127.0.0.1,
// listening at default port (9042).
shared_ptr<cql::cql_builder_t> builder = cql::cql_cluster_t::builder();
builder->add_contact_point(boost::asio::ip::address::from_string("127.0.0.1"));

// Now build a model of cluster and connect it to DB.
shared_ptr<cql::cql_cluster_t> cluster(builder->build());
shared_ptr<cql::cql_session_t> session(cluster->connect());

// Write a query, switch keyspaces.
shared_ptr<cql::cql_query_t> my_first_query(new cql::cql_query_t("SELECT * FROM system.schema_keyspaces;"));

// Send the query.
boost::shared_future<cql::cql_future_result_t> future = session->query(my_first_query);

// Wait for the query to execute; retrieve the result.
future.wait();
shared_ptr<cql_result_t> result = future.get().result;

// Boilerplate: close the connection session and perform the cleanup.
session->close();
cluster->shutdown();
cds::gc::HP::force_dispose();
return 0;
}
```
Expand All @@ -111,4 +109,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Loading