Warning, /libraries/kdb/cmake/modules/FindPostgreSQL.cmake is written in an unsupported language. File is not indexed.
0001 #.rst: 0002 # FindPostgreSQL 0003 # -------------- 0004 # 0005 # Find the PostgreSQL installation. 0006 # 0007 # In Windows, we make the assumption that, if the PostgreSQL files are 0008 # installed, the default directory will be C:\Program Files\PostgreSQL. 0009 # 0010 # This module defines 0011 # 0012 # :: 0013 # 0014 # PostgreSQL_LIBRARIES - the PostgreSQL libraries needed for linking 0015 # PostgreSQL_INCLUDE_DIRS - the directories of the PostgreSQL headers 0016 # PostgreSQL_VERSION_STRING - the version of PostgreSQL found (since CMake 2.8.8) 0017 0018 #============================================================================= 0019 # Copyright 2004-2009 Kitware, Inc. 0020 # 0021 # Distributed under the OSI-approved BSD License (the "License"); 0022 # see accompanying file Copyright.txt for details. 0023 # 0024 # This software is distributed WITHOUT ANY WARRANTY; without even the 0025 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 0026 # See the License for more information. 0027 #============================================================================= 0028 # (To distribute this file outside of CMake, substitute the full 0029 # License text for the above reference.) 0030 0031 # ---------------------------------------------------------------------------- 0032 # History: 0033 # This module is derived from the module originally found in the VTK source tree. 0034 # 0035 # ---------------------------------------------------------------------------- 0036 # Note: 0037 # PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the 0038 # version mumber of the implementation of PostgreSQL. 0039 # In Windows the default installation of PostgreSQL uses that as part of the path. 0040 # E.g C:\Program Files\PostgreSQL\8.4. 0041 # Currently, the following version numbers are known to this module: 0042 # "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" 0043 # 0044 # To use this variable just do something like this: 0045 # set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4") 0046 # before calling find_package(PostgreSQL) in your CMakeLists.txt file. 0047 # This will mean that the versions you set here will be found first in the order 0048 # specified before the default ones are searched. 0049 # 0050 # ---------------------------------------------------------------------------- 0051 # You may need to manually set: 0052 # PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are. 0053 # PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are. 0054 # If FindPostgreSQL.cmake cannot find the include files or the library files. 0055 # 0056 # ---------------------------------------------------------------------------- 0057 # The following variables are set if PostgreSQL is found: 0058 # PostgreSQL_FOUND - Set to true when PostgreSQL is found. 0059 # PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL 0060 # PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries 0061 # PostgreSQL_LIBRARIES - The PostgreSQL libraries. 0062 # 0063 # ---------------------------------------------------------------------------- 0064 # If you have installed PostgreSQL in a non-standard location. 0065 # (Please note that in the following comments, it is assumed that <Your Path> 0066 # points to the root directory of the include directory of PostgreSQL.) 0067 # Then you have three options. 0068 # 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to <Your Path>/include and 0069 # PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is 0070 # 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/PostgreSQL<-version>. This will allow find_path() 0071 # to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file 0072 # set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include") 0073 # 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have 0074 # installed PostgreSQL, e.g. <Your Path>. 0075 # 0076 # ---------------------------------------------------------------------------- 0077 0078 include(FeatureSummary) 0079 set_package_properties(PostgreSQL 0080 PROPERTIES DESCRIPTION "C API to PostgreSQL (libpq)" URL "https://www.postgresql.org") 0081 0082 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") 0083 set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}") 0084 set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.") 0085 set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}") 0086 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") 0087 0088 set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS} 0089 "16" "15" "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") 0090 0091 # Define additional search paths for root directories. 0092 foreach (suffix ${PostgreSQL_KNOWN_VERSIONS} ) 0093 if (WIN32) 0094 set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} "C:/Program Files/PostgreSQL/${suffix}") 0095 else() 0096 set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} "/usr/include/postgresql/${suffix}/server") 0097 endif() 0098 endforeach() 0099 0100 # Use pkg-config to get the directories and then use these values in the find_path() 0101 # and find_library() calls. 0102 if(NOT WIN32) 0103 find_package(PkgConfig) 0104 pkg_check_modules(PC_LIBPQ QUIET libpq) 0105 set(LIBPQ_DEFINITIONS ${PC_LIBPQ_CFLAGS_OTHER}) 0106 endif() 0107 0108 set( PostgreSQL_ROOT_DIRECTORIES 0109 ENV PostgreSQL_ROOT 0110 ${PostgreSQL_ROOT} 0111 ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} 0112 ${PC_LIBPQ_INCLUDEDIR} 0113 ${PC_LIBPQ_INCLUDE_DIRS} 0114 ) 0115 0116 # 0117 # Look for an installation. 0118 # 0119 find_path(PostgreSQL_INCLUDE_DIR 0120 NAMES libpq-fe.h 0121 PATHS 0122 # Look in other places. 0123 ${PostgreSQL_ROOT_DIRECTORIES} 0124 PATH_SUFFIXES 0125 pgsql 0126 postgresql 0127 include 0128 # Help the user find it if we cannot. 0129 DOC "${PostgreSQL_INCLUDE_DIR_MESSAGE}" 0130 ) 0131 0132 find_path(PostgreSQL_TYPE_INCLUDE_DIR 0133 NAMES catalog/pg_type.h 0134 PATHS 0135 # Look in other places. 0136 ${PostgreSQL_ROOT_DIRECTORIES} 0137 PATH_SUFFIXES 0138 postgresql 0139 pgsql/server 0140 postgresql/server 0141 include/server 0142 # Help the user find it if we cannot. 0143 DOC "${PostgreSQL_INCLUDE_DIR_MESSAGE}" 0144 ) 0145 0146 # The PostgreSQL library. 0147 if(PC_LIBPQ_LIBRARIES) 0148 set(PostgreSQL_LIBRARY_TO_FIND ${PC_LIBPQ_LIBRARIES}) 0149 else() 0150 set(PostgreSQL_LIBRARY_TO_FIND pq) 0151 endif() 0152 # Setting some more prefixes for the library 0153 set (PostgreSQL_LIB_PREFIX "") 0154 if ( WIN32 ) 0155 set (PostgreSQL_LIB_PREFIX "lib") 0156 set ( PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND}) 0157 endif() 0158 0159 find_library( PostgreSQL_LIBRARY 0160 NAMES ${PostgreSQL_LIBRARY_TO_FIND} 0161 PATHS 0162 ${PostgreSQL_ROOT_DIRECTORIES} 0163 PATH_SUFFIXES 0164 lib 0165 # Help the user find it if we cannot. 0166 DOC "${PostgreSQL_LIBRARY_DIR_MESSAGE}" 0167 ) 0168 get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH) 0169 0170 if (PC_LIBPQ_VERSION) 0171 set(PostgreSQL_VERSION_STRING ${PC_LIBPQ_VERSION}) 0172 else() 0173 if (PostgreSQL_INCLUDE_DIR) 0174 # Some platforms include multiple pg_config.hs for multi-lib configurations 0175 # This is a temporary workaround. A better solution would be to compile 0176 # a dummy c file and extract the value of the symbol. 0177 file(GLOB _PG_CONFIG_HEADERS "${PostgreSQL_INCLUDE_DIR}/pg_config*.h") 0178 foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS}) 0179 if(EXISTS "${_PG_CONFIG_HEADER}") 0180 file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str 0181 REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"") 0182 if(pgsql_version_str) 0183 string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*" 0184 "\\1" PostgreSQL_VERSION_STRING "${pgsql_version_str}") 0185 break() 0186 endif() 0187 endif() 0188 endforeach() 0189 unset(pgsql_version_str) 0190 endif() 0191 endif() 0192 0193 # Did we find anything? 0194 include(FindPackageHandleStandardArgs) 0195 find_package_handle_standard_args(PostgreSQL 0196 REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR 0197 VERSION_VAR PostgreSQL_VERSION_STRING) 0198 0199 # Now try to get the include and library path. 0200 if(PostgreSQL_FOUND) 0201 0202 set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ${PostgreSQL_TYPE_INCLUDE_DIR} ) 0203 if(WIN32) 0204 list(APPEND PostgreSQL_INCLUDE_DIRS ${PostgreSQL_TYPE_INCLUDE_DIR}/port/win32) 0205 endif() 0206 set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} ) 0207 set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY}) 0208 0209 #message("Final PostgreSQL include dir: ${PostgreSQL_INCLUDE_DIRS}") 0210 #message("Final PostgreSQL library dir: ${PostgreSQL_LIBRARY_DIRS}") 0211 #message("Final PostgreSQL libraries: ${PostgreSQL_LIBRARIES}") 0212 endif() 0213 0214 mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR PostgreSQL_LIBRARY PostgreSQL_ADDITIONAL_SEARCH_PATHS)