From f1fa9cc84e67c9f28f651b926f55f93d60bbb963 Mon Sep 17 00:00:00 2001 From: Andrei Lebedev Date: Sun, 5 May 2019 21:22:49 +0300 Subject: [PATCH] Find PostgreSQL debug library Signed-off-by: Andrei Lebedev --- cmake/modules/FindPostgreSQL.cmake | 31 +++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/cmake/modules/FindPostgreSQL.cmake b/cmake/modules/FindPostgreSQL.cmake index 48937e2..e2e557b 100644 --- a/cmake/modules/FindPostgreSQL.cmake +++ b/cmake/modules/FindPostgreSQL.cmake @@ -124,16 +124,21 @@ if ( WIN32 ) set (POSTGRESQL_LIBRARY_TO_FIND ${POSTGRESQL_LIB_PREFIX}${POSTGRESQL_LIBRARY_TO_FIND}) endif() -find_library(POSTGRESQL_LIBRARY - NAMES ${POSTGRESQL_LIBRARY_TO_FIND} - PATHS - ${POSTGRESQL_ROOT_DIRECTORIES} - PATH_SUFFIXES - lib - ${POSTGRESQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES} - # Help the user find it if we cannot. - DOC "The ${POSTGRESQL_LIBRARY_DIR_MESSAGE}" -) +function(__postgresql_find_library _name) + find_library(${_name} + NAMES ${ARGN} + PATHS + ${POSTGRESQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + lib + ${POSTGRESQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES} + # Help the user find it if we cannot. + DOC "The ${POSTGRESQL_LIBRARY_DIR_MESSAGE}" + ) +endfunction() + +__postgresql_find_library(POSTGRESQL_LIBRARY ${POSTGRESQL_LIBRARY_TO_FIND}) +__postgresql_find_library(POSTGRESQL_LIBRARY_DEBUG ${POSTGRESQL_LIBRARY_TO_FIND}d) get_filename_component(POSTGRESQL_LIBRARY_DIR ${POSTGRESQL_LIBRARY} PATH) if (POSTGRESQL_INCLUDE_DIR) @@ -169,7 +174,11 @@ set(POSTGRESQL_FOUND ${POSTGRESQL_FOUND}) if(POSTGRESQL_FOUND) set(POSTGRESQL_INCLUDE_DIRS ${POSTGRESQL_INCLUDE_DIR}) set(POSTGRESQL_LIBRARY_DIRS ${POSTGRESQL_LIBRARY_DIR}) - set(POSTGRESQL_LIBRARIES ${POSTGRESQL_LIBRARY}) + if(POSTGRESQL_LIBRARY AND POSTGRESQL_LIBRARY_DEBUG) + set(POSTGRESQL_LIBRARIES optimized ${POSTGRESQL_LIBRARY} debug ${POSTGRESQL_LIBRARY_DEBUG}) + else() + set(POSTGRESQL_LIBRARIES ${POSTGRESQL_LIBRARY}) + endif() set(POSTGRESQL_VERSION ${POSTGRESQL_VERSION_STRING}) endif() -- 2.20.1.windows.1