Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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()


Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion chaotic-openapi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion chaotic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion clickhouse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
68 changes: 39 additions & 29 deletions cmake/PrepareInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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()

Expand All @@ -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"
Expand All @@ -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()
Expand Down
38 changes: 25 additions & 13 deletions cmake/UserverModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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})
Expand Down Expand Up @@ -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})
Expand All @@ -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
Expand Down Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion grpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 0 additions & 1 deletion grpc/handlers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion kafka/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
Loading
Loading