From 5e93e1745b7010528b7d57a106c4abb604589cf4 Mon Sep 17 00:00:00 2001 From: vasily-sviridov Date: Wed, 25 Feb 2026 18:31:05 +0300 Subject: [PATCH] feat conan: add libpq patch support --- cmake/SetupPostgresqlDeps.cmake | 12 +++++++++--- conanfile.py | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/cmake/SetupPostgresqlDeps.cmake b/cmake/SetupPostgresqlDeps.cmake index 903c61f1d9aa..8abed00b00fe 100644 --- a/cmake/SetupPostgresqlDeps.cmake +++ b/cmake/SetupPostgresqlDeps.cmake @@ -5,9 +5,15 @@ _userver_macos_set_default_dir(USERVER_PG_LIBRARY_DIR "pg_config;--libdir") _userver_macos_set_default_dir(USERVER_PG_SERVER_INCLUDE_DIR "pg_config;--includedir-server") _userver_macos_set_default_dir(USERVER_PG_SERVER_LIBRARY_DIR "pg_config;--pkglibdir") -# We need libldap to statically link with libpq There is no FindLdap.cmake and no package config files for ldap library, -# so need to search for it by hand. -find_library(LDAP_LIBRARY NAMES libldap.so libldap.dylib libldap.framework) +find_package(OpenLDAP CONFIG QUIET) +if(OpenLDAP_FOUND) + set(LDAP_LIBRARY openldap::openldap) +endif() + +if(NOT LDAP_LIBRARY) + find_library(LDAP_LIBRARY NAMES libldap.so libldap.dylib libldap.framework) +endif() + if(NOT LDAP_LIBRARY) message( FATAL_ERROR diff --git a/conanfile.py b/conanfile.py index 2bbfdcd46cfd..0f23c92941b3 100644 --- a/conanfile.py +++ b/conanfile.py @@ -144,6 +144,9 @@ def requirements(self): # `run=True` required to find `pg_config` binary during `psycopg2` python module build # without system package. We use system package. self.requires('libpq/[>=14.9 <20]') + if self.options.with_postgresql_extra: + self.requires('openldap/[^2.6]') + self.requires('krb5/[^1.21]') if self.options.with_mongodb or self.options.with_kafka: self.requires('cyrus-sasl/[^2.1]') if self.options.with_mongodb: @@ -222,6 +225,13 @@ def generate(self): tool_ch.cache_variables['USERVER_FEATURE_GRPC_PROTOVALIDATE'] = self.options.with_grpc_protovalidate tool_ch.cache_variables['USERVER_DISABLE_PHDR_CACHE'] = not self.options.with_phdr_cache + cmake_modules_path = os.path.join(self.source_folder, 'cmake', 'modules') + existing_module_path = tool_ch.cache_variables.get('CMAKE_MODULE_PATH', '') + if existing_module_path: + tool_ch.cache_variables['CMAKE_MODULE_PATH'] = f'{cmake_modules_path};{existing_module_path}' + else: + tool_ch.cache_variables['CMAKE_MODULE_PATH'] = cmake_modules_path + if self.options.with_grpc: tool_ch.cache_variables['USERVER_GOOGLE_COMMON_PROTOS'] = ( self.dependencies['googleapis'].cpp_info.components['google_rpc_status_proto'].resdirs[0] @@ -234,6 +244,15 @@ def generate(self): 'user.opentelemetry-proto:proto_root', ) + if self.options.with_postgresql_extra: + libpq = self.dependencies['libpq'] + libpq_package_folder = libpq.package_folder + + tool_ch.cache_variables['USERVER_PG_SERVER_INCLUDE_DIR'] = os.path.join( + libpq_package_folder, 'include', 'postgresql', 'server' + ) + tool_ch.cache_variables['USERVER_PG_SERVER_LIBRARY_DIR'] = os.path.join(libpq_package_folder, 'lib') + tool_ch.generate() CMakeDeps(self).generate()