@@ -13,6 +13,11 @@ if(POLICY CMP0042)
1313 cmake_policy (SET CMP0042 OLD)
1414endif ()
1515
16+ # Force OLD style of implicitly dereferencing variables
17+ if (POLICY CMP0054)
18+ cmake_policy (SET CMP0054 OLD)
19+ endif ()
20+
1621# Title the project and define the versioning
1722project (${PROJECT_NAME_STR} C CXX)
1823
@@ -60,6 +65,8 @@ option(CASS_BUILD_STATIC "Build static library" OFF)
6065option (CASS_BUILD_EXAMPLES "Build examples" OFF )
6166option (CASS_BUILD_DOCS "Build documentation" OFF )
6267option (CASS_BUILD_TESTS "Build tests" OFF )
68+ option (CASS_BUILD_INTEGRATION_TESTS "Build integration tests" OFF )
69+ option (CASS_BUILD_UNIT_TESTS "Build unit tests" OFF )
6370option (CASS_INSTALL_HEADER "Install header file" ON )
6471option (CASS_MULTICORE_COMPILATION "Enable multicore compilation" OFF )
6572option (CASS_USE_STATIC_LIBS "Link static libraries when building executables" OFF )
@@ -69,8 +76,18 @@ option(CASS_USE_OPENSSL "Use OpenSSL" ON)
6976option (CASS_USE_TCMALLOC "Use tcmalloc" OFF )
7077option (CASS_USE_SPARSEHASH "Use sparsehash" OFF )
7178option (CASS_USE_ZLIB "Use zlib" OFF )
79+ option (CASS_USE_LIBSSH2 "Use libssh2 for integration tests" ON )
7280
81+ # Handle testing dependencies
7382if (CASS_BUILD_TESTS)
83+ # Enable integration and unit tests for backwards compatibility
84+ set (CASS_BUILD_INTEGRATION_TESTS ON )
85+ set (CASS_BUILD_UNIT_TESTS ON )
86+ endif ()
87+ if (CASS_BUILD_INTEGRATION_TESTS)
88+ set (CASS_USE_OPENSSL ON ) # Required for integration tests
89+ endif ()
90+ if (CASS_BUILD_UNIT_TESTS)
7491 set (CASS_BUILD_STATIC ON ) # Required for unit tests
7592endif ()
7693
@@ -142,7 +159,7 @@ set(CASS_LIBS ${CASS_LIBS} ${LIBUV_LIBRARY})
142159#------------------------
143160
144161# Boost
145- if (CASS_USE_BOOST_ATOMIC OR CASS_BUILD_TESTS )
162+ if (CASS_USE_BOOST_ATOMIC OR CASS_BUILD_INTEGRATION_TESTS OR CASS_BUILD_UNIT_TESTS )
146163 # Allow for boost directory to be specified on the command line
147164 set (ENV{BOOST_ROOT} "${PROJECT_SOURCE_DIR} /lib/boost/" )
148165 if (BOOST_ROOT_DIR)
@@ -178,7 +195,7 @@ if(CASS_USE_BOOST_ATOMIC OR CASS_BUILD_TESTS)
178195 endif ()
179196
180197 # Ensure unit and integration test boost components exist
181- if (CASS_BUILD_TESTS )
198+ if (CASS_BUILD_UNIT_TESTS OR CASS_BUILD_INTEGRATION_TESTS )
182199 find_package (Boost ${CASS_MINIMUM_BOOST_VERSION} COMPONENTS chrono date_time filesystem log log_setup system regex thread unit_test_framework)
183200 if (NOT Boost_FOUND)
184201 message (FATAL_ERROR "Boost [chrono, date_time, filesystem, log, log_setup, system, regex, thread, and unit_test_framework] are required to build tests" )
@@ -295,21 +312,24 @@ endif()
295312#--------------------
296313
297314# libssh2
298- if (CASS_BUILD_TESTS)
299- # Setup the root directory for libssh2
300- set (LIBSSH2_ROOT "${PROJECT_SOURCE_DIR} /lib/libssh2/" $ENV{LIBSSH2_ROOT} )
301- set (LIBSSH2_ROOT ${LIBSSH2_ROOT} ${LIBSSH2_ROOT_DIR} $ENV{LIBSSH2_ROOT_DIR} )
302-
303- # Discover libssh2
304- find_package (LIBSSH2 REQUIRED)
305- if (NOT LIBSSH2_FOUND)
306- message (FATAL_ERROR "libssh2 are required to build tests" )
307- endif ()
308-
309- # Assign test libraries (additional boost and libssh2 dependencies)
310- set (CASS_TEST_LIBS ${Boost_LIBRARIES} ${LIBSSH2_LIBRARIES} )
311- if (UNIX )
312- set (CASS_TEST_LIBS ${CASS_TEST_LIBS} pthread)
315+ if (CASS_BUILD_INTEGRATION_TESTS)
316+ if (CASS_USE_LIBSSH2)
317+ # Setup the root directory for libssh2
318+ set (LIBSSH2_ROOT "${PROJECT_SOURCE_DIR} /lib/libssh2/" $ENV{LIBSSH2_ROOT} )
319+ set (LIBSSH2_ROOT ${LIBSSH2_ROOT} ${LIBSSH2_ROOT_DIR} $ENV{LIBSSH2_ROOT_DIR} )
320+
321+ # Discover libssh2
322+ find_package (LIBSSH2 QUIET )
323+ if (LIBSSH2_FOUND)
324+ # Assign test libraries (additional boost and libssh2 dependencies)
325+ set (CASS_TEST_LIBS ${Boost_LIBRARIES} ${LIBSSH2_LIBRARIES} )
326+ if (UNIX )
327+ set (CASS_TEST_LIBS ${CASS_TEST_LIBS} pthread)
328+ endif ()
329+ add_definitions (-DCASS_USE_LIBSSH2)
330+ else ()
331+ message (STATUS "libssh2 is Unavailable: Building integration tests without libssh2 support" )
332+ endif ()
313333 endif ()
314334endif ()
315335
@@ -400,8 +420,8 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
400420 string (REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
401421
402422 # Create specific linker flags
423+ set (WINDOWS_LINKER_FLAGS "/INCREMENTAL:NO /LTCG /NODEFAULTLIB:LIBCMT.LIB /NODEFAULTLIB:LIBCMTD.LIB" )
403424 if (CASS_USE_STATIC_LIBS)
404- set (WINDOWS_LINKER_FLAGS "/INCREMENTAL:NO /LTCG /NODEFAULTLIB:LIBCMT.LIB /NODEFAULTLIB:LIBCMTD.LIB" )
405425 set (PROJECT_CXX_LINKER_FLAGS "${WINDOWS_LINKER_FLAGS} " )
406426 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WINDOWS_LINKER_FLAGS} " )
407427 endif ()
@@ -631,10 +651,11 @@ set(INSTALL_DLL_EXE_DIR "bin")
631651#-----------------------------
632652
633653# Add the unit and integration tests to the build process
634- if (CASS_BUILD_TESTS )
654+ if (CASS_BUILD_UNIT_TESTS )
635655 # Add the unit test project
636656 add_subdirectory (test /unit_tests)
637-
657+ endif ()
658+ if (CASS_BUILD_INTEGRATION_TESTS)
638659 # Add CCM bridge as a dependency for integration tests
639660 add_subdirectory ("${PROJECT_SOURCE_DIR} /test/ccm_bridge" )
640661 set (CCM_BRIDGE_INCLUDES "${PROJECT_SOURCE_DIR} /test/ccm_bridge/src" )
0 commit comments