From e6d01ea1c8d5365024499830bd8d85b4b5309a12 Mon Sep 17 00:00:00 2001 From: Sergey Avseyev Date: Mon, 13 Jan 2025 13:37:33 -0800 Subject: [PATCH] CXXCBC-639: Allow to build both static and shared libraries To avoid issues with generation of cmake helper scripts the following changes has been made: * interface libraries that are used to carry compiler options and flags are declared as IMPORTED to avoid unnecessary INTERFACE_LINK dependencies for the static library * jsonsl, asio and couchbase_backtrace libraries are not linked as a targets, but rather as a object files directly. This is also done to avoid announcing them as a transitive dependencies. All these libraries are hidden and never exposed. * for other third-party dependencies do not disable install tasks, which generate export files This patch also removes some unused cmake files (of crypto, sasl and operations/management directories). Fixes #701 --- CMakeLists.txt | 26 ++-- bin/build_boringssl | 55 -------- bin/build_boringssl_win.bat | 122 ------------------ cmake/APKBUILD.in | 6 +- cmake/OpenSSL.cmake | 3 +- cmake/Packaging.cmake | 11 +- cmake/Testing.cmake | 147 ++++++++++------------ cmake/ThirdPartyDependencies.cmake | 22 ++-- cmake/couchbase-cxx-client.spec.in | 3 +- cmake/debian/rules | 4 +- cmake/test_boringssl.cxx | 7 -- core/crypto/CMakeLists.txt | 21 ---- core/operations/management/CMakeLists.txt | 80 ------------ core/sasl/CMakeLists.txt | 16 --- test/CMakeLists.txt | 8 +- 15 files changed, 111 insertions(+), 420 deletions(-) delete mode 100755 bin/build_boringssl delete mode 100644 bin/build_boringssl_win.bat delete mode 100644 cmake/test_boringssl.cxx delete mode 100644 core/crypto/CMakeLists.txt delete mode 100644 core/operations/management/CMakeLists.txt delete mode 100644 core/sasl/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index ee3a26854..cec4ce8c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,14 +35,14 @@ include(cmake/PreventInSourceBuilds.cmake) include(cmake/StandardProjectSettings.cmake) # 'library' to set the c++ standard / compile-time options requested -add_library(project_options INTERFACE) +add_library(project_options INTERFACE IMPORTED) target_compile_features(project_options INTERFACE cxx_std_17) if(MSVC) target_compile_options(project_options INTERFACE /bigobj) endif() # 'library' to use the warnings specified in CompilerWarnings.cmake -add_library(project_warnings INTERFACE) +add_library(project_warnings INTERFACE IMPORTED) include(cmake/BuildTracing.cmake) @@ -72,8 +72,6 @@ find_package(Threads REQUIRED) include(cmake/ThirdPartyDependencies.cmake) -include(cmake/OpenSSL.cmake) - include(cmake/VersionInfo.cmake) include(cmake/RPath.cmake) @@ -505,8 +503,11 @@ foreach(TARGET ${couchbase_cxx_client_LIBRARIES}) $>) target_include_directories( - ${TARGET} SYSTEM PRIVATE $ - $) + ${TARGET} SYSTEM + PRIVATE $ + $ + $> + $>) target_include_directories(${TARGET} PUBLIC $) @@ -517,13 +518,13 @@ foreach(TARGET ${couchbase_cxx_client_LIBRARIES}) project_warnings spdlog::spdlog Microsoft.GSL::GSL - asio llhttp::llhttp taocpp::json snappy - jsonsl - couchbase_backtrace - hdr_histogram_static) + hdr_histogram_static + $ + $ + $) if(WIN32) target_link_libraries(${TARGET} PRIVATE iphlpapi) @@ -542,7 +543,10 @@ foreach(TARGET ${couchbase_cxx_client_LIBRARIES}) if(MINGW) target_link_libraries(${TARGET} PUBLIC ws2_32) endif() - target_link_libraries(${TARGET} PRIVATE OpenSSL::SSL OpenSSL::Crypto) + target_link_libraries(${TARGET} PUBLIC $ $) + target_include_directories( + ${TARGET} SYSTEM PRIVATE $> + $>) else() if(TARGET PkgConfig::PKG_CONFIG_OPENSSL) target_link_libraries(${TARGET} PUBLIC PkgConfig::PKG_CONFIG_OPENSSL) diff --git a/bin/build_boringssl b/bin/build_boringssl deleted file mode 100755 index edc0da731..000000000 --- a/bin/build_boringssl +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash - -set -xe - -BORINGSSL_SRC_DIR=$1 -BORINGSSL_BUILD_DIR=$2 -BORINGSSL_OUTPUT_DIR=$3 -BORINGSSL_PREFIX=$4 -BORINGSSL_CMAKE_EXE="$5" -BORINGSSL_CMAKE_GENERATOR="$6" -BORINGSSL_CMAKE_OPTIONS="$7" -BORINGSSL_LIB_DIR=$BORINGSSL_OUTPUT_DIR/lib -BORINGSSL_INCLUDE_DIR=$BORINGSSL_OUTPUT_DIR/include - -cd $BORINGSSL_SRC_DIR - -echo "Starting initial build phase." -$BORINGSSL_CMAKE_EXE \ - -G"${BORINGSSL_CMAKE_GENERATOR}" \ - -S$BORINGSSL_SRC_DIR \ - -B$BORINGSSL_BUILD_DIR \ - ${BORINGSSL_CMAKE_OPTIONS} -$BORINGSSL_CMAKE_EXE --build $BORINGSSL_BUILD_DIR --verbose --target crypto ssl - -cd $BORINGSSL_BUILD_DIR -[ -f ssl/libssl.a ] || { echo "Failed to build libssl.a" ; exit 1 ; } -[ -f crypto/libcrypto.a ] || { echo "Failed to build libcrypto.a" ; exit 1 ; } - -if [ -n "$BORINGSSL_PREFIX" ]; then - cd $BORINGSSL_SRC_DIR/util - go run read_symbols.go $BORINGSSL_BUILD_DIR/ssl/libssl.a > $BORINGSSL_OUTPUT_DIR/symbols.txt - go run read_symbols.go $BORINGSSL_BUILD_DIR/crypto/libcrypto.a >> $BORINGSSL_OUTPUT_DIR/symbols.txt - - rm -rf $BORINGSSL_BUILD_DIR - - echo "Starting build phase with symbol prefixing." - $BORINGSSL_CMAKE_EXE \ - -G"${BORINGSSL_CMAKE_GENERATOR}" \ - -S$BORINGSSL_SRC_DIR \ - -B$BORINGSSL_BUILD_DIR \ - -DBORINGSSL_PREFIX=$BORINGSSL_PREFIX \ - -DBORINGSSL_PREFIX_SYMBOLS=$BORINGSSL_OUTPUT_DIR/symbols.txt \ - ${BORINGSSL_CMAKE_OPTIONS} - $BORINGSSL_CMAKE_EXE --build $BORINGSSL_BUILD_DIR --verbose --target crypto ssl - cd $BORINGSSL_BUILD_DIR - [ -f symbol_prefix_include/boringssl_prefix_symbols.h ] || { echo "Failed to build boringssl_prefix_symbols.h" ; exit 1 ; } - - cp symbol_prefix_include/boringssl_prefix_symbols.h $BORINGSSL_INCLUDE_DIR -fi - -cp ssl/libssl.a $BORINGSSL_LIB_DIR -cp crypto/libcrypto.a $BORINGSSL_LIB_DIR -cp -r $BORINGSSL_SRC_DIR/include/openssl $BORINGSSL_INCLUDE_DIR - -echo "Done. Libs saved in: $BORINGSSL_LIB_DIR, headers saved in: $BORINGSSL_INCLUDE_DIR" diff --git a/bin/build_boringssl_win.bat b/bin/build_boringssl_win.bat deleted file mode 100644 index 7bfc5deee..000000000 --- a/bin/build_boringssl_win.bat +++ /dev/null @@ -1,122 +0,0 @@ -set BORINGSSL_SRC_DIR=%~1 -set BORINGSSL_BUILD_DIR=%~2 -set BORINGSSL_OUTPUT_DIR=%~3 -set BORINGSSL_PREFIX=%~4 -set LIB_CRYPTO=%~5 -set LIB_SSL=%~6 -set BORINGSSL_CMAKE_EXE=%7 -set BORINGSSL_CMAKE_GENERATOR=%8 -set BORINGSSL_CMAKE_BUILD_TYPE=%9 -shift -set BORINGSSL_CMAKE_OPTIONS=%~9 - -rem Normalize all paths by replacing Unix '/' with Windows '\'. -rem Also all quotes removed from the arguments, so all paths must be quoted below. - -set BORINGSSL_SRC_DIR=%BORINGSSL_SRC_DIR:/=\% -set BORINGSSL_BUILD_DIR=%BORINGSSL_BUILD_DIR:/=\% -set BORINGSSL_OUTPUT_DIR=%BORINGSSL_OUTPUT_DIR:/=\% -set BORINGSSL_PREFIX=%BORINGSSL_PREFIX:/=\% -set LIB_CRYPTO=%LIB_CRYPTO:/=\% -set LIB_SSL=%LIB_SSL:/=\% -set BORINGSSL_LIB_DIR=%BORINGSSL_OUTPUT_DIR%\lib -set BORINGSSL_INCLUDE_DIR=%BORINGSSL_OUTPUT_DIR%\include - -cd %BORINGSSL_SRC_DIR% - -@echo "Starting initial build phase." - -%BORINGSSL_CMAKE_EXE% ^ - -G %BORINGSSL_CMAKE_GENERATOR% ^ - -S "%BORINGSSL_SRC_DIR%" ^ - -B "%BORINGSSL_BUILD_DIR%" ^ - -D CMAKE_BUILD_TYPE=%BORINGSSL_CMAKE_BUILD_TYPE% ^ - %BORINGSSL_CMAKE_OPTIONS% - -%BORINGSSL_CMAKE_EXE% ^ - --build "%BORINGSSL_BUILD_DIR%" ^ - --config=%BORINGSSL_CMAKE_BUILD_TYPE% ^ - --verbose ^ - --target crypto ssl - -cd "%BORINGSSL_BUILD_DIR%" -if not exist "%BORINGSSL_BUILD_DIR%\ssl\%LIB_SSL%" ( - @echo "Failed to build %LIB_SSL%" - exit 1 -) -if not exist "%BORINGSSL_BUILD_DIR%\crypto\%LIB_CRYPTO%" ( - @echo "Failed to build %LIB_CRYPTO%" - exit 1 -) - -if [%BORINGSSL_PREFIX%] NEQ [] ( - cd "%BORINGSSL_SRC_DIR%\util" - > "%BORINGSSL_OUTPUT_DIR%\symbols.txt" ( - go run read_symbols.go "%BORINGSSL_BUILD_DIR%\ssl\%LIB_SSL%" - go run read_symbols.go "%BORINGSSL_BUILD_DIR%\crypto\%LIB_CRYPTO%" - ) - - setlocal enableextensions enabledelayedexpansion - REM space delimited array of symbols to EXCLUDE - set skipSymbols=snprintf - set keepSymbols[0]= - set /a kIdx=0 - for /F "usebackq tokens=*" %%s in ("%BORINGSSL_OUTPUT_DIR%\symbols.txt") do ( - set found= - for %%k in (%skipSymbols%) do ( - if %%k==%%s ( - set found=y - ) - ) - if not defined found ( - set keepSymbols[!kIdx!]=%%s - set /A kIdx+=1 - ) - ) - set /a end=%kIdx%-1 - - for /L %%i in (0,1,%end%) do ( - if %%i equ 0 ( - echo !keepSymbols[%%i]! > "%BORINGSSL_OUTPUT_DIR%\symbols_parsed.txt" - ) else ( - echo !keepSymbols[%%i]! >> "%BORINGSSL_OUTPUT_DIR%\symbols_parsed.txt" - ) - ) - endlocal - - if exist "%BORINGSSL_OUTPUT_DIR%\symbols_parsed.txt" ( - move "%BORINGSSL_OUTPUT_DIR%\symbols_parsed.txt" "%BORINGSSL_OUTPUT_DIR%\symbols.txt" - ) - - rd /S /Q "%BORINGSSL_BUILD_DIR%" - - @echo "Starting build phase with symbol prefixing." - %BORINGSSL_CMAKE_EXE% ^ - -G %BORINGSSL_CMAKE_GENERATOR% ^ - -S "%BORINGSSL_SRC_DIR%" ^ - -B "%BORINGSSL_BUILD_DIR%" ^ - -DBORINGSSL_PREFIX=%BORINGSSL_PREFIX% ^ - -DBORINGSSL_PREFIX_SYMBOLS="%BORINGSSL_OUTPUT_DIR%/symbols.txt" ^ - %BORINGSSL_CMAKE_OPTIONS% - %BORINGSSL_CMAKE_EXE% ^ - --build "%BORINGSSL_BUILD_DIR%" ^ - --config=%BORINGSSL_CMAKE_BUILD_TYPE% ^ - --verbose ^ - --target crypto ssl - cd "%BORINGSSL_BUILD_DIR%" - if not exist "%BORINGSSL_BUILD_DIR%\symbol_prefix_include\boringssl_prefix_symbols.h" ( - @echo "Failed to build boringssl_prefix_symbols.h" - exit 1 - ) - - copy "%BORINGSSL_BUILD_DIR%\symbol_prefix_include\boringssl_prefix_symbols.h" ^ - "%BORINGSSL_INCLUDE_DIR%" -) - -copy "%BORINGSSL_BUILD_DIR%\ssl\%LIB_SSL%" "%BORINGSSL_LIB_DIR%" -copy "%BORINGSSL_BUILD_DIR%\crypto\%LIB_CRYPTO%" "%BORINGSSL_LIB_DIR%" -robocopy "%BORINGSSL_SRC_DIR%\include\openssl" ^ - "%BORINGSSL_INCLUDE_DIR%\openssl" ^ - /s /np /nfl /njh /njs /ndl /nc /ns -@echo "Done. Libs saved in: %BORINGSSL_LIB_DIR%, headers saved in: %BORINGSSL_INCLUDE_DIR%" -exit 0 diff --git a/cmake/APKBUILD.in b/cmake/APKBUILD.in index 090bf0004..85eeee1b0 100644 --- a/cmake/APKBUILD.in +++ b/cmake/APKBUILD.in @@ -16,9 +16,7 @@ license="Apache-2.0" depends="" makedepends=" linux-headers - cmake - ninja -" + cmake ninja " subpackages="${pkgname}-dev ${pkgname}-tools" options="!check" @@ -37,7 +35,7 @@ build() { -DCOUCHBASE_CXX_CLIENT_BUILD_EXAMPLES=OFF \ -DCOUCHBASE_CXX_CLIENT_BUILD_TESTS=OFF \ -DCOUCHBASE_CXX_CLIENT_BUILD_TOOLS=ON \ - -DCOUCHBASE_CXX_CLIENT_BUILD_STATIC=OFF \ + -DCOUCHBASE_CXX_CLIENT_BUILD_STATIC=ON \ -DCOUCHBASE_CXX_CLIENT_BUILD_SHARED=ON cmake --build apk-build } diff --git a/cmake/OpenSSL.cmake b/cmake/OpenSSL.cmake index dcff6f8a5..83057ca70 100644 --- a/cmake/OpenSSL.cmake +++ b/cmake/OpenSSL.cmake @@ -55,8 +55,9 @@ elseif(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL) endif() endif() declare_system_library(ssl) + declare_system_library(crypto) add_library(OpenSSL::SSL ALIAS ssl) - add_library(OpenSSL::Crypto ALIAS ssl) + add_library(OpenSSL::Crypto ALIAS crypto) else() option(COUCHBASE_CXX_CLIENT_STATIC_OPENSSL "Statically link OpenSSL library" FALSE) if(COUCHBASE_CXX_CLIENT_STATIC_OPENSSL) diff --git a/cmake/Packaging.cmake b/cmake/Packaging.cmake index ddaabb04e..65f1e5e58 100644 --- a/cmake/Packaging.cmake +++ b/cmake/Packaging.cmake @@ -250,12 +250,13 @@ if(COUCHBASE_CXX_CLIENT_RPM_TARGETS) list( APPEND COUCHBASE_CXX_CLIENT_SUPPORTED_ROOTS - "opensuse-leap-15.5-${CMAKE_SYSTEM_PROCESSOR}" - "rocky-9-${CMAKE_SYSTEM_PROCESSOR}" - "rocky-8-${CMAKE_SYSTEM_PROCESSOR}" - "amazonlinux-2023-${CMAKE_SYSTEM_PROCESSOR}" + # "opensuse-leap-15.5-${CMAKE_SYSTEM_PROCESSOR}" + # "rocky-9-${CMAKE_SYSTEM_PROCESSOR}" + # "rocky-8-${CMAKE_SYSTEM_PROCESSOR}" + # "amazonlinux-2023-${CMAKE_SYSTEM_PROCESSOR}" "fedora-41-${CMAKE_SYSTEM_PROCESSOR}" - "fedora-40-${CMAKE_SYSTEM_PROCESSOR}") + # "fedora-40-${CMAKE_SYSTEM_PROCESSOR}" + ) message(STATUS "Supported build roots for RPM packages: ${COUCHBASE_CXX_CLIENT_SUPPORTED_ROOTS}") diff --git a/cmake/Testing.cmake b/cmake/Testing.cmake index f5a60490e..7118b718d 100644 --- a/cmake/Testing.cmake +++ b/cmake/Testing.cmake @@ -41,29 +41,24 @@ macro(integration_test name) add_executable(test_integration_${name} "${PROJECT_SOURCE_DIR}/test/test_integration_${name}.cxx") target_include_directories(test_integration_${name} PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR}/generated ${PROJECT_BINARY_DIR}/generated_$) - target_include_directories( - test_integration_${name} SYSTEM PRIVATE - ${PROJECT_SOURCE_DIR}/third_party/cxx_function - ${PROJECT_SOURCE_DIR}/third_party/expected/include) + target_include_directories(test_integration_${name} SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/third_party/cxx_function + ${PROJECT_SOURCE_DIR}/third_party/expected/include) target_link_libraries( test_integration_${name} - project_options - project_warnings - ${couchbase_cxx_client_DEFAULT_LIBRARY} - Catch2::Catch2WithMain - Threads::Threads - Microsoft.GSL::GSL - asio - taocpp::json - spdlog::spdlog - test_utils) - if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL) - target_link_libraries(test_integration_${name} OpenSSL::SSL) - if(WIN32) - # Ignore the `LNK4099: PDB ['crypto.pdb'|'ssl.pdb'] was not found` warnings, as we don't (atm) keep track fo the - # *.PDB from the BoringSSL build - set_target_properties(test_integration_${name} PROPERTIES LINK_FLAGS "/ignore:4099") - endif() + PRIVATE project_options + project_warnings + ${couchbase_cxx_client_DEFAULT_LIBRARY} + Catch2::Catch2WithMain + Threads::Threads + Microsoft.GSL::GSL + asio + taocpp::json + spdlog::spdlog + test_utils) + if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL AND WIN32) + # Ignore the `LNK4099: PDB ['crypto.pdb'|'ssl.pdb'] was not found` warnings, as we don't (atm) keep track fo the + # *.PDB from the BoringSSL build + set_target_properties(test_integration_${name} PROPERTIES LINK_FLAGS "/ignore:4099") endif() catch_discover_tests( test_integration_${name} @@ -86,29 +81,24 @@ macro(transaction_test name) add_executable(test_transaction_${name} "${PROJECT_SOURCE_DIR}/test/test_transaction_${name}.cxx") target_include_directories(test_transaction_${name} PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR}/generated ${PROJECT_BINARY_DIR}/generated_$) - target_include_directories( - test_transaction_${name} SYSTEM PRIVATE - ${PROJECT_SOURCE_DIR}/third_party/cxx_function - ${PROJECT_SOURCE_DIR}/third_party/expected/include) + target_include_directories(test_transaction_${name} SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/third_party/cxx_function + ${PROJECT_SOURCE_DIR}/third_party/expected/include) target_link_libraries( test_transaction_${name} - project_options - project_warnings - Catch2::Catch2WithMain - Threads::Threads - Microsoft.GSL::GSL - asio - taocpp::json - spdlog::spdlog - ${couchbase_cxx_client_DEFAULT_LIBRARY} - test_utils) - if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL) - target_link_libraries(test_transaction_${name} OpenSSL::SSL) - if(WIN32) - # Ignore the `LNK4099: PDB ['crypto.pdb'|'ssl.pdb'] was not found` warnings, as we don't (atm) keep track fo the - # *.PDB from the BoringSSL build - set_target_properties(test_transaction_${name} PROPERTIES LINK_FLAGS "/ignore:4099") - endif() + PRIVATE project_options + project_warnings + Catch2::Catch2WithMain + Threads::Threads + Microsoft.GSL::GSL + asio + taocpp::json + spdlog::spdlog + ${couchbase_cxx_client_DEFAULT_LIBRARY} + test_utils) + if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL AND WIN32) + # Ignore the `LNK4099: PDB ['crypto.pdb'|'ssl.pdb'] was not found` warnings, as we don't (atm) keep track fo the + # *.PDB from the BoringSSL build + set_target_properties(test_transaction_${name} PROPERTIES LINK_FLAGS "/ignore:4099") endif() catch_discover_tests( test_transaction_${name} @@ -130,29 +120,24 @@ macro(unit_test name) add_executable(test_unit_${name} "${PROJECT_SOURCE_DIR}/test/test_unit_${name}.cxx") target_include_directories(test_unit_${name} PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR}/generated ${PROJECT_BINARY_DIR}/generated_$) - target_include_directories( - test_unit_${name} SYSTEM PRIVATE - ${PROJECT_SOURCE_DIR}/third_party/cxx_function - ${PROJECT_SOURCE_DIR}/third_party/expected/include) + target_include_directories(test_unit_${name} SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/third_party/cxx_function + ${PROJECT_SOURCE_DIR}/third_party/expected/include) target_link_libraries( test_unit_${name} - project_options - project_warnings - Catch2::Catch2WithMain - Threads::Threads - Microsoft.GSL::GSL - asio - taocpp::json - spdlog::spdlog - ${couchbase_cxx_client_DEFAULT_LIBRARY} - test_utils) - if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL) - target_link_libraries(test_unit_${name} OpenSSL::SSL) - if(WIN32) - # Ignore the `LNK4099: PDB ['crypto.pdb'|'ssl.pdb'] was not found` warnings, as we don't (atm) keep track fo the - # *.PDB from the BoringSSL build - set_target_properties(test_unit_${name} PROPERTIES LINK_FLAGS "/ignore:4099") - endif() + PRIVATE project_options + project_warnings + Catch2::Catch2WithMain + Threads::Threads + Microsoft.GSL::GSL + asio + taocpp::json + spdlog::spdlog + ${couchbase_cxx_client_DEFAULT_LIBRARY} + test_utils) + if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL AND WIN32) + # Ignore the `LNK4099: PDB ['crypto.pdb'|'ssl.pdb'] was not found` warnings, as we don't (atm) keep track fo the + # *.PDB from the BoringSSL build + set_target_properties(test_unit_${name} PROPERTIES LINK_FLAGS "/ignore:4099") endif() catch_discover_tests( test_unit_${name} @@ -176,29 +161,25 @@ macro(integration_benchmark name) benchmark_integration_${name} PRIVATE ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR}/generated ${PROJECT_BINARY_DIR}/generated_$) target_include_directories( - benchmark_integration_${name} SYSTEM PRIVATE - ${PROJECT_SOURCE_DIR}/third_party/cxx_function - ${PROJECT_SOURCE_DIR}/third_party/expected/include) + benchmark_integration_${name} SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/third_party/cxx_function + ${PROJECT_SOURCE_DIR}/third_party/expected/include) target_link_libraries( benchmark_integration_${name} - project_options - project_warnings - Catch2::Catch2WithMain - Threads::Threads - Microsoft.GSL::GSL - asio - taocpp::json - spdlog::spdlog - ${couchbase_cxx_client_DEFAULT_LIBRARY} - test_utils) - if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL) - target_link_libraries(benchmark_integration_${name} OpenSSL::SSL) - if(WIN32) - # Ignore the `LNK4099: PDB ['crypto.pdb'|'ssl.pdb'] was not found` warnings, as we don't (atm) keep track fo the - # *.PDB from the BoringSSL build - set_target_properties(benchmark_integration_${name} PROPERTIES LINK_FLAGS "/ignore:4099") - endif() + PRIVATE project_options + project_warnings + Catch2::Catch2WithMain + Threads::Threads + Microsoft.GSL::GSL + asio + taocpp::json + spdlog::spdlog + ${couchbase_cxx_client_DEFAULT_LIBRARY} + test_utils) + if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL AND WIN32) + # Ignore the `LNK4099: PDB ['crypto.pdb'|'ssl.pdb'] was not found` warnings, as we don't (atm) keep track fo the + # *.PDB from the BoringSSL build + set_target_properties(benchmark_integration_${name} PROPERTIES LINK_FLAGS "/ignore:4099") endif() catch_discover_tests( benchmark_integration_${name} diff --git a/cmake/ThirdPartyDependencies.cmake b/cmake/ThirdPartyDependencies.cmake index 87021db15..c16bfacf3 100644 --- a/cmake/ThirdPartyDependencies.cmake +++ b/cmake/ThirdPartyDependencies.cmake @@ -17,6 +17,8 @@ function(declare_system_library target) $) endfunction() +include(cmake/OpenSSL.cmake) + if(NOT TARGET spdlog::spdlog) # https://github.com/gabime/spdlog/releases cpmaddpackage( @@ -28,14 +30,11 @@ if(NOT TARGET spdlog::spdlog) "gabime/spdlog" EXCLUDE_FROM_ALL ON OPTIONS - "SPDLOG_INSTALL OFF" + "SPDLOG_INSTALL ON" "BUILD_SHARED_LIBS OFF" "CMAKE_C_VISIBILITY_PRESET hidden" "CMAKE_CXX_VISIBILITY_PRESET hidden" "CMAKE_POSITION_INDEPENDENT_CODE ON" - "NO_CMAKE_SYSTEM_PATH ON" - "NO_CMAKE_INSTALL_PREFIX ON" - "NO_CMAKE_SYSTEM_PACKAGE_REGISTRY ON" "SPDLOG_BUILD_SHARED OFF" "SPDLOG_FMT_EXTERNAL OFF") endif() @@ -51,7 +50,7 @@ if(NOT TARGET Microsoft.GSL::GSL) "microsoft/gsl" EXCLUDE_FROM_ALL ON OPTIONS - "GSL_INSTALL OFF" + "GSL_INSTALL ON" "CMAKE_C_VISIBILITY_PRESET hidden" "CMAKE_CXX_VISIBILITY_PRESET hidden" "CMAKE_POSITION_INDEPENDENT_CODE ON") @@ -111,7 +110,7 @@ if(NOT TARGET snappy) "google/snappy" EXCLUDE_FROM_ALL ON OPTIONS - "SNAPPY_INSTALL OFF" + "SNAPPY_INSTALL ON" "CMAKE_C_VISIBILITY_PRESET hidden" "CMAKE_CXX_VISIBILITY_PRESET hidden" "CMAKE_POSITION_INDEPENDENT_CODE ON" @@ -153,7 +152,6 @@ if(NOT TARGET taocpp::json) "TAOCPP_JSON_BUILD_EXAMPLES OFF") endif() - if(NOT TARGET asio::asio) # https://github.com/chriskohlhoff/asio/tags cpmaddpackage( @@ -179,7 +177,15 @@ if(asio_ADDED) target_include_directories(asio SYSTEM PUBLIC ${asio_SOURCE_DIR}/asio/include) target_compile_definitions(asio PRIVATE ASIO_STANDALONE=1 ASIO_NO_DEPRECATED=1 ASIO_SEPARATE_COMPILATION=1) - target_link_libraries(asio PRIVATE Threads::Threads OpenSSL::SSL OpenSSL::Crypto) + target_link_libraries(asio PRIVATE Threads::Threads) + if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL) + target_link_libraries(asio PUBLIC $ $) + target_include_directories( + asio SYSTEM PRIVATE $> + $>) + else() + target_link_libraries(asio PRIVATE OpenSSL::SSL OpenSSL::Crypto) + endif() set_target_properties( asio PROPERTIES C_VISIBILITY_PRESET hidden diff --git a/cmake/couchbase-cxx-client.spec.in b/cmake/couchbase-cxx-client.spec.in index 26872c991..7237571b7 100644 --- a/cmake/couchbase-cxx-client.spec.in +++ b/cmake/couchbase-cxx-client.spec.in @@ -57,7 +57,7 @@ Development files for the Couchbase C++ SDK. -DCOUCHBASE_CXX_CLIENT_BUILD_EXAMPLES=OFF \ -DCOUCHBASE_CXX_CLIENT_BUILD_TESTS=OFF \ -DCOUCHBASE_CXX_CLIENT_BUILD_TOOLS=ON \ - -DCOUCHBASE_CXX_CLIENT_BUILD_STATIC=OFF \ + -DCOUCHBASE_CXX_CLIENT_BUILD_STATIC=ON \ -DCOUCHBASE_CXX_CLIENT_BUILD_SHARED=ON %build @@ -97,6 +97,7 @@ DESTDIR="%{buildroot}" /usr/bin/cmake --install "redhat-linux-build" %{_includedir}/tao %{_libdir}/cmake/*/*.cmake %{_libdir}/libcouchbase_cxx_client.so +%{_libdir}/libcouchbase_cxx_client_static.a %{_libdir}/pkgconfig/couchbase_cxx_client.pc %changelog diff --git a/cmake/debian/rules b/cmake/debian/rules index b9abdabae..c0ac9e7f4 100755 --- a/cmake/debian/rules +++ b/cmake/debian/rules @@ -10,7 +10,7 @@ override_dh_strip: override_dh_auto_configure: echo "usr/include/couchbase" \ > debian/couchbase-cxx-client-dev.install - echo "usr/lib/$(DEB_HOST_MULTIARCH)/libcouchbase_cxx_client.so" \ + echo "usr/lib/$(DEB_HOST_MULTIARCH)/libcouchbase_cxx_client.{so,a}" \ >> debian/couchbase-cxx-client-dev.install echo "usr/lib/$(DEB_HOST_MULTIARCH)/cmake" \ >> debian/couchbase-cxx-client-dev.install @@ -34,7 +34,7 @@ override_dh_auto_configure: -DCOUCHBASE_CXX_CLIENT_BUILD_EXAMPLES=OFF \ -DCOUCHBASE_CXX_CLIENT_BUILD_TESTS=OFF \ -DCOUCHBASE_CXX_CLIENT_BUILD_TOOLS=ON \ - -DCOUCHBASE_CXX_CLIENT_BUILD_STATIC=OFF \ + -DCOUCHBASE_CXX_CLIENT_BUILD_STATIC=ON \ -DCOUCHBASE_CXX_CLIENT_BUILD_SHARED=ON override_dh_auto_build: diff --git a/cmake/test_boringssl.cxx b/cmake/test_boringssl.cxx deleted file mode 100644 index 13868463a..000000000 --- a/cmake/test_boringssl.cxx +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int -main() -{ - return static_cast(OpenSSL_version_num()); -} diff --git a/core/crypto/CMakeLists.txt b/core/crypto/CMakeLists.txt deleted file mode 100644 index c87e92147..000000000 --- a/core/crypto/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -add_library(couchbase_crypto OBJECT cbcrypto.cc) -set_target_properties(couchbase_crypto PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_link_libraries(couchbase_crypto PRIVATE project_options project_warnings) -target_include_directories(couchbase_crypto PRIVATE ${PROJECT_BINARY_DIR}/generated ${PROJECT_SOURCE_DIR}) - -if(COUCHBASE_CXX_CLIENT_STATIC_BORINGSSL AND COUCHBASE_CXX_CLIENT_USE_BORINGSSL_PREFIX) - target_compile_definitions(couchbase_crypto PUBLIC BORINGSSL_PREFIX=${COUCHBASE_CXX_CLIENT_BORINGSSL_PREFIX}) -endif() - -# this will work for boringssl too -if(NOT COUCHBASE_CXX_CLIENT_POST_LINKED_OPENSSL) - if(TARGET PkgConfig::PKG_CONFIG_OPENSSL) - target_link_libraries(couchbase_crypto PUBLIC PkgConfig::PKG_CONFIG_OPENSSL) - else() - target_link_libraries(couchbase_crypto PUBLIC OpenSSL::SSL OpenSSL::Crypto) - endif() -endif() - -if(WIN32) - target_link_libraries(couchbase_crypto PUBLIC bcrypt.lib) -endif() diff --git a/core/operations/management/CMakeLists.txt b/core/operations/management/CMakeLists.txt deleted file mode 100644 index 0f4deb2fa..000000000 --- a/core/operations/management/CMakeLists.txt +++ /dev/null @@ -1,80 +0,0 @@ -add_library( - couchbase_operations_management OBJECT - analytics_dataset_create.cxx - analytics_dataset_drop.cxx - analytics_dataset_get_all.cxx - analytics_dataverse_create.cxx - analytics_dataverse_drop.cxx - analytics_get_pending_mutations.cxx - analytics_index_create.cxx - analytics_index_drop.cxx - analytics_index_get_all.cxx - analytics_link_connect.cxx - analytics_link_create.cxx - analytics_link_disconnect.cxx - analytics_link_drop.cxx - analytics_link_get_all.cxx - analytics_link_replace.cxx - bucket_create.cxx - bucket_describe.cxx - bucket_drop.cxx - bucket_flush.cxx - bucket_get.cxx - bucket_get_all.cxx - bucket_update.cxx - change_password.cxx - cluster_describe.cxx - cluster_developer_preview_enable.cxx - collection_create.cxx - collection_drop.cxx - collections_manifest_get.cxx - collection_update.cxx - error_utils.cxx - eventing_deploy_function.cxx - eventing_drop_function.cxx - eventing_get_all_functions.cxx - eventing_get_function.cxx - eventing_get_status.cxx - eventing_pause_function.cxx - eventing_resume_function.cxx - eventing_undeploy_function.cxx - eventing_upsert_function.cxx - freeform.cxx - group_drop.cxx - group_get.cxx - group_get_all.cxx - group_upsert.cxx - query_index_build.cxx - query_index_create.cxx - query_index_drop.cxx - query_index_get_all.cxx - role_get_all.cxx - scope_create.cxx - scope_drop.cxx - scope_get_all.cxx - search_get_stats.cxx - search_index_analyze_document.cxx - search_index_control_ingest.cxx - search_index_control_plan_freeze.cxx - search_index_control_query.cxx - search_index_drop.cxx - search_index_get.cxx - search_index_get_all.cxx - search_index_get_documents_count.cxx - search_index_get_stats.cxx - search_index_upsert.cxx - user_drop.cxx - user_get.cxx - user_get_all.cxx - user_upsert.cxx - view_index_drop.cxx - view_index_get.cxx - view_index_get_all.cxx - view_index_upsert.cxx) -set_target_properties(couchbase_operations_management PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_link_libraries( - couchbase_operations_management - PRIVATE project_options - project_warnings - spdlog::spdlog) -target_include_directories(couchbase_operations_management PRIVATE ../../..) diff --git a/core/sasl/CMakeLists.txt b/core/sasl/CMakeLists.txt deleted file mode 100644 index c71856b38..000000000 --- a/core/sasl/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -add_library( - couchbase_sasl OBJECT - client.cc - context.cc - mechanism.cc - plain/plain.cc - scram-sha/scram-sha.cc - scram-sha/stringutils.cc) -set_target_properties(couchbase_sasl PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_include_directories(couchbase_sasl PRIVATE ../..) -target_link_libraries( - couchbase_sasl - PRIVATE project_options - project_warnings - Microsoft.GSL::GSL - spdlog::spdlog) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1f2f93696..2c931f614 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -36,7 +36,7 @@ unit_test(management_query_index) unit_test(management_search_index) unit_test(metrics) unit_test(range_scan) -target_link_libraries(test_unit_jsonsl jsonsl) +target_link_libraries(test_unit_jsonsl PRIVATE jsonsl) integration_benchmark(get) @@ -54,7 +54,7 @@ integration_test(examples) transaction_test(examples) if(COUCHBASE_CXX_CLIENT_COLUMNAR) - integration_test(columnar_query) - integration_test(columnar_management) - unit_test(columnar_retry) + integration_test(columnar_query) + integration_test(columnar_management) + unit_test(columnar_retry) endif()