From d0272276e700eef24e54b4dddfce47138064f920 Mon Sep 17 00:00:00 2001 From: Michael Fero Date: Thu, 18 Sep 2014 07:01:33 -0700 Subject: [PATCH] - Updated CMake configuration + Add preprocessor definition to ensure Boost does not use rvalue references (this allows the integration tests to build without c++11). + Added a check to validate CMAKE_CXX_COMPILER_VERSION variable existence and added a workaround to get the compiler version from gcc (CMAKE_CXX_COMPILER variables were not added until 2.8.x) + Ensured the LIBUV_INCLUDE_DIR discovered by the parent was used for the unit tests (fixes unit test build) - Changed INT64_MAX/MIN to use c++ numeric limits - Updating TavisCI configuration + Install libssh2 and build Boost v1.55 from source + Build tests and run unit tests (increases build status information) NOTE: CMake configuration needs some more TLC to work properly on CentOS5. The LIBSSH2 package available by the default yum repositories is v1.0.0 and method calls used by the integration tests were not available until v1.2.5. CMake configuration should check for LIBSSH2_ROOT_DIR similar to LIBUV_ROOT_DIR. --- .gitignore | 1 + .travis.yml | 13 +++++++++---- CMakeLists.txt | 8 +++++++- test/integration_tests/src/prepared.cpp | 4 ++-- test/unit_tests/CMakeLists.txt | 1 + 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 5b329a245..c54ad97ce 100644 --- a/.gitignore +++ b/.gitignore @@ -73,6 +73,7 @@ lib/libuv/include/** !lib/libuv/include/README lib/libuv/lib/** !lib/libuv/lib/README +boost_1_* config*.txt diff --git a/.travis.yml b/.travis.yml index 15d9c2db8..bcc72af1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,15 @@ language: c++ compiler: gcc before_install: - sudo apt-get update -qq - - sudo apt-get install libssl-dev -qq - - wget http://libuv.org/dist/v0.10.28/libuv-v0.10.28.tar.gz + - sudo apt-get install libssl-dev libssh2-1-dev -qq + - wget -q http://libuv.org/dist/v0.10.28/libuv-v0.10.28.tar.gz + - wget -q http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz/download -O boost_1_55_0.tar.gz install: - tar xzf libuv-v0.10.28.tar.gz - - cd libuv-v0.10.28 && make && cd - && cp -r libuv-v0.10.28/libuv.a libuv-v0.10.28/libuv.so lib/libuv/lib && cp -r libuv-v0.10.28/include/* lib/libuv/include + - cd libuv-v0.10.28 && make && cd - && cp -r libuv-v0.10.28/libuv.a libuv-v0.10.28/libuv.so lib/libuv/lib && ln -s lib/libuv/lib/libuv.so lib/libuv/lib/libuv.so.0.10 && cp -r libuv-v0.10.28/include/* lib/libuv/include + - tar xzf boost_1_55_0.tar.gz + - cd boost_1_55_0 && ./bootstrap.sh --with-libraries=chrono,date_time,log,program_options,system,thread,test && sudo ./b2 install --prefix=/usr && cd - before_script: cmake -DLIBUV_ROOT_DIR=lib/libuv/ . -script: make +script: + - make + - test/unit_tests/cassandra_unit_tests diff --git a/CMakeLists.txt b/CMakeLists.txt index a803c2cc7..f4cbad228 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,7 +93,7 @@ endif() set(MULTICORE_CORES_NUMBER "3" CACHE STRING "Number of cores (for multicore compilation)") option(MULTICORE_COMPILATION "Enable multicore compilation" OFF) -set(TEST_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_THREAD_USES_MOVE") +set(TEST_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_THREAD_USES_MOVE -DBOOST_NO_CXX11_RVALUE_REFERENCES") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") if(MULTICORE_COMPILATION) @@ -125,6 +125,12 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_definitions(-DBOOST_ALL_NO_LIB) add_definitions(-DNOMINMAX) elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + # CMAKE_CXX_COMPILER variables do not exist in 2.6.4 (min version) + # Parse the -dumpversion argument into the variable not already set + if ("${CMAKE_CXX_COMPILER_VERSION}" STREQUAL "") + execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION) + endif() + # GCC specific compiler options # I disabled long-long warning because boost generates about 50 such warnings set(WARNING_COMPILER_FLAGS "-Wall -pedantic -Wextra -Werror -Wno-long-long -Wno-deprecated-declarations -Wno-unused-parameter") diff --git a/test/integration_tests/src/prepared.cpp b/test/integration_tests/src/prepared.cpp index 668c5328d..015e996a9 100644 --- a/test/integration_tests/src/prepared.cpp +++ b/test/integration_tests/src/prepared.cpp @@ -180,7 +180,7 @@ BOOST_AUTO_TEST_CASE(test_bound_all_types_different_values) all_types[0].id = test_utils::generate_time_uuid(); all_types[0].text_sample = cass_string_init("first"); all_types[0].int_sample = 10; - all_types[0].bigint_sample = INT64_MAX - 1L; + all_types[0].bigint_sample = std::numeric_limits::max() - 1L; all_types[0].float_sample = 1.999f; all_types[0].double_sample = 32.002; all_types[0].decimal_sample = cass_decimal_init(1, cass_bytes_init(varint1, sizeof(varint1))); @@ -204,7 +204,7 @@ BOOST_AUTO_TEST_CASE(test_bound_all_types_different_values) all_types[2].id = test_utils::generate_time_uuid(); all_types[2].text_sample = cass_string_init("third"); all_types[2].int_sample = -100; - all_types[2].bigint_sample = INT64_MIN + 1; + all_types[2].bigint_sample = std::numeric_limits::min() + 1; all_types[2].float_sample = -150.111f; all_types[2].double_sample = -5.12342; all_types[2].decimal_sample = cass_decimal_init(3, cass_bytes_init(varint3, sizeof(varint3))); diff --git a/test/unit_tests/CMakeLists.txt b/test/unit_tests/CMakeLists.txt index 69bc62838..65b5b0789 100644 --- a/test/unit_tests/CMakeLists.txt +++ b/test/unit_tests/CMakeLists.txt @@ -30,6 +30,7 @@ file(GLOB UNIT_TESTS_SRC_FILES ${PROJECT_SOURCE_DIR}/test/unit_tests/src/*.cpp) set(INCLUDES ${PROJECT_INCLUDE_DIR}) set(INCLUDES ${INCLUDES} "${PROJECT_SOURCE_DIR}/src") set(INCLUDES ${INCLUDES} ${Boost_INCLUDE_DIRS}) +set(INCLUDES ${INCLUDES} ${LIBUV_INCLUDE_DIR}) # Create source groups - this is only needed to create # neat folder structure in Visual Studio...