From 5e97087a895de2b7993405c2b3c5a9cfd6784c36 Mon Sep 17 00:00:00 2001 From: Anton Zhilin Date: Fri, 26 Jun 2026 01:05:48 +0300 Subject: [PATCH 1/2] feat install: auto-derived components, multipackage .deb fix, sample install Mirrored from arc branch install-fixes. Co-authored-by: Cursor --- CMakeLists.txt | 18 ------- chaotic-openapi/CMakeLists.txt | 2 +- chaotic/CMakeLists.txt | 2 +- clickhouse/CMakeLists.txt | 2 +- cmake/PrepareInstall.cmake | 68 ++++++++++++++---------- cmake/UserverModule.cmake | 38 ++++++++----- core/CMakeLists.txt | 2 +- grpc/CMakeLists.txt | 2 +- grpc/handlers/CMakeLists.txt | 1 - kafka/CMakeLists.txt | 2 +- libraries/easy/CMakeLists.txt | 19 ++++++- libraries/easy/samples/CMakeLists.txt | 9 ++-- libraries/grpc-reflection/CMakeLists.txt | 2 +- libraries/multi-index-lru/CMakeLists.txt | 2 +- libraries/protobuf/CMakeLists.txt | 1 - libraries/s3api/CMakeLists.txt | 2 +- mongo/CMakeLists.txt | 2 +- mysql/CMakeLists.txt | 2 +- odbc/CMakeLists.txt | 2 +- otlp/CMakeLists.txt | 2 +- postgresql/CMakeLists.txt | 8 +-- postgresql/pq-extra/CMakeLists.txt | 6 +-- postgresql/utest/CMakeLists.txt | 4 +- rabbitmq/CMakeLists.txt | 2 +- redis/CMakeLists.txt | 2 +- rocks/CMakeLists.txt | 2 +- samples/CMakeLists.txt | 8 ++- scripts/build_and_install.sh | 2 +- scripts/sqldto/CMakeLists.txt | 2 +- scylla/CMakeLists.txt | 2 +- sqlite/CMakeLists.txt | 2 +- universal/CMakeLists.txt | 2 +- ydb/CMakeLists.txt | 2 +- 33 files changed, 123 insertions(+), 101 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ac8edb59551..e91f4e81e91e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,8 +27,6 @@ if(CMAKE_VERSION GREATER_EQUAL 3.31) cmake_policy(SET CMP0177 NEW) endif() -set(USERVER_AVAILABLE_COMPONENTS universal) - # @ingroup libraries option(USERVER_FEATURE_CORE "Provide a core library with coroutines, otherwise build only userver-universal" ON) # @ingroup libraries @@ -250,12 +248,10 @@ add_subdirectory(universal) if(USERVER_FEATURE_CHAOTIC) add_subdirectory(chaotic) - list(APPEND USERVER_AVAILABLE_COMPONENTS chaotic) if(USERVER_FEATURE_CHAOTIC_EXPERIMENTAL) _require_userver_core(USERVER_FEATURE_CHAOTIC_EXPERIMENTAL) add_subdirectory(chaotic-openapi) - list(APPEND USERVER_AVAILABLE_COMPONENTS chaotic-openapi) endif() endif() @@ -264,38 +260,32 @@ if(USERVER_FEATURE_CORE) message(FATAL_ERROR "'USERVER_FEATURE_CORE' requires 'USERVER_FEATURE_CHAOTIC=ON'") endif() add_subdirectory(core) - list(APPEND USERVER_AVAILABLE_COMPONENTS core) endif() if(USERVER_FEATURE_MONGODB) _require_userver_core("USERVER_FEATURE_MONGODB") add_subdirectory(mongo) - list(APPEND USERVER_AVAILABLE_COMPONENTS mongo) endif() if(USERVER_FEATURE_POSTGRESQL) _require_userver_core("USERVER_FEATURE_POSTGRESQL") add_subdirectory(postgresql) - list(APPEND USERVER_AVAILABLE_COMPONENTS postgresql) endif() if(USERVER_FEATURE_REDIS) _require_userver_core("USERVER_FEATURE_REDIS") add_subdirectory(redis) - list(APPEND USERVER_AVAILABLE_COMPONENTS redis) endif() if(USERVER_FEATURE_GRPC) _require_userver_core("USERVER_FEATURE_GRPC") add_subdirectory(libraries/protobuf) add_subdirectory(grpc) - list(APPEND USERVER_AVAILABLE_COMPONENTS grpc) endif() if(USERVER_FEATURE_SCYLLADB) _require_userver_core("USERVER_FEATURE_SCYLLADB") add_subdirectory(scylla) - list(APPEND USERVER_AVAILABLE_COMPONENTS scylla) endif() @@ -305,31 +295,26 @@ if(USERVER_FEATURE_OTLP) endif() _require_userver_core("USERVER_FEATURE_OTLP") add_subdirectory(otlp) - list(APPEND USERVER_AVAILABLE_COMPONENTS otlp) endif() if(USERVER_FEATURE_CLICKHOUSE) _require_userver_core("USERVER_FEATURE_CLICKHOUSE") add_subdirectory(clickhouse) - list(APPEND USERVER_AVAILABLE_COMPONENTS clickhouse) endif() if(USERVER_FEATURE_KAFKA) _require_userver_core("USERVER_FEATURE_KAFKA") add_subdirectory(kafka) - list(APPEND USERVER_AVAILABLE_COMPONENTS kafka) endif() if(USERVER_FEATURE_RABBITMQ) _require_userver_core("USERVER_FEATURE_RABBITMQ") add_subdirectory(rabbitmq) - list(APPEND USERVER_AVAILABLE_COMPONENTS rabbitmq) endif() if(USERVER_FEATURE_MYSQL) _require_userver_core("USERVER_FEATURE_MYSQL") add_subdirectory(mysql) - list(APPEND USERVER_AVAILABLE_COMPONENTS mysql) endif() if(USERVER_FEATURE_ROCKS) @@ -340,19 +325,16 @@ endif() if(USERVER_FEATURE_YDB) _require_userver_core("USERVER_FEATURE_YDB") add_subdirectory(ydb) - list(APPEND USERVER_AVAILABLE_COMPONENTS ydb) endif() if(USERVER_FEATURE_SQLITE) _require_userver_core("USERVER_FEATURE_SQLITE") add_subdirectory(sqlite) - list(APPEND USERVER_AVAILABLE_COMPONENTS sqlite) endif() if(USERVER_FEATURE_ODBC) _require_userver_core("USERVER_FEATURE_ODBC") add_subdirectory(odbc) - list(APPEND USERVER_AVAILABLE_COMPONENTS odbc) endif() add_subdirectory(libraries) diff --git a/chaotic-openapi/CMakeLists.txt b/chaotic-openapi/CMakeLists.txt index fcee84d6711e..6b33cb998512 100644 --- a/chaotic-openapi/CMakeLists.txt +++ b/chaotic-openapi/CMakeLists.txt @@ -10,7 +10,7 @@ userver_module( LINK_LIBRARIES userver-core userver-chaotic UTEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_test.cpp" UTEST_LINK_LIBRARIES userver-core userver-chaotic - DEPENDS core + COMPONENT_DEPENDS core ) if(USERVER_BUILD_TESTS) diff --git a/chaotic/CMakeLists.txt b/chaotic/CMakeLists.txt index 42601654adf0..640c0dc4b082 100644 --- a/chaotic/CMakeLists.txt +++ b/chaotic/CMakeLists.txt @@ -14,7 +14,7 @@ userver_module( SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" UTEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_test.cpp" LINK_LIBRARIES userver::universal - DEPENDS universal + COMPONENT_DEPENDS universal NO_CORE_LINK ) diff --git a/clickhouse/CMakeLists.txt b/clickhouse/CMakeLists.txt index a9035f55c4c4..2f694e4db3e7 100644 --- a/clickhouse/CMakeLists.txt +++ b/clickhouse/CMakeLists.txt @@ -16,7 +16,7 @@ userver_module( # HACK: common source between unittest and dbtest targets. "${CMAKE_CURRENT_SOURCE_DIR}/src/storages/tests/utils_test.cpp" DBTEST_DATABASES clickhouse - DEPENDS core + COMPONENT_DEPENDS core EMBED_FILES src/storages/clickhouse/component.yaml ) diff --git a/cmake/PrepareInstall.cmake b/cmake/PrepareInstall.cmake index 3ee9c477c4f5..084b90bdedd9 100644 --- a/cmake/PrepareInstall.cmake +++ b/cmake/PrepareInstall.cmake @@ -3,9 +3,10 @@ include_guard(GLOBAL) set_property(GLOBAL PROPERTY userver_cmake_dir "${CMAKE_CURRENT_LIST_DIR}") function(_userver_install_targets) + set(options) set(oneValueArgs COMPONENT) set(multiValueArgs TARGETS) - cmake_parse_arguments(ARG "${option}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}") + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}") if(NOT ARG_COMPONENT) message(FATAL_ERROR "No COMPONENT for install") endif() @@ -78,7 +79,7 @@ function(_userver_directory_install) endif() set(option) set(oneValueArgs COMPONENT DESTINATION PATTERN RENAME) - set(multiValueArgs FILES DIRECTORY PROGRAMS) + set(multiValueArgs FILES DIRECTORY PROGRAMS EXCLUDE_PATTERNS) cmake_parse_arguments(ARG "${option}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}") if(NOT ARG_COMPONENT) message(FATAL_ERROR "No COMPONENT for install") @@ -109,22 +110,20 @@ function(_userver_directory_install) ) endif() if(ARG_DIRECTORY) + set(install_args) if(ARG_PATTERN) - install( - DIRECTORY ${ARG_DIRECTORY} - DESTINATION ${ARG_DESTINATION} - COMPONENT ${ARG_COMPONENT} - USE_SOURCE_PERMISSIONS FILES_MATCHING - PATTERN ${ARG_PATTERN} - ) - else() - install( - DIRECTORY ${ARG_DIRECTORY} - DESTINATION ${ARG_DESTINATION} - COMPONENT ${ARG_COMPONENT} - USE_SOURCE_PERMISSIONS - ) + list(APPEND install_args FILES_MATCHING PATTERN ${ARG_PATTERN}) endif() + foreach(pattern IN LISTS ARG_EXCLUDE_PATTERNS) + list(APPEND install_args PATTERN "${pattern}" EXCLUDE) + endforeach() + install( + DIRECTORY ${ARG_DIRECTORY} + DESTINATION ${ARG_DESTINATION} + COMPONENT ${ARG_COMPONENT} + USE_SOURCE_PERMISSIONS + ${install_args} + ) endif() endfunction() @@ -133,6 +132,12 @@ function(_userver_make_install_config) return() endif() + # USERVER_AVAILABLE_COMPONENTS is collected automatically from + # _userver_install_component() calls (see the global property of the same + # name). It is substituted into Config.cmake.in as the default list of + # find_package(userver) components. + get_property(USERVER_AVAILABLE_COMPONENTS GLOBAL PROPERTY USERVER_AVAILABLE_COMPONENTS) + configure_package_config_file( "${USERVER_ROOT_DIR}/cmake/install/Config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/userverConfig.cmake" INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/userver" @@ -156,41 +161,46 @@ function(_userver_install_component) return() endif() - set(oneValueArgs MODULE) + set(options NON_FINDABLE) + set(oneValueArgs COMPONENT) set(multiValueArgs DEPENDS) - cmake_parse_arguments(ARG "${option}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}") + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}") + + if(NOT ARG_NON_FINDABLE) + set_property(GLOBAL APPEND PROPERTY USERVER_AVAILABLE_COMPONENTS ${ARG_COMPONENT}) + endif() - string(TOUPPER "${ARG_MODULE}" MODULE_UPPER) + string(TOUPPER "${ARG_COMPONENT}" COMPONENT_UPPER) if(CPACK_COMPONENTS_GROUPING STREQUAL ONE_PER_GROUP) - if(NOT CPACK_DEBIAN_${MODULE_UPPER}_PACKAGE_DEPENDS) + if(NOT CPACK_DEBIAN_${COMPONENT_UPPER}_PACKAGE_DEPENDS) message( FATAL_ERROR - "File with per-component dependencies is missing (component ${ARG_MODULE}). Either use CPACK_COMPONENTS_GROUPING=ALL_COMPONENTS_IN_ONE to build a single all-in-one package, or create dependency file ${USERVER_ROOT_DIR}/scripts/docs/en/deps/${DEPENDENCIES_FILESTEM}/${ARG_MODULE}." + "File with per-component dependencies is missing (component ${ARG_COMPONENT}). Either use CPACK_COMPONENTS_GROUPING=ALL_COMPONENTS_IN_ONE to build a single all-in-one package, or create dependency file ${USERVER_ROOT_DIR}/scripts/docs/en/deps/${DEPENDENCIES_FILESTEM}/${ARG_COMPONENT}." ) endif() endif() execute_process( - COMMAND cat "${USERVER_ROOT_DIR}/scripts/docs/en/deps/${DEPENDENCIES_FILESTEM}/${ARG_MODULE}" + COMMAND cat "${USERVER_ROOT_DIR}/scripts/docs/en/deps/${DEPENDENCIES_FILESTEM}/${ARG_COMPONENT}" COMMAND tr "\n" " " COMMAND sed "s/ \\(.\\)/, \\1/g" - OUTPUT_VARIABLE MODULE_DEPENDS + OUTPUT_VARIABLE COMPONENT_DEPENDS ) file( APPEND "${CMAKE_BINARY_DIR}/cpack.variables.inc" " - set(CPACK_DEBIAN_${MODULE_UPPER}_PACKAGE_NAME libuserver-${ARG_MODULE}-dev) - set(CPACK_DEBIAN_${MODULE_UPPER}_PACKAGE_CONFLICTS libuserver-all-dev) - set(CPACK_COMPONENT_${MODULE_UPPER}_DEPENDS ${ARG_DEPENDS}) - set(CPACK_DEBIAN_${MODULE_UPPER}_PACKAGE_DEPENDS \"${MODULE_DEPENDS}\") + set(CPACK_DEBIAN_${COMPONENT_UPPER}_PACKAGE_NAME libuserver-${ARG_COMPONENT}-dev) + set(CPACK_DEBIAN_${COMPONENT_UPPER}_PACKAGE_CONFLICTS libuserver-all-dev) + set(CPACK_COMPONENT_${COMPONENT_UPPER}_DEPENDS ${ARG_DEPENDS}) + set(CPACK_DEBIAN_${COMPONENT_UPPER}_PACKAGE_DEPENDS \"${COMPONENT_DEPENDS}\") " ) file( APPEND "${CMAKE_BINARY_DIR}/cpack.inc" " - cpack_add_component_group(${ARG_MODULE} EXPANDED) - cpack_add_component(${ARG_MODULE} GROUP ${ARG_MODULE} INSTALL_TYPES Full) + cpack_add_component_group(${ARG_COMPONENT} EXPANDED) + cpack_add_component(${ARG_COMPONENT} GROUP ${ARG_COMPONENT} INSTALL_TYPES Full) " ) endfunction() diff --git a/cmake/UserverModule.cmake b/cmake/UserverModule.cmake index 12049610336f..1dea5b8af188 100644 --- a/cmake/UserverModule.cmake +++ b/cmake/UserverModule.cmake @@ -31,7 +31,8 @@ include_guard(GLOBAL) # @multiparam UBENCH_LINK_LIBRARIES ??? # @multiparam UBENCH_DATABASES Databases to start for benchmarks # @multiparam UBENCH_ENV Environment variables to set for benchmarks -# @multiparam DEPENDS Userver module name(s) that the current module depends on +# @multiparam COMPONENT_DEPENDS userver component name(s) that the current component depends on. +# Only valid for the main module of a component (i.e. when INSTALL_COMPONENT is not set). # @multiparam EMBED_FILES Files to embed function(userver_module MODULE) unset(ARG_UNPARSED_ARGUMENTS) @@ -56,7 +57,7 @@ function(userver_module MODULE) UBENCH_LINK_LIBRARIES UBENCH_DATABASES UBENCH_ENV - DEPENDS + COMPONENT_DEPENDS EMBED_FILES ) cmake_parse_arguments(ARG "${OPTIONS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN}) @@ -102,6 +103,13 @@ function(userver_module MODULE) if(NOT ARG_NO_INSTALL) if(ARG_INSTALL_COMPONENT) + if(ARG_COMPONENT_DEPENDS) + message( + FATAL_ERROR + "userver_module(${MODULE}): COMPONENT_DEPENDS is meaningless together with INSTALL_COMPONENT. " + "Specify the dependencies on the main module of the '${ARG_INSTALL_COMPONENT}' component instead." + ) + endif() set(INSTALL_COMPONENT ${ARG_INSTALL_COMPONENT}) else() set(INSTALL_COMPONENT ${MODULE}) @@ -113,19 +121,20 @@ function(userver_module MODULE) ) _userver_install_targets(COMPONENT ${INSTALL_COMPONENT} TARGETS userver-${MODULE}) if(NOT ARG_INSTALL_COMPONENT) - set(install_config_file "${USERVER_ROOT_DIR}/cmake/install/userver-${MODULE}-config.cmake") + # Main module of the component. + set(install_config_file "${USERVER_ROOT_DIR}/cmake/install/userver-${INSTALL_COMPONENT}-config.cmake") if(NOT EXISTS ${install_config_file}) - message(FATAL_ERROR "Can not install ${MODULE}, no installation config in ${install_config_file}") + message(FATAL_ERROR "Can not install ${INSTALL_COMPONENT}, no installation config in ${install_config_file}") endif() _userver_directory_install( - COMPONENT ${MODULE} + COMPONENT ${INSTALL_COMPONENT} FILES "${install_config_file}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/userver" ) - endif() - _userver_install_component(MODULE ${MODULE} DEPENDS ${ARG_DEPENDS}) + _userver_install_component(COMPONENT ${INSTALL_COMPONENT} DEPENDS ${ARG_COMPONENT_DEPENDS}) + endif() endif() # 1. userver-${MODULE}-unittest @@ -179,12 +188,15 @@ function(userver_module MODULE) if(ARG_GENERATE_DYNAMIC_CONFIGS) userver_target_generate_chaotic_dynamic_configs(userver-${MODULE}-dynamic-configs dynamic_configs/*.yaml) target_link_libraries(userver-${MODULE} PUBLIC userver-${MODULE}-dynamic-configs) - _userver_install_targets(COMPONENT ${MODULE} TARGETS userver-${MODULE}-dynamic-configs) - _userver_directory_install( - COMPONENT ${MODULE} - DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dynamic_configs/include - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/.." - ) + + if(NOT ARG_NO_INSTALL) + _userver_install_targets(COMPONENT ${INSTALL_COMPONENT} TARGETS userver-${MODULE}-dynamic-configs) + _userver_directory_install( + COMPONENT ${INSTALL_COMPONENT} + DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dynamic_configs/include + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/.." + ) + endif() endif() foreach(FILE ${ARG_EMBED_FILES}) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 16f0edabf146..a8cb7ed39b66 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -345,4 +345,4 @@ _userver_directory_install( DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/userver/testsuite/pytest_plugins/ ) -_userver_install_component(MODULE core DEPENDS chaotic) +_userver_install_component(COMPONENT core DEPENDS chaotic) diff --git a/grpc/CMakeLists.txt b/grpc/CMakeLists.txt index 3426f875b912..7887bcc1d87a 100644 --- a/grpc/CMakeLists.txt +++ b/grpc/CMakeLists.txt @@ -229,4 +229,4 @@ _userver_directory_install( DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/userver/modules ) -_userver_install_component(MODULE grpc DEPENDS core) +_userver_install_component(COMPONENT grpc DEPENDS core) diff --git a/grpc/handlers/CMakeLists.txt b/grpc/handlers/CMakeLists.txt index 696c854e3731..bbd226db2744 100644 --- a/grpc/handlers/CMakeLists.txt +++ b/grpc/handlers/CMakeLists.txt @@ -6,7 +6,6 @@ userver_module( INSTALL_COMPONENT grpc LINK_LIBRARIES userver-grpc-internal UTEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_test.cpp" - DEPENDS grpc ) userver_add_grpc_library(${PROJECT_NAME}-proto PROTOS health/v1/health.proto) diff --git a/kafka/CMakeLists.txt b/kafka/CMakeLists.txt index 0cb58d7e3b10..e283b6ad4062 100644 --- a/kafka/CMakeLists.txt +++ b/kafka/CMakeLists.txt @@ -12,7 +12,7 @@ userver_module( LINK_LIBRARIES_PRIVATE RdKafka::rdkafka DBTEST_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests" DBTEST_LINK_LIBRARIES userver::kafka-utest - DEPENDS core + COMPONENT_DEPENDS core EMBED_FILES src/kafka/consumer_component.yaml src/kafka/producer_component.yaml ) diff --git a/libraries/easy/CMakeLists.txt b/libraries/easy/CMakeLists.txt index 7b5c38799531..39ca22b0458d 100644 --- a/libraries/easy/CMakeLists.txt +++ b/libraries/easy/CMakeLists.txt @@ -5,9 +5,26 @@ userver_module( SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" LINK_LIBRARIES userver::postgresql UTEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_test.cpp" - DEPENDS core + COMPONENT_DEPENDS core ) if(USERVER_BUILD_SAMPLES) + # Imitate an installed userver for the leaf find_package(userver) calls. + file(WRITE "${CMAKE_BINARY_DIR}/package_stubs/userverConfig.cmake" "") + add_subdirectory(samples) + + # Install the easy samples as a standalone project under + # share/userver/samples/easy (a dedicated subdirectory so they do not clutter + # the root userver samples). The trailing slash installs the directory + # contents, including samples/CMakeLists.txt which becomes the project root. + _userver_directory_install( + COMPONENT examples + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/samples/" + DESTINATION "${CMAKE_INSTALL_DATADIR}/userver/samples/easy" + ) + + # Clean up the fake userver installation above to avoid messing with + # find_package(userver) in the parent project. + file(REMOVE "${CMAKE_BINARY_DIR}/package_stubs/userverConfig.cmake") endif() diff --git a/libraries/easy/samples/CMakeLists.txt b/libraries/easy/samples/CMakeLists.txt index ce2e034ce281..bfe9ee41386d 100644 --- a/libraries/easy/samples/CMakeLists.txt +++ b/libraries/easy/samples/CMakeLists.txt @@ -1,9 +1,9 @@ +cmake_minimum_required(VERSION 3.14) project(userver-easy-samples CXX) -add_custom_target(${PROJECT_NAME}) +find_package(userver COMPONENTS easy REQUIRED) -# Imitate an installed userver in samples. -file(WRITE "${CMAKE_BINARY_DIR}/package_stubs/userverConfig.cmake" ) +add_custom_target(${PROJECT_NAME}) add_subdirectory(0_hello_world) add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-hello-world) @@ -25,6 +25,3 @@ add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-pg-service-template) add_subdirectory(6_pg_service_template_no_http_with) add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-pg-service-template-no-http-with) - -# Clean up fake userver installation above to avoid messing with find_package(userver) in the parent project. -file(REMOVE "${CMAKE_BINARY_DIR}/package_stubs/userverConfig.cmake") diff --git a/libraries/grpc-reflection/CMakeLists.txt b/libraries/grpc-reflection/CMakeLists.txt index f712c542e006..5dfa53ab295a 100644 --- a/libraries/grpc-reflection/CMakeLists.txt +++ b/libraries/grpc-reflection/CMakeLists.txt @@ -9,7 +9,7 @@ userver_module( SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" LINK_LIBRARIES ${PROJECT_NAME}-proto userver::grpc UTEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_test.cpp" - DEPENDS grpc + COMPONENT_DEPENDS grpc ) if(USERVER_BUILD_TESTS) diff --git a/libraries/multi-index-lru/CMakeLists.txt b/libraries/multi-index-lru/CMakeLists.txt index b473b8773ea1..b59829f4f6ea 100644 --- a/libraries/multi-index-lru/CMakeLists.txt +++ b/libraries/multi-index-lru/CMakeLists.txt @@ -7,7 +7,7 @@ userver_module( SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" UTEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_test.cpp" UBENCH_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_benchmark.cpp" - DEPENDS core + COMPONENT_DEPENDS core ) target_include_directories( diff --git a/libraries/protobuf/CMakeLists.txt b/libraries/protobuf/CMakeLists.txt index 15982a57f7f4..69ee2182f796 100644 --- a/libraries/protobuf/CMakeLists.txt +++ b/libraries/protobuf/CMakeLists.txt @@ -9,7 +9,6 @@ userver_module( "${CMAKE_CURRENT_SOURCE_DIR}/tests/datetime_test.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/tests/json/*.cpp" UTEST_LINK_LIBRARIES userver-protobuf-unittest-proto - DEPENDS universal ) if(USERVER_BUILD_TESTS) diff --git a/libraries/s3api/CMakeLists.txt b/libraries/s3api/CMakeLists.txt index 40be9c3e9115..39cf0efc7675 100644 --- a/libraries/s3api/CMakeLists.txt +++ b/libraries/s3api/CMakeLists.txt @@ -7,7 +7,7 @@ userver_module( SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" LINK_LIBRARIES_PRIVATE pugixml::pugixml UTEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_test.cpp" - DEPENDS core + COMPONENT_DEPENDS core ) _userver_directory_install( diff --git a/mongo/CMakeLists.txt b/mongo/CMakeLists.txt index d2ee99f85658..ed3cfb0e3037 100644 --- a/mongo/CMakeLists.txt +++ b/mongo/CMakeLists.txt @@ -20,7 +20,7 @@ userver_module( # Tests that use IsCollectionWriteConcernTimeout require multi-instance mongo DBTEST_ENV TESTSUITE_MONGO_RS_INSTANCE_COUNT=5 UBENCH_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*_benchmark.cpp" - DEPENDS core + COMPONENT_DEPENDS core GENERATE_DYNAMIC_CONFIGS EMBED_FILES src/cache/base_mongo_cache.yaml src/storages/mongo/component.yaml src/storages/mongo/component_multi.yaml src/storages/mongo/dist_lock_component_base.yaml diff --git a/mysql/CMakeLists.txt b/mysql/CMakeLists.txt index 8643f4188c52..fc57c17f746b 100644 --- a/mysql/CMakeLists.txt +++ b/mysql/CMakeLists.txt @@ -14,7 +14,7 @@ userver_module( UBENCH_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/benchmarks" UBENCH_LINK_LIBRARIES libmariadb UBENCH_DATABASES mysql - DEPENDS core + COMPONENT_DEPENDS core EMBED_FILES src/storages/mysql/component.yaml ) diff --git a/odbc/CMakeLists.txt b/odbc/CMakeLists.txt index 9bfce118c729..fd97e56ce2fd 100644 --- a/odbc/CMakeLists.txt +++ b/odbc/CMakeLists.txt @@ -8,7 +8,7 @@ userver_module( UTEST_LINK_LIBRARIES odbc DBTEST_DATABASES postgresql DBTEST_ENV POSTGRES_TEST_DSN=postgresql://testsuite@localhost:15433/postgres - DEPENDS core + COMPONENT_DEPENDS core EMBED_FILES src/storages/odbc/component.yaml ) diff --git a/otlp/CMakeLists.txt b/otlp/CMakeLists.txt index 43cf42119586..2e088b6dd699 100644 --- a/otlp/CMakeLists.txt +++ b/otlp/CMakeLists.txt @@ -9,7 +9,7 @@ userver_module( LINK_LIBRARIES userver-otlp-proto UTEST_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests" UTEST_LINK_LIBRARIES userver-grpc-utest - DEPENDS grpc + COMPONENT_DEPENDS grpc EMBED_FILES src/otlp/logs/component.yaml ) diff --git a/postgresql/CMakeLists.txt b/postgresql/CMakeLists.txt index f23d91edffe4..7d14802c854d 100644 --- a/postgresql/CMakeLists.txt +++ b/postgresql/CMakeLists.txt @@ -49,7 +49,7 @@ userver_module( UBENCH_LINK_LIBRARIES userver-libpq UBENCH_DATABASES postgresql UBENCH_ENV POSTGRES_DSN_BENCH=postgresql://testsuite@localhost:15433/postgres - DEPENDS core + COMPONENT_DEPENDS core GENERATE_DYNAMIC_CONFIGS EMBED_FILES src/cache/base_postgres_cache.yaml src/storages/postgres/component.yaml src/storages/postgres/dist_lock_component_base.yaml @@ -57,14 +57,14 @@ userver_module( target_sources(${PROJECT_NAME} PRIVATE "${LIBPQ_VERSION_DIR}/userver_libpq_version.hpp") -_userver_install_targets(COMPONENT postgres TARGETS userver-libpq) +_userver_install_targets(COMPONENT postgresql TARGETS userver-libpq) _userver_directory_install( - COMPONENT postgres + COMPONENT postgresql FILES "${USERVER_ROOT_DIR}/cmake/UserverSql.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/userver" ) _userver_directory_install( - COMPONENT postgres + COMPONENT postgresql DIRECTORY "${USERVER_ROOT_DIR}/scripts/sql" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/userver/scripts" ) diff --git a/postgresql/pq-extra/CMakeLists.txt b/postgresql/pq-extra/CMakeLists.txt index b5bd233d956a..105002574f11 100644 --- a/postgresql/pq-extra/CMakeLists.txt +++ b/postgresql/pq-extra/CMakeLists.txt @@ -37,15 +37,15 @@ if(NOT "${COMPILE_RESULT}") ) endif() -_userver_install_targets(COMPONENT postgres TARGETS ${PROJECT_NAME}) +_userver_install_targets(COMPONENT postgresql TARGETS ${PROJECT_NAME}) _userver_directory_install( - COMPONENT postgres + COMPONENT postgresql FILES "${USERVER_ROOT_DIR}/cmake/SetupPostgresqlDeps.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/userver ) _userver_directory_install( - COMPONENT postgres + COMPONENT postgresql FILES "${USERVER_ROOT_DIR}/cmake/modules/FindPostgreSQLInternal.cmake" "${USERVER_ROOT_DIR}/cmake/modules/FindGssApi.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/userver/modules diff --git a/postgresql/utest/CMakeLists.txt b/postgresql/utest/CMakeLists.txt index dffcea15f77f..3bb4e4bbfc24 100644 --- a/postgresql/utest/CMakeLists.txt +++ b/postgresql/utest/CMakeLists.txt @@ -8,8 +8,8 @@ target_include_directories(${PROJECT_NAME} PUBLIC $ Date: Fri, 26 Jun 2026 02:42:30 +0300 Subject: [PATCH 2/2] Fix --- libraries/protobuf/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/protobuf/CMakeLists.txt b/libraries/protobuf/CMakeLists.txt index 69ee2182f796..5af7a207c369 100644 --- a/libraries/protobuf/CMakeLists.txt +++ b/libraries/protobuf/CMakeLists.txt @@ -16,6 +16,9 @@ if(USERVER_BUILD_TESTS) set(_PROTO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/tests/proto") set(_PROTO_GEN "${CMAKE_CURRENT_BINARY_DIR}/proto") + # protoc requires its output directory to already exist. + file(MAKE_DIRECTORY "${_PROTO_GEN}") + add_library(userver-protobuf-unittest-proto STATIC "${_PROTO_SRC}") protobuf_generate( TARGET userver-protobuf-unittest-proto