From 38e91123cad90c91dad86dcb3f15331b535f5a3e Mon Sep 17 00:00:00 2001 From: antonyzhilin Date: Mon, 18 Nov 2024 14:10:01 +0300 Subject: [PATCH] feat cmake: don't build everything by default, improve cmake options docs * Add `USERVER_BUILD_TESTS` and `USERVER_BUILD_SAMPLES` options * Add `USERVER_BUILD_EVERYTHING` option (now `OFF` by default) * Clean up and document `userver/tools` * Split cmake options table into multiple tables commit_hash:01842127a27ffe72d963ecc61c71e95a53648688 --- .github/workflows/ci.yml | 28 +- .github/workflows/docker.yaml | 38 ++- .github/workflows/macos.yml | 6 +- .mapping.json | 24 +- CMakeLists.txt | 56 ++-- chaotic/CMakeLists.txt | 2 +- clickhouse/CMakeLists.txt | 2 +- cmake/UserverModule.cmake | 6 +- cmake/UserverSql.cmake | 4 +- conanfile.py | 1 - core/CMakeLists.txt | 10 +- core/utest/CMakeLists.txt | 2 +- grpc/CMakeLists.txt | 2 +- grpc/handlers/CMakeLists.txt | 2 +- kafka/CMakeLists.txt | 2 +- libraries/grpc-reflection/CMakeLists.txt | 2 +- mongo/CMakeLists.txt | 2 +- mysql/CMakeLists.txt | 2 +- postgresql/CMakeLists.txt | 2 +- rabbitmq/CMakeLists.txt | 2 +- redis/CMakeLists.txt | 2 +- scripts/build_and_install_all.sh | 2 +- scripts/docs/en/userver/build/build.md | 15 +- scripts/docs/en/userver/build/options.md | 241 ++++++++++-------- scripts/docs/en/userver/build/userver.md | 24 +- testsuite/CMakeLists.txt | 2 +- tools/CMakeLists.txt | 18 ++ tools/Readme.md | 3 + .../CMakeLists.txt | 11 + .../congestion_control_emulator.cpp | 0 .../data/const-overload.txt | 0 .../data/temp-overload.txt | 0 .../policy/production-2020-10-09.json | 0 .../CMakeLists.txt | 11 - .../CMakeLists.txt | 10 +- .../resolver.cpp | 0 tools/engine-perf/CMakeLists.txt | 11 + tools/{engine => engine-perf}/engine_perf.cpp | 0 tools/engine/CMakeLists.txt | 11 - tools/http-client-perf/CMakeLists.txt | 11 + .../httpclient_perf.cpp | 0 tools/httpclient/CMakeLists.txt | 11 - tools/netcat/CMakeLists.txt | 8 +- universal/CMakeLists.txt | 4 +- universal/utest/CMakeLists.txt | 2 +- ydb/CMakeLists.txt | 2 +- 46 files changed, 348 insertions(+), 246 deletions(-) create mode 100644 tools/CMakeLists.txt create mode 100644 tools/Readme.md create mode 100644 tools/congestion-control-emulator/CMakeLists.txt rename tools/{congestion_control_emulator => congestion-control-emulator}/congestion_control_emulator.cpp (100%) rename tools/{congestion_control_emulator => congestion-control-emulator}/data/const-overload.txt (100%) rename tools/{congestion_control_emulator => congestion-control-emulator}/data/temp-overload.txt (100%) rename tools/{congestion_control_emulator => congestion-control-emulator}/policy/production-2020-10-09.json (100%) delete mode 100644 tools/congestion_control_emulator/CMakeLists.txt rename tools/{dns_resolver => dns-resolver}/CMakeLists.txt (57%) rename tools/{dns_resolver => dns-resolver}/resolver.cpp (100%) create mode 100644 tools/engine-perf/CMakeLists.txt rename tools/{engine => engine-perf}/engine_perf.cpp (100%) delete mode 100644 tools/engine/CMakeLists.txt create mode 100644 tools/http-client-perf/CMakeLists.txt rename tools/{httpclient => http-client-perf}/httpclient_perf.cpp (100%) delete mode 100644 tools/httpclient/CMakeLists.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1bb13eafab9a..b7c760d00b47 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,9 +22,12 @@ jobs: -GNinja -DCMAKE_CXX_COMPILER=clang++-18 -DCMAKE_C_COMPILER=clang-18 - -DUSERVER_SANITIZE="ub addr" -DCMAKE_BUILD_TYPE=Debug - -DUSERVER_NO_WERROR=OFF + -DUSERVER_SANITIZE="ub addr" + -DUSERVER_NO_WERROR=0 + -DUSERVER_BUILD_ALL_COMPONENTS=1 + -DUSERVER_BUILD_SAMPLES=1 + -DUSERVER_BUILD_TESTS=1 -DUSERVER_NAMESPACE=userver_ns -DUSERVER_NAMESPACE_BEGIN="namespace userver_ns { inline namespace v1 {" @@ -40,9 +43,12 @@ jobs: -GNinja -DCMAKE_CXX_COMPILER=clang++-14 -DCMAKE_C_COMPILER=clang-14 - -DUSERVER_SANITIZE="ub addr" -DCMAKE_BUILD_TYPE=Debug - -DUSERVER_NO_WERROR=OFF + -DUSERVER_SANITIZE="ub addr" + -DUSERVER_NO_WERROR=0 + -DUSERVER_BUILD_ALL_COMPONENTS=1 + -DUSERVER_BUILD_SAMPLES=1 + -DUSERVER_BUILD_TESTS=1 -DUSERVER_NAMESPACE=userver_ns -DUSERVER_NAMESPACE_BEGIN="namespace userver_ns { inline namespace v1 {" @@ -56,12 +62,15 @@ jobs: - cmake-flags: >- -GNinja + -DCMAKE_BUILD_TYPE=Release + -DUSERVER_BUILD_ALL_COMPONENTS=1 + -DUSERVER_BUILD_SAMPLES=1 + -DUSERVER_BUILD_TESTS=1 + -DUSERVER_NO_WERROR=1 -DUSERVER_FEATURE_CRYPTOPP_BLAKE2=0 -DUSERVER_FEATURE_REDIS_HI_MALLOC=1 - -DUSERVER_NO_WERROR=1 -DUSERVER_FORCE_DOWNLOAD_ABSEIL=0 -DUSERVER_DOWNLOAD_PACKAGE_ABSEIL=0 - -DCMAKE_BUILD_TYPE=Release os: ubuntu-20.04 info: g++-9 + release tests-flags: '--gtest_filter=-HttpClient.RedirectHeaders:HttpClient.TestUseIPv4v6' @@ -72,12 +81,15 @@ jobs: -GNinja -DCMAKE_CXX_COMPILER=g++-8 -DCMAKE_C_COMPILER=gcc-8 + -DCMAKE_BUILD_TYPE=Debug + -DUSERVER_BUILD_ALL_COMPONENTS=1 + -DUSERVER_BUILD_SAMPLES=1 + -DUSERVER_BUILD_TESTS=1 + -DUSERVER_NO_WERROR=1 -DUSERVER_FEATURE_CRYPTOPP_BLAKE2=0 -DUSERVER_FEATURE_REDIS_HI_MALLOC=1 - -DUSERVER_NO_WERROR=1 -DUSERVER_FORCE_DOWNLOAD_ABSEIL=0 -DUSERVER_DOWNLOAD_PACKAGE_ABSEIL=0 - -DCMAKE_BUILD_TYPE=Debug os: ubuntu-20.04 info: g++-8 + debug tests-flags: '--gtest_filter=-HttpClient.RedirectHeaders:HttpClient.TestUseIPv4v6' diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index d315820108a6..997a3c779bc3 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -15,38 +15,56 @@ jobs: matrix: include: - cmake-flags: >- - -DUSERVER_BUILD_ALL_LIBRARIES=0 + -DCMAKE_CXX_STANDARD=17 + -DUSERVER_NO_WERROR=0 + -DUSERVER_BUILD_SAMPLES=1 + -DUSERVER_BUILD_TESTS=1 -DUSERVER_FEATURE_CORE=1 -DUSERVER_FEATURE_CHAOTIC=0 - -DCMAKE_CXX_STANDARD=17 image: ubuntu-22.04-userver-base info: ubuntu + clang + cxx17 + core id: ubuntu_clang_cxx17_core - cmake-flags: >- - -DCMAKE_CXX_COMPILER=clang++-16 -DCMAKE_C_COMPILER=clang-16 - -DUSERVER_BUILD_ALL_LIBRARIES=1 + -DCMAKE_C_COMPILER=clang-16 + -DCMAKE_CXX_COMPILER=clang++-16 -DCMAKE_CXX_STANDARD=17 + -DUSERVER_NO_WERROR=0 + -DUSERVER_BUILD_ALL_COMPONENTS=1 + -DUSERVER_BUILD_SAMPLES=1 + -DUSERVER_BUILD_TESTS=1 image: ubuntu-22.04-userver-base-ci info: ubuntu + clang + cxx17 id: ubuntu_clang_cxx17 - cmake-flags: >- - -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_C_COMPILER=gcc-11 - -DUSERVER_BUILD_ALL_LIBRARIES=1 + -DCMAKE_C_COMPILER=gcc-11 + -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_CXX_STANDARD=17 + -DUSERVER_NO_WERROR=0 + -DUSERVER_BUILD_ALL_COMPONENTS=1 + -DUSERVER_BUILD_SAMPLES=1 + -DUSERVER_BUILD_TESTS=1 image: ubuntu-22.04-userver-base-ci info: ubuntu + gcc + cxx17 id: ubuntu_gcc_cxx17 - cmake-flags: >- - -DCMAKE_CXX_COMPILER=clang++-16 -DCMAKE_C_COMPILER=clang-16 - -DUSERVER_BUILD_ALL_LIBRARIES=1 + -DCMAKE_C_COMPILER=clang-16 + -DCMAKE_CXX_COMPILER=clang++-16 -DCMAKE_CXX_STANDARD=20 + -DUSERVER_NO_WERROR=0 + -DUSERVER_BUILD_ALL_COMPONENTS=1 + -DUSERVER_BUILD_SAMPLES=1 + -DUSERVER_BUILD_TESTS=1 image: ubuntu-22.04-userver-base-ci info: ubuntu + clang + cxx20 id: ubuntu_clang_cxx20 - cmake-flags: >- - -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_C_COMPILER=gcc-11 - -DUSERVER_BUILD_ALL_LIBRARIES=1 + -DCMAKE_C_COMPILER=gcc-11 + -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_CXX_STANDARD=20 + -DUSERVER_NO_WERROR=0 + -DUSERVER_BUILD_ALL_COMPONENTS=1 + -DUSERVER_BUILD_SAMPLES=1 + -DUSERVER_BUILD_TESTS=1 image: ubuntu-22.04-userver-base-ci info: ubuntu + gcc + cxx20 id: ubuntu_gcc_cxx20 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 3c5d0f847c32..71318f1e6889 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -16,10 +16,12 @@ jobs: CMAKE_FLAGS: >- -GNinja -DCMAKE_BUILD_TYPE=Debug - -DUSERVER_NO_WERROR=OFF + -DUSERVER_NO_WERROR=1 + -DUSERVER_BUILD_ALL_COMPONENTS=1 + -DUSERVER_BUILD_SAMPLES=1 + -DUSERVER_BUILD_TESTS=1 -DUSERVER_FEATURE_REDIS_HI_MALLOC=1 -DUSERVER_FEATURE_CRYPTOPP_BLAKE2=0 - -DUSERVER_BUILD_ALL_LIBRARIES=1 -DUSERVER_FEATURE_POSTGRESQL=0 -DUSERVER_FEATURE_GRPC=0 -DUSERVER_FEATURE_GRPC_REFLECTION=0 diff --git a/.mapping.json b/.mapping.json index f6e0c2cb6507..5af8b8385869 100644 --- a/.mapping.json +++ b/.mapping.json @@ -3850,17 +3850,19 @@ "third_party/uboost_coro/src/context/fiber.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/fiber.cpp", "third_party/uboost_coro/src/context/posix/stack_traits.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/posix/stack_traits.cpp", "third_party/uboost_coro/src/context/untested.cpp":"taxi/uservices/userver/third_party/uboost_coro/src/context/untested.cpp", - "tools/congestion_control_emulator/CMakeLists.txt":"taxi/uservices/userver/tools/congestion_control_emulator/CMakeLists.txt", - "tools/congestion_control_emulator/congestion_control_emulator.cpp":"taxi/uservices/userver/tools/congestion_control_emulator/congestion_control_emulator.cpp", - "tools/congestion_control_emulator/data/const-overload.txt":"taxi/uservices/userver/tools/congestion_control_emulator/data/const-overload.txt", - "tools/congestion_control_emulator/data/temp-overload.txt":"taxi/uservices/userver/tools/congestion_control_emulator/data/temp-overload.txt", - "tools/congestion_control_emulator/policy/production-2020-10-09.json":"taxi/uservices/userver/tools/congestion_control_emulator/policy/production-2020-10-09.json", - "tools/dns_resolver/CMakeLists.txt":"taxi/uservices/userver/tools/dns_resolver/CMakeLists.txt", - "tools/dns_resolver/resolver.cpp":"taxi/uservices/userver/tools/dns_resolver/resolver.cpp", - "tools/engine/CMakeLists.txt":"taxi/uservices/userver/tools/engine/CMakeLists.txt", - "tools/engine/engine_perf.cpp":"taxi/uservices/userver/tools/engine/engine_perf.cpp", - "tools/httpclient/CMakeLists.txt":"taxi/uservices/userver/tools/httpclient/CMakeLists.txt", - "tools/httpclient/httpclient_perf.cpp":"taxi/uservices/userver/tools/httpclient/httpclient_perf.cpp", + "tools/CMakeLists.txt":"taxi/uservices/userver/tools/CMakeLists.txt", + "tools/Readme.md":"taxi/uservices/userver/tools/Readme.md", + "tools/congestion-control-emulator/CMakeLists.txt":"taxi/uservices/userver/tools/congestion-control-emulator/CMakeLists.txt", + "tools/congestion-control-emulator/congestion_control_emulator.cpp":"taxi/uservices/userver/tools/congestion-control-emulator/congestion_control_emulator.cpp", + "tools/congestion-control-emulator/data/const-overload.txt":"taxi/uservices/userver/tools/congestion-control-emulator/data/const-overload.txt", + "tools/congestion-control-emulator/data/temp-overload.txt":"taxi/uservices/userver/tools/congestion-control-emulator/data/temp-overload.txt", + "tools/congestion-control-emulator/policy/production-2020-10-09.json":"taxi/uservices/userver/tools/congestion-control-emulator/policy/production-2020-10-09.json", + "tools/dns-resolver/CMakeLists.txt":"taxi/uservices/userver/tools/dns-resolver/CMakeLists.txt", + "tools/dns-resolver/resolver.cpp":"taxi/uservices/userver/tools/dns-resolver/resolver.cpp", + "tools/engine-perf/CMakeLists.txt":"taxi/uservices/userver/tools/engine-perf/CMakeLists.txt", + "tools/engine-perf/engine_perf.cpp":"taxi/uservices/userver/tools/engine-perf/engine_perf.cpp", + "tools/http-client-perf/CMakeLists.txt":"taxi/uservices/userver/tools/http-client-perf/CMakeLists.txt", + "tools/http-client-perf/httpclient_perf.cpp":"taxi/uservices/userver/tools/http-client-perf/httpclient_perf.cpp", "tools/netcat/CMakeLists.txt":"taxi/uservices/userver/tools/netcat/CMakeLists.txt", "tools/netcat/netcat.cpp":"taxi/uservices/userver/tools/netcat/netcat.cpp", "universal/CMakeLists.txt":"taxi/uservices/userver/universal/CMakeLists.txt", diff --git a/CMakeLists.txt b/CMakeLists.txt index ff0fc38796ac..21d36e664134 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,10 +20,6 @@ option( ) set(USERVER_AVAILABLE_COMPONENTS universal) -set(USERVER_NOT_INCLUDED_AS_SUBDIR OFF) -if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR AND NOT USERVER_INSTALL) - set(USERVER_NOT_INCLUDED_AS_SUBDIR ON) -endif() option(USERVER_FEATURE_CORE "Provide a core library with coroutines, otherwise build only userver-universal" ON) option(USERVER_FEATURE_CHAOTIC "Provide chaotic-codegen for jsonschema" ON) @@ -45,35 +41,40 @@ if (USERVER_FEATURE_UTEST) endif() option( - USERVER_IS_THE_ROOT_PROJECT - "Contributor mode: build userver tests, samples and helper tools" - "${USERVER_NOT_INCLUDED_AS_SUBDIR}" + USERVER_BUILD_TESTS + "Build unit tests, functional tests and benchmarks for userver itself" + OFF ) -if (USERVER_IS_THE_ROOT_PROJECT) - message(STATUS "Building userver as a primary project") - if (NOT USERVER_FEATURE_UTEST) - message(FATAL_ERROR "Cannot build tests without utest") - endif() -else() - message(STATUS "Building userver as a subproject") +option(USERVER_BUILD_SAMPLES "Build userver samples" OFF) + +if(USERVER_BUILD_TESTS AND NOT USERVER_FEATURE_UTEST) + message(FATAL_ERROR "Running unit tests for userver requires utest, disabling it is meaningless") +endif() + +if(USERVER_INSTALL AND (USERVER_BUILD_TESTS OR USERVER_BUILD_SAMPLES)) + message( + FATAL_ERROR + "For USERVER_INSTALL, please turn off USERVER_BUILD_TESTS and USERVER_BUILD_SAMPLES " + "to avoid accidentally installing them" + ) endif() option( - USERVER_BUILD_ALL_LIBRARIES + USERVER_BUILD_ALL_COMPONENTS "\ Build all libraries except for those explicitly turned off by 'USERVER_FEATURE_*'\ and except for libraries disabled for the current platform" - "${USERVER_IS_THE_ROOT_PROJECT}" + OFF ) set(USERVER_LIB_ENABLED_DEFAULT OFF) -if(USERVER_FEATURE_CORE AND USERVER_BUILD_ALL_LIBRARIES) +if(USERVER_FEATURE_CORE AND USERVER_BUILD_ALL_COMPONENTS) set(USERVER_LIB_ENABLED_DEFAULT ON) endif() set(USERVER_MONGODB_DEFAULT OFF) set(USERVER_CLICKHOUSE_DEFAULT OFF) -if(USERVER_FEATURE_CORE AND USERVER_BUILD_ALL_LIBRARIES AND USERVER_BUILD_PLATFORM_X86) +if(USERVER_FEATURE_CORE AND USERVER_BUILD_ALL_COMPONENTS AND USERVER_BUILD_PLATFORM_X86) if(NOT CMAKE_SYSTEM_NAME MATCHES "BSD") set(USERVER_MONGODB_DEFAULT ON) endif() @@ -81,12 +82,12 @@ if(USERVER_FEATURE_CORE AND USERVER_BUILD_ALL_LIBRARIES AND USERVER_BUILD_PLATFO endif() set(USERVER_YDB_DEFAULT OFF) -if(USERVER_FEATURE_CORE AND USERVER_BUILD_ALL_LIBRARIES AND +if(USERVER_FEATURE_CORE AND USERVER_BUILD_ALL_COMPONENTS AND DEFINED CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD GREATER_EQUAL 20 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(USERVER_YDB_DEFAULT ON) endif() -option(USERVER_CONAN "Build with Conan packages" ${CONAN_EXPORTED}) +option(USERVER_CONAN "Build with Conan packages" "${CONAN_EXPORTED}") option( USERVER_DOWNLOAD_PACKAGES @@ -171,7 +172,7 @@ if (USERVER_FEATURE_GRPC) include(SetupProtobuf) endif() -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) include(testsuite/SetupUserverTestsuiteEnv.cmake) add_subdirectory(testsuite) endif() @@ -188,14 +189,6 @@ if (USERVER_FEATURE_CHAOTIC) list(APPEND USERVER_AVAILABLE_COMPONENTS chaotic) endif() -if (USERVER_IS_THE_ROOT_PROJECT AND USERVER_FEATURE_CORE) - add_subdirectory(tools/engine) - add_subdirectory(tools/httpclient) - add_subdirectory(tools/netcat) - add_subdirectory(tools/dns_resolver) - add_subdirectory(tools/congestion_control_emulator) -endif() - if (USERVER_FEATURE_MONGODB) _require_userver_core("USERVER_FEATURE_MONGODB") add_subdirectory(mongo) @@ -271,9 +264,12 @@ add_subdirectory(scripts/gdb/tests) _userver_export_targets() _userver_make_install_config() -if (USERVER_IS_THE_ROOT_PROJECT AND USERVER_FEATURE_CORE) +if (USERVER_BUILD_SAMPLES AND USERVER_FEATURE_CORE) add_subdirectory(samples) endif() +if (USERVER_BUILD_TESTS AND USERVER_FEATURE_CORE) + add_subdirectory(tools) +endif() if(USERVER_INSTALL) include(cmake/UserverPack.cmake) diff --git a/chaotic/CMakeLists.txt b/chaotic/CMakeLists.txt index d5cee635760c..47a8afd306c1 100644 --- a/chaotic/CMakeLists.txt +++ b/chaotic/CMakeLists.txt @@ -14,7 +14,7 @@ target_include_directories( ) target_link_libraries(${PROJECT_NAME} PUBLIC userver-universal) -if(USERVER_IS_THE_ROOT_PROJECT) +if(USERVER_BUILD_TESTS) userver_venv_setup( NAME userver-chaotic-tests PYTHON_OUTPUT_VAR USERVER_CHAOTIC_PYTEST_PYTHON_BINARY diff --git a/clickhouse/CMakeLists.txt b/clickhouse/CMakeLists.txt index fd254201e457..bc01fac37423 100644 --- a/clickhouse/CMakeLists.txt +++ b/clickhouse/CMakeLists.txt @@ -25,7 +25,7 @@ _userver_directory_install(COMPONENT clickhouse FILES DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/userver/modules ) -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) set_tests_properties(${PROJECT_NAME}-dbtest PROPERTIES ENVIRONMENT "TESTSUITE_CLICKHOUSE_SERVER_START_TIMEOUT=120.0") diff --git a/cmake/UserverModule.cmake b/cmake/UserverModule.cmake index 82de801894b3..5b4884d58bee 100644 --- a/cmake/UserverModule.cmake +++ b/cmake/UserverModule.cmake @@ -106,7 +106,7 @@ function(userver_module MODULE) endif() ## 2. userver-${MODULE}-unittest - if(USERVER_IS_THE_ROOT_PROJECT AND UTEST_SOURCES) + if(USERVER_BUILD_TESTS AND UTEST_SOURCES) add_executable(userver-${MODULE}-unittest ${UTEST_SOURCES}) target_link_libraries(userver-${MODULE}-unittest PRIVATE userver-utest @@ -121,7 +121,7 @@ function(userver_module MODULE) endif() ## 3. userver-${MODULE}-dbtest - if(USERVER_IS_THE_ROOT_PROJECT AND DBTEST_SOURCES) + if(USERVER_BUILD_TESTS AND DBTEST_SOURCES) add_executable(userver-${MODULE}-dbtest ${DBTEST_SOURCES}) target_link_libraries(userver-${MODULE}-dbtest PRIVATE userver-utest @@ -140,7 +140,7 @@ function(userver_module MODULE) endif() ## 4. userver-${MODULE}-benchmark - if(USERVER_IS_THE_ROOT_PROJECT AND UBENCH_SOURCES) + if(USERVER_BUILD_TESTS AND UBENCH_SOURCES) add_executable(userver-${MODULE}-benchmark ${UBENCH_SOURCES}) target_link_libraries(userver-${MODULE}-benchmark PRIVATE userver-ubench diff --git a/cmake/UserverSql.cmake b/cmake/UserverSql.cmake index 8d80ce953360..27b3a4484cc8 100644 --- a/cmake/UserverSql.cmake +++ b/cmake/UserverSql.cmake @@ -47,10 +47,10 @@ function(userver_add_sql_library TARGET) add_custom_command( OUTPUT ${ARG_OUTPUT_DIR}/include/${ARG_NAMESPACE}/${FILENAME}.hpp - ${ARG_OUTPUT_DIR}/src/${ARG_NAMESPACE}/${FILENAME}.cpp + ${ARG_OUTPUT_DIR}/src/${ARG_NAMESPACE}/${FILENAME}.cpp COMMAND ${USERVER_SQL_PYTHON_BINARY} - ${USERVER_SQL_SCRIPTS_PATH}/generator.py + ${USERVER_SQL_SCRIPTS_PATH}/generator.py --namespace ${ARG_NAMESPACE} --output-dir ${ARG_OUTPUT_DIR} --query-log-mode ${ARG_QUERY_LOG_MODE} diff --git a/conanfile.py b/conanfile.py index e72e471d4c29..27ecbc4bb655 100644 --- a/conanfile.py +++ b/conanfile.py @@ -191,7 +191,6 @@ def generate(self): tool_ch.variables['CMAKE_FIND_DEBUG_MODE'] = False tool_ch.variables['USERVER_CONAN'] = True - tool_ch.variables['USERVER_IS_THE_ROOT_PROJECT'] = False tool_ch.variables['USERVER_DOWNLOAD_PACKAGES'] = True tool_ch.variables['USERVER_FEATURE_DWCAS'] = True tool_ch.variables['USERVER_NAMESPACE'] = self.options.namespace diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index dee3966fea89..2e44039e755c 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -229,7 +229,7 @@ target_include_directories(${PROJECT_NAME} # Must go below all the target options and definitions. _check_compile_flags(${PROJECT_NAME}) -if (USERVER_IS_THE_ROOT_PROJECT OR USERVER_FEATURE_UTEST) +if (USERVER_FEATURE_UTEST) add_library(userver-core-internal OBJECT ${INTERNAL_SOURCES}) target_compile_definitions(userver-core-internal PUBLIC $) target_include_directories(userver-core-internal PUBLIC @@ -250,11 +250,11 @@ if (USERVER_IS_THE_ROOT_PROJECT OR USERVER_FEATURE_UTEST) _userver_install_targets(COMPONENT core TARGETS userver-core-internal) endif() -if (USERVER_FEATURE_UTEST OR USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_FEATURE_UTEST) add_subdirectory(utest) endif() -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) add_executable(${PROJECT_NAME}-unittest ${UNIT_TEST_SOURCES}) target_include_directories (${PROJECT_NAME}-unittest PRIVATE $ @@ -268,7 +268,7 @@ if (USERVER_IS_THE_ROOT_PROJECT) add_subdirectory(functional_tests) endif() -if (USERVER_FEATURE_UTEST OR USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_FEATURE_UTEST) add_library(userver-ubench ${LIBUBENCH_SOURCES}) target_include_directories(userver-ubench PUBLIC $) target_compile_definitions(userver-ubench PUBLIC $) @@ -282,7 +282,7 @@ if (USERVER_FEATURE_UTEST OR USERVER_IS_THE_ROOT_PROJECT) _userver_install_targets(COMPONENT core TARGETS userver-ubench userver-universal-internal-ubench) endif() -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) add_executable(${PROJECT_NAME}-benchmark ${BENCH_SOURCES}) target_link_libraries(${PROJECT_NAME}-benchmark diff --git a/core/utest/CMakeLists.txt b/core/utest/CMakeLists.txt index c83158fdfc4b..69ce9ae225d1 100644 --- a/core/utest/CMakeLists.txt +++ b/core/utest/CMakeLists.txt @@ -40,7 +40,7 @@ _userver_install_targets(COMPONENT core TARGETS userver-utest ) -if(USERVER_IS_THE_ROOT_PROJECT) +if(USERVER_BUILD_TESTS) add_executable(${PROJECT_NAME}-unittest ${UNIT_TEST_SOURCES}) target_include_directories(${PROJECT_NAME}-unittest SYSTEM PRIVATE $ diff --git a/grpc/CMakeLists.txt b/grpc/CMakeLists.txt index d9a12d0d50e0..ee6299b66b7a 100644 --- a/grpc/CMakeLists.txt +++ b/grpc/CMakeLists.txt @@ -157,7 +157,7 @@ if (USERVER_FEATURE_UTEST) ) endif() -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) userver_add_grpc_library(${PROJECT_NAME}-unittest-proto PROTOS # Absolute paths are allowed diff --git a/grpc/handlers/CMakeLists.txt b/grpc/handlers/CMakeLists.txt index 3d5c51b9717e..71ed2dc45c59 100644 --- a/grpc/handlers/CMakeLists.txt +++ b/grpc/handlers/CMakeLists.txt @@ -26,7 +26,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC userver-grpc-internal) userver_add_grpc_library(${PROJECT_NAME}-proto PROTOS healthchecking/healthchecking.proto) target_link_libraries(${PROJECT_NAME} PUBLIC ${PROJECT_NAME}-proto) -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) add_executable(${PROJECT_NAME}-unittest ${UNIT_TEST_SOURCES}) target_include_directories(${PROJECT_NAME}-unittest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include diff --git a/kafka/CMakeLists.txt b/kafka/CMakeLists.txt index 8404a8f20e1e..650d52d4a1b1 100644 --- a/kafka/CMakeLists.txt +++ b/kafka/CMakeLists.txt @@ -45,6 +45,6 @@ if(USERVER_FEATURE_UTEST) add_subdirectory(utest) endif() -if(USERVER_IS_THE_ROOT_PROJECT) +if(USERVER_BUILD_TESTS) add_subdirectory(functional_tests) endif() diff --git a/libraries/grpc-reflection/CMakeLists.txt b/libraries/grpc-reflection/CMakeLists.txt index 33f810dd4bb8..02e0b6b44a6a 100644 --- a/libraries/grpc-reflection/CMakeLists.txt +++ b/libraries/grpc-reflection/CMakeLists.txt @@ -10,6 +10,6 @@ userver_module(grpc-reflection UTEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_test.cpp" ) -if(USERVER_IS_THE_ROOT_PROJECT) +if(USERVER_BUILD_TESTS) add_subdirectory(functional_tests) endif() diff --git a/mongo/CMakeLists.txt b/mongo/CMakeLists.txt index 0513ff1949c9..f225cf1826fa 100644 --- a/mongo/CMakeLists.txt +++ b/mongo/CMakeLists.txt @@ -31,7 +31,7 @@ _userver_directory_install(COMPONENT mongo FILES DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/userver/modules ) -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) target_include_directories(${PROJECT_NAME}-unittest PRIVATE # TODO: hack, expose formats/common/merge_test.hpp as public API $ diff --git a/mysql/CMakeLists.txt b/mysql/CMakeLists.txt index 4ee86b36de47..326aadbb52d5 100644 --- a/mysql/CMakeLists.txt +++ b/mysql/CMakeLists.txt @@ -23,6 +23,6 @@ _userver_directory_install(COMPONENT mysql FILES DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/userver/modules" ) -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) add_subdirectory(functional_tests) endif() diff --git a/postgresql/CMakeLists.txt b/postgresql/CMakeLists.txt index 0d3d8b7e6e30..4050013d584f 100644 --- a/postgresql/CMakeLists.txt +++ b/postgresql/CMakeLists.txt @@ -59,7 +59,7 @@ _userver_directory_install(COMPONENT postgres DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/userver/scripts" ) -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) add_subdirectory(functional_tests) endif() diff --git a/rabbitmq/CMakeLists.txt b/rabbitmq/CMakeLists.txt index 7cc3f3f57285..5afcaac82daf 100644 --- a/rabbitmq/CMakeLists.txt +++ b/rabbitmq/CMakeLists.txt @@ -20,7 +20,7 @@ _userver_directory_install( DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/userver" ) -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) set_tests_properties(${PROJECT_NAME}-dbtest PROPERTIES ENVIRONMENT "TESTSUITE_RABBITMQ_SERVER_START_TIMEOUT=120.0") diff --git a/redis/CMakeLists.txt b/redis/CMakeLists.txt index 68b5f537ebf1..127eab230a26 100644 --- a/redis/CMakeLists.txt +++ b/redis/CMakeLists.txt @@ -60,6 +60,6 @@ if (USERVER_FEATURE_UTEST) add_subdirectory(testing) endif() -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) add_subdirectory(functional_tests) endif() diff --git a/scripts/build_and_install_all.sh b/scripts/build_and_install_all.sh index 53ee95357077..bb7c86d01044 100755 --- a/scripts/build_and_install_all.sh +++ b/scripts/build_and_install_all.sh @@ -9,7 +9,7 @@ set -euox pipefail ALL_FEATURES=" - -DUSERVER_BUILD_ALL_LIBRARIES=1 \ + -DUSERVER_BUILD_ALL_COMPONENTS=1 \ -DUSERVER_FEATURE_YDB=0 \ -DUSERVER_FEATURE_GRPC_CHANNELZ=0 \ " diff --git a/scripts/docs/en/userver/build/build.md b/scripts/docs/en/userver/build/build.md index e1d1b67559d2..407e526195f0 100644 --- a/scripts/docs/en/userver/build/build.md +++ b/scripts/docs/en/userver/build/build.md @@ -109,6 +109,7 @@ target_link_libraries(${PROJECT_NAME} userver::grpc) ``` @see @ref userver_libraries +@see @ref cmake_options See @ref tutorial_services for minimal usage examples of various userver libraries. @@ -207,6 +208,8 @@ cmake --install build_debug/ cmake --install build_release/ ``` +@see @ref cmake_options + ### Use userver in your projects @@ -245,11 +248,11 @@ target_link_libraries(${PROJECT_NAME}-mysql_objs PUBLIC userver::mysql mariadbcl The Docker images provide a container with all the build dependencies preinstalled and with a proper setup of PPAs with databases, compilers and tools: -Image reference | Contains | ------------------------------------------------------------- | -------------------------------------- | -`ghcr.io/userver-framework/ubuntu-22.04-userver-pg:latest` | PostgreSQL and userver preinstalled | -`ghcr.io/userver-framework/ubuntu-22.04-userver:latest` | userver preinstalled | -`ghcr.io/userver-framework/ubuntu-22.04-userver-base:latest` | only userver dependencies preinstalled | +| Image reference | Contains | +|--------------------------------------------------------------|----------------------------------------| +| `ghcr.io/userver-framework/ubuntu-22.04-userver-pg:latest` | PostgreSQL and userver preinstalled | +| `ghcr.io/userver-framework/ubuntu-22.04-userver:latest` | userver preinstalled | +| `ghcr.io/userver-framework/ubuntu-22.04-userver-base:latest` | only userver dependencies preinstalled | To run it just use a command like @@ -338,6 +341,8 @@ You can use PGO compilation doing the following steps: The resulting binary should be 2-15% faster than without PGO, depending on the code and workload. +@see @ref cmake_options + ---------- @htmlonly
@endhtmlonly diff --git a/scripts/docs/en/userver/build/options.md b/scripts/docs/en/userver/build/options.md index efcd97eee6e0..6d8288867473 100644 --- a/scripts/docs/en/userver/build/options.md +++ b/scripts/docs/en/userver/build/options.md @@ -6,28 +6,30 @@ userver is split into multiple CMake libraries. -| CMake target | CMake option to enable building the library | Component for install | Main documentation page | -|----------------------------|---------------------------------------------------|-----------------------|----------------------------------------------------| -| `userver::universal` | Always on | `universal` | @ref scripts/docs/en/index.md | -| `userver::universal-utest` | `USERVER_FEATURE_UTEST` (`ON` by default) | `universal` | @ref scripts/docs/en/userver/testing.md | -| `userver::core` | `USERVER_FEATURE_CORE` (`ON` by default) | `core` | @ref scripts/docs/en/index.md | -| `userver::utest` | `USERVER_FEATURE_CORE` + `USERVER_FEATURE_UTEST` | `core` | @ref scripts/docs/en/userver/testing.md | -| `userver::ubench` | `USERVER_FEATURE_CORE` + `USERVER_FEATURE_UTEST` | `core` | @ref scripts/docs/en/userver/testing.md | -| `userver::grpc` | `USERVER_FEATURE_GRPC` | `grpc` | @ref scripts/docs/en/userver/grpc.md | -| `userver::grpc-utest` | `USERVER_FEATURE_GRPC` + `USERVER_FEATURE_UTEST` | `grpc` | @ref scripts/docs/en/userver/grpc.md | -| `userver::mongo` | `USERVER_FEATURE_MONGODB` | `mongo` | @ref scripts/docs/en/userver/mongodb.md | -| `userver::postgresql` | `USERVER_FEATURE_POSTGRESQL` | `postgresql` | @ref pg_driver | -| `userver::redis` | `USERVER_FEATURE_REDIS` | `redis` | @ref scripts/docs/en/userver/redis.md | -| `userver::clickhouse` | `USERVER_FEATURE_CLICKHOUSE` | `clickhouse` | @ref clickhouse_driver | -| `userver::kafka` | `USERVER_FEATURE_KAFKA` | `kafka` | @ref scripts/docs/en/userver/kafka.md | -| `userver::kafka-utest` | `USERVER_FEATURE_KAFKA` + `USERVER_FEATURE_UTEST` | `kafka` | @ref scripts/docs/en/userver/kafka.md | -| `userver::rabbitmq` | `USERVER_FEATURE_RABBITMQ` | `rabbitmq` | @ref rabbitmq_driver | -| `userver::mysql` | `USERVER_FEATURE_MYSQL` | `mysql` | @ref scripts/docs/en/userver/mysql/mysql_driver.md | -| `userver::rocks` | `USERVER_FEATURE_ROCKS` | `rocks` | TODO | -| `userver::ydb` | `USERVER_FEATURE_YDB` | `ydb` | @ref scripts/docs/en/userver/ydb.md | -| `userver::otlp` | `USERVER_FEATURE_OTLP` | `otlp` | @ref opentelemetry "OpenTelemetry Protocol" | -| `userver::s3api` | `USERVER_FEATURE_S3API` | `s3api` | @ref scripts/docs/en/userver/libraries/s3api.md | -| `userver::grpc-reflection` | `USERVER_FEATURE_GRPC_REFLECTION` | `grpc-reflection` | @ref scripts/docs/en/userver/libraries/grpc-reflection.md | +| CMake target | CMake option to enable building the library | Component for install | Main documentation page | +|----------------------------|---------------------------------------------------|-----------------------|-----------------------------------------------------------| +| `userver::universal` | Always on | `universal` | @ref scripts/docs/en/index.md | +| `userver::universal-utest` | `USERVER_FEATURE_UTEST` (`ON` by default) | `universal` | @ref scripts/docs/en/userver/testing.md | +| `userver::core` | `USERVER_FEATURE_CORE` (`ON` by default) | `core` | @ref scripts/docs/en/index.md | +| `userver::utest` | `USERVER_FEATURE_CORE` + `USERVER_FEATURE_UTEST` | `core` | @ref scripts/docs/en/userver/testing.md | +| `userver::ubench` | `USERVER_FEATURE_CORE` + `USERVER_FEATURE_UTEST` | `core` | @ref scripts/docs/en/userver/testing.md | +| `userver::chaotic` | `USERVER_FEATURE_CHAOTIC` (`ON` by default) | `chaotic` | @ref scripts/docs/en/userver/chaotic.md | +| `userver::grpc` | `USERVER_FEATURE_GRPC` | `grpc` | @ref scripts/docs/en/userver/grpc.md | +| `userver::grpc-utest` | `USERVER_FEATURE_GRPC` + `USERVER_FEATURE_UTEST` | `grpc` | @ref scripts/docs/en/userver/grpc.md | +| `userver::mongo` | `USERVER_FEATURE_MONGODB` | `mongo` | @ref scripts/docs/en/userver/mongodb.md | +| `userver::postgresql` | `USERVER_FEATURE_POSTGRESQL` | `postgresql` | @ref pg_driver | +| `userver::redis` | `USERVER_FEATURE_REDIS` | `redis` | @ref scripts/docs/en/userver/redis.md | +| `userver::redis-utest` | `USERVER_FEATURE_REDIS` + `USERVER_FEATURE_UTEST` | `redis` | @ref scripts/docs/en/userver/redis.md | +| `userver::clickhouse` | `USERVER_FEATURE_CLICKHOUSE` | `clickhouse` | @ref clickhouse_driver | +| `userver::kafka` | `USERVER_FEATURE_KAFKA` | `kafka` | @ref scripts/docs/en/userver/kafka.md | +| `userver::kafka-utest` | `USERVER_FEATURE_KAFKA` + `USERVER_FEATURE_UTEST` | `kafka` | @ref scripts/docs/en/userver/kafka.md | +| `userver::rabbitmq` | `USERVER_FEATURE_RABBITMQ` | `rabbitmq` | @ref rabbitmq_driver | +| `userver::mysql` | `USERVER_FEATURE_MYSQL` | `mysql` | @ref scripts/docs/en/userver/mysql/mysql_driver.md | +| `userver::rocks` | `USERVER_FEATURE_ROCKS` | `rocks` | TODO | +| `userver::ydb` | `USERVER_FEATURE_YDB` | `ydb` | @ref scripts/docs/en/userver/ydb.md | +| `userver::otlp` | `USERVER_FEATURE_OTLP` | `otlp` | @ref opentelemetry "OpenTelemetry Protocol" | +| `userver::s3api` | `USERVER_FEATURE_S3API` | `s3api` | @ref scripts/docs/en/userver/libraries/s3api.md | +| `userver::grpc-reflection` | `USERVER_FEATURE_GRPC_REFLECTION` | `grpc-reflection` | @ref scripts/docs/en/userver/libraries/grpc-reflection.md | Make sure to: @@ -45,89 +47,124 @@ The details vary depending on the method of building userver: @anchor cmake_options ## CMake options -The following CMake options are used by userver: - -| Option | Description | Default | -|----------------------------------------|-----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------| -| USERVER_FEATURE_CORE | Provide a core library with coroutines, otherwise build only `userver::universal` | ON | -| USERVER_FEATURE_MONGODB | Provide asynchronous driver for MongoDB | ${USERVER_BUILD_ALL_LIBRARIES} AND x86\* AND NOT \*BSD | -| USERVER_FEATURE_POSTGRESQL | Provide asynchronous driver for PostgreSQL | ${USERVER_BUILD_ALL_LIBRARIES} | -| USERVER_FEATURE_REDIS | Provide asynchronous driver for Redis | ${USERVER_BUILD_ALL_LIBRARIES} | -| USERVER_FEATURE_CLICKHOUSE | Provide asynchronous driver for ClickHouse | ${USERVER_BUILD_ALL_LIBRARIES} AND x86\* | -| USERVER_FEATURE_GRPC | Provide asynchronous driver for gRPC | ${USERVER_BUILD_ALL_LIBRARIES} | -| USERVER_FEATURE_KAFKA | Provide asynchronous driver for Apache Kafka | ${USERVER_BUILD_ALL_LIBRARIES} | -| USERVER_FEATURE_RABBITMQ | Provide asynchronous driver for RabbitMQ (AMQP 0-9-1) | ${USERVER_BUILD_ALL_LIBRARIES} | -| USERVER_FEATURE_MYSQL | Provide asynchronous driver for MySQL/MariaDB | ${USERVER_BUILD_ALL_LIBRARIES} | -| USERVER_FEATURE_ROCKS | Provide asynchronous driver for RocksDB | ${USERVER_BUILD_ALL_LIBRARIES} | -| USERVER_FEATURE_YDB | Provide asynchronous driver for YDB | ${USERVER_BUILD_ALL_LIBRARIES} AND C++ standard >= 20 | -| USERVER_FEATURE_OTLP | Provide Logger for OpenTelemetry protocol | ${USERVER_BUILD_ALL_LIBRARIES} | -| USERVER_FEATURE_GRPC_REFLECTION | Provide reflection service for gRPC | ${USERVER_BUILD_ALL_LIBRARIES} | -| USERVER_FEATURE_S3API | Provide S3 client for gRPC | ${USERVER_BUILD_ALL_LIBRARIES} | -| USERVER_FEATURE_UTEST | Provide 'utest' and 'ubench' for unit testing and benchmarking coroutines | ${USERVER_FEATURE_CORE} | -| USERVER_FEATURE_CRYPTOPP_BLAKE2 | Provide wrappers for blake2 algorithms of crypto++ | ON | -| USERVER_FEATURE_PATCH_LIBPQ | Apply patches to the libpq (add portals support), requires libpq.a | ON | -| USERVER_FEATURE_CRYPTOPP_BASE64_URL | Provide wrappers for Base64 URL decoding and encoding algorithms of crypto++ | ON | -| USERVER_FEATURE_REDIS_HI_MALLOC | Provide a `hi_malloc(unsigned long)` [issue][hi_malloc] workaround | OFF | -| USERVER_FEATURE_REDIS_TLS | SSL/TLS support for Redis driver | OFF | -| USERVER_FEATURE_STACKTRACE | Allow capturing stacktraces using boost::stacktrace | OFF if platform is not \*BSD; ON otherwise | -| USERVER_FEATURE_JEMALLOC | Use jemalloc memory allocator | ON | -| USERVER_FEATURE_DWCAS | Require double-width compare-and-swap | ON | -| USERVER_FEATURE_TESTSUITE | Enable functional tests via testsuite | ON | -| USERVER_FEATURE_GRPC_CHANNELZ | Enable Channelz for gRPC | ON for "sufficiently new" gRPC versions | -| USERVER_BUILD_ALL_LIBRARIES | Build all userver libraries compatible with the host except for ones disabled by `USERVER_FEATURE_*` | ${USERVER_IS_THE_ROOT_PROJECT} | -| USERVER_CHECK_PACKAGE_VERSIONS | Check package versions | ON | -| USERVER_SANITIZE | Build with sanitizers support, allows combination of values via 'val1 val2' | '' | -| USERVER_SANITIZE_BLACKLIST | Path to file that is passed to the -fsanitize-blacklist option | '' | -| USERVER_USE_LD | Linker to use, e.g. 'gold' or 'lld' | '' | -| USERVER_LTO | Use link time optimizations | OFF | -| USERVER_LTO_CACHE | Use LTO cache if present, disable for benchmarking build times | ON | -| USERVER_LTO_CACHE_DIR | LTO cache directory | `${CMAKE_CURRENT_BINARY_DIR}/.ltocache` | -| USERVER_LTO_CACHE_SIZE_MB | LTO cache size limit in MB | 6000 | -| USERVER_PGO_GENERATE | Generate PGO profile | OFF | -| USERVER_PGO_USE | Path to PGO profile file | '' | -| USERVER_USE_CCACHE | Use ccache if present, disable for benchmarking build times | ON | -| USERVER_COMPILATION_TIME_TRACE | Generate Clang compilation time trace | OFF | -| USERVER_NO_WERROR | Do not treat warnings as errors | ON | -| USERVER_PYTHON_PATH | Path to the python3 binary for use in testsuite tests | python3 | -| USERVER_FEATURE_ERASE_LOG_WITH_LEVEL | Logs of this and below levels are removed from binary. Possible values: trace, info, debug, warning, error | OFF | -| USERVER_PIP_USE_SYSTEM_PACKAGES | Use system python packages inside venv. Useful for Docker, CI and other controlled environments | OFF | -| USERVER_PIP_OPTIONS | Options for all pip calls. Useful for `--no | '' | -| USERVER_DOWNLOAD_PACKAGES | Download missing third party packages and use the downloaded versions | ON | -| 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} | -| USERVER_DOWNLOAD_PACKAGE_CRYPTOPP | Download and setup CryptoPP if no CryptoPP of matching version was found | ${USERVER_DOWNLOAD_PACKAGES} | -| USERVER_DOWNLOAD_PACKAGE_CURL | Download and setup libcurl if no libcurl of matching version was found | ${USERVER_DOWNLOAD_PACKAGES} | -| USERVER_DOWNLOAD_PACKAGE_FMT | Download and setup Fmt if no Fmt of matching version was found | ${USERVER_DOWNLOAD_PACKAGES} | -| USERVER_DOWNLOAD_PACKAGE_GBENCH | Download and setup gbench if no gbench of matching version was found | ${USERVER_DOWNLOAD_PACKAGES} | -| USERVER_DOWNLOAD_PACKAGE_GRPC | Download and setup gRPC if no gRPC of matching version was found | ${USERVER_DOWNLOAD_PACKAGES} | -| USERVER_DOWNLOAD_PACKAGE_GTEST | Download and setup gtest if no gtest of matching version was found | ${USERVER_DOWNLOAD_PACKAGES} | -| USERVER_DOWNLOAD_PACKAGE_PROTOBUF | Download and setup Protobuf if no Protobuf of matching version was found | ${USERVER_DOWNLOAD_PACKAGE_GRPC} | -| USERVER_DOWNLOAD_PACKAGE_KAFKA | Download and setup librdkafka if no librdkafka matching version was found | ${USERVER_DOWNLOAD_PACKAGES} | -| USERVER_DOWNLOAD_PACKAGE_YDBCPPSDK | Download and setup ydb-cpp-sdk if no ydb-cpp-sdk of matching version was found | ${USERVER_DOWNLOAD_PACKAGES} | -| USERVER_FORCE_DOWNLOAD_PACKAGES | Download all possible third-party packages even if there is an installed system package | OFF | -| USERVER_FORCE_DOWNLOAD_PROTOBUF | Download Protobuf even if there is an installed system package | ${USERVER_FORCE_DOWNLOAD_PACKAGES} | -| USERVER_FORCE_DOWNLOAD_GRPC | Download gRPC even if there is an installed system package | ${USERVER_FORCE_DOWNLOAD_PACKAGES} | -| USERVER_INSTALL | Build userver for further installation | OFF | -| USERVER_IS_THE_ROOT_PROJECT | Contributor mode: build userver tests, samples and helper tools | auto-detects if userver is the top level project | -| USERVER_GOOGLE_COMMON_PROTOS_TARGET | Name of cmake target preparing google common proto library | Builds userver-api-common-protos | -| USERVER_GOOGLE_COMMON_PROTOS | Path to the folder with google common proto files | Downloads automatically | -| USERVER_PG_SERVER_INCLUDE_DIR | Path to the folder with @ref POSTGRES_LIBS "PostgreSQL server headers", e.g. /usr/include/postgresql/15/server | autodetected | -| USERVER_PG_SERVER_LIBRARY_DIR | Path to the folder with @ref POSTGRES_LIBS "PostgreSQL server libraries", e.g. /usr/lib/postgresql/15/lib | autodetected | -| USERVER_PG_INCLUDE_DIR | Path to the folder with @ref POSTGRES_LIBS "PostgreSQL libpq headers", e.g. /usr/local/include | autodetected | -| USERVER_PG_LIBRARY_DIR | Path to the folder with @ref POSTGRES_LIBS "PostgreSQL libpq libraries", e.g. /usr/local/lib | autodetected | -| USERVER_MYSQL_ALLOW_BUGGY_LIBMARIADB | Allows mysql driver to leak memory instead of aborting in some rare cases when linked against libmariadb3<3.3.4 | OFF | -| USERVER_DISABLE_PHDR_CACHE | Disable caching of dl_phdr_info items, which interferes with dlopen | OFF | -| USERVER_DISABLE_RSEQ_ACCELERATION | Disable rseq-based optimizations, which may not work depending on kernel/glibc/distro/etc version | OFF for x86 Linux, ON otherwise | -| USERVER_FEATURE_UBOOST_CORO | Build with vendored version of Boost.context and Boost.coroutine2, is needed for sanitizers builds | OFF for arm64 macOS, ON otherwise | -| USERVER_GENERATE_PROTOS_AT_CONFIGURE | Run protoc at CMake Configure time for better IDE integration | OFF for downloaded Protobuf, ON otherwise | +To explicitly specialize the compiler, use the cmake options `CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER`. +For example, to use `clang-12` compiler, install it and add the following options to cmake Configure: + +```shell +cmake ... -DCMAKE_C_COMPILER=clang-12 -DCMAKE_CXX_COMPILER=clang++-12 +``` + +### CMake options for selecting userver libraries to build + +| Option | Description | Default | +|-----------------------------------|-----------------------------------------------------------------------------------|-------------------------------------------------------------| +| `USERVER_FEATURE_CORE` | Provide a core library with coroutines, otherwise build only `userver::universal` | `ON` | +| `USERVER_FEATURE_CHAOTIC` | Provide chaotic-codegen for jsonschema | `ON` | +| `USERVER_FEATURE_UTEST` | Provide `utest` and `ubench` for unit testing and benchmarking coroutines | `${USERVER_FEATURE_CORE}` | +| `USERVER_FEATURE_TESTSUITE` | Enable functional tests via testsuite | `ON` | +| `USERVER_FEATURE_MONGODB` | Provide asynchronous driver for MongoDB | `${USERVER_BUILD_ALL_COMPONENTS}` AND `x86*` AND NOT `*BSD` | +| `USERVER_FEATURE_POSTGRESQL` | Provide asynchronous driver for PostgreSQL | `${USERVER_BUILD_ALL_COMPONENTS}` | +| `USERVER_FEATURE_REDIS` | Provide asynchronous driver for Redis | `${USERVER_BUILD_ALL_COMPONENTS}` | +| `USERVER_FEATURE_CLICKHOUSE` | Provide asynchronous driver for ClickHouse | `${USERVER_BUILD_ALL_COMPONENTS}` AND `x86*` | +| `USERVER_FEATURE_GRPC` | Provide asynchronous driver for gRPC | `${USERVER_BUILD_ALL_COMPONENTS}` | +| `USERVER_FEATURE_KAFKA` | Provide asynchronous driver for Apache Kafka | `${USERVER_BUILD_ALL_COMPONENTS}` | +| `USERVER_FEATURE_RABBITMQ` | Provide asynchronous driver for RabbitMQ (AMQP 0-9-1) | `${USERVER_BUILD_ALL_COMPONENTS}` | +| `USERVER_FEATURE_MYSQL` | Provide asynchronous driver for MySQL/MariaDB | `${USERVER_BUILD_ALL_COMPONENTS}` | +| `USERVER_FEATURE_ROCKS` | Provide asynchronous driver for RocksDB | `${USERVER_BUILD_ALL_COMPONENTS}` | +| `USERVER_FEATURE_YDB` | Provide asynchronous driver for YDB | `${USERVER_BUILD_ALL_COMPONENTS}` AND C++ standard >= 20 | +| `USERVER_FEATURE_OTLP` | Provide Logger for OpenTelemetry protocol | `${USERVER_BUILD_ALL_COMPONENTS}` | +| `USERVER_FEATURE_GRPC_REFLECTION` | Provide reflection service for gRPC | `${USERVER_BUILD_ALL_COMPONENTS}` | +| `USERVER_FEATURE_S3API` | Provide S3 client for gRPC | `${USERVER_BUILD_ALL_COMPONENTS}` | + +### CMake options for building everything + +@see @ref scripts/docs/en/userver/build/userver.md + +| Option | Description | Default | +|--------------------------------|------------------------------------------------------------------------------------------------------|---------| +| `USERVER_BUILD_ALL_COMPONENTS` | Build all userver libraries compatible with the host except for ones disabled by `USERVER_FEATURE_*` | `OFF` | +| `USERVER_BUILD_TESTS` | Build unit tests, functional tests and benchmarks for userver itself | `OFF` | +| `USERVER_BUILD_SAMPLES` | Build userver samples | `OFF` | + +### CMake options for features that are unavailable for some platforms + +@see @ref scripts/docs/en/userver/build/dependencies.md + +| Option | Description | Default | +|----------------------------------------|-------------------------------------------------------------------------------------------------------------------|---------------------------------------------| +| `USERVER_FEATURE_CRYPTOPP_BLAKE2` | Provide wrappers for blake2 algorithms of crypto++ | `ON` | +| `USERVER_FEATURE_PATCH_LIBPQ` | Apply patches to the libpq (add portals support), requires `libpq.a` | `ON` | +| `USERVER_FEATURE_CRYPTOPP_BASE64_URL` | Provide wrappers for Base64 URL decoding and encoding algorithms of crypto++ | `ON` | +| `USERVER_FEATURE_REDIS_HI_MALLOC` | Provide a `hi_malloc(unsigned long)` [issue][hi_malloc] workaround | `OFF` | +| `USERVER_FEATURE_REDIS_TLS` | SSL/TLS support for Redis driver | `OFF` | +| `USERVER_FEATURE_STACKTRACE` | Allow capturing stacktraces using `boost::stacktrace` | `ON` except for macOS, `*BSD` and old Boost | +| `USERVER_FEATURE_JEMALLOC` | Use jemalloc memory allocator | `ON` | +| `USERVER_FEATURE_DWCAS` | Require double-width compare-and-swap | `ON` | +| `USERVER_FEATURE_GRPC_CHANNELZ` | Enable Channelz for gRPC | `ON` for "sufficiently new" gRPC versions | +| `USERVER_MYSQL_ALLOW_BUGGY_LIBMARIADB` | Allows mysql driver to leak memory instead of aborting in some rare cases when linked against `libmariadb3<3.3.4` | `OFF` | +| `USERVER_DISABLE_PHDR_CACHE` | Disable caching of `dl_phdr_info` items, which interferes with `dlopen` | `OFF` | +| `USERVER_DISABLE_RSEQ_ACCELERATION` | Disable rseq-based optimizations, which may not work depending on kernel/glibc/distro/etc version | `OFF` for x86 Linux, `ON` otherwise | +| `USERVER_FEATURE_UBOOST_CORO` | Build with vendored version of Boost.context and Boost.coroutine2, is needed for sanitizers builds | `OFF` for arm64 macOS, `ON` otherwise | [hi_malloc]: https://bugs.launchpad.net/ubuntu/+source/hiredis/+bug/1888025 -To explicitly specialize the compiler use the cmake options `CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER`. -For example to use clang-12 compiler install it and add the following options to cmake: -`-DCMAKE_CXX_COMPILER=clang++-12 -DCMAKE_C_COMPILER=clang-12` +### CMake options for downloading userver dependencies + +| Option | Description | Default | +|------------------------------------------|-----------------------------------------------------------------------------------------|--------------------------------------| +| `USERVER_DOWNLOAD_PACKAGES` | Download missing third party packages and use the downloaded versions | `ON` | +| `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}` | +| `USERVER_DOWNLOAD_PACKAGE_CRYPTOPP` | Download and setup CryptoPP if no CryptoPP of matching version was found | `${USERVER_DOWNLOAD_PACKAGES}` | +| `USERVER_DOWNLOAD_PACKAGE_CURL` | Download and setup libcurl if no libcurl of matching version was found | `${USERVER_DOWNLOAD_PACKAGES}` | +| `USERVER_DOWNLOAD_PACKAGE_FMT` | Download and setup Fmt if no Fmt of matching version was found | `${USERVER_DOWNLOAD_PACKAGES}` | +| `USERVER_DOWNLOAD_PACKAGE_GBENCH` | Download and setup gbench if no gbench of matching version was found | `${USERVER_DOWNLOAD_PACKAGES}` | +| `USERVER_DOWNLOAD_PACKAGE_GRPC` | Download and setup gRPC if no gRPC of matching version was found | `${USERVER_DOWNLOAD_PACKAGES}` | +| `USERVER_DOWNLOAD_PACKAGE_GTEST` | Download and setup gtest if no gtest of matching version was found | `${USERVER_DOWNLOAD_PACKAGES}` | +| `USERVER_DOWNLOAD_PACKAGE_PROTOBUF` | Download and setup Protobuf if no Protobuf of matching version was found | `${USERVER_DOWNLOAD_PACKAGE_GRPC}` | +| `USERVER_DOWNLOAD_PACKAGE_KAFKA` | Download and setup librdkafka if no librdkafka matching version was found | `${USERVER_DOWNLOAD_PACKAGES}` | +| `USERVER_DOWNLOAD_PACKAGE_YDBCPPSDK` | Download and setup ydb-cpp-sdk if no ydb-cpp-sdk of matching version was found | `${USERVER_DOWNLOAD_PACKAGES}` | +| `USERVER_FORCE_DOWNLOAD_PACKAGES` | Download all possible third-party packages even if there is an installed system package | `OFF` | +| `USERVER_FORCE_DOWNLOAD_PROTOBUF` | Download Protobuf even if there is an installed system package | `${USERVER_FORCE_DOWNLOAD_PACKAGES}` | +| `USERVER_FORCE_DOWNLOAD_GRPC` | Download gRPC even if there is an installed system package | `${USERVER_FORCE_DOWNLOAD_PACKAGES}` | + +### CMake options for paths to dependencies + +| Option | Description | Default | +|---------------------------------------|----------------------------------------------------------------------------------------------------------------|------------------------------------| +| `USERVER_PYTHON_PATH` | Path to the python3 binary for use in testsuite tests | `python3` | +| `USERVER_PG_SERVER_INCLUDE_DIR` | Path to the folder with @ref POSTGRES_LIBS "PostgreSQL server headers", e.g. /usr/include/postgresql/15/server | autodetected | +| `USERVER_PG_SERVER_LIBRARY_DIR` | Path to the folder with @ref POSTGRES_LIBS "PostgreSQL server libraries", e.g. /usr/lib/postgresql/15/lib | autodetected | +| `USERVER_PG_INCLUDE_DIR` | Path to the folder with @ref POSTGRES_LIBS "PostgreSQL libpq headers", e.g. /usr/local/include | autodetected | +| `USERVER_PG_LIBRARY_DIR` | Path to the folder with @ref POSTGRES_LIBS "PostgreSQL libpq libraries", e.g. /usr/local/lib | autodetected | +| `USERVER_GOOGLE_COMMON_PROTOS_TARGET` | Name of cmake target preparing google common proto library | Builds `userver-api-common-protos` | +| `USERVER_GOOGLE_COMMON_PROTOS` | Path to the folder with google common proto files | Downloads automatically | + +### CMake options for various compilation modes + +| Option | Description | Default | +|----------------------------------------|-------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------| +| `USERVER_CHECK_PACKAGE_VERSIONS` | Check package versions | `ON` | +| `USERVER_SANITIZE` | Build with sanitizers support, allows combination of values via 'val1 val2'. Available: `addr`, `mem`, `ub` | `''` (no sanitizers) | +| `USERVER_SANITIZE_BLACKLIST` | Path to file that is passed to the -fsanitize-blacklist option | `''` (no blacklist) | +| `USERVER_USE_LD` | Linker to use, e.g. `gold` or `lld` | `lld` for Clang, system linker otherwise (typically GNU ld) | +| `USERVER_LTO` | Use link time optimizations (SEE NOTE BELOW) | `OFF` | +| `USERVER_LTO_CACHE` | Use LTO cache if present, disable for benchmarking build times | `ON` | +| `USERVER_LTO_CACHE_DIR` | LTO cache directory | `${CMAKE_CURRENT_BINARY_DIR}/.ltocache` | +| `USERVER_LTO_CACHE_SIZE_MB` | LTO cache size limit in MB | `6000` | +| `USERVER_PGO_GENERATE` | Generate PGO profile | `OFF` | +| `USERVER_PGO_USE` | Path to PGO profile file | `''` | +| `USERVER_USE_CCACHE` | Use ccache if present, disable for benchmarking build times | `ON` | +| `USERVER_COMPILATION_TIME_TRACE` | Generate Clang compilation time trace | `OFF` | +| `USERVER_NO_WERROR` | Do not treat warnings as errors | `ON` | +| `USERVER_FEATURE_ERASE_LOG_WITH_LEVEL` | Logs of this and below levels are removed from binary. Possible values: trace, info, debug, warning, error | `OFF` | +| `USERVER_PIP_USE_SYSTEM_PACKAGES` | Use system python packages inside venv. Useful for Docker, CI and other controlled environments | `OFF` | +| `USERVER_PIP_OPTIONS` | Options for all pip calls. Useful for passing `--no-index` option to prevent network usage | `''` | +| `USERVER_INSTALL` | Build userver for further installation | `OFF` | +| `USERVER_CONAN` | Build userver using Conan packages | `ON` if build is launched from Conan, `OFF` otherwise | +| `USERVER_GENERATE_PROTOS_AT_CONFIGURE` | Run protoc at CMake Configure time for better IDE integration | `OFF` for downloaded Protobuf, `ON` otherwise | @warning Using LTO can lead to [some problems](https://github.com/userver-framework/userver/issues/242). We don't recommend using `USERVER_LTO`. diff --git a/scripts/docs/en/userver/build/userver.md b/scripts/docs/en/userver/build/userver.md index 2befffcfbade..a5817c588d80 100644 --- a/scripts/docs/en/userver/build/userver.md +++ b/scripts/docs/en/userver/build/userver.md @@ -14,20 +14,30 @@ cd userver 2. Install the @ref scripts/docs/en/userver/build/dependencies.md "build dependencies" -3. Build the userver: +Alternatively you could use a docker container with all the building dependencies +installed from @ref docker_with_ubuntu_22_04 "Docker". + +3. Build userver: ```bash -mkdir build_release -cd build_release -cmake -DCMAKE_BUILD_TYPE=Release .. # Adjust with flags from "Configure and Build" section +mkdir build_debug +cd build_debug +# Adjust with flags from "Platform-specific build dependencies" section +cmake -S .. \ + -DCMAKE_C_COMPILER=clang-16 \ + -DCMAKE_CXX_COMPILER=clang++-16 \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCPM_SOURCE_CACHE=~/cpm \ + -DUSERVER_BUILD_ALL_COMPONENTS=1 \ + -DUSERVER_BUILD_SAMPLES=1 \ + -DUSERVER_BUILD_TESTS=1 cmake --build . -j$(nproc) ``` -4. Run tests via `ulimit -n 4096 && ctest -V` +@see @ref cmake_options +4. Run tests via `ulimit -n 4096 && ctest -V` -Alternatively you could use a docker container with all the building dependencies -installed from @ref scripts/docs/en/userver/build/dependencies.md "build dependencies" If you need to edit or make your own docker image with custom configuration, read about it at @ref scripts/docker/Readme.md. diff --git a/testsuite/CMakeLists.txt b/testsuite/CMakeLists.txt index 5d0747942022..8a8404809dc6 100644 --- a/testsuite/CMakeLists.txt +++ b/testsuite/CMakeLists.txt @@ -1,3 +1,3 @@ -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) add_subdirectory(tests) endif() diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 000000000000..e133d572f449 --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,18 @@ +project(userver-tools CXX) + +add_custom_target(${PROJECT_NAME}) + +add_subdirectory(congestion-control-emulator) +add_dependencies(${PROJECT_NAME} userver-tool-congestion-control-emulator) + +add_subdirectory(dns-resolver) +add_dependencies(${PROJECT_NAME} userver-tool-dns-resolver) + +add_subdirectory(engine-perf) +add_dependencies(${PROJECT_NAME} userver-tool-engine-perf) + +add_subdirectory(http-client-perf) +add_dependencies(${PROJECT_NAME} userver-tool-http-client-perf) + +add_subdirectory(netcat) +add_dependencies(${PROJECT_NAME} userver-tool-netcat) diff --git a/tools/Readme.md b/tools/Readme.md new file mode 100644 index 000000000000..111a1d7efdc1 --- /dev/null +++ b/tools/Readme.md @@ -0,0 +1,3 @@ +# userver Tools + +Contains non-automated tests and benchmarks for userver. diff --git a/tools/congestion-control-emulator/CMakeLists.txt b/tools/congestion-control-emulator/CMakeLists.txt new file mode 100644 index 000000000000..fe124a5b7e2f --- /dev/null +++ b/tools/congestion-control-emulator/CMakeLists.txt @@ -0,0 +1,11 @@ +project(userver-tool-congestion-control-emulator CXX) + +file(GLOB_RECURSE SOURCES *.cpp) + +find_package(Boost REQUIRED COMPONENTS program_options) + +add_executable(${PROJECT_NAME} ${SOURCES}) +target_link_libraries(${PROJECT_NAME} + userver-core + Boost::program_options +) diff --git a/tools/congestion_control_emulator/congestion_control_emulator.cpp b/tools/congestion-control-emulator/congestion_control_emulator.cpp similarity index 100% rename from tools/congestion_control_emulator/congestion_control_emulator.cpp rename to tools/congestion-control-emulator/congestion_control_emulator.cpp diff --git a/tools/congestion_control_emulator/data/const-overload.txt b/tools/congestion-control-emulator/data/const-overload.txt similarity index 100% rename from tools/congestion_control_emulator/data/const-overload.txt rename to tools/congestion-control-emulator/data/const-overload.txt diff --git a/tools/congestion_control_emulator/data/temp-overload.txt b/tools/congestion-control-emulator/data/temp-overload.txt similarity index 100% rename from tools/congestion_control_emulator/data/temp-overload.txt rename to tools/congestion-control-emulator/data/temp-overload.txt diff --git a/tools/congestion_control_emulator/policy/production-2020-10-09.json b/tools/congestion-control-emulator/policy/production-2020-10-09.json similarity index 100% rename from tools/congestion_control_emulator/policy/production-2020-10-09.json rename to tools/congestion-control-emulator/policy/production-2020-10-09.json diff --git a/tools/congestion_control_emulator/CMakeLists.txt b/tools/congestion_control_emulator/CMakeLists.txt deleted file mode 100644 index 373e68675919..000000000000 --- a/tools/congestion_control_emulator/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -project (congestion_control_emulator) - -file (GLOB_RECURSE SOURCES *.cpp) - -find_package(Boost REQUIRED COMPONENTS program_options) - -add_executable (${PROJECT_NAME} ${SOURCES}) -target_link_libraries (${PROJECT_NAME} - userver-core - Boost::program_options -) diff --git a/tools/dns_resolver/CMakeLists.txt b/tools/dns-resolver/CMakeLists.txt similarity index 57% rename from tools/dns_resolver/CMakeLists.txt rename to tools/dns-resolver/CMakeLists.txt index f94215266812..37c9e69de998 100644 --- a/tools/dns_resolver/CMakeLists.txt +++ b/tools/dns-resolver/CMakeLists.txt @@ -1,17 +1,17 @@ -project (dns-resolver) +project(userver-tool-dns-resolver CXX) -file (GLOB_RECURSE SOURCES *.cpp) +file(GLOB_RECURSE SOURCES *.cpp) find_package(Boost REQUIRED COMPONENTS program_options) -add_executable (${PROJECT_NAME} ${SOURCES}) -target_link_libraries (${PROJECT_NAME} +add_executable(${PROJECT_NAME} ${SOURCES}) +target_link_libraries(${PROJECT_NAME} userver-core Boost::program_options ) # Include directories marked SYSTEM so that includes from external projects # do not generate warnings treated as errors -target_include_directories (${PROJECT_NAME} SYSTEM PRIVATE +target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE $ ) diff --git a/tools/dns_resolver/resolver.cpp b/tools/dns-resolver/resolver.cpp similarity index 100% rename from tools/dns_resolver/resolver.cpp rename to tools/dns-resolver/resolver.cpp diff --git a/tools/engine-perf/CMakeLists.txt b/tools/engine-perf/CMakeLists.txt new file mode 100644 index 000000000000..339377e8243e --- /dev/null +++ b/tools/engine-perf/CMakeLists.txt @@ -0,0 +1,11 @@ +project(userver-tool-engine-perf) + +file(GLOB_RECURSE SOURCES *.cpp) + +find_package(Boost REQUIRED COMPONENTS program_options) + +add_executable(${PROJECT_NAME} ${SOURCES}) +target_link_libraries(${PROJECT_NAME} + userver-core + Boost::program_options +) diff --git a/tools/engine/engine_perf.cpp b/tools/engine-perf/engine_perf.cpp similarity index 100% rename from tools/engine/engine_perf.cpp rename to tools/engine-perf/engine_perf.cpp diff --git a/tools/engine/CMakeLists.txt b/tools/engine/CMakeLists.txt deleted file mode 100644 index cb8a24fca078..000000000000 --- a/tools/engine/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -project (engine_perf) - -file (GLOB_RECURSE SOURCES *.cpp) - -find_package(Boost REQUIRED COMPONENTS program_options) - -add_executable (${PROJECT_NAME} ${SOURCES}) -target_link_libraries (${PROJECT_NAME} - userver-core - Boost::program_options -) diff --git a/tools/http-client-perf/CMakeLists.txt b/tools/http-client-perf/CMakeLists.txt new file mode 100644 index 000000000000..a7cccd702d82 --- /dev/null +++ b/tools/http-client-perf/CMakeLists.txt @@ -0,0 +1,11 @@ +project(userver-tool-http-client-perf CXX) + +file(GLOB_RECURSE SOURCES *.cpp) + +find_package(Boost REQUIRED COMPONENTS program_options) + +add_executable(${PROJECT_NAME} ${SOURCES}) +target_link_libraries(${PROJECT_NAME} + userver-core + Boost::program_options +) diff --git a/tools/httpclient/httpclient_perf.cpp b/tools/http-client-perf/httpclient_perf.cpp similarity index 100% rename from tools/httpclient/httpclient_perf.cpp rename to tools/http-client-perf/httpclient_perf.cpp diff --git a/tools/httpclient/CMakeLists.txt b/tools/httpclient/CMakeLists.txt deleted file mode 100644 index 393ba7128965..000000000000 --- a/tools/httpclient/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -project (httpclient_perf) - -file (GLOB_RECURSE SOURCES *.cpp) - -find_package(Boost REQUIRED COMPONENTS program_options) - -add_executable (${PROJECT_NAME} ${SOURCES}) -target_link_libraries (${PROJECT_NAME} - userver-core - Boost::program_options -) diff --git a/tools/netcat/CMakeLists.txt b/tools/netcat/CMakeLists.txt index a627025f7784..fbbec511d3aa 100644 --- a/tools/netcat/CMakeLists.txt +++ b/tools/netcat/CMakeLists.txt @@ -1,11 +1,11 @@ -project (netcat) +project(userver-tool-netcat CXX) -file (GLOB_RECURSE SOURCES *.cpp) +file(GLOB_RECURSE SOURCES *.cpp) find_package(Boost REQUIRED COMPONENTS program_options) -add_executable (${PROJECT_NAME} ${SOURCES}) -target_link_libraries (${PROJECT_NAME} +add_executable(${PROJECT_NAME} ${SOURCES}) +target_link_libraries(${PROJECT_NAME} userver-core Boost::program_options ) diff --git a/universal/CMakeLists.txt b/universal/CMakeLists.txt index c0ea3c58003c..7b8ca8eb2fc0 100644 --- a/universal/CMakeLists.txt +++ b/universal/CMakeLists.txt @@ -307,7 +307,7 @@ _userver_directory_install(COMPONENT universal ) _userver_install_targets(COMPONENT universal TARGETS ${PROJECT_NAME}) -if (USERVER_IS_THE_ROOT_PROJECT OR USERVER_FEATURE_UTEST) +if (USERVER_FEATURE_UTEST) add_subdirectory(utest) add_library(${PROJECT_NAME}-internal-ubench INTERFACE) @@ -323,7 +323,7 @@ if (USERVER_IS_THE_ROOT_PROJECT OR USERVER_FEATURE_UTEST) ) endif() -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) add_library(${PROJECT_NAME}-internal OBJECT ${INTERNAL_SOURCES}) target_compile_definitions(${PROJECT_NAME}-internal PUBLIC $ diff --git a/universal/utest/CMakeLists.txt b/universal/utest/CMakeLists.txt index e58c48d53926..e1b6614c3179 100644 --- a/universal/utest/CMakeLists.txt +++ b/universal/utest/CMakeLists.txt @@ -46,7 +46,7 @@ _userver_install_targets(COMPONENT universal TARGETS userver-universal-utest ) -if(USERVER_IS_THE_ROOT_PROJECT) +if(USERVER_BUILD_TESTS) add_executable(${PROJECT_NAME}-unittest ${UNIT_TEST_SOURCES}) target_include_directories(${PROJECT_NAME}-unittest SYSTEM PRIVATE $ diff --git a/ydb/CMakeLists.txt b/ydb/CMakeLists.txt index 660f2b1a74e5..6bfcf782a579 100644 --- a/ydb/CMakeLists.txt +++ b/ydb/CMakeLists.txt @@ -34,6 +34,6 @@ _userver_directory_install(COMPONENT ydb DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/userver" ) -if (USERVER_IS_THE_ROOT_PROJECT) +if (USERVER_BUILD_TESTS) add_subdirectory(functional_tests) endif()