From 658f12f4bb8c1e0847db6de6a2768ccce51e2ff1 Mon Sep 17 00:00:00 2001 From: Severin Leonhardt Date: Fri, 16 Jun 2023 08:55:06 +0200 Subject: [PATCH 1/3] Place generated driver_config.hpp in build dir It's best practice to not modify the source during a build so a single source folder can be used to build multiple variations. Especially with WSL on Windows this makes it very easy to verify code changes work even across platforms. --- src/CMakeLists.txt | 3 ++- tests/CMakeLists.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 46be79ccd..64ac48e38 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -129,7 +129,8 @@ set(HAVE_ZLIB ${CASS_USE_ZLIB}) # Generate the driver_config.hpp file configure_file( ${CASS_ROOT_DIR}/driver_config.hpp.in - ${CMAKE_CURRENT_SOURCE_DIR}/driver_config.hpp) + ${CMAKE_CURRENT_BINARY_DIR}/generated/driver_config.hpp) +list(APPEND INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/generated) #------------------------------ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1c0c44f47..3a14ee26a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -48,6 +48,7 @@ include_directories(${CASS_ROOT_DIR}/tests/src/vendor) include_directories(${CASS_INCLUDE_DIR}) include_directories(${CASS_SRC_DIR}) include_directories(${CASS_SRC_DIR}/third_party/sparsehash/src) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src/generated) set(GOOGLE_TEST_DIR ${CASS_ROOT_DIR}/tests/src/vendor/gtest) set(GOOGLE_TEST_HEADER_FILES "${GOOGLE_TEST_DIR}/gtest.h") From c3c600058a019c83c6cc603e45f012f99c341afc Mon Sep 17 00:00:00 2001 From: Severin Leonhardt Date: Fri, 16 Jun 2023 09:16:33 +0200 Subject: [PATCH 2/3] Rename static library target Building the unit tests on Windows failed at the linking stage: LINK : fatal error LNK1104: cannot open file 'scylla-cpp-driver_static.lib' This is caused by the tests being forced to use the static library on Windows but link against `${PROJECT_LIB_NAME_TARGET}` which is set to `scylla-cpp-driver_static` in the main `CMakeLists.txt` while the target was actually still called `cassandra_static`. Renamed the static library target to be consistent with the dynamic library target and `${PROJECT_LIB_NAME_TARGET}` so the tests can be successfully linked on Windows. --- src/CMakeLists.txt | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 64ac48e38..cc74dc34f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -175,39 +175,39 @@ if(CASS_BUILD_SHARED) endif() if(CASS_BUILD_STATIC) - add_library(cassandra_static STATIC + add_library(scylla-cpp-driver_static STATIC ${SOURCES} $ $ $ $) - target_link_libraries(cassandra_static ${CASS_LIBS}) - target_include_directories(cassandra_static PRIVATE ${INCLUDE_DIRS} ${CASS_INCLUDES}) + target_link_libraries(scylla-cpp-driver_static ${CASS_LIBS}) + target_include_directories(scylla-cpp-driver_static PRIVATE ${INCLUDE_DIRS} ${CASS_INCLUDES}) - set_target_properties(cassandra_static PROPERTIES OUTPUT_NAME scylla-cpp-driver_static) - set_target_properties(cassandra_static PROPERTIES VERSION ${PROJECT_VERSION_STRING} SOVERSION ${PROJECT_VERSION_MAJOR}) - set_target_properties(cassandra_static PROPERTIES - COMPILE_PDB_NAME "cassandra_static" + set_target_properties(scylla-cpp-driver_static PROPERTIES OUTPUT_NAME scylla-cpp-driver_static) + set_target_properties(scylla-cpp-driver_static PROPERTIES VERSION ${PROJECT_VERSION_STRING} SOVERSION ${PROJECT_VERSION_MAJOR}) + set_target_properties(scylla-cpp-driver_static PROPERTIES + COMPILE_PDB_NAME "scylla-cpp-driver_static" COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - set_target_properties(cassandra_static PROPERTIES + set_target_properties(scylla-cpp-driver_static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - set_target_properties(cassandra_static PROPERTIES FOLDER "Driver") + set_target_properties(scylla-cpp-driver_static PROPERTIES FOLDER "Driver") - target_compile_definitions(cassandra_static PRIVATE CASS_STATIC) + target_compile_definitions(scylla-cpp-driver_static PRIVATE CASS_STATIC) if(CASS_USE_BOOST_ATOMIC AND BOOST_LIBRARY_NAME) - add_dependencies(cassandra_static ${BOOST_LIBRARY_NAME}) + add_dependencies(scylla-cpp-driver_static ${BOOST_LIBRARY_NAME}) endif() if(LIBUV_LIBRARY_NAME) - add_dependencies(cassandra_static ${LIBUV_LIBRARY_NAME}) + add_dependencies(scylla-cpp-driver_static ${LIBUV_LIBRARY_NAME}) endif() if(OPENSSL_LIBRARY_NAME) - add_dependencies(cassandra_static ${OPENSSL_LIBRARY_NAME}) + add_dependencies(scylla-cpp-driver_static ${OPENSSL_LIBRARY_NAME}) endif() if(ZLIB_LIBRARY_NAME) - add_dependencies(cassandra_static ${ZLIB_LIBRARY_NAME}) + add_dependencies(scylla-cpp-driver_static ${ZLIB_LIBRARY_NAME}) endif() endif() @@ -293,7 +293,7 @@ if(CASS_BUILD_SHARED) endif() if(CASS_BUILD_STATIC) - install(TARGETS cassandra_static + install(TARGETS scylla-cpp-driver_static RUNTIME DESTINATION ${INSTALL_DLL_EXE_DIR} # for dll/executable/pdb files LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # for shared library ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) # for static library From dfcc5049694077ae92f93582624f5703e60b4d76 Mon Sep 17 00:00:00 2001 From: Severin Leonhardt Date: Fri, 16 Jun 2023 09:48:35 +0200 Subject: [PATCH 3/3] Fix failing ProtocolVersionUnitTest The test failed with: tests/src/unit/tests/test_protocol_version.cpp:33: Failure Expected: ProtocolVersion(CASS_PROTOCOL_VERSION_DSEV2) Which is: 4-byte object <42-00 00-00> To be equal to: ProtocolVersion::highest_supported() Which is: 4-byte object <04-00 00-00> This most likely broke with 9d37d1b23d7c19c41715f5fa24886aee48e11207 where the default value of the parameter changed. Changed the expected value to match what the function now returns since the mentioned commit looks like it intentionally changed that value. --- tests/src/unit/tests/test_protocol_version.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/unit/tests/test_protocol_version.cpp b/tests/src/unit/tests/test_protocol_version.cpp index 4d2e2ce6e..08cab2918 100644 --- a/tests/src/unit/tests/test_protocol_version.cpp +++ b/tests/src/unit/tests/test_protocol_version.cpp @@ -30,7 +30,7 @@ TEST_F(ProtocolVersionUnitTest, LowestSupported) { } TEST_F(ProtocolVersionUnitTest, HighestSupported) { - EXPECT_EQ(ProtocolVersion(CASS_PROTOCOL_VERSION_DSEV2), ProtocolVersion::highest_supported()); + EXPECT_EQ(ProtocolVersion(CASS_PROTOCOL_VERSION_V4), ProtocolVersion::highest_supported()); } TEST_F(ProtocolVersionUnitTest, NewestBeta) {