This file is part of MXE. See LICENSE.md for licensing information. Contains ad hoc patches for cross building. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001From: brodieG <brodieG@users.noreply.github.com>Date: Sat, 5 Nov 2022 23:59:32 +0000Subject: [PATCH 1/5] Apply vcpkg Module Find* Fixes Taken from https://github.com/microsoft/vcpkg/pull/22392/commits diff --git a/cmake/modules/packages/FindFreeXL.cmake b/cmake/modules/packages/FindFreeXL.cmakeindex 1111111..2222222 100644--- a/cmake/modules/packages/FindFreeXL.cmake+++ b/cmake/modules/packages/FindFreeXL.cmake@@ -37,7 +37,15 @@ include(SelectLibraryConfigurations) find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND)- pkg_check_modules(PC_FREEXL QUIET freexl)+ pkg_check_modules(PC_FREEXL QUIET IMPORTED_TARGET freexl)+endif()+if(PC_FREEXL_FOUND)+ set(FREEXL_INCLUDE_DIR "${PC_FREEXL_INCLUDE_DIRS}" CACHE STRING "")+ set(FREEXL_LIBRARY "${PC_FREEXL_LIBRARIES}" CACHE STRING "")+ if(NOT TARGET FREEXL::freexl)+ add_library(FREEXL::freexl INTERFACE IMPORTED)+ set_target_properties(FREEXL::freexl PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_FREEXL)+ endif() endif() find_path(FREEXL_INCLUDE_DIRdiff --git a/cmake/modules/packages/FindOpenJPEG.cmake b/cmake/modules/packages/FindOpenJPEG.cmakeindex 1111111..2222222 100644--- a/cmake/modules/packages/FindOpenJPEG.cmake+++ b/cmake/modules/packages/FindOpenJPEG.cmake@@ -32,9 +32,18 @@ endfunction() find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND)- pkg_check_modules(PC_OPENJPEG QUIET libopenjp2)+ pkg_check_modules(PC_OPENJPEG QUIET IMPORTED_TARGET libopenjp2) set(OPENJPEG_VERSION_STRING ${PC_OPENJPEG_VERSION}) endif()+if(PC_OPENJPEG_FOUND)+ set(OPENJPEG_INCLUDE_DIR "${PC_OPENJPEG_INCLUDE_DIRS}" CACHE STRING "")+ set(OPENJPEG_LIBRARY "${PC_OPENJPEG_LIBRARIES}" CACHE STRING "")+ if(NOT TARGET OPENJPEG::OpenJPEG)+ add_library(OPENJPEG::OpenJPEG INTERFACE IMPORTED)+ set_target_properties(OPENJPEG::OpenJPEG PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PC_OPENJPEG_INCLUDE_DIRS}")+ set_target_properties(OPENJPEG::OpenJPEG PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_OPENJPEG)+ endif()+endif() find_path(OPENJPEG_INCLUDE_DIR opj_config.hdiff --git a/cmake/modules/packages/FindPoppler.cmake b/cmake/modules/packages/FindPoppler.cmakeindex 1111111..2222222 100644--- a/cmake/modules/packages/FindPoppler.cmake+++ b/cmake/modules/packages/FindPoppler.cmake@@ -42,11 +42,19 @@ This module defines the following variables: find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND)- pkg_check_modules(PC_Poppler QUIET poppler)+ pkg_check_modules(PC_Poppler QUIET IMPORTED_TARGET poppler) if(PC_Poppler_VERSION) set(Poppler_VERSION_STRING ${PC_Poppler_VERSION}) endif() endif()+if(PC_Poppler_FOUND)+ set(Poppler_INCLUDE_DIR "${PC_Poppler_INCLUDE_DIRS}" CACHE STRING "")+ set(Poppler_LIBRARY "${PC_Poppler_LIBRARIES}" CACHE STRING "")+ if(NOT TARGET Poppler::Poppler)+ add_library(Poppler::Poppler INTERFACE IMPORTED)+ set_target_properties(Poppler::Poppler PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_Poppler)+ endif()+endif() find_path(Poppler_INCLUDE_DIR NAMES "poppler-config.h" "cpp/poppler-version.h" "qt5/poppler-qt5.h" "qt4/poppler-qt4.h" "glib/poppler.h" HINTS ${PC_Poppler_INCLUDE_DIRS}@@ -77,6 +85,15 @@ endforeach() foreach(_comp IN LISTS Poppler_known_components) list(FIND Poppler_FIND_COMPONENTS "${_comp}" _nextcomp) if(_nextcomp GREATER -1)+ pkg_check_modules(PC_Poppler_${_comp} QUIET IMPORTED_TARGET ${Poppler_${_comp}_pkg_config})+ if(PC_Poppler_${_comp}_FOUND)+ set(Poppler_${_comp}_INCLUDE_DIR "${PC_Poppler_${_comp}_INCLUDE_DIRS}" CACHE STRING "")+ set(Poppler_${_comp}_LIBRARY "${PC_Poppler_${_comp}_LIBRARIES}" CACHE STRING "")+ if(NOT TARGET Poppler::Poppler_${_comp})+ add_library(Poppler::${_comp} INTERFACE IMPORTED)+ set_target_properties(Poppler::${_comp} PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_Poppler_${_comp})+ endif()+ endif() find_path(Poppler_${_comp}_INCLUDE_DIR NAMES ${Poppler_${_comp}_header} PATH_SUFFIXES popplerdiff --git a/cmake/modules/packages/FindSPATIALITE.cmake b/cmake/modules/packages/FindSPATIALITE.cmakeindex 1111111..2222222 100644--- a/cmake/modules/packages/FindSPATIALITE.cmake+++ b/cmake/modules/packages/FindSPATIALITE.cmake@@ -38,9 +38,17 @@ endif() find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND)- pkg_check_modules(PC_SPATIALITE QUIET spatialite)+ pkg_check_modules(PC_SPATIALITE QUIET IMPORTED_TARGET spatialite) set(SPATIALITE_VERSION_STRING ${PC_SPATIALITE_VERSION}) endif()+if(PC_SPATIALITE_FOUND)+ set(SPATIALITE_INCLUDE_DIR "${PC_SPATIALITE_INCLUDE_DIRS}" CACHE STRING "")+ set(SPATIALITE_LIBRARY "${PC_SPATIALITE_LIBRARIES}" CACHE STRING "")+ if(NOT TARGET SPATIALITE::SPATIALITE)+ add_library(SPATIALITE::SPATIALITE INTERFACE IMPORTED)+ set_target_properties(SPATIALITE::SPATIALITE PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_SPATIALITE)+ endif()+endif() find_path(SPATIALITE_INCLUDE_DIR NAMES spatialite.h From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001From: brodieG <brodieG@users.noreply.github.com>Date: Sun, 6 Nov 2022 00:00:26 +0000Subject: [PATCH 2/5] Add/Fix Find* for HDF4 and PostgreSQL diff --git a/cmake/modules/packages/FindHDF4.cmake b/cmake/modules/packages/FindHDF4.cmakeindex 1111111..2222222 100644--- a/cmake/modules/packages/FindHDF4.cmake+++ b/cmake/modules/packages/FindHDF4.cmake@@ -22,110 +22,54 @@ This module defines the following :prop_tgt:`IMPORTED` target: #]=======================================================================] # --include(SelectLibraryConfigurations)--set(HDF4_PATHS- /usr/lib/hdf4- /usr/local/hdf4- )--find_path(HDF4_INCLUDE_DIR hdf.h- PATHS ${HDF4_PATHS}- PATH_SUFFIXES- include- Include- hdf- hdf4- )-mark_as_advanced(HDF4_INCLUDE_DIR)--if(HDF4_INCLUDE_DIR AND EXISTS "${HDF4_INCLUDE_DIR}/hfile.h")- file(STRINGS "${HDF4_INCLUDE_DIR}/hfile.h" hdf4_version_string- REGEX "^#define[\t ]+LIBVER.*")- string(REGEX MATCH "LIBVER_MAJOR[ \t]+([0-9]+)" HDF4_VERSION_MAJOR "${hdf4_version_string}")- string(REGEX MATCH "([0-9]+)" HDF4_VERSION_MAJOR ${HDF4_VERSION_MAJOR})- string(REGEX MATCH "LIBVER_MINOR[ \t]+([0-9]+)" HDF4_VERSION_MINOR "${hdf4_version_string}")- string(REGEX MATCH "([0-9]+)" HDF4_VERSION_MINOR ${HDF4_VERSION_MINOR})- string(REGEX MATCH "LIBVER_RELEASE[ \t]+([0-9]+)" HDF4_VERSION_RELEASE "${hdf4_version_string}")- string(REGEX MATCH "([0-9]+)" HDF4_VERSION_RELEASE ${HDF4_VERSION_RELEASE})- string(REGEX MATCH "LIBVER_SUBRELEASE[ \t]+([0-9A-Za-z]+)" HDF4_VERSION_SUBRELEASE "${hdf4_version_string}")- unset(hdf4_version_string)- if(NOT HDF4_VERSION_SUBRELEASE STREQUAL "")- string(REGEX MATCH "([0-9A-Za-z]+)" LIBVER_SUBRELEASE ${LIBVER_SUBRELEASE})- set(HDF4_VERSION_STRING "${HDF4_VERSION_MAJOR}.${HDF4_VERSION_MINOR}.${HDF4_VERSION_RELEASE}_${HDF4_VERSION_SUBRELEASE}")- else()- set(HDF4_VERSION_STRING "${HDF4_VERSION_MAJOR}.${HDF4_VERSION_MINOR}.${HDF4_VERSION_RELEASE}")- endif()+# The original code is modified for use with MXE where hdf4 is configured+# with autotools and .pc files are available.++find_package(PkgConfig QUIET)+if(PKG_CONFIG_FOUND)+ pkg_check_modules(PC_Hdf4df QUIET IMPORTED_TARGET df)+ if(PC_Hdf4df_VERSION)+ set(HDF4_VERSION_STRING ${PC_Hdf4df_VERSION})+ endif() endif()+if(PC_Hdf4df_FOUND)+ if(NOT TARGET PkgConfig::Hdf4df)+ add_library(PkgConfig::Hdf4df INTERFACE IMPORTED)+ set_target_properties(PkgConfig::Hdf4df PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_Hdf4df)+ endif()+ list(APPEND HDF4_TARGETS PkgConfig::Hdf4df) -if(NOT DEFINED HDF4_COMPONENTS)- set(HDF4_COMPONENTS df mfhdf xdr szip)+ pkg_check_modules(PC_Hdf4mfhdf QUIET IMPORTED_TARGET mfhdf)+ if(PC_Hdf4mfhdf_FOUND)+ if(NOT TARGET PkgConfig::Hdf4mfhdf)+ add_library(PkgConfig::Hdf4mfhdf INTERFACE IMPORTED)+ set_target_properties(PkgConfig::Hdf4mfhdf PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_Hdf4mfhdf)+ endif()+ list(APPEND HDF4_TARGETS PkgConfig::Hdf4mfhdf)+ endif() endif() -if(HDF4_INCLUDE_DIR)- # Debian supplies the HDF4 library which does not conflict with NetCDF.- # Test for Debian flavor first. Hint: install the libhdf4-alt-dev package.- foreach(tgt IN LISTS HDF4_COMPONENTS)- if(tgt STREQUAL "df")- # hdf.lib (dynamic) used by conda, but libhdf.lib (static) also present- set(_names_debug ${tgt}altd ${tgt}d hdfd libhdfd)- set(_names_release ${tgt}alt ${tgt} hdf libhdf)- else()- set(_names_debug ${tgt}altd ${tgt}d)- set(_names_release ${tgt}alt ${tgt} lib${tgt})- endif()- find_library(HDF4_${tgt}_LIBRARY_DEBUG- NAMES ${_names_debug}- PATHS ${HDF4_PATHS}/lib)- find_library(HDF4_${tgt}_LIBRARY_RELEASE- NAMES ${_names_release}- PATHS ${HDF4_PATHS}/lib)- select_library_configurations(HDF4_${tgt})- mark_as_advanced(HDF4_${tgt}_LIBRARY HDF4_${tgt}_LIBRARY_RELEASE HDF4_${tgt}_LIBRARY_DEBUG )- endforeach()-- set(HDF4_LIBRARIES)- foreach(_comp IN LISTS HDF4_COMPONENTS)- if(HDF4_${_comp}_LIBRARY)- list(APPEND HDF4_LIBRARIES "${HDF4_${_comp}_LIBRARY}")- endif()- endforeach()+find_path(+ HDF4_INCLUDE_DIR NAMES "hdf.h"+ HINTS ${PC_Hdf4df_INCLUDE_DIRS}) - if(WIN32)- find_library(WS2_32_LIBRARY ws2_32)- if(WS2_32_LIBRARY)- list(APPEND HDF4_LIBRARIES ${WS2_32_LIBRARY})- endif()- endif()-endif()+find_library(HDF4DF_LIBRARY NAMES df HINTS ${PC_Hdf4df_LIBRARY_DIRS})+find_library(HDF4MFHDF_LIBRARY NAMES mfhdf HINTS ${PC_Hdf4mfhdf_LIBRARY_DIRS}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(HDF4 FOUND_VAR HDF4_FOUND- REQUIRED_VARS HDF4_df_LIBRARY HDF4_mfhdf_LIBRARY HDF4_INCLUDE_DIR+ REQUIRED_VARS HDF4DF_LIBRARY HDF4_INCLUDE_DIR VERSION_VAR HDF4_VERSION_STRING HANDLE_COMPONENTS ) -# set output variables if(HDF4_FOUND) set(HDF4_INCLUDE_DIRS "${HDF4_INCLUDE_DIR}") if(NOT TARGET HDF4::HDF4)- set(INCR 1)- set(HDF4_TARGETS)- foreach(_lib IN LISTS HDF4_LIBRARIES)- add_library(HDF4::HDF4_${INCR} UNKNOWN IMPORTED)- set_target_properties(HDF4::HDF4_${INCR} PROPERTIES- IMPORTED_LINK_INTERFACE_LANGUAGES "C"- IMPORTED_LOCATION "${_lib}")- list(APPEND HDF4_TARGETS HDF4::HDF4_${INCR})- math(EXPR INCR "${INCR}+1")- endforeach()-- add_library(HDF4::HDF4 INTERFACE IMPORTED)- set_target_properties(HDF4::HDF4 PROPERTIES- INTERFACE_INCLUDE_DIRECTORIES ${HDF4_INCLUDE_DIRS}- INTERFACE_LINK_LIBRARIES "${HDF4_TARGETS}")+ add_library(HDF4::HDF4 INTERFACE IMPORTED)+ set_target_properties(HDF4::HDF4 PROPERTIES+ INTERFACE_INCLUDE_DIRECTORIES ${HDF4_INCLUDE_DIRS}+ INTERFACE_LINK_LIBRARIES "${HDF4_TARGETS}") endif() endif()diff --git a/cmake/modules/packages/FindPostgreSQL.cmake b/cmake/modules/packages/FindPostgreSQL.cmakenew file mode 100644index 0000000..61725fb--- /dev/null+++ b/cmake/modules/packages/FindPostgreSQL.cmake@@ -0,0 +1,328 @@+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying+# file Copyright.txt or https://cmake.org/licensing for details.++# This file has been modified from the original CMake 3.24 version:+# * Adapted to work from gdal tree+# * use pkgconfig for linked library information.++#[=======================================================================[.rst:+FindPostgreSQL+--------------++Find the PostgreSQL installation.++IMPORTED Targets+^^^^^^^^^^^^^^^^++.. versionadded:: 3.14++This module defines :prop_tgt:`IMPORTED` target ``PostgreSQL::PostgreSQL``+if PostgreSQL has been found.++Result Variables+^^^^^^^^^^^^^^^^++This module will set the following variables in your project:++``PostgreSQL_FOUND``+ True if PostgreSQL is found.+``PostgreSQL_LIBRARIES``+ the PostgreSQL libraries needed for linking+``PostgreSQL_INCLUDE_DIRS``+ the directories of the PostgreSQL headers+``PostgreSQL_LIBRARY_DIRS``+ the link directories for PostgreSQL libraries+``PostgreSQL_VERSION_STRING``+ the version of PostgreSQL found+``PostgreSQL_TYPE_INCLUDE_DIR``+ the directories of the PostgreSQL server headers++Components+^^^^^^^^^^++This module contains additional ``Server`` component, that forcibly checks+for the presence of server headers. Note that ``PostgreSQL_TYPE_INCLUDE_DIR``+is set regardless of the presence of the ``Server`` component in find_package call.++#]=======================================================================]++# ----------------------------------------------------------------------------+# History:+# This module is derived from the module originally found in the VTK source tree.+#+# ----------------------------------------------------------------------------+# Note:+# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the+# version number of the implementation of PostgreSQL.+# In Windows the default installation of PostgreSQL uses that as part of the path.+# E.g C:\Program Files\PostgreSQL\8.4.+# Currently, the following version numbers are known to this module:+# "14" "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0"+#+# To use this variable just do something like this:+# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4")+# before calling find_package(PostgreSQL) in your CMakeLists.txt file.+# This will mean that the versions you set here will be found first in the order+# specified before the default ones are searched.+#+# ----------------------------------------------------------------------------+# You may need to manually set:+# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are.+# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are.+# If FindPostgreSQL.cmake cannot find the include files or the library files.+#+# ----------------------------------------------------------------------------+# The following variables are set if PostgreSQL is found:+# PostgreSQL_FOUND - Set to true when PostgreSQL is found.+# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL+# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries+# PostgreSQL_LIBRARIES - The PostgreSQL libraries.+#+# The ``PostgreSQL::PostgreSQL`` imported target is also created.+#+# ----------------------------------------------------------------------------+# If you have installed PostgreSQL in a non-standard location.+# (Please note that in the following comments, it is assumed that <Your Path>+# points to the root directory of the include directory of PostgreSQL.)+# Then you have three options.+# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to <Your Path>/include and+# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is+# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/PostgreSQL<-version>. This will allow find_path()+# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file+# set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include")+# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have+# installed PostgreSQL, e.g. <Your Path>.+#+# ----------------------------------------------------------------------------++cmake_policy(PUSH)+cmake_policy(SET CMP0057 NEW) # if IN_LIST++set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include")+set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}")+set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.")+set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}")+set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4")+++set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS}+ "14" "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")++# Define additional search paths for root directories.+set( PostgreSQL_ROOT_DIRECTORIES+ ENV PostgreSQL_ROOT+ ${PostgreSQL_ROOT}+)+foreach(suffix ${PostgreSQL_KNOWN_VERSIONS})+ if(WIN32)+ list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES+ "PostgreSQL/${suffix}/lib")+ list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES+ "PostgreSQL/${suffix}/include")+ list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES+ "PostgreSQL/${suffix}/include/server")+ endif()+ if(UNIX)+ list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES+ "postgresql${suffix}"+ "postgresql@${suffix}"+ "pgsql-${suffix}/lib")+ list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES+ "postgresql${suffix}"+ "postgresql@${suffix}"+ "postgresql/${suffix}"+ "pgsql-${suffix}/include")+ list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES+ "postgresql${suffix}/server"+ "postgresql@${suffix}/server"+ "postgresql/${suffix}/server"+ "pgsql-${suffix}/include/server")+ endif()+endforeach()++#+# Look for an installation.+#+find_path(PostgreSQL_INCLUDE_DIR+ NAMES libpq-fe.h+ PATHS+ # Look in other places.+ ${PostgreSQL_ROOT_DIRECTORIES}+ PATH_SUFFIXES+ pgsql+ postgresql+ include+ ${PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES}+ # Help the user find it if we cannot.+ DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"+)++find_path(PostgreSQL_TYPE_INCLUDE_DIR+ NAMES catalog/pg_type.h+ PATHS+ # Look in other places.+ ${PostgreSQL_ROOT_DIRECTORIES}+ PATH_SUFFIXES+ postgresql+ pgsql/server+ postgresql/server+ include/server+ ${PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES}+ # Help the user find it if we cannot.+ DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"+)++# The PostgreSQL library.+set (PostgreSQL_LIBRARY_TO_FIND pq)+# Setting some more prefixes for the library+set (PostgreSQL_LIB_PREFIX "")+if ( WIN32 )+ set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib")+ set (PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND})+endif()++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()++# For compatibility with versions prior to this multi-config search, honor+# any PostgreSQL_LIBRARY that is already specified and skip the search.+if(PostgreSQL_LIBRARY)+ set(PostgreSQL_LIBRARIES "${PostgreSQL_LIBRARY}")+ get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY}" PATH)+else()+ __postgresql_find_library(PostgreSQL_LIBRARY_RELEASE ${PostgreSQL_LIBRARY_TO_FIND})+ __postgresql_find_library(PostgreSQL_LIBRARY_DEBUG ${PostgreSQL_LIBRARY_TO_FIND}d)+ include(SelectLibraryConfigurations)+ select_library_configurations(PostgreSQL)+ mark_as_advanced(PostgreSQL_LIBRARY_RELEASE PostgreSQL_LIBRARY_DEBUG)+ if(PostgreSQL_LIBRARY_RELEASE)+ get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_RELEASE}" PATH)+ elseif(PostgreSQL_LIBRARY_DEBUG)+ get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_DEBUG}" PATH)+ else()+ set(PostgreSQL_LIBRARY_DIR "")+ endif()+endif()++if (PostgreSQL_INCLUDE_DIR)+ # Some platforms include multiple pg_config.hs for multi-lib configurations+ # This is a temporary workaround. A better solution would be to compileLines 1–500 of 943. Load more
This file is part of MXE. See LICENSE.md for licensing information. Contains ad hoc patches for cross building. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: brodieG <brodieG@users.noreply.github.com> Date: Sat, 5 Nov 2022 23:59:32 +0000 Subject: [PATCH 1/5] Apply vcpkg Module Find* Fixes Taken from https://github.com/microsoft/vcpkg/pull/22392/commits diff --git a/cmake/modules/packages/FindFreeXL.cmake b/cmake/modules/packages/FindFreeXL.cmake index 1111111..2222222 100644 --- a/cmake/modules/packages/FindFreeXL.cmake +++ b/cmake/modules/packages/FindFreeXL.cmake @@ -37,7 +37,15 @@ include(SelectLibraryConfigurations) find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_FREEXL QUIET freexl) + pkg_check_modules(PC_FREEXL QUIET IMPORTED_TARGET freexl) +endif() +if(PC_FREEXL_FOUND) + set(FREEXL_INCLUDE_DIR "${PC_FREEXL_INCLUDE_DIRS}" CACHE STRING "") + set(FREEXL_LIBRARY "${PC_FREEXL_LIBRARIES}" CACHE STRING "") + if(NOT TARGET FREEXL::freexl) + add_library(FREEXL::freexl INTERFACE IMPORTED) + set_target_properties(FREEXL::freexl PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_FREEXL) + endif() endif() find_path(FREEXL_INCLUDE_DIR diff --git a/cmake/modules/packages/FindOpenJPEG.cmake b/cmake/modules/packages/FindOpenJPEG.cmake index 1111111..2222222 100644 --- a/cmake/modules/packages/FindOpenJPEG.cmake +++ b/cmake/modules/packages/FindOpenJPEG.cmake @@ -32,9 +32,18 @@ endfunction() find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_OPENJPEG QUIET libopenjp2) + pkg_check_modules(PC_OPENJPEG QUIET IMPORTED_TARGET libopenjp2) set(OPENJPEG_VERSION_STRING ${PC_OPENJPEG_VERSION}) endif() +if(PC_OPENJPEG_FOUND) + set(OPENJPEG_INCLUDE_DIR "${PC_OPENJPEG_INCLUDE_DIRS}" CACHE STRING "") + set(OPENJPEG_LIBRARY "${PC_OPENJPEG_LIBRARIES}" CACHE STRING "") + if(NOT TARGET OPENJPEG::OpenJPEG) + add_library(OPENJPEG::OpenJPEG INTERFACE IMPORTED) + set_target_properties(OPENJPEG::OpenJPEG PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PC_OPENJPEG_INCLUDE_DIRS}") + set_target_properties(OPENJPEG::OpenJPEG PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_OPENJPEG) + endif() +endif() find_path(OPENJPEG_INCLUDE_DIR opj_config.h diff --git a/cmake/modules/packages/FindPoppler.cmake b/cmake/modules/packages/FindPoppler.cmake index 1111111..2222222 100644 --- a/cmake/modules/packages/FindPoppler.cmake +++ b/cmake/modules/packages/FindPoppler.cmake @@ -42,11 +42,19 @@ This module defines the following variables: find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_Poppler QUIET poppler) + pkg_check_modules(PC_Poppler QUIET IMPORTED_TARGET poppler) if(PC_Poppler_VERSION) set(Poppler_VERSION_STRING ${PC_Poppler_VERSION}) endif() endif() +if(PC_Poppler_FOUND) + set(Poppler_INCLUDE_DIR "${PC_Poppler_INCLUDE_DIRS}" CACHE STRING "") + set(Poppler_LIBRARY "${PC_Poppler_LIBRARIES}" CACHE STRING "") + if(NOT TARGET Poppler::Poppler) + add_library(Poppler::Poppler INTERFACE IMPORTED) + set_target_properties(Poppler::Poppler PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_Poppler) + endif() +endif() find_path(Poppler_INCLUDE_DIR NAMES "poppler-config.h" "cpp/poppler-version.h" "qt5/poppler-qt5.h" "qt4/poppler-qt4.h" "glib/poppler.h" HINTS ${PC_Poppler_INCLUDE_DIRS} @@ -77,6 +85,15 @@ endforeach() foreach(_comp IN LISTS Poppler_known_components) list(FIND Poppler_FIND_COMPONENTS "${_comp}" _nextcomp) if(_nextcomp GREATER -1) + pkg_check_modules(PC_Poppler_${_comp} QUIET IMPORTED_TARGET ${Poppler_${_comp}_pkg_config}) + if(PC_Poppler_${_comp}_FOUND) + set(Poppler_${_comp}_INCLUDE_DIR "${PC_Poppler_${_comp}_INCLUDE_DIRS}" CACHE STRING "") + set(Poppler_${_comp}_LIBRARY "${PC_Poppler_${_comp}_LIBRARIES}" CACHE STRING "") + if(NOT TARGET Poppler::Poppler_${_comp}) + add_library(Poppler::${_comp} INTERFACE IMPORTED) + set_target_properties(Poppler::${_comp} PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_Poppler_${_comp}) + endif() + endif() find_path(Poppler_${_comp}_INCLUDE_DIR NAMES ${Poppler_${_comp}_header} PATH_SUFFIXES poppler diff --git a/cmake/modules/packages/FindSPATIALITE.cmake b/cmake/modules/packages/FindSPATIALITE.cmake index 1111111..2222222 100644 --- a/cmake/modules/packages/FindSPATIALITE.cmake +++ b/cmake/modules/packages/FindSPATIALITE.cmake @@ -38,9 +38,17 @@ endif() find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_SPATIALITE QUIET spatialite) + pkg_check_modules(PC_SPATIALITE QUIET IMPORTED_TARGET spatialite) set(SPATIALITE_VERSION_STRING ${PC_SPATIALITE_VERSION}) endif() +if(PC_SPATIALITE_FOUND) + set(SPATIALITE_INCLUDE_DIR "${PC_SPATIALITE_INCLUDE_DIRS}" CACHE STRING "") + set(SPATIALITE_LIBRARY "${PC_SPATIALITE_LIBRARIES}" CACHE STRING "") + if(NOT TARGET SPATIALITE::SPATIALITE) + add_library(SPATIALITE::SPATIALITE INTERFACE IMPORTED) + set_target_properties(SPATIALITE::SPATIALITE PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_SPATIALITE) + endif() +endif() find_path(SPATIALITE_INCLUDE_DIR NAMES spatialite.h From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: brodieG <brodieG@users.noreply.github.com> Date: Sun, 6 Nov 2022 00:00:26 +0000 Subject: [PATCH 2/5] Add/Fix Find* for HDF4 and PostgreSQL diff --git a/cmake/modules/packages/FindHDF4.cmake b/cmake/modules/packages/FindHDF4.cmake index 1111111..2222222 100644 --- a/cmake/modules/packages/FindHDF4.cmake +++ b/cmake/modules/packages/FindHDF4.cmake @@ -22,110 +22,54 @@ This module defines the following :prop_tgt:`IMPORTED` target: #]=======================================================================] # - -include(SelectLibraryConfigurations) - -set(HDF4_PATHS - /usr/lib/hdf4 - /usr/local/hdf4 - ) - -find_path(HDF4_INCLUDE_DIR hdf.h - PATHS ${HDF4_PATHS} - PATH_SUFFIXES - include - Include - hdf - hdf4 - ) -mark_as_advanced(HDF4_INCLUDE_DIR) - -if(HDF4_INCLUDE_DIR AND EXISTS "${HDF4_INCLUDE_DIR}/hfile.h") - file(STRINGS "${HDF4_INCLUDE_DIR}/hfile.h" hdf4_version_string - REGEX "^#define[\t ]+LIBVER.*") - string(REGEX MATCH "LIBVER_MAJOR[ \t]+([0-9]+)" HDF4_VERSION_MAJOR "${hdf4_version_string}") - string(REGEX MATCH "([0-9]+)" HDF4_VERSION_MAJOR ${HDF4_VERSION_MAJOR}) - string(REGEX MATCH "LIBVER_MINOR[ \t]+([0-9]+)" HDF4_VERSION_MINOR "${hdf4_version_string}") - string(REGEX MATCH "([0-9]+)" HDF4_VERSION_MINOR ${HDF4_VERSION_MINOR}) - string(REGEX MATCH "LIBVER_RELEASE[ \t]+([0-9]+)" HDF4_VERSION_RELEASE "${hdf4_version_string}") - string(REGEX MATCH "([0-9]+)" HDF4_VERSION_RELEASE ${HDF4_VERSION_RELEASE}) - string(REGEX MATCH "LIBVER_SUBRELEASE[ \t]+([0-9A-Za-z]+)" HDF4_VERSION_SUBRELEASE "${hdf4_version_string}") - unset(hdf4_version_string) - if(NOT HDF4_VERSION_SUBRELEASE STREQUAL "") - string(REGEX MATCH "([0-9A-Za-z]+)" LIBVER_SUBRELEASE ${LIBVER_SUBRELEASE}) - set(HDF4_VERSION_STRING "${HDF4_VERSION_MAJOR}.${HDF4_VERSION_MINOR}.${HDF4_VERSION_RELEASE}_${HDF4_VERSION_SUBRELEASE}") - else() - set(HDF4_VERSION_STRING "${HDF4_VERSION_MAJOR}.${HDF4_VERSION_MINOR}.${HDF4_VERSION_RELEASE}") - endif() +# The original code is modified for use with MXE where hdf4 is configured +# with autotools and .pc files are available. + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_Hdf4df QUIET IMPORTED_TARGET df) + if(PC_Hdf4df_VERSION) + set(HDF4_VERSION_STRING ${PC_Hdf4df_VERSION}) + endif() endif() +if(PC_Hdf4df_FOUND) + if(NOT TARGET PkgConfig::Hdf4df) + add_library(PkgConfig::Hdf4df INTERFACE IMPORTED) + set_target_properties(PkgConfig::Hdf4df PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_Hdf4df) + endif() + list(APPEND HDF4_TARGETS PkgConfig::Hdf4df) -if(NOT DEFINED HDF4_COMPONENTS) - set(HDF4_COMPONENTS df mfhdf xdr szip) + pkg_check_modules(PC_Hdf4mfhdf QUIET IMPORTED_TARGET mfhdf) + if(PC_Hdf4mfhdf_FOUND) + if(NOT TARGET PkgConfig::Hdf4mfhdf) + add_library(PkgConfig::Hdf4mfhdf INTERFACE IMPORTED) + set_target_properties(PkgConfig::Hdf4mfhdf PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::PC_Hdf4mfhdf) + endif() + list(APPEND HDF4_TARGETS PkgConfig::Hdf4mfhdf) + endif() endif() -if(HDF4_INCLUDE_DIR) - # Debian supplies the HDF4 library which does not conflict with NetCDF. - # Test for Debian flavor first. Hint: install the libhdf4-alt-dev package. - foreach(tgt IN LISTS HDF4_COMPONENTS) - if(tgt STREQUAL "df") - # hdf.lib (dynamic) used by conda, but libhdf.lib (static) also present - set(_names_debug ${tgt}altd ${tgt}d hdfd libhdfd) - set(_names_release ${tgt}alt ${tgt} hdf libhdf) - else() - set(_names_debug ${tgt}altd ${tgt}d) - set(_names_release ${tgt}alt ${tgt} lib${tgt}) - endif() - find_library(HDF4_${tgt}_LIBRARY_DEBUG - NAMES ${_names_debug} - PATHS ${HDF4_PATHS}/lib) - find_library(HDF4_${tgt}_LIBRARY_RELEASE - NAMES ${_names_release} - PATHS ${HDF4_PATHS}/lib) - select_library_configurations(HDF4_${tgt}) - mark_as_advanced(HDF4_${tgt}_LIBRARY HDF4_${tgt}_LIBRARY_RELEASE HDF4_${tgt}_LIBRARY_DEBUG ) - endforeach() - - set(HDF4_LIBRARIES) - foreach(_comp IN LISTS HDF4_COMPONENTS) - if(HDF4_${_comp}_LIBRARY) - list(APPEND HDF4_LIBRARIES "${HDF4_${_comp}_LIBRARY}") - endif() - endforeach() +find_path( + HDF4_INCLUDE_DIR NAMES "hdf.h" + HINTS ${PC_Hdf4df_INCLUDE_DIRS}) - if(WIN32) - find_library(WS2_32_LIBRARY ws2_32) - if(WS2_32_LIBRARY) - list(APPEND HDF4_LIBRARIES ${WS2_32_LIBRARY}) - endif() - endif() -endif() +find_library(HDF4DF_LIBRARY NAMES df HINTS ${PC_Hdf4df_LIBRARY_DIRS}) +find_library(HDF4MFHDF_LIBRARY NAMES mfhdf HINTS ${PC_Hdf4mfhdf_LIBRARY_DIRS}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(HDF4 FOUND_VAR HDF4_FOUND - REQUIRED_VARS HDF4_df_LIBRARY HDF4_mfhdf_LIBRARY HDF4_INCLUDE_DIR + REQUIRED_VARS HDF4DF_LIBRARY HDF4_INCLUDE_DIR VERSION_VAR HDF4_VERSION_STRING HANDLE_COMPONENTS ) -# set output variables if(HDF4_FOUND) set(HDF4_INCLUDE_DIRS "${HDF4_INCLUDE_DIR}") if(NOT TARGET HDF4::HDF4) - set(INCR 1) - set(HDF4_TARGETS) - foreach(_lib IN LISTS HDF4_LIBRARIES) - add_library(HDF4::HDF4_${INCR} UNKNOWN IMPORTED) - set_target_properties(HDF4::HDF4_${INCR} PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${_lib}") - list(APPEND HDF4_TARGETS HDF4::HDF4_${INCR}) - math(EXPR INCR "${INCR}+1") - endforeach() - - add_library(HDF4::HDF4 INTERFACE IMPORTED) - set_target_properties(HDF4::HDF4 PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${HDF4_INCLUDE_DIRS} - INTERFACE_LINK_LIBRARIES "${HDF4_TARGETS}") + add_library(HDF4::HDF4 INTERFACE IMPORTED) + set_target_properties(HDF4::HDF4 PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${HDF4_INCLUDE_DIRS} + INTERFACE_LINK_LIBRARIES "${HDF4_TARGETS}") endif() endif() diff --git a/cmake/modules/packages/FindPostgreSQL.cmake b/cmake/modules/packages/FindPostgreSQL.cmake new file mode 100644 index 0000000..61725fb --- /dev/null +++ b/cmake/modules/packages/FindPostgreSQL.cmake @@ -0,0 +1,328 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# This file has been modified from the original CMake 3.24 version: +# * Adapted to work from gdal tree +# * use pkgconfig for linked library information. + +#[=======================================================================[.rst: +FindPostgreSQL +-------------- + +Find the PostgreSQL installation. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.14 + +This module defines :prop_tgt:`IMPORTED` target ``PostgreSQL::PostgreSQL`` +if PostgreSQL has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``PostgreSQL_FOUND`` + True if PostgreSQL is found. +``PostgreSQL_LIBRARIES`` + the PostgreSQL libraries needed for linking +``PostgreSQL_INCLUDE_DIRS`` + the directories of the PostgreSQL headers +``PostgreSQL_LIBRARY_DIRS`` + the link directories for PostgreSQL libraries +``PostgreSQL_VERSION_STRING`` + the version of PostgreSQL found +``PostgreSQL_TYPE_INCLUDE_DIR`` + the directories of the PostgreSQL server headers + +Components +^^^^^^^^^^ + +This module contains additional ``Server`` component, that forcibly checks +for the presence of server headers. Note that ``PostgreSQL_TYPE_INCLUDE_DIR`` +is set regardless of the presence of the ``Server`` component in find_package call. + +#]=======================================================================] + +# ---------------------------------------------------------------------------- +# History: +# This module is derived from the module originally found in the VTK source tree. +# +# ---------------------------------------------------------------------------- +# Note: +# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the +# version number of the implementation of PostgreSQL. +# In Windows the default installation of PostgreSQL uses that as part of the path. +# E.g C:\Program Files\PostgreSQL\8.4. +# Currently, the following version numbers are known to this module: +# "14" "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" +# +# To use this variable just do something like this: +# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4") +# before calling find_package(PostgreSQL) in your CMakeLists.txt file. +# This will mean that the versions you set here will be found first in the order +# specified before the default ones are searched. +# +# ---------------------------------------------------------------------------- +# You may need to manually set: +# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are. +# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are. +# If FindPostgreSQL.cmake cannot find the include files or the library files. +# +# ---------------------------------------------------------------------------- +# The following variables are set if PostgreSQL is found: +# PostgreSQL_FOUND - Set to true when PostgreSQL is found. +# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL +# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries +# PostgreSQL_LIBRARIES - The PostgreSQL libraries. +# +# The ``PostgreSQL::PostgreSQL`` imported target is also created. +# +# ---------------------------------------------------------------------------- +# If you have installed PostgreSQL in a non-standard location. +# (Please note that in the following comments, it is assumed that <Your Path> +# points to the root directory of the include directory of PostgreSQL.) +# Then you have three options. +# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to <Your Path>/include and +# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is +# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/PostgreSQL<-version>. This will allow find_path() +# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file +# set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include") +# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have +# installed PostgreSQL, e.g. <Your Path>. +# +# ---------------------------------------------------------------------------- + +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + +set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include") +set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}") +set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.") +set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}") +set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4") + + +set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS} + "14" "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0") + +# Define additional search paths for root directories. +set( PostgreSQL_ROOT_DIRECTORIES + ENV PostgreSQL_ROOT + ${PostgreSQL_ROOT} +) +foreach(suffix ${PostgreSQL_KNOWN_VERSIONS}) + if(WIN32) + list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES + "PostgreSQL/${suffix}/lib") + list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES + "PostgreSQL/${suffix}/include") + list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES + "PostgreSQL/${suffix}/include/server") + endif() + if(UNIX) + list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES + "postgresql${suffix}" + "postgresql@${suffix}" + "pgsql-${suffix}/lib") + list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES + "postgresql${suffix}" + "postgresql@${suffix}" + "postgresql/${suffix}" + "pgsql-${suffix}/include") + list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES + "postgresql${suffix}/server" + "postgresql@${suffix}/server" + "postgresql/${suffix}/server" + "pgsql-${suffix}/include/server") + endif() +endforeach() + +# +# Look for an installation. +# +find_path(PostgreSQL_INCLUDE_DIR + NAMES libpq-fe.h + PATHS + # Look in other places. + ${PostgreSQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + pgsql + postgresql + include + ${PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES} + # Help the user find it if we cannot. + DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}" +) + +find_path(PostgreSQL_TYPE_INCLUDE_DIR + NAMES catalog/pg_type.h + PATHS + # Look in other places. + ${PostgreSQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + postgresql + pgsql/server + postgresql/server + include/server + ${PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES} + # Help the user find it if we cannot. + DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}" +) + +# The PostgreSQL library. +set (PostgreSQL_LIBRARY_TO_FIND pq) +# Setting some more prefixes for the library +set (PostgreSQL_LIB_PREFIX "") +if ( WIN32 ) + set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib") + set (PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND}) +endif() + +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() + +# For compatibility with versions prior to this multi-config search, honor +# any PostgreSQL_LIBRARY that is already specified and skip the search. +if(PostgreSQL_LIBRARY) + set(PostgreSQL_LIBRARIES "${PostgreSQL_LIBRARY}") + get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY}" PATH) +else() + __postgresql_find_library(PostgreSQL_LIBRARY_RELEASE ${PostgreSQL_LIBRARY_TO_FIND}) + __postgresql_find_library(PostgreSQL_LIBRARY_DEBUG ${PostgreSQL_LIBRARY_TO_FIND}d) + include(SelectLibraryConfigurations) + select_library_configurations(PostgreSQL) + mark_as_advanced(PostgreSQL_LIBRARY_RELEASE PostgreSQL_LIBRARY_DEBUG) + if(PostgreSQL_LIBRARY_RELEASE) + get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_RELEASE}" PATH) + elseif(PostgreSQL_LIBRARY_DEBUG) + get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_DEBUG}" PATH) + else() + set(PostgreSQL_LIBRARY_DIR "") + endif() +endif() + +if (PostgreSQL_INCLUDE_DIR) + # Some platforms include multiple pg_config.hs for multi-lib configurations + # This is a temporary workaround. A better solution would be to compile