From 11766b22283a4b8e621ced259f4e9cc35fe6f65b Mon Sep 17 00:00:00 2001 From: fdr400 Date: Fri, 10 Jan 2025 12:43:41 +0300 Subject: [PATCH] feat build: prefer static libs when possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tests: протестировано CI Pull Request resolved: https://github.com/userver-framework/userver/pull/821 commit_hash:1762ad5ac6e6a712c45b4964ddf2f57ac73be0c1 --- .github/workflows/alpine.yml | 5 +-- .github/workflows/ci-conan.yml | 1 - .github/workflows/ci.yml | 12 +++++-- .github/workflows/docker.yaml | 5 +-- .github/workflows/macos.yml | 9 +++++- .mapping.json | 8 ++--- CMakeLists.txt | 13 ++++++++ clickhouse/CMakeLists.txt | 3 ++ cmake/ModuleHelpers.cmake | 27 +++------------- cmake/SetupCURL.cmake | 17 ++++++++-- cmake/SetupClickhouseCPP.cmake | 9 +++++- cmake/SetupGrpc.cmake | 2 +- cmake/SetupHomebrew.cmake | 29 +++++++++++++++++ cmake/SetupMongoDeps.cmake | 17 ++++++++++ cmake/SetupPostgresqlDeps.cmake | 16 ++++++---- cmake/SetupProtobuf.cmake | 5 ++- cmake/SetupRdKafka.cmake | 15 +++++++-- cmake/SetupRocksDB.cmake | 9 ++++-- cmake/UserverPreferStaticLibs.cmake | 21 +++++++++++++ cmake/UserverSetupEnvironment.cmake | 4 +++ cmake/install/Config.cmake.in | 3 ++ cmake/install/userver-core-config.cmake | 9 +++--- cmake/install/userver-kafka-config.cmake | 3 +- cmake/install/userver-mongo-config.cmake | 3 +- cmake/install/userver-universal-config.cmake | 5 +++ cmake/modules/FindCrypto.cmake | 12 ------- cmake/modules/FindCryptoPP.cmake | 2 +- cmake/modules/FindGssApi.cmake | 1 + cmake/modules/FindRdKafka.cmake | 6 +++- cmake/modules/FindRocksDB.cmake | 2 +- cmake/modules/FindSASL2.cmake | 30 ++++++++++++++++++ cmake/modules/FindSSL.cmake | 12 ------- cmake/modules/FindUserverGrpc.cmake | 8 ++--- cmake/modules/Findbson.cmake | 6 +++- cmake/modules/Findc-ares.cmake | 2 +- cmake/modules/Findcctz.cmake | 1 - cmake/modules/Findclickhouse-cpp.cmake | 17 ++++++++-- cmake/modules/Findlibintl.cmake | 14 --------- cmake/modules/Findlibmariadb.cmake | 4 +-- cmake/modules/Findlibsnappy.cmake | 5 +++ cmake/modules/Findlibzip.cmake | 19 ------------ cmake/modules/Findlibzstd.cmake | 5 +++ cmake/modules/Findlz4.cmake | 6 ++-- cmake/modules/Findmongoc.cmake | 6 +++- conanfile.py | 5 +++ kafka/CMakeLists.txt | 27 +++++----------- kafka/functional_tests/CMakeLists.txt | 2 -- kafka/utest/src/kafka/utest/kafka_fixture.cpp | 4 +-- mongo/CMakeLists.txt | 9 ++++-- mysql/CMakeLists.txt | 4 ++- postgresql/CMakeLists.txt | 7 ++++- rabbitmq/CMakeLists.txt | 2 +- scripts/build_and_install.sh | 1 - scripts/docs/en/deps/alpine.md | 17 ++++++++++ scripts/docs/en/deps/macos.md | 29 ++++++++--------- scripts/docs/en/deps/ubuntu-18.04.md | 1 + scripts/docs/en/deps/ubuntu-20.04.md | 2 ++ scripts/docs/en/deps/ubuntu-21.10.md | 1 + scripts/docs/en/deps/ubuntu-22.04.md | 2 ++ scripts/docs/en/deps/ubuntu-24.04.md | 1 + scripts/gdb/tests/CMakeLists.txt | 4 +++ testsuite/requirements-grpc-3.txt | 1 + testsuite/requirements-grpc-4.txt | 1 + testsuite/requirements-grpc-5.txt | 1 + testsuite/requirements-internal-tests.txt | 1 - universal/CMakeLists.txt | 31 ++++++++++--------- universal/utest/CMakeLists.txt | 2 +- 67 files changed, 367 insertions(+), 196 deletions(-) create mode 100644 cmake/SetupHomebrew.cmake create mode 100644 cmake/SetupMongoDeps.cmake create mode 100644 cmake/UserverPreferStaticLibs.cmake delete mode 100644 cmake/modules/FindCrypto.cmake create mode 100644 cmake/modules/FindSASL2.cmake delete mode 100644 cmake/modules/FindSSL.cmake delete mode 100644 cmake/modules/Findlibintl.cmake delete mode 100644 cmake/modules/Findlibzip.cmake diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml index 7594ee2e9661..3f2cdc673aea 100644 --- a/.github/workflows/alpine.yml +++ b/.github/workflows/alpine.yml @@ -37,7 +37,7 @@ jobs: path: | ${{env.CCACHE_DIR}} ${{env.CPM_SOURCE_CACHE}} - key: 'alpine-cache-dir ${{github.ref}}' + key: 'alpine-cache-dir ${{github.ref}} run-${{github.run_number}}' restore-keys: | alpine-cache-dir ${{github.ref}} alpine-cache-dir @@ -59,7 +59,7 @@ jobs: run: | pwd cat /etc/alpine-release - apk add lld ccache git + apk add lld ccache git gdb apk add $(cat scripts/docs/en/deps/alpine.md) - name: Install test dependencies @@ -91,6 +91,7 @@ jobs: CMAKE_PROGRAM_PATH=/usr/lib/llvm17/bin/ \ cmake -S . -B build_debug \ -DCMAKE_BUILD_TYPE=Debug \ + -DUSERVER_USE_STATIC_LIBS=1 \ -DUSERVER_USE_LD=lld \ -DUSERVER_NO_WERROR=OFF \ -DUSERVER_BUILD_ALL_COMPONENTS=1 \ diff --git a/.github/workflows/ci-conan.yml b/.github/workflows/ci-conan.yml index 305a871ed0eb..1c8fea82540a 100644 --- a/.github/workflows/ci-conan.yml +++ b/.github/workflows/ci-conan.yml @@ -38,7 +38,6 @@ jobs: run: | brew update brew install postgresql redis clang-format - brew install libiconv # https://stackoverflow.com/questions/57734434/libiconv-or-iconv-undefined-symbol-on-mac-osx brew install python@3.11 - name: Install common packages diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db898ebf6dde..bafb6929be9c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,7 @@ jobs: -DCMAKE_CXX_COMPILER=clang++-18 -DCMAKE_C_COMPILER=clang-18 -DCMAKE_BUILD_TYPE=Debug + -DUSERVER_USE_STATIC_LIBS=1 -DUSERVER_SANITIZE="ub addr" -DUSERVER_NO_WERROR=0 -DUSERVER_BUILD_ALL_COMPONENTS=1 @@ -45,6 +46,7 @@ jobs: -DCMAKE_CXX_COMPILER=clang++-14 -DCMAKE_C_COMPILER=clang-14 -DCMAKE_BUILD_TYPE=Debug + -DUSERVER_USE_STATIC_LIBS=1 -DUSERVER_SANITIZE="ub addr" -DUSERVER_NO_WERROR=0 -DUSERVER_BUILD_ALL_COMPONENTS=1 @@ -71,6 +73,7 @@ jobs: -DUSERVER_FEATURE_REDIS_HI_MALLOC=1 -DUSERVER_FORCE_DOWNLOAD_ABSEIL=0 -DUSERVER_DOWNLOAD_PACKAGE_ABSEIL=0 + -DUSERVER_MONGODB_USE_CMAKE_CONFIG=0 os: ubuntu-20.04 info: g++-9 + release id: ubuntu20_gcc9_release @@ -91,6 +94,7 @@ jobs: -DUSERVER_FEATURE_REDIS_HI_MALLOC=1 -DUSERVER_FORCE_DOWNLOAD_ABSEIL=0 -DUSERVER_DOWNLOAD_PACKAGE_ABSEIL=0 + -DUSERVER_MONGODB_USE_CMAKE_CONFIG=0 os: ubuntu-20.04 info: g++-8 + debug id: ubuntu20_gcc8_debug @@ -109,7 +113,7 @@ jobs: path: | ${{env.CCACHE_DIR}} ${{env.CPM_SOURCE_CACHE}} - key: 'ubuntu-cache-dir ${{matrix.id}} ${{github.ref}}' + key: 'ubuntu-cache-dir ${{matrix.id}} ${{github.ref}} run-${{github.run_number}}' restore-keys: | ubuntu-cache-dir ${{matrix.id}} ${{github.ref}} ubuntu-cache-dir ${{matrix.id}} @@ -217,7 +221,11 @@ jobs: git clone --recursive --depth 1 -b v1.45.0 https://github.com/grpc/grpc new_grpc GRPC_BUILD_ENABLE_CCACHE=true \ cmake -GNinja -S./new_grpc -B./new_grpc/build \ - -DABSL_PROPAGATE_CXX_STD=ON -DABSL_ENABLE_INSTALL=ON + -DABSL_PROPAGATE_CXX_STD=ON -DABSL_ENABLE_INSTALL=ON \ + -DgRPC_SSL_PROVIDER=package \ + -DgRPC_CARES_PROVIDER=package \ + -DgRPC_ZLIB_PROVIDER=package \ + -DgRPC_INSTALL=ON cmake --build new_grpc/build -j$(nproc) sudo cmake --install new_grpc/build rm -rf new_grpc diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 9ddbb8ef53b9..26154cbf9e1e 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -17,7 +17,6 @@ jobs: - cmake-flags: >- -DCMAKE_CXX_STANDARD=17 -DCPM_SOURCE_CACHE=~/.cache/CPM - -DUSERVER_USE_LD=gold -DUSERVER_NO_WERROR=0 -DUSERVER_BUILD_SAMPLES=1 -DUSERVER_BUILD_TESTS=1 @@ -32,6 +31,7 @@ jobs: -DCMAKE_CXX_COMPILER=clang++-16 -DCMAKE_CXX_STANDARD=17 -DCPM_SOURCE_CACHE=~/.cache/CPM + -DUSERVER_USE_STATIC_LIBS=1 -DUSERVER_NO_WERROR=0 -DUSERVER_BUILD_ALL_COMPONENTS=1 -DUSERVER_BUILD_SAMPLES=1 @@ -59,6 +59,7 @@ jobs: -DCMAKE_CXX_COMPILER=clang++-16 -DCMAKE_CXX_STANDARD=20 -DCPM_SOURCE_CACHE=~/.cache/CPM + -DUSERVER_USE_STATIC_LIBS=1 -DUSERVER_BUILD_ALL_COMPONENTS=1 -DUSERVER_BUILD_SAMPLES=1 -DUSERVER_BUILD_TESTS=1 @@ -97,7 +98,7 @@ jobs: path: | .ccache .cache/CPM - key: 'docker-cache-dir ${{matrix.id}} ${{github.ref}}' + key: 'docker-cache-dir ${{matrix.id}} ${{github.ref}} run-${{github.run_number}}' restore-keys: | docker-cache-dir ${{matrix.id}} ${{github.ref}} docker-cache-dir ${{matrix.id}} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 7233eed5dc81..cfdb9bea93ac 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -25,6 +25,7 @@ jobs: CMAKE_FLAGS: >- -GNinja -DCMAKE_BUILD_TYPE=Debug + -DUSERVER_USE_STATIC_LIBS=1 -DUSERVER_NO_WERROR=1 -DUSERVER_BUILD_ALL_COMPONENTS=1 -DUSERVER_BUILD_SAMPLES=1 @@ -48,7 +49,7 @@ jobs: path: | ${{env.CCACHE_DIR}} ${{env.CPM_SOURCE_CACHE}} - key: 'macos-cache-dir ${{github.ref}}' + key: 'macos-cache-dir ${{github.ref}} run-${{github.run_number}}' restore-keys: | macos-cache-dir ${{github.ref}} macos-cache-dir @@ -63,6 +64,12 @@ jobs: brew install lld brew link postgresql@16 # postgresql is keg-only + brew link --force zlib # keg-only + need for static linkage + brew link --force icu4c@76 # keg-only + need for static boost linkage + brew link --force curl # keg-only + brew link --force cyrus-sasl # keg-only + brew link --force openldap # keg-only + brew remove --ignore-dependencies abseil - name: Setup ccache run: | diff --git a/.mapping.json b/.mapping.json index 5e4339230c57..85d7fe5c64cb 100644 --- a/.mapping.json +++ b/.mapping.json @@ -405,8 +405,10 @@ "cmake/SetupGTest.cmake":"taxi/uservices/userver/cmake/SetupGTest.cmake", "cmake/SetupGoogleProtoApis.cmake":"taxi/uservices/userver/cmake/SetupGoogleProtoApis.cmake", "cmake/SetupGrpc.cmake":"taxi/uservices/userver/cmake/SetupGrpc.cmake", + "cmake/SetupHomebrew.cmake":"taxi/uservices/userver/cmake/SetupHomebrew.cmake", "cmake/SetupLTO.cmake":"taxi/uservices/userver/cmake/SetupLTO.cmake", "cmake/SetupLinker.cmake":"taxi/uservices/userver/cmake/SetupLinker.cmake", + "cmake/SetupMongoDeps.cmake":"taxi/uservices/userver/cmake/SetupMongoDeps.cmake", "cmake/SetupOpentelemetryProto.cmake":"taxi/uservices/userver/cmake/SetupOpentelemetryProto.cmake", "cmake/SetupPGO.cmake":"taxi/uservices/userver/cmake/SetupPGO.cmake", "cmake/SetupPostgresqlDeps.cmake":"taxi/uservices/userver/cmake/SetupPostgresqlDeps.cmake", @@ -420,6 +422,7 @@ "cmake/UserverGrpcTargets.cmake":"taxi/uservices/userver/cmake/UserverGrpcTargets.cmake", "cmake/UserverModule.cmake":"taxi/uservices/userver/cmake/UserverModule.cmake", "cmake/UserverPack.cmake":"taxi/uservices/userver/cmake/UserverPack.cmake", + "cmake/UserverPreferStaticLibs.cmake":"taxi/uservices/userver/cmake/UserverPreferStaticLibs.cmake", "cmake/UserverRequireDWCAS.cmake":"taxi/uservices/userver/cmake/UserverRequireDWCAS.cmake", "cmake/UserverRequireDWCAS.cpp":"taxi/uservices/userver/cmake/UserverRequireDWCAS.cpp", "cmake/UserverSetupEnvironment.cmake":"taxi/uservices/userver/cmake/UserverSetupEnvironment.cmake", @@ -448,7 +451,6 @@ "cmake/install/userver-universal-config.cmake":"taxi/uservices/userver/cmake/install/userver-universal-config.cmake", "cmake/install/userver-ydb-config.cmake":"taxi/uservices/userver/cmake/install/userver-ydb-config.cmake", "cmake/modules/FindBrotli.cmake":"taxi/uservices/userver/cmake/modules/FindBrotli.cmake", - "cmake/modules/FindCrypto.cmake":"taxi/uservices/userver/cmake/modules/FindCrypto.cmake", "cmake/modules/FindCryptoPP.cmake":"taxi/uservices/userver/cmake/modules/FindCryptoPP.cmake", "cmake/modules/FindGrpcChannelz.cmake":"taxi/uservices/userver/cmake/modules/FindGrpcChannelz.cmake", "cmake/modules/FindGssApi.cmake":"taxi/uservices/userver/cmake/modules/FindGssApi.cmake", @@ -461,7 +463,7 @@ "cmake/modules/FindPythonDev.cmake":"taxi/uservices/userver/cmake/modules/FindPythonDev.cmake", "cmake/modules/FindRdKafka.cmake":"taxi/uservices/userver/cmake/modules/FindRdKafka.cmake", "cmake/modules/FindRocksDB.cmake":"taxi/uservices/userver/cmake/modules/FindRocksDB.cmake", - "cmake/modules/FindSSL.cmake":"taxi/uservices/userver/cmake/modules/FindSSL.cmake", + "cmake/modules/FindSASL2.cmake":"taxi/uservices/userver/cmake/modules/FindSASL2.cmake", "cmake/modules/FindUserverGBench.cmake":"taxi/uservices/userver/cmake/modules/FindUserverGBench.cmake", "cmake/modules/FindUserverGrpc.cmake":"taxi/uservices/userver/cmake/modules/FindUserverGrpc.cmake", "cmake/modules/Findbson.cmake":"taxi/uservices/userver/cmake/modules/Findbson.cmake", @@ -470,11 +472,9 @@ "cmake/modules/Findclickhouse-cpp.cmake":"taxi/uservices/userver/cmake/modules/Findclickhouse-cpp.cmake", "cmake/modules/Findfmt.cmake":"taxi/uservices/userver/cmake/modules/Findfmt.cmake", "cmake/modules/Findlibgflags.cmake":"taxi/uservices/userver/cmake/modules/Findlibgflags.cmake", - "cmake/modules/Findlibintl.cmake":"taxi/uservices/userver/cmake/modules/Findlibintl.cmake", "cmake/modules/Findlibmariadb.cmake":"taxi/uservices/userver/cmake/modules/Findlibmariadb.cmake", "cmake/modules/Findlibsnappy.cmake":"taxi/uservices/userver/cmake/modules/Findlibsnappy.cmake", "cmake/modules/Findlibyamlcpp.cmake":"taxi/uservices/userver/cmake/modules/Findlibyamlcpp.cmake", - "cmake/modules/Findlibzip.cmake":"taxi/uservices/userver/cmake/modules/Findlibzip.cmake", "cmake/modules/Findlibzstd.cmake":"taxi/uservices/userver/cmake/modules/Findlibzstd.cmake", "cmake/modules/Findlz4.cmake":"taxi/uservices/userver/cmake/modules/Findlz4.cmake", "cmake/modules/Findmongoc.cmake":"taxi/uservices/userver/cmake/modules/Findmongoc.cmake", diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d8b5db0ee81..974711d19f6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,9 @@ option( "Prepare build of userver to install in system" OFF ) +if(CMAKE_VERSION GREATER_EQUAL 3.31) + cmake_policy(SET CMP0177 NEW) +endif() set(USERVER_AVAILABLE_COMPONENTS universal) @@ -144,6 +147,16 @@ option(USERVER_FEATURE_OTLP "Provide asynchronous OTLP exporters" "${USERVER_LIB set(CMAKE_DEBUG_POSTFIX d) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") + +option(USERVER_USE_STATIC_LIBS "Tries to find all dependencies as static libraries" OFF) + +if(USERVER_USE_STATIC_LIBS) + message( + WARNING + "USERVER_USE_STATIC_LIBS turned ON, prioritized to find static libraries. Not all dependencies may be taken into account and linkage may be broken") + include(UserverPreferStaticLibs) +endif() + include(UserverSetupEnvironment) userver_setup_environment() diff --git a/clickhouse/CMakeLists.txt b/clickhouse/CMakeLists.txt index 35c78b9727b7..5ad66e788c81 100644 --- a/clickhouse/CMakeLists.txt +++ b/clickhouse/CMakeLists.txt @@ -20,6 +20,9 @@ userver_module(clickhouse DBTEST_DATABASES clickhouse ) +target_compile_options(${PROJECT_NAME} PUBLIC "-Wno-error=pedantic") + + _userver_directory_install(COMPONENT clickhouse FILES "${USERVER_ROOT_DIR}/cmake/modules/Findclickhouse-cpp.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/userver/modules diff --git a/cmake/ModuleHelpers.cmake b/cmake/ModuleHelpers.cmake index 800bc1d7cc25..261e291a87ea 100644 --- a/cmake/ModuleHelpers.cmake +++ b/cmake/ModuleHelpers.cmake @@ -7,10 +7,6 @@ macro(_userver_module_begin) set(oneValueArgs # Target name, also used for package name by default NAME - # Custom package name; NAME is used by default - PACKAGE_NAME - # For multi-target packages - COMMON_NAME VERSION ) set(multiValueArgs @@ -130,6 +126,7 @@ macro(_userver_module_find_part) PATH_SUFFIXES ${ARG_PATH_SUFFIXES} PATHS ${ARG_PATHS} ) + message(DEBUG "STATUS FIND(${ARG_NAMES}) ARGS: ${find_command_args}") if("${ARG_PART_TYPE}" STREQUAL "library") find_library(${find_command_args}) elseif("${ARG_PART_TYPE}" STREQUAL "path") @@ -226,11 +223,7 @@ macro(_userver_module_end) include("${USERVER_CMAKE_DIR}/DetectVersion.cmake") set(name "${ARG_NAME}") - if(ARG_PACKAGE_NAME) - set(current_package_name "${ARG_PACKAGE_NAME}") - else() - set(current_package_name "${ARG_NAME}") - endif() + set(current_package_name "${ARG_NAME}") set(libraries_variable "${ARG_NAME}_LIBRARIES") set(includes_variable "${ARG_NAME}_INCLUDE_DIRS") set(programs_variable "${ARG_NAME}_EXECUTABLE") @@ -295,18 +288,11 @@ macro(_userver_module_end) mark_as_advanced(${required_vars}) else() # Forward to another CMake module, add nice error messages if missing. - if(ARG_COMMON_NAME) - set(wrapped_package_name "${ARG_COMMON_NAME}") - else() - set(wrapped_package_name "${current_package_name}") - endif() + set(wrapped_package_name "${current_package_name}") set(find_command_args "${wrapped_package_name}") if(ARG_VERSION) list(APPEND find_command_args "${ARG_VERSION}") endif() - if(ARG_COMMON_NAME) - list(APPEND find_command_args COMPONENTS "${name}") - endif() find_package(${find_command_args}) set("${name}_FOUND" "${${wrapped_package_name}_FOUND}") endif() @@ -332,16 +318,11 @@ macro(_userver_module_end) endif() endif() - if(ARG_COMMON_NAME - OR (NOT "${${libraries_variable}}" STREQUAL "") + if((NOT "${${libraries_variable}}" STREQUAL "") OR (NOT "${${includes_variable}}" STREQUAL "")) if(NOT TARGET "${name}") add_library("${name}" INTERFACE IMPORTED GLOBAL) - if(ARG_COMMON_NAME AND TARGET "${ARG_COMMON_NAME}::${name}") - target_link_libraries("${name}" INTERFACE "${ARG_COMMON_NAME}::${name}") - endif() - if(NOT "${${includes_variable}}" STREQUAL "") target_include_directories("${name}" INTERFACE ${${includes_variable}}) message(STATUS "${name} include directories: ${${includes_variable}}") diff --git a/cmake/SetupCURL.cmake b/cmake/SetupCURL.cmake index 3a83295da067..d9957d517731 100644 --- a/cmake/SetupCURL.cmake +++ b/cmake/SetupCURL.cmake @@ -1,10 +1,20 @@ option(USERVER_DOWNLOAD_PACKAGE_CURL "Download and setup libcurl if no libcurl of matching version was found" ${USERVER_DOWNLOAD_PACKAGES}) if(NOT USERVER_FORCE_DOWNLOAD_PACKAGES) + # Curl has too many dependencies to reliably + # link with all of them statically without CMake Config + if (USERVER_USE_STATIC_LIBS) + list(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES) + endif() + if(USERVER_DOWNLOAD_PACKAGE_CURL) - find_package(CURL "7.68" QUIET) + find_package(CURL "7.68") else() - find_package_required_version(CURL "libcurl4-openssl-dev" "7.68") + find_package(CURL "7.68" REQUIRED) + endif() + + if (USERVER_USE_STATIC_LIBS) + list(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES) endif() if(CURL_FOUND) @@ -45,3 +55,6 @@ CPMAddPackage( "CURL_DISABLE_TESTS ON" ${CURL_LTO_OPTION} ) + +mark_targets_as_system("${CURL_SOURCE_DIR}") +write_package_stub(CURL) diff --git a/cmake/SetupClickhouseCPP.cmake b/cmake/SetupClickhouseCPP.cmake index b04d623ab098..1716d39e5aa9 100644 --- a/cmake/SetupClickhouseCPP.cmake +++ b/cmake/SetupClickhouseCPP.cmake @@ -1,5 +1,10 @@ option(USERVER_DOWNLOAD_PACKAGE_CLICKHOUSECPP "Download and setup clickhouse-cpp" ${USERVER_DOWNLOAD_PACKAGES}) +if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + find_package(lz4 REQUIRED) + include(SetupAbseil) +endif() + if (NOT USERVER_FORCE_DOWNLOAD_PACKAGES) if (USERVER_DOWNLOAD_PACKAGE_CLICKHOUSECPP) find_package(clickhouse-cpp QUIET) @@ -8,6 +13,9 @@ if (NOT USERVER_FORCE_DOWNLOAD_PACKAGES) endif() if (clickhouse-cpp_FOUND) + if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + target_link_libraries(clickhouse-cpp INTERFACE lz4::lz4 absl::int128) + endif() return() endif() endif() @@ -27,4 +35,3 @@ CPMAddPackage( ) add_library(clickhouse-cpp ALIAS clickhouse-cpp-lib) -target_compile_options(clickhouse-cpp-lib PUBLIC -Wno-pedantic) diff --git a/cmake/SetupGrpc.cmake b/cmake/SetupGrpc.cmake index da6ea6639471..a16be3104be9 100644 --- a/cmake/SetupGrpc.cmake +++ b/cmake/SetupGrpc.cmake @@ -85,7 +85,7 @@ CPMAddPackage( "gRPC_SSL_PROVIDER package" "gRPC_PROTOBUF_PROVIDER package" "gRPC_BENCHMARK_PROVIDER none" - "gRPC_ABSL_PROVIDER none" + "gRPC_ABSL_PROVIDER package" "gRPC_CARES_LIBRARIES c-ares::cares" "gRPC_INSTALL OFF" ) diff --git a/cmake/SetupHomebrew.cmake b/cmake/SetupHomebrew.cmake new file mode 100644 index 000000000000..670c01252021 --- /dev/null +++ b/cmake/SetupHomebrew.cmake @@ -0,0 +1,29 @@ +option(USERVER_USE_BREW_LIBRARIES "(MacOS) Find package preferes libraries installed with homebrew and make linker search libraries in brew folders" ON) + +if(NOT DEFINED $CACHE{USERVER_BREW_PREFIX}) + find_program(BREW_BIN brew) + if(BREW_BIN) + execute_process( + COMMAND ${BREW_BIN} --prefix + OUTPUT_VARIABLE brew_prefix + RESULT_VARIABLE brew_prefix_result + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if(brew_prefix_result EQUAL 0) + set(USERVER_BREW_PREFIX "${brew_prefix}" CACHE INTERNAL "Brew prefix") + message(STATUS "brew prefix is: ${USERVER_BREW_PREFIX}") + endif() + endif() +endif() + +if (USERVER_BREW_PREFIX) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${USERVER_BREW_PREFIX}/lib") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${USERVER_BREW_PREFIX}/lib") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation") + + if(NOT USERVER_BREW_PREFIX IN_LIST CMAKE_PREFIX_PATH AND NOT USERVER_CONAN) + set(CMAKE_PREFIX_PATH "${USERVER_BREW_PREFIX}" ${CMAKE_PREFIX_PATH} PARENT_SCOPE) + endif() +endif() diff --git a/cmake/SetupMongoDeps.cmake b/cmake/SetupMongoDeps.cmake new file mode 100644 index 000000000000..55ab17abddf1 --- /dev/null +++ b/cmake/SetupMongoDeps.cmake @@ -0,0 +1,17 @@ +include_guard(GLOBAL) + +option(USERVER_MONGODB_USE_CMAKE_CONFIG "Use mongoc cmake configuration" ON) + +if (USERVER_MONGODB_USE_CMAKE_CONFIG) + find_package(mongoc-1.0 QUIET CONFIG) + if(mongoc-1.0_FOUND) + message(STATUS "Mongoc: using config version: (bson: ${bson-1.0_VERSION}, mongoc: ${mongoc-1.0_VERSION})") + add_library(bson ALIAS mongo::bson_static) + add_library(mongoc ALIAS mongo::mongoc_static) + return() + endif() +endif() + +find_package(bson REQUIRED) +find_package(mongoc REQUIRED) + diff --git a/cmake/SetupPostgresqlDeps.cmake b/cmake/SetupPostgresqlDeps.cmake index 9cb13af39b26..3a392f9f895f 100644 --- a/cmake/SetupPostgresqlDeps.cmake +++ b/cmake/SetupPostgresqlDeps.cmake @@ -9,13 +9,14 @@ _userver_macos_set_default_dir(OPENSSL_ROOT_DIR "brew;--prefix;openssl") # We need libldap to statically link with libpq # There is no FindLdap.cmake and no package config files # for ldap library, so need to search for it by hand. -find_library(LDAP_LIBRARY NAMES ldap) +find_library(LDAP_LIBRARY NAMES libldap.so libldap.dylib libldap.framework) if(NOT LDAP_LIBRARY) message(FATAL_ERROR "Failed to find libldap.so.\n" "The linux system ldap installs shared objects with very ugly names, " "so please install `libldap2-dev` package. " "For Mac OS X please install `openldap`.") endif() +message(STATUS "Found ldap: ${LDAP_LIBRARY}") find_package(PostgreSQLInternal REQUIRED) find_package(GssApi REQUIRED) @@ -42,13 +43,16 @@ target_link_libraries(PostgreSQLInternal ${USERVER_LIB_MATH} ) -if(${CMAKE_SYSTEM_NAME} MATCHES "BSD") - find_package(libintl REQUIRED) - target_link_libraries(PostgreSQLInternal INTERFACE libintl) +if(${CMAKE_SYSTEM_NAME} MATCHES "BSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + find_package(Intl REQUIRED) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) + target_link_libraries(PostgreSQLInternal INTERFACE Intl::Intl) + else() + target_link_libraries(PostgreSQLInternal INTERFACE ${Intl_LIBRARIES}) + endif() endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - find_package(libintl REQUIRED) find_package(Iconv REQUIRED) - target_link_libraries(PostgreSQLInternal INTERFACE libintl Iconv::Iconv "-framework Foundation") + target_link_libraries(PostgreSQLInternal INTERFACE Iconv::Iconv) endif() diff --git a/cmake/SetupProtobuf.cmake b/cmake/SetupProtobuf.cmake index 7f47c593db3b..75b09ad1f9ab 100644 --- a/cmake/SetupProtobuf.cmake +++ b/cmake/SetupProtobuf.cmake @@ -25,7 +25,7 @@ function(_userver_set_protobuf_version_category) endfunction() if(USERVER_CONAN) - find_package(Protobuf REQUIRED) + find_package(Protobuf REQUIRED CONFIG) _userver_set_protobuf_version_category() set(PROTOBUF_PROTOC "${Protobuf_PROTOC_EXECUTABLE}") return() @@ -33,7 +33,6 @@ endif() if(NOT USERVER_FORCE_DOWNLOAD_PROTOBUF) # Use the builtin CMake FindProtobuf - set(Protobuf_USE_STATIC_LIBS ON) if(USERVER_DOWNLOAD_PACKAGE_PROTOBUF) find_package(Protobuf QUIET) else() @@ -69,7 +68,7 @@ CPMAddPackage( "protobuf_BUILD_TESTS OFF" "protobuf_INSTALL OFF" "protobuf_MSVC_STATIC_RUNTIME OFF" - "protobuf_ABSL_PROVIDER none" + "protobuf_ABSL_PROVIDER package" ) set(Protobuf_VERSION "${CPM_PACKAGE_Protobuf_VERSION}") diff --git a/cmake/SetupRdKafka.cmake b/cmake/SetupRdKafka.cmake index 535ace7c30a4..76d32b287355 100644 --- a/cmake/SetupRdKafka.cmake +++ b/cmake/SetupRdKafka.cmake @@ -4,11 +4,13 @@ option(USERVER_DOWNLOAD_PACKAGE_KAFKA "Download and setup librdkafka if no librd set(USERVER_KAFKA_VERSION "2.3.0") -find_package(OpenSSL COMPONENTS SSL Crypto REQUIRED) -find_package(CURL REQUIRED) +include("${CMAKE_CURRENT_LIST_DIR}/SetupCURL.cmake") + +find_package(OpenSSL REQUIRED) find_package(ZLIB REQUIRED) find_package(libzstd REQUIRED) find_package(lz4 REQUIRED) +find_package(SASL2 REQUIRED) if(NOT USERVER_FORCE_DOWNLOAD_PACKAGES) if(USERVER_DOWNLOAD_PACKAGE_KAFKA) @@ -18,6 +20,13 @@ if(NOT USERVER_FORCE_DOWNLOAD_PACKAGES) endif() if(RdKafka_FOUND) + target_link_libraries(RdKafka + INTERFACE + ZLIB::ZLIB + lz4::lz4 CURL::libcurl + OpenSSL::SSL OpenSSL::Crypto + SASL2::SASL2 zstd::zstd + ) return() endif() endif() @@ -46,4 +55,4 @@ set(KAFKA_CPM TRUE) target_compile_options(rdkafka PRIVATE "-Wno-ignored-qualifiers") mark_targets_as_system("${RdKafka_SOURCE_DIR}") -add_library(RdKafka ALIAS rdkafka) +add_library(RdKafka::rdkafka ALIAS rdkafka) diff --git a/cmake/SetupRocksDB.cmake b/cmake/SetupRocksDB.cmake index 95f3315b15cc..b3082de16ee0 100644 --- a/cmake/SetupRocksDB.cmake +++ b/cmake/SetupRocksDB.cmake @@ -17,7 +17,7 @@ endif() find_package(libgflags REQUIRED) find_package(libsnappy REQUIRED) find_package(ZLIB REQUIRED) -find_package(libzip REQUIRED) +find_package(BZip2 REQUIRED) find_package(libzstd REQUIRED) include(DownloadUsingCPM) @@ -28,12 +28,17 @@ CPMAddPackage( GIT_TAG v9.7.4 OPTIONS "ROCKSDB_BUILD_SHARED OFF" + "WITH_SNAPPY ON" + "WITH_BZ2 ON" + "WITH_ZSTD ON" "WITH_TESTS OFF" "WITH_BENCHMARK_TOOLS OFF" "WITH_TOOLS OFF" + "WITH_CORE_TOOLS OFF" + "WITH_TRACE_TOOLS OFF" "USE_RTTI ON" + "GFLAGS_SHARED FALSE" ) mark_targets_as_system("${rocksdb_SOURCE_DIR}") -write_package_stub(rocksdb) add_library(RocksDB::rocksdb ALIAS rocksdb) diff --git a/cmake/UserverPreferStaticLibs.cmake b/cmake/UserverPreferStaticLibs.cmake new file mode 100644 index 000000000000..b601f37934c5 --- /dev/null +++ b/cmake/UserverPreferStaticLibs.cmake @@ -0,0 +1,21 @@ +include_guard(GLOBAL) + +if(USERVER_USE_STATIC_LIBS) + set(OPENSSL_USE_STATIC_LIBS ON) + set(ZLIB_USE_STATIC_LIBS ON) + set(Protobuf_USE_STATIC_LIBS ON) + set(Boost_USE_STATIC_LIBS ON) + set(CURL_USE_STATIC_LIBS ON) + + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so") + if (CMAKE_SYSTEM_NAME MATCHES "Darwin") + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dylib") + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".tbd") + endif() + + set(_FIND_LIB_PRIORITY_MESSAGE "Static libraries are prefered") +else() + set(_FIND_LIB_PRIORITY_MESSAGE "Default ordered") +endif() + +message(STATUS "Modules type search priority order: ${CMAKE_FIND_LIBRARY_SUFFIXES} (${_FIND_LIB_PRIORITY_MESSAGE})") diff --git a/cmake/UserverSetupEnvironment.cmake b/cmake/UserverSetupEnvironment.cmake index 0c3f8d276171..6c4eeb9658e5 100644 --- a/cmake/UserverSetupEnvironment.cmake +++ b/cmake/UserverSetupEnvironment.cmake @@ -29,6 +29,9 @@ function(_userver_setup_environment_impl) message(STATUS "C++ compiler: ${CMAKE_CXX_COMPILER}") cmake_policy(SET CMP0057 NEW) + if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + include("${USERVER_CMAKE_DIR}/SetupHomebrew.cmake") + endif() if(NOT "${USERVER_CMAKE_DIR}/modules" IN_LIST CMAKE_MODULE_PATH AND NOT USERVER_CONAN) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${USERVER_CMAKE_DIR}/modules" PARENT_SCOPE) endif() @@ -63,6 +66,7 @@ function(_userver_setup_environment_impl) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" PARENT_SCOPE) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" PARENT_SCOPE) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION "${CMAKE_INTERPROCEDURAL_OPTIMIZATION}" PARENT_SCOPE) + message(STATUS "Linker global flags: ${CMAKE_EXE_LINKER_FLAGS}") option(USERVER_USE_CCACHE "Use ccache for build" ON) if(USERVER_USE_CCACHE) diff --git a/cmake/install/Config.cmake.in b/cmake/install/Config.cmake.in index 485a7145c1cb..e14b18eeb56e 100644 --- a/cmake/install/Config.cmake.in +++ b/cmake/install/Config.cmake.in @@ -42,10 +42,13 @@ set(USERVER_TESTSUITE_DIR "${USERVER_CMAKE_DIR}/testsuite") set(USERVER_CONAN @USERVER_CONAN@) set(USERVER_IMPL_ORIGINAL_CXX_STANDARD @CMAKE_CXX_STANDARD@) set(USERVER_IMPL_FEATURE_JEMALLOC @USERVER_FEATURE_JEMALLOC@) +set(USERVER_USE_STATIC_LIBS @USERVER_USE_STATIC_LIBS@) set_property(GLOBAL PROPERTY userver_cmake_dir "${USERVER_CMAKE_DIR}") list(APPEND CMAKE_MODULE_PATH "${USERVER_CMAKE_DIR}/modules") +include("${USERVER_CMAKE_DIR}/UserverPreferStaticLibs.cmake") + foreach(ITEM_COMPONENT IN LISTS userver_FIND_COMPONENTS) include("${USERVER_CMAKE_DIR}/userver-${ITEM_COMPONENT}-config.cmake") endforeach() diff --git a/cmake/install/userver-core-config.cmake b/cmake/install/userver-core-config.cmake index b1d16ead75c1..dabd8c4d4c1e 100644 --- a/cmake/install/userver-core-config.cmake +++ b/cmake/install/userver-core-config.cmake @@ -13,7 +13,6 @@ find_package(Boost REQUIRED CONFIG COMPONENTS iostreams ) -find_package(CURL "7.68" REQUIRED) find_package(ZLIB REQUIRED) include("${USERVER_CMAKE_DIR}/UserverTestsuite.cmake") @@ -23,13 +22,15 @@ if (USERVER_CONAN) find_package(libnghttp2 REQUIRED CONFIG) find_package(libev REQUIRED CONFIG) find_package(concurrentqueue REQUIRED CONFIG) + find_package(CURL "7.68" REQUIRED) else() - include("${USERVER_CMAKE_DIR}/modules/Findc-ares.cmake") + find_package(Nghttp2 REQUIRED) + find_package(LibEv REQUIRED) + find_package(c-ares REQUIRED) if (c-ares_FOUND AND NOT TARGET c-ares::cares) add_library(c-ares::cares ALIAS c-ares) endif() - find_package(Nghttp2 REQUIRED) - find_package(LibEv REQUIRED) + include("${USERVER_CMAKE_DIR}/SetupCURL.cmake") endif() set(userver_core_FOUND TRUE) diff --git a/cmake/install/userver-kafka-config.cmake b/cmake/install/userver-kafka-config.cmake index 666d1537bc7b..7aa7ea930a1c 100644 --- a/cmake/install/userver-kafka-config.cmake +++ b/cmake/install/userver-kafka-config.cmake @@ -11,8 +11,7 @@ find_package(userver REQUIRED COMPONENTS if(USERVER_CONAN) find_package(RdKafka REQUIRED CONFIG) else() - include("${USERVER_CMAKE_DIR}/modules/Findlz4.cmake") - include("${USERVER_CMAKE_DIR}/modules/FindRdKafka.cmake") + include("${USERVER_CMAKE_DIR}/SetupRdKafka.cmake") endif() set(userver_kafka_FOUND TRUE) diff --git a/cmake/install/userver-mongo-config.cmake b/cmake/install/userver-mongo-config.cmake index 5650fe2d05bd..cd9c182a6172 100644 --- a/cmake/install/userver-mongo-config.cmake +++ b/cmake/install/userver-mongo-config.cmake @@ -11,8 +11,7 @@ find_package(userver REQUIRED COMPONENTS if (USERVER_CONAN) find_package(mongoc-1.0 REQUIRED CONFIG) else() - include("${USERVER_CMAKE_DIR}/modules/Findbson.cmake") - include("${USERVER_CMAKE_DIR}/modules/Findmongoc.cmake") + include("${USERVER_CMAKE_DIR}/SetupMongoDeps.cmake") endif() set(userver_mongo_FOUND TRUE) diff --git a/cmake/install/userver-universal-config.cmake b/cmake/install/userver-universal-config.cmake index f69f1a1410c2..6580978a2f88 100644 --- a/cmake/install/userver-universal-config.cmake +++ b/cmake/install/userver-universal-config.cmake @@ -17,6 +17,11 @@ find_package(Boost REQUIRED CONFIG COMPONENTS ) find_package(Iconv REQUIRED) +if(Boost_USE_STATIC_LIBS AND Boost_VERSION VERSION_LESS 1.75) + # https://github.com/boostorg/locale/issues/156 + find_package(ICU COMPONENTS uc i18n data REQUIRED) +endif() + _userver_macos_set_default_dir(OPENSSL_ROOT_DIR "brew;--prefix;openssl") find_package(OpenSSL REQUIRED) diff --git a/cmake/modules/FindCrypto.cmake b/cmake/modules/FindCrypto.cmake deleted file mode 100644 index 3ea31c4cc6af..000000000000 --- a/cmake/modules/FindCrypto.cmake +++ /dev/null @@ -1,12 +0,0 @@ -_userver_module_begin( - NAME Crypto - COMMON_NAME OpenSSL - PACKAGE_NAME OpenSSL - DEBIAN_NAMES libssl-dev - FORMULA_NAMES openssl - RPM_NAMES openssl-devel - PACMAN_NAMES openssl - PKG_CONFIG_NAMES openssl -) - -_userver_module_end() diff --git a/cmake/modules/FindCryptoPP.cmake b/cmake/modules/FindCryptoPP.cmake index ce8148fb41c0..cad086daf05c 100644 --- a/cmake/modules/FindCryptoPP.cmake +++ b/cmake/modules/FindCryptoPP.cmake @@ -13,7 +13,7 @@ _userver_module_find_include( ) _userver_module_find_library( - NAMES cryptlib cryptopp + NAMES cryptopp cryptlib PATH_SUFFIXES lib ) diff --git a/cmake/modules/FindGssApi.cmake b/cmake/modules/FindGssApi.cmake index 600984cb644a..eed04fd30b68 100644 --- a/cmake/modules/FindGssApi.cmake +++ b/cmake/modules/FindGssApi.cmake @@ -12,6 +12,7 @@ _userver_module_find_include( _userver_module_find_library( NAMES gssapi_krb5 gssapi + PATH_SUFFIXES gssapi ) _userver_module_end() diff --git a/cmake/modules/FindRdKafka.cmake b/cmake/modules/FindRdKafka.cmake index e39ceaf353ca..4cb5bf62dbb9 100644 --- a/cmake/modules/FindRdKafka.cmake +++ b/cmake/modules/FindRdKafka.cmake @@ -12,7 +12,11 @@ _userver_module_find_include( ) _userver_module_find_library( - NAMES librdkafka.a + NAMES rdkafka ) _userver_module_end() + +if(NOT TARGET RdKafka::rdkafka) + add_library(RdKafka::rdkafka ALIAS RdKafka) +endif() diff --git a/cmake/modules/FindRocksDB.cmake b/cmake/modules/FindRocksDB.cmake index 0c3d575d3d7f..30ed4593dd07 100644 --- a/cmake/modules/FindRocksDB.cmake +++ b/cmake/modules/FindRocksDB.cmake @@ -12,7 +12,7 @@ _userver_module_find_include( ) _userver_module_find_library( - NAMES librocksdb.a + NAMES rocksdb ) _userver_module_end() diff --git a/cmake/modules/FindSASL2.cmake b/cmake/modules/FindSASL2.cmake new file mode 100644 index 000000000000..9569f1ea8ad8 --- /dev/null +++ b/cmake/modules/FindSASL2.cmake @@ -0,0 +1,30 @@ +if(TARGET SASL2::SASL2) +# Maybe already found by mongoc-1.0 config + return() +endif() + +_userver_module_begin( + NAME SASL2 + DEBIAN_NAMES libsasl2-dev + FORMULA_NAMES cyrus-sasl + PKG_CONFIG_NAMES libsasl2 +) + +_userver_module_find_include( + NAMES sasl/sasl.h + PATHS + /usr/lib/x86_64-linux-gnu + /opt/homebrew/include +) + +# sasl2 has to many dependencies to reliably be linked statically +_userver_module_find_library( + NAMES libsasl2.dylib libsasl2.tbd libsasl2.so + PATHS + /usr/lib/x86_64-linux-gnu + /opt/homebrew/lib +) + +_userver_module_end() + +add_library(SASL2::SASL2 ALIAS SASL2) diff --git a/cmake/modules/FindSSL.cmake b/cmake/modules/FindSSL.cmake deleted file mode 100644 index c590d78e36e2..000000000000 --- a/cmake/modules/FindSSL.cmake +++ /dev/null @@ -1,12 +0,0 @@ -_userver_module_begin( - NAME SSL - COMMON_NAME OpenSSL - PACKAGE_NAME OpenSSL - DEBIAN_NAMES libssl-dev - FORMULA_NAMES openssl - RPM_NAMES openssl-devel - PACMAN_NAMES openssl - PKG_CONFIG_NAMES libssl -) - -_userver_module_end() diff --git a/cmake/modules/FindUserverGrpc.cmake b/cmake/modules/FindUserverGrpc.cmake index 63d2a8a24d37..86fa240c5474 100644 --- a/cmake/modules/FindUserverGrpc.cmake +++ b/cmake/modules/FindUserverGrpc.cmake @@ -11,21 +11,21 @@ _userver_module_find_include( ) _userver_module_find_library( - NAMES grpc + NAMES libgrpc.so ) _userver_module_find_library( - NAMES grpc++ + NAMES libgrpc++.so ) _userver_module_find_library( - NAMES gpr + NAMES libgpr.so ) _userver_module_find_library( NAMES absl - absl_synchronization + libabsl_synchronization.so grpc # fallback, old versions of gRPC do not link with absl ) diff --git a/cmake/modules/Findbson.cmake b/cmake/modules/Findbson.cmake index 82f525df10a9..0f98ba186cca 100644 --- a/cmake/modules/Findbson.cmake +++ b/cmake/modules/Findbson.cmake @@ -17,7 +17,11 @@ _userver_module_find_include( ) _userver_module_find_library( - NAMES bson bson-1.0 + NAMES bson-1.0 bson + PATHS + /usr/include/libbson-1.0 + /usr/local/opt/mongo-c-driver/include/libbson-1.0 + /opt/homebrew/opt/mongo-c-driver/include/libbson-1.0 ) _userver_module_end() diff --git a/cmake/modules/Findc-ares.cmake b/cmake/modules/Findc-ares.cmake index e98fe19228c1..cbb7f856cc26 100644 --- a/cmake/modules/Findc-ares.cmake +++ b/cmake/modules/Findc-ares.cmake @@ -13,7 +13,7 @@ _userver_module_find_include( ) _userver_module_find_library( - NAMES libcares.a libcares_static.a libcares.so + NAMES cares_static cares ) _userver_module_end() diff --git a/cmake/modules/Findcctz.cmake b/cmake/modules/Findcctz.cmake index 001b31377217..c1b75af445b0 100644 --- a/cmake/modules/Findcctz.cmake +++ b/cmake/modules/Findcctz.cmake @@ -13,7 +13,6 @@ _userver_module_find_include( _userver_module_find_library( NAMES cctz - PATHS /usr/lib/x86_64-linux-gnu ) _userver_module_end() diff --git a/cmake/modules/Findclickhouse-cpp.cmake b/cmake/modules/Findclickhouse-cpp.cmake index 617c0dc2b802..8c01568d0a3c 100644 --- a/cmake/modules/Findclickhouse-cpp.cmake +++ b/cmake/modules/Findclickhouse-cpp.cmake @@ -1,16 +1,27 @@ _userver_module_begin( NAME clickhouse-cpp + FORMULA_NAMES clickhouse-cpp ) _userver_module_find_include( NAMES clickhouse/block.h PATH_SUFFIXES - clickhouse-cpp - yandex/clickhouse-cpp + clickhouse-cpp + yandex/clickhouse-cpp ) _userver_module_find_library( - NAMES libclickhouse-cpp-lib.so + NAMES clickhouse-cpp-lib + PATH_SUFFIXES + clickhouse-cpp + yandex/clickhouse-cpp ) +if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + _userver_module_find_library( + NAMES libcityhash.a + PATHS /opt/homebrew/opt/clickhouse-cpp/libexec/lib + ) +endif() + _userver_module_end() diff --git a/cmake/modules/Findlibintl.cmake b/cmake/modules/Findlibintl.cmake deleted file mode 100644 index 6f02d1f1601c..000000000000 --- a/cmake/modules/Findlibintl.cmake +++ /dev/null @@ -1,14 +0,0 @@ -_userver_module_begin( - NAME libintl -) - -_userver_module_find_include( - NAMES stdio.h -) - -_userver_module_find_library( - NAMES libintl.a # FreeBSD - PATHS /usr/local/lib -) - -_userver_module_end() diff --git a/cmake/modules/Findlibmariadb.cmake b/cmake/modules/Findlibmariadb.cmake index 8dfe8f715d92..d5b066d18a90 100644 --- a/cmake/modules/Findlibmariadb.cmake +++ b/cmake/modules/Findlibmariadb.cmake @@ -7,12 +7,12 @@ _userver_module_begin( ) _userver_module_find_include( - NAMES mysql/mysql.h mariadb/mysql.h + NAMES mysql.h + PATH_SUFFIXES mariadb mysql ) _userver_module_find_library( NAMES mariadb - PATH_SUFFIXES lib ) _userver_module_end() diff --git a/cmake/modules/Findlibsnappy.cmake b/cmake/modules/Findlibsnappy.cmake index 225685291c2b..47a7148132ae 100644 --- a/cmake/modules/Findlibsnappy.cmake +++ b/cmake/modules/Findlibsnappy.cmake @@ -21,3 +21,8 @@ _userver_module_find_library( ) _userver_module_end() + +if(NOT TARGET Snappy::snappy) + add_library(Snappy::snappy ALIAS libsnappy) + add_library(Snappy::snappy-static ALIAS libsnappy) +endif() diff --git a/cmake/modules/Findlibzip.cmake b/cmake/modules/Findlibzip.cmake deleted file mode 100644 index f0c04b5fa42d..000000000000 --- a/cmake/modules/Findlibzip.cmake +++ /dev/null @@ -1,19 +0,0 @@ -_userver_module_begin( - NAME libzip - DEBIAN_NAMES libbz2-dev - FORMULA_NAMES libbz2 - RPM_NAMES libbz2-dev - PACMAN_NAMES bzip2 -) - -_userver_module_find_include( - NAMES bzlib.h - PATH_SUFFIXES include -) - -_userver_module_find_library( - NAMES bz2 libbz2 - PATH_SUFFIXES lib -) - -_userver_module_end() diff --git a/cmake/modules/Findlibzstd.cmake b/cmake/modules/Findlibzstd.cmake index 54b5f0cbe53b..bff352056bc4 100644 --- a/cmake/modules/Findlibzstd.cmake +++ b/cmake/modules/Findlibzstd.cmake @@ -20,3 +20,8 @@ _userver_module_find_library( ) _userver_module_end() + +if(NOT TARGET zstd::zstd) + add_library(zstd::zstd ALIAS libzstd) +endif() +add_library(zstd ALIAS libzstd) diff --git a/cmake/modules/Findlz4.cmake b/cmake/modules/Findlz4.cmake index d4abb3a4a5d6..7f557b2ef4d8 100644 --- a/cmake/modules/Findlz4.cmake +++ b/cmake/modules/Findlz4.cmake @@ -11,9 +11,11 @@ _userver_module_find_include( ) _userver_module_find_library( - NAMES liblz4.a + NAMES lz4 ) _userver_module_end() -add_library(lz4::lz4 ALIAS lz4) +if(NOT TARGET lz4::lz4) + add_library(lz4::lz4 ALIAS lz4) +endif() diff --git a/cmake/modules/Findmongoc.cmake b/cmake/modules/Findmongoc.cmake index 9a4445bc42db..b14e1a83ada8 100644 --- a/cmake/modules/Findmongoc.cmake +++ b/cmake/modules/Findmongoc.cmake @@ -17,7 +17,11 @@ _userver_module_find_include( ) _userver_module_find_library( - NAMES mongoc mongoc-1.0 + NAMES mongoc-1.0 mongoc + PATHS + /usr/include/libmongoc-1.0 + /usr/local/opt/mongo-c/include/libmongoc-1.0 + /opt/homebrew/opt/mongo-c-driver/include/libmongoc-1.0 ) _userver_module_end() diff --git a/conanfile.py b/conanfile.py index 37e098be765b..4b98bffda1ea 100644 --- a/conanfile.py +++ b/conanfile.py @@ -76,6 +76,11 @@ class UserverConan(ConanFile): 'grpc/*:ruby_plugin': False, 'grpc/*:csharp_plugin': False, 'grpc/*:objective_c_plugin': False, + 'librdkafka/*:ssl': True, + 'librdkafka/*:curl': True, + 'librdkafka/*:sasl': True, + 'librdkafka/*:zlib': True, + 'librdkafka/*:zstd': True, } def set_version(self): diff --git a/kafka/CMakeLists.txt b/kafka/CMakeLists.txt index 06bb49305dfa..27f37b7a25b5 100644 --- a/kafka/CMakeLists.txt +++ b/kafka/CMakeLists.txt @@ -1,32 +1,14 @@ project(userver-kafka CXX) if(USERVER_CONAN) - find_package(OpenSSL COMPONENTS SSL Crypto REQUIRED CONFIG) - find_package(CURL REQUIRED CONFIG) - find_package(ZLIB REQUIRED CONFIG) - - find_package(zstd REQUIRED CONFIG) - # According to https://conan.io/center/recipes/zstd should be - # zstd::libzstd_static, but it does not work that way - if (TARGET zstd::libzstd_static) - add_library(libzstd ALIAS zstd::libzstd_static) - else() - add_library(libzstd ALIAS zstd::libzstd_shared) - endif() - find_package(RdKafka REQUIRED CONFIG) - set_target_properties(RdKafka::rdkafka PROPERTIES IMPORTED_GLOBAL TRUE) - add_library(RdKafka ALIAS RdKafka::rdkafka) - - find_package(cyrus-sasl REQUIRED CONFIG) - add_library(sasl2 ALIAS cyrus-sasl::cyrus-sasl) else() include(SetupRdKafka) endif() userver_module(kafka SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" - LINK_LIBRARIES_PRIVATE RdKafka sasl2 ZLIB::ZLIB libzstd lz4::lz4 CURL::libcurl OpenSSL::SSL OpenSSL::Crypto + LINK_LIBRARIES_PRIVATE RdKafka::rdkafka DBTEST_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests" DBTEST_LINK_LIBRARIES userver::kafka-utest DBTEST_DATABASES kafka @@ -47,10 +29,17 @@ if(KAFKA_CPM) ) endif() +_userver_directory_install(COMPONENT kafka + FILES + "${USERVER_ROOT_DIR}/cmake/SetupRdKafka.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/userver" +) + _userver_directory_install(COMPONENT kafka FILES "${USERVER_ROOT_DIR}/cmake/modules/FindRdKafka.cmake" "${USERVER_ROOT_DIR}/cmake/modules/Findlz4.cmake" + "${USERVER_ROOT_DIR}/cmake/modules/FindSASL2.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/userver/modules" ) diff --git a/kafka/functional_tests/CMakeLists.txt b/kafka/functional_tests/CMakeLists.txt index 3cb1804c3d7c..7acf990ca0b8 100644 --- a/kafka/functional_tests/CMakeLists.txt +++ b/kafka/functional_tests/CMakeLists.txt @@ -1,7 +1,5 @@ project(userver-kafka-tests CXX) -message(STATUS "Configuring Kafka functional_tests") - add_custom_target(${PROJECT_NAME}) add_subdirectory(balanced_consumer_groups) diff --git a/kafka/utest/src/kafka/utest/kafka_fixture.cpp b/kafka/utest/src/kafka/utest/kafka_fixture.cpp index f9cb0667f0f5..49af0b6b71b9 100644 --- a/kafka/utest/src/kafka/utest/kafka_fixture.cpp +++ b/kafka/utest/src/kafka/utest/kafka_fixture.cpp @@ -49,7 +49,7 @@ impl::Secret MakeSecrets(std::string_view bootstrap_servers) { return secrets; } -impl::ProducerConfiguration PatchDeliveryTimeout(impl::ProducerConfiguration&& configuration) { +impl::ProducerConfiguration PatchDeliveryTimeout(impl::ProducerConfiguration configuration) { static const impl::ProducerConfiguration kDefaultProducerConfiguration{}; if (configuration.delivery_timeout == kDefaultProducerConfiguration.delivery_timeout) { @@ -102,7 +102,7 @@ Producer KafkaCluster::MakeProducer(const std::string& name, impl::ProducerConfi engine::current_task::GetTaskProcessor(), PatchDeliveryTimeout(std::move(configuration)), MakeSecrets(bootstrap_servers_)}; -}; +} std::deque KafkaCluster::MakeProducers( std::size_t count, diff --git a/mongo/CMakeLists.txt b/mongo/CMakeLists.txt index 9e5b99837f87..b34f1e1ad0b5 100644 --- a/mongo/CMakeLists.txt +++ b/mongo/CMakeLists.txt @@ -6,10 +6,8 @@ if (USERVER_CONAN) set_target_properties(mongo::mongoc_static PROPERTIES IMPORTED_GLOBAL TRUE) add_library(bson ALIAS mongo::bson_static) add_library(mongoc ALIAS mongo::mongoc_static) - find_package(cyrus-sasl REQUIRED CONFIG) else() - find_package(bson REQUIRED) - find_package(mongoc REQUIRED) + include(SetupMongoDeps) endif() userver_module(mongo @@ -25,6 +23,11 @@ userver_module(mongo UBENCH_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_benchmark.cpp" ) +_userver_directory_install(COMPONENT mongo FILES + "${USERVER_ROOT_DIR}/cmake/SetupMongoDeps.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/userver +) + _userver_directory_install(COMPONENT mongo FILES "${USERVER_ROOT_DIR}/cmake/modules/Findmongoc.cmake" "${USERVER_ROOT_DIR}/cmake/modules/Findbson.cmake" diff --git a/mysql/CMakeLists.txt b/mysql/CMakeLists.txt index 5cfba0ff793c..8dc6ee5ed6e6 100644 --- a/mysql/CMakeLists.txt +++ b/mysql/CMakeLists.txt @@ -1,10 +1,12 @@ project(userver-mysql CXX) +find_package(OpenSSL REQUIRED) +find_package(ZLIB REQUIRED) find_package(libmariadb REQUIRED) userver_module(mysql SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" - LINK_LIBRARIES_PRIVATE libmariadb + LINK_LIBRARIES_PRIVATE libmariadb ZLIB::ZLIB OpenSSL::SSL OpenSSL::Crypto DBTEST_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests" UTEST_LINK_LIBRARIES libmariadb diff --git a/postgresql/CMakeLists.txt b/postgresql/CMakeLists.txt index 4050013d584f..6f31ea25ce74 100644 --- a/postgresql/CMakeLists.txt +++ b/postgresql/CMakeLists.txt @@ -12,7 +12,12 @@ else() PROPERTIES COMPILE_FLAGS -DUSERVER_NO_LIBPQ_PATCHES=1 ) - find_package(PostgreSQL REQUIRED) + if(USERVER_CONAN) + find_package(PostgreSQL REQUIRED CONFIG) + else() + find_library(PostgreSQL_LIBRARY NAMES libpq.so libpq.dylib REQUIRED) + find_package(PostgreSQL REQUIRED) + endif() target_link_libraries(userver-libpq INTERFACE PostgreSQL::PostgreSQL) endif() diff --git a/rabbitmq/CMakeLists.txt b/rabbitmq/CMakeLists.txt index 5afcaac82daf..206ebd053ec8 100644 --- a/rabbitmq/CMakeLists.txt +++ b/rabbitmq/CMakeLists.txt @@ -1,7 +1,7 @@ project(userver-rabbitmq CXX) if (USERVER_CONAN) - find_package(amqpcpp) + find_package(amqpcpp REQUIRED CONFIG) else() include(SetupAmqpCPP) endif() diff --git a/scripts/build_and_install.sh b/scripts/build_and_install.sh index 6a1bc22147d1..d1d2223207aa 100755 --- a/scripts/build_and_install.sh +++ b/scripts/build_and_install.sh @@ -44,7 +44,6 @@ for BUILD_TYPE in Debug Release; do done cpack -G DEB --config build_release/CPackConfig.cmake -D CPACK_INSTALL_CMAKE_PROJECTS="build_debug;userver;ALL;/;build_release;userver;ALL;/" ${PACKAGE_OPTIONS:-""} -apt update DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends ./libuserver-all-dev*.deb rm -rf ./build_debug/ ./build_release/ diff --git a/scripts/docs/en/deps/alpine.md b/scripts/docs/en/deps/alpine.md index 187cade1aaa5..0f13f206c9f6 100644 --- a/scripts/docs/en/deps/alpine.md +++ b/scripts/docs/en/deps/alpine.md @@ -1,24 +1,35 @@ boost1.84-dev +boost1.84-static +benchmark-dev clang17-extra-tools clang18 cmake +crypto++-dev curl-dev +curl-static gflags-dev git grpc-cpp grpc-dev +gtest-dev hiredis-dev jemalloc-dev krb5-dev libev-dev +libbson-dev +libbson-static lz4-dev lz4-static make mariadb-dev mariadb-static mongo-c-driver-dev +mongo-c-driver-static nghttp2-dev +nghttp2-static openldap-dev +openssl-dev +openssl-libs-static postgresql16-dev protobuf-c-compiler protobuf-c-dev @@ -29,6 +40,12 @@ py3-jinja2 py3-protobuf python3 python3-dev +rabbitmq-c-dev +rocksdb-dev snappy-dev snappy-static yaml-cpp-dev +zlib-dev +zlib-static +zstd-dev +zstd-static diff --git a/scripts/docs/en/deps/macos.md b/scripts/docs/en/deps/macos.md index 76b83406ffe5..9d87781ae344 100644 --- a/scripts/docs/en/deps/macos.md +++ b/scripts/docs/en/deps/macos.md @@ -1,29 +1,30 @@ +boost@1.87 +c-ares ccache +cctz cmake +coreutils +clickhouse-cpp cryptopp cyrus-sasl +fmt git google-benchmark -boost -ares -cctz -libev -fmt googletest hiredis +icu4c@76 jemalloc krb5 +libev +librdkafka +mariadb +mongo-c-driver nghttp2 ninja -pugixml +openldap openssl -yaml-cpp -librdkafka -rocksdb postgresql@16 -redis +pugixml +rocksdb +yaml-cpp zlib -c-ares -coreutils -mongo-c-driver -mariadb diff --git a/scripts/docs/en/deps/ubuntu-18.04.md b/scripts/docs/en/deps/ubuntu-18.04.md index 59d5cb74a67a..f75ffdd26741 100644 --- a/scripts/docs/en/deps/ubuntu-18.04.md +++ b/scripts/docs/en/deps/ubuntu-18.04.md @@ -25,6 +25,7 @@ libjemalloc-dev libkrb5-dev libldap2-dev librdkafka-dev +liblzma-dev libmongoc-dev libnghttp2-dev libpq-dev=10.* diff --git a/scripts/docs/en/deps/ubuntu-20.04.md b/scripts/docs/en/deps/ubuntu-20.04.md index 9ad81f135c9f..babf5acf543e 100644 --- a/scripts/docs/en/deps/ubuntu-20.04.md +++ b/scripts/docs/en/deps/ubuntu-20.04.md @@ -14,6 +14,7 @@ libboost-regex1.71-dev libboost-stacktrace1.71-dev libboost1.71-dev libbson-dev +libc-ares-dev libcctz-dev libcrypto++-dev libcurl4-openssl-dev @@ -28,6 +29,7 @@ libjemalloc-dev libkrb5-dev libldap2-dev librdkafka-dev +liblzma-dev libmariadb-dev libmongoc-dev libnghttp2-dev diff --git a/scripts/docs/en/deps/ubuntu-21.10.md b/scripts/docs/en/deps/ubuntu-21.10.md index 8890b21c5cd1..79f5745038a6 100644 --- a/scripts/docs/en/deps/ubuntu-21.10.md +++ b/scripts/docs/en/deps/ubuntu-21.10.md @@ -29,6 +29,7 @@ libjemalloc-dev libkrb5-dev libldap2-dev librdkafka-dev +liblzma-dev libmongoc-dev libnghttp2-dev libpq-dev diff --git a/scripts/docs/en/deps/ubuntu-22.04.md b/scripts/docs/en/deps/ubuntu-22.04.md index b58a1236b03e..59df4e13739b 100644 --- a/scripts/docs/en/deps/ubuntu-22.04.md +++ b/scripts/docs/en/deps/ubuntu-22.04.md @@ -29,12 +29,14 @@ libgrpc++1 libgrpc-dev libgtest-dev libhiredis-dev +libicu-dev libidn11-dev libjemalloc-dev libkrb5-dev libldap2-dev librdkafka-dev liblz4-dev +liblzma-dev libmariadb-dev libmongoc-dev libnghttp2-dev diff --git a/scripts/docs/en/deps/ubuntu-24.04.md b/scripts/docs/en/deps/ubuntu-24.04.md index 56acaff818c9..03f3ccb3d895 100644 --- a/scripts/docs/en/deps/ubuntu-24.04.md +++ b/scripts/docs/en/deps/ubuntu-24.04.md @@ -36,6 +36,7 @@ libldap2-dev librdkafka-dev librocksdb-dev liblz4-dev +liblzma-dev libmariadb-dev libmongoc-dev libnghttp2-dev diff --git a/scripts/gdb/tests/CMakeLists.txt b/scripts/gdb/tests/CMakeLists.txt index 224557dd67ca..fc50617d8bdb 100644 --- a/scripts/gdb/tests/CMakeLists.txt +++ b/scripts/gdb/tests/CMakeLists.txt @@ -1,6 +1,10 @@ if (NOT (CMAKE_BUILD_TYPE MATCHES "Debug" OR CMAKE_BUILD_TYPE MATCHES "Test")) return() endif() +if (CMAKE_SYSTEM_NAME MATCHES "Darwin") + # There is not GDB for MacOS + return() +endif() find_program(GDB_EXECUTABLE gdb DOC "GDB executable") if ("${GDB_EXECUTABLE}" STREQUAL GDB_EXECUTABLE-NOTFOUND) diff --git a/testsuite/requirements-grpc-3.txt b/testsuite/requirements-grpc-3.txt index 1649bd5d6882..50ec3359a7bd 100644 --- a/testsuite/requirements-grpc-3.txt +++ b/testsuite/requirements-grpc-3.txt @@ -11,4 +11,5 @@ new_python_is_incompatible_with_old_grpc >= 9999; python_version >= '3.11' grpcio >= 1.32.0, <= 1.49.0 grpcio-tools >= 1.32.0, <= 1.49.0 +grpcio-reflection >= 1.32.0, <= 1.49.0 protobuf >= 3.12.0, < 4.0dev diff --git a/testsuite/requirements-grpc-4.txt b/testsuite/requirements-grpc-4.txt index a962fcfb4381..25ec503dd28a 100644 --- a/testsuite/requirements-grpc-4.txt +++ b/testsuite/requirements-grpc-4.txt @@ -1,3 +1,4 @@ grpcio >= 1.50.0 grpcio-tools >= 1.50.0 +grpcio-reflection >= 1.50.0 protobuf >= 4.21.12, < 5.0dev diff --git a/testsuite/requirements-grpc-5.txt b/testsuite/requirements-grpc-5.txt index 11e706c941eb..22440ee3f549 100644 --- a/testsuite/requirements-grpc-5.txt +++ b/testsuite/requirements-grpc-5.txt @@ -1,3 +1,4 @@ grpcio >= 1.63.0 grpcio-tools >= 1.63.0 +grpcio-reflection >= 1.63.0 protobuf >= 5.26.0, < 6.0dev diff --git a/testsuite/requirements-internal-tests.txt b/testsuite/requirements-internal-tests.txt index 09d4bd599408..1417a31d199a 100644 --- a/testsuite/requirements-internal-tests.txt +++ b/testsuite/requirements-internal-tests.txt @@ -1,3 +1,2 @@ httpx >= 0.27.0 h2 >= 4.1.0 -grpcio-reflection diff --git a/universal/CMakeLists.txt b/universal/CMakeLists.txt index 2eb72d7e10fc..6de3e791d44f 100644 --- a/universal/CMakeLists.txt +++ b/universal/CMakeLists.txt @@ -56,13 +56,13 @@ endif() find_package_required(OpenSSL "libssl-dev") if (USERVER_CONAN) - find_package(cryptopp REQUIRED) - find_package(yaml-cpp REQUIRED) - find_package(fmt REQUIRED) - find_package(cctz REQUIRED) - find_package(zstd REQUIRED) + find_package(cryptopp REQUIRED CONFIG) + find_package(yaml-cpp REQUIRED CONFIG) + find_package(fmt REQUIRED CONFIG) + find_package(cctz REQUIRED CONFIG) + find_package(zstd REQUIRED CONFIG) - find_package(RapidJSON REQUIRED) + find_package(RapidJSON REQUIRED CONFIG) target_compile_definitions(rapidjson INTERFACE RAPIDJSON_HAS_STDSTRING) else() include(SetupCryptoPP) @@ -249,14 +249,8 @@ if (USERVER_CONAN) yaml-cpp cryptopp::cryptopp rapidjson + zstd::libzstd_static ) - # According to https://conan.io/center/recipes/zstd should be - # zstd::libzstd_static, but it does not work that way - if (TARGET zstd::libzstd_static) - target_link_libraries(${PROJECT_NAME} PRIVATE zstd::libzstd_static) - else() - target_link_libraries(${PROJECT_NAME} PRIVATE zstd::libzstd_shared) - endif() else() include(Stacktrace) _make_stacktrace_target(userver-stacktrace "${Boost_VERSION_STRING}") @@ -272,6 +266,12 @@ else() libzstd CryptoPP ) + + if(Boost_USE_STATIC_LIBS AND Boost_FOUND AND Boost_VERSION VERSION_LESS 1.75) + # https://github.com/boostorg/locale/issues/156 + find_package(ICU COMPONENTS uc i18n data REQUIRED) + target_link_libraries(${PROJECT_NAME} PRIVATE ICU::uc ICU::i18n ICU::data) + endif() endif() target_include_directories(${PROJECT_NAME} @@ -312,7 +312,7 @@ if (USERVER_FEATURE_UTEST) add_library(${PROJECT_NAME}-internal-ubench INTERFACE) if (USERVER_CONAN) - find_package(benchmark REQUIRED) + find_package(benchmark REQUIRED CONFIG) else() include(SetupGBench) endif() @@ -376,6 +376,7 @@ endif() _userver_directory_install(COMPONENT universal FILES "${USERVER_ROOT_DIR}/cmake/ModuleHelpers.cmake" + "${USERVER_ROOT_DIR}/cmake/SetupCURL.cmake" "${USERVER_ROOT_DIR}/cmake/SetupGTest.cmake" "${USERVER_ROOT_DIR}/cmake/SetupGBench.cmake" "${USERVER_ROOT_DIR}/cmake/sanitize.blacklist.txt" @@ -384,12 +385,14 @@ _userver_directory_install(COMPONENT universal FILES "${USERVER_ROOT_DIR}/cmake/SetupLTO.cmake" "${USERVER_ROOT_DIR}/cmake/SetupPGO.cmake" "${USERVER_ROOT_DIR}/cmake/SetupLinker.cmake" + "${USERVER_ROOT_DIR}/cmake/SetupHomebrew.cmake" "${USERVER_ROOT_DIR}/cmake/Sanitizers.cmake" "${USERVER_ROOT_DIR}/cmake/AddGoogleTests.cmake" "${USERVER_ROOT_DIR}/cmake/DetectVersion.cmake" "${USERVER_ROOT_DIR}/cmake/UserverSetupEnvironment.cmake" "${USERVER_ROOT_DIR}/cmake/UserverVenv.cmake" "${USERVER_ROOT_DIR}/cmake/UserverEmbedFile.cmake" + "${USERVER_ROOT_DIR}/cmake/UserverPreferStaticLibs.cmake" "${USERVER_ROOT_DIR}/cmake/embedded_config.cmake" "${USERVER_ROOT_DIR}/cmake/install/userver-universal-config.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/userver diff --git a/universal/utest/CMakeLists.txt b/universal/utest/CMakeLists.txt index e1b6614c3179..5b69530da94f 100644 --- a/universal/utest/CMakeLists.txt +++ b/universal/utest/CMakeLists.txt @@ -1,7 +1,7 @@ project(userver-universal-utest CXX) if(USERVER_CONAN) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED CONFIG) else() include(SetupGTest) endif()