diff --git a/.mapping.json b/.mapping.json index 5ff1fed21ef3..d26a596b2333 100644 --- a/.mapping.json +++ b/.mapping.json @@ -305,6 +305,7 @@ "cmake/Sanitizers.cmake":"taxi/uservices/userver/cmake/Sanitizers.cmake", "cmake/SetupAbseil.cmake":"taxi/uservices/userver/cmake/SetupAbseil.cmake", "cmake/SetupAmqpCPP.cmake":"taxi/uservices/userver/cmake/SetupAmqpCPP.cmake", + "cmake/SetupBrotli.cmake":"taxi/uservices/userver/cmake/SetupBrotli.cmake", "cmake/SetupCAres.cmake":"taxi/uservices/userver/cmake/SetupCAres.cmake", "cmake/SetupCCTZ.cmake":"taxi/uservices/userver/cmake/SetupCCTZ.cmake", "cmake/SetupCURL.cmake":"taxi/uservices/userver/cmake/SetupCURL.cmake", diff --git a/cmake/SetupBrotli.cmake b/cmake/SetupBrotli.cmake new file mode 100644 index 000000000000..317b5545ebf8 --- /dev/null +++ b/cmake/SetupBrotli.cmake @@ -0,0 +1,40 @@ +option(USERVER_DOWNLOAD_PACKAGE_BROTLI "Download and setup Brotli if no Brotli of matching version was found" ${USERVER_DOWNLOAD_PACKAGES}) + +set(USERVER_BROTLI_VERSION 1.1.0) + +if (NOT USERVER_FORCE_DOWNLOAD_PACKAGES) + if (USERVER_DOWNLOAD_PACKAGE_BROTLI) + find_package(Brotli ${USERVER_BROTLI_VERSION} QUIET) + else() + find_package(Brotli ${USERVER_BROTLI_VERSION} REQUIRED) + endif() + + if (Brotli_FOUND) + if(NOT TARGET Brotli::dec) + add_library(Brotli::dec ALIAS brotlidec) + endif() + if(NOT TARGET Brotli::enc) + add_library(Brotli::enc ALIAS brotlienc) + endif() + return() + endif() +endif() + +include(DownloadUsingCPM) +CPMAddPackage( + NAME Brotli + VERSION ${USERVER_BROTLI_VERSION} + GITHUB_REPOSITORY google/brotli +) + +set(Brotli_FOUND TRUE) +set(Brotli_VERSION ${USERVER_BROTLI_VERSION}) +add_custom_target(Brotli) +write_package_stub(Brotli) + +if(NOT TARGET Brotli::dec) + add_library(Brotli::dec ALIAS brotlidec) +endif() +if(NOT TARGET Brotli::enc) + add_library(Brotli::enc ALIAS brotlienc) +endif() diff --git a/cmake/SetupYdbCppSDK.cmake b/cmake/SetupYdbCppSDK.cmake index 2bbf4e4d247e..34e2391559e4 100644 --- a/cmake/SetupYdbCppSDK.cmake +++ b/cmake/SetupYdbCppSDK.cmake @@ -1,6 +1,7 @@ option(USERVER_DOWNLOAD_PACKAGE_YDBCPPSDK "Download and setup ydb-cpp-sdk" ${USERVER_DOWNLOAD_PACKAGES}) include(DownloadUsingCPM) +include(SetupBrotli) CPMAddPackage( NAME base64 @@ -10,15 +11,6 @@ CPMAddPackage( write_package_stub(base64) add_library(aklomp::base64 ALIAS base64) -CPMAddPackage( - NAME Brotli - VERSION 1.1.0 - GITHUB_REPOSITORY google/brotli -) -write_package_stub(Brotli) -add_library(Brotli::dec ALIAS brotlidec) -add_library(Brotli::enc ALIAS brotlienc) - CPMAddPackage( NAME jwt-cpp VERSION 0.7.0 @@ -43,6 +35,7 @@ CPMAddPackage( GIT_TAG main GITHUB_REPOSITORY ydb-platform/ydb-cpp-sdk OPTIONS + "Brotli_VERSION ${Brotli_VERSION}" "RAPIDJSON_INCLUDE_DIRS ${RAPIDJSON_INCLUDE_DIRS}" "YDB_SDK_GOOGLE_COMMON_PROTOS_TARGET ${YDB_SDK_GOOGLE_COMMON_PROTOS_TARGET}" ) diff --git a/scripts/docs/en/userver/tutorial/build.md b/scripts/docs/en/userver/tutorial/build.md index f2715fa5b88e..d068e1aa6fc9 100644 --- a/scripts/docs/en/userver/tutorial/build.md +++ b/scripts/docs/en/userver/tutorial/build.md @@ -106,6 +106,7 @@ The following CMake options are used by userver: | USERVER_DOWNLOAD_PACKAGES | Download missing third party packages and use the downloaded versions | ON | | USERVER_PIP_USE_SYSTEM_PACKAGES | Use system python packages inside venv | OFF | | USERVER_PIP_OPTIONS | Options for all pip calls | '' | +| USERVER_DOWNLOAD_PACKAGE_BROTLI | Download and setup Brotli if no Brotli of matching version was found | ${USERVER_DOWNLOAD_PACKAGES} | | USERVER_DOWNLOAD_PACKAGE_CARES | Download and setup c-ares if no c-ares of matching version was found | ${USERVER_DOWNLOAD_PACKAGES} | | USERVER_DOWNLOAD_PACKAGE_CCTZ | Download and setup cctz if no cctz of matching version was found | ${USERVER_DOWNLOAD_PACKAGES} | | USERVER_DOWNLOAD_PACKAGE_CLICKHOUSECPP | Download and setup clickhouse-cpp | ${USERVER_DOWNLOAD_PACKAGES} |