Skip to content

Commit

Permalink
Statis mongo and mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
fdr400 committed Jan 6, 2025
1 parent f9577de commit 974d97e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ option(USERVER_FEATURE_OTLP "Provide asynchronous OTLP exporters" "${USERVER_LIB

set(CMAKE_DEBUG_POSTFIX d)

set(OPENSSL_USE_STATIC_LIBS ON)
set(ZLIB_USE_STATIC_LIBS ON)
set(Protobuf_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_LIBS ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(UserverSetupEnvironment)
userver_setup_environment()
Expand Down
13 changes: 13 additions & 0 deletions cmake/SetupMongoDeps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
include_guard(GLOBAL)

find_package(bson-1.0 QUIET CONFIG)
find_package(mongoc-1.0 QUIET CONFIG)
if(bson-1.0_FOUND AND mongoc-1.0_FOUND)
message(STATUS "Using config version for bson + mongoc")
add_library(bson ALIAS mongo::bson_static)
add_library(mongoc ALIAS mongo::mongoc_static)
else()
find_package(bson REQUIRED)
find_package(mongoc REQUIRED)
endif()

3 changes: 1 addition & 2 deletions cmake/SetupProtobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ function(_userver_set_protobuf_version_category)
endfunction()

if(USERVER_CONAN)
find_package(Protobuf REQUIRED)
find_package(Protobuf REQUIRED CONFIG)
_userver_set_protobuf_version_category()
set(PROTOBUF_PROTOC "${Protobuf_PROTOC_EXECUTABLE}")
return()
endif()

if(NOT USERVER_FORCE_DOWNLOAD_PROTOBUF)
# Use the builtin CMake FindProtobuf
set(Protobuf_USE_STATIC_LIBS ON)
if(USERVER_DOWNLOAD_PACKAGE_PROTOBUF)
find_package(Protobuf QUIET)
else()
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/Findbson.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES bson bson-1.0
NAMES libbson-static-1.0.a bson bson-1.0
)

_userver_module_end()
2 changes: 1 addition & 1 deletion cmake/modules/Findmongoc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _userver_module_find_include(
)

_userver_module_find_library(
NAMES mongoc mongoc-1.0
NAMES libmongoc-static-1.0.a mongoc mongoc-1.0
)

_userver_module_end()
3 changes: 1 addition & 2 deletions mongo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ if (USERVER_CONAN)
add_library(mongoc ALIAS mongo::mongoc_static)
find_package(cyrus-sasl REQUIRED CONFIG)
else()
find_package(bson REQUIRED)
find_package(mongoc REQUIRED)
include(SetupMongoDeps)
endif()

userver_module(mongo
Expand Down
3 changes: 2 additions & 1 deletion mysql/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
project(userver-mysql CXX)

find_package(ZLIB REQUIRED)
find_package(libmariadb REQUIRED)

userver_module(mysql
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
LINK_LIBRARIES_PRIVATE libmariadb
LINK_LIBRARIES_PRIVATE libmariadb ZLIB::ZLIB

DBTEST_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/tests"
UTEST_LINK_LIBRARIES libmariadb
Expand Down

0 comments on commit 974d97e

Please sign in to comment.