Skip to content

Commit

Permalink
feat build: prepare to reuse CMake installed configs in Conan
Browse files Browse the repository at this point in the history
Tests: протестировано локально и в CI
commit_hash:4de9285654f58dd8222cf10f4bb83770c9a3f0a1
  • Loading branch information
apolukhin committed Dec 27, 2024
1 parent a78eb7b commit c5e03d4
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 31 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ endif()
if (USERVER_FEATURE_POSTGRESQL)
_require_userver_core("USERVER_FEATURE_POSTGRESQL")
add_subdirectory(postgresql)
list(APPEND USERVER_AVAILABLE_COMPONENTS postgres)
list(APPEND USERVER_AVAILABLE_COMPONENTS postgresql)
endif()

if (USERVER_FEATURE_REDIS)
Expand Down
2 changes: 1 addition & 1 deletion clickhouse/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(userver-clickhouse CXX)

if (USERVER_CONAN)
find_package(clickhouse-cpp REQUIRED)
find_package(clickhouse-cpp REQUIRED CONFIG)
set(CLICKHOUSE_CPP_TARGET clickhouse-cpp-lib::clickhouse-cpp-lib)
else()
include(SetupClickhouseCPP)
Expand Down
6 changes: 5 additions & 1 deletion cmake/install/userver-clickhouse-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ find_package(userver REQUIRED COMPONENTS
core
)

include("${USERVER_CMAKE_DIR}/modules/Findclickhouse-cpp.cmake")
if (USERVER_CONAN)
find_package(clickhouse-cpp REQUIRED CONFIG)
else()
include("${USERVER_CMAKE_DIR}/modules/Findclickhouse-cpp.cmake")
endif()

set(userver_clickhouse_FOUND TRUE)
18 changes: 13 additions & 5 deletions cmake/install/userver-core-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@ find_package(Boost REQUIRED CONFIG COMPONENTS

find_package(CURL "7.68" REQUIRED)
find_package(ZLIB REQUIRED)
find_package(Nghttp2 REQUIRED)
find_package(LibEv REQUIRED)

include("${USERVER_CMAKE_DIR}/UserverTestsuite.cmake")
include("${USERVER_CMAKE_DIR}/modules/Findc-ares.cmake")
if (c-ares_FOUND AND NOT TARGET c-ares::cares)
add_library(c-ares::cares ALIAS c-ares)

if (USERVER_CONAN)
find_package(c-ares REQUIRED CONFIG)
find_package(libnghttp2 REQUIRED CONFIG)
find_package(libev REQUIRED CONFIG)
find_package(concurrentqueue REQUIRED CONFIG)
else()
include("${USERVER_CMAKE_DIR}/modules/Findc-ares.cmake")
if (c-ares_FOUND AND NOT TARGET c-ares::cares)
add_library(c-ares::cares ALIAS c-ares)
endif()
find_package(Nghttp2 REQUIRED)
find_package(LibEv REQUIRED)
endif()

set(userver_core_FOUND TRUE)
8 changes: 6 additions & 2 deletions cmake/install/userver-kafka-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ find_package(userver REQUIRED COMPONENTS
core
)

include("${USERVER_CMAKE_DIR}/modules/Findlz4.cmake")
include("${USERVER_CMAKE_DIR}/modules/FindRdKafka.cmake")
if(USERVER_CONAN)
find_package(RdKafka REQUIRED CONFIG)
else()
include("${USERVER_CMAKE_DIR}/modules/Findlz4.cmake")
include("${USERVER_CMAKE_DIR}/modules/FindRdKafka.cmake")
endif()

set(userver_kafka_FOUND TRUE)
8 changes: 6 additions & 2 deletions cmake/install/userver-mongo-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ find_package(userver REQUIRED COMPONENTS
core
)

include("${USERVER_CMAKE_DIR}/modules/Findbson.cmake")
include("${USERVER_CMAKE_DIR}/modules/Findmongoc.cmake")
if (USERVER_CONAN)
find_package(mongoc-1.0 REQUIRED CONFIG)
else()
include("${USERVER_CMAKE_DIR}/modules/Findbson.cmake")
include("${USERVER_CMAKE_DIR}/modules/Findmongoc.cmake")
endif()

set(userver_mongo_FOUND TRUE)
6 changes: 5 additions & 1 deletion cmake/install/userver-mysql-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ find_package(userver REQUIRED COMPONENTS
core
)

include("${USERVER_CMAKE_DIR}/modules/Findlibmariadb.cmake")
if (USERVER_CONAN)
find_package(libmariadb REQUIRED CONFIG)
else()
include("${USERVER_CMAKE_DIR}/modules/Findlibmariadb.cmake")
endif()

set(userver_mysql_FOUND TRUE)
6 changes: 5 additions & 1 deletion cmake/install/userver-redis-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ find_package(userver REQUIRED COMPONENTS
core
)

include("${USERVER_CMAKE_DIR}/modules/FindHiredis.cmake")
if (USERVER_CONAN)
find_package(hiredis REQUIRED CONFIG)
else()
include("${USERVER_CMAKE_DIR}/modules/FindHiredis.cmake")
endif()

set(userver_redis_FOUND TRUE)
23 changes: 19 additions & 4 deletions cmake/install/userver-universal-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,28 @@ if(NOT TARGET fmt)
endif()

find_package(cctz REQUIRED)
find_package(CryptoPP REQUIRED)
find_package(libyamlcpp REQUIRED)
find_package(libzstd REQUIRED)

if (USERVER_IMPL_FEATURE_JEMALLOC AND
NOT USERVER_SANITIZE AND
NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
find_package(Jemalloc REQUIRED)

if (USERVER_CONAN)
find_package(jemalloc REQUIRED CONFIG)
else()
find_package(Jemalloc REQUIRED)
endif()
endif()

if (USERVER_CONAN)
find_package(cryptopp REQUIRED CONFIG)
find_package(yaml-cpp REQUIRED CONFIG)
find_package(zstd REQUIRED CONFIG)

find_package(RapidJSON REQUIRED CONFIG)
else()
find_package(CryptoPP REQUIRED)
find_package(libyamlcpp REQUIRED)
find_package(libzstd REQUIRED)
endif()

include("${USERVER_CMAKE_DIR}/AddGoogleTests.cmake")
Expand Down
12 changes: 6 additions & 6 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ find_package(Iconv REQUIRED)
find_package_required(OpenSSL "libssl-dev")

if (USERVER_CONAN)
find_package(c-ares REQUIRED)
find_package(CURL REQUIRED)
find_package(cryptopp REQUIRED)
find_package(libnghttp2 REQUIRED)
find_package(libev REQUIRED)
find_package(c-ares REQUIRED CONFIG)
find_package(CURL REQUIRED CONFIG)
find_package(cryptopp REQUIRED CONFIG)
find_package(libnghttp2 REQUIRED CONFIG)
find_package(libev REQUIRED CONFIG)

find_package(concurrentqueue REQUIRED)
find_package(concurrentqueue REQUIRED CONFIG)
else()
include(SetupCAres)
include(SetupCURL)
Expand Down
18 changes: 14 additions & 4 deletions kafka/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
project(userver-kafka CXX)

if(USERVER_CONAN)
find_package(OpenSSL COMPONENTS SSL Crypto REQUIRED)
find_package(CURL REQUIRED)
find_package(ZLIB REQUIRED)
find_package(RdKafka REQUIRED)
find_package(OpenSSL COMPONENTS SSL Crypto REQUIRED CONFIG)
find_package(CURL REQUIRED CONFIG)
find_package(ZLIB REQUIRED CONFIG)

find_package(zstd REQUIRED CONFIG)
# According to https://conan.io/center/recipes/zstd should be
# zstd::libzstd_static, but it does not work that way
if (TARGET zstd::libzstd_static)
add_library(libzstd ALIAS zstd::libzstd_static)
else()
add_library(libzstd ALIAS zstd::libzstd_shared)
endif()

find_package(RdKafka REQUIRED CONFIG)
set_target_properties(RdKafka::rdkafka PROPERTIES IMPORTED_GLOBAL TRUE)
add_library(RdKafka ALIAS RdKafka::rdkafka)
else()
Expand Down
2 changes: 1 addition & 1 deletion mongo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(userver-mongo CXX)

if (USERVER_CONAN)
find_package(mongoc-1.0 REQUIRED)
find_package(mongoc-1.0 REQUIRED CONFIG)
set_target_properties(mongo::bson_static PROPERTIES IMPORTED_GLOBAL TRUE)
set_target_properties(mongo::mongoc_static PROPERTIES IMPORTED_GLOBAL TRUE)
add_library(bson ALIAS mongo::bson_static)
Expand Down
2 changes: 1 addition & 1 deletion redis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if(USERVER_FEATURE_REDIS_TLS)
endif()

if (USERVER_CONAN)
find_package(hiredis REQUIRED)
find_package(hiredis REQUIRED CONFIG)
target_link_libraries(${PROJECT_NAME} PUBLIC hiredis::hiredis)
else()
find_package(Hiredis REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion universal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ target_compile_definitions(${PROJECT_NAME} PUBLIC
# https://github.com/jemalloc/jemalloc/issues/820
if (USERVER_FEATURE_JEMALLOC AND NOT USERVER_SANITIZE AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
if (USERVER_CONAN)
find_package(jemalloc REQUIRED)
find_package(jemalloc REQUIRED CONFIG)
target_link_libraries(${PROJECT_NAME} PUBLIC jemalloc::jemalloc)
else()
find_package_required(Jemalloc "libjemalloc-dev")
Expand Down

0 comments on commit c5e03d4

Please sign in to comment.