FindPostgreSQL: Do not require pg_type.h

In systems where PostgreSQL has separate developer packages for
server and client libraries `PostgreSQL_TYPE_INCLUDE_DIR` is not
specified. According to initial logic server part was not required
but was accidentally added to `REQUIRED_VARS` during the migration to
`find_package_handle_standard_args`.

Fixes: #17223
This commit is contained in:
Alexey Edelev
2020-12-28 18:16:15 +01:00
committed by Brad King
parent 6b1adada4c
commit f254e67bf6

View File

@@ -247,7 +247,7 @@ endif()
# Did we find anything?
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(PostgreSQL
REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR
REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR
VERSION_VAR PostgreSQL_VERSION_STRING)
set(PostgreSQL_FOUND ${POSTGRESQL_FOUND})
@@ -271,16 +271,19 @@ endfunction()
# Now try to get the include and library path.
if(PostgreSQL_FOUND)
set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR})
if(PostgreSQL_TYPE_INCLUDE_DIR)
list(APPEND PostgreSQL_INCLUDE_DIRS ${PostgreSQL_TYPE_INCLUDE_DIR})
endif()
set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} )
if (NOT TARGET PostgreSQL::PostgreSQL)
add_library(PostgreSQL::PostgreSQL UNKNOWN IMPORTED)
set_target_properties(PostgreSQL::PostgreSQL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${PostgreSQL_INCLUDE_DIR};${PostgreSQL_TYPE_INCLUDE_DIR}")
INTERFACE_INCLUDE_DIRECTORIES "${PostgreSQL_INCLUDE_DIRS}")
__postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "")
__postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "RELEASE")
__postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "DEBUG")
endif ()
set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ${PostgreSQL_TYPE_INCLUDE_DIR} )
set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} )
endif()
mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR)