diff options
author | Brad King <brad.king@kitware.com> | 2021-01-18 16:15:49 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-01-18 16:16:04 (GMT) |
commit | 28523d63ffc0e155bd7c32630d132f2c4418fd1c (patch) | |
tree | 0831b5da27394e470a638068c08923fa7a55f7d2 | |
parent | 21fc98ceec58e841d489dac37057fb45908a3fad (diff) | |
parent | 8b066f1a65466ae2dc542b097f877795f386f942 (diff) | |
download | CMake-28523d63ffc0e155bd7c32630d132f2c4418fd1c.zip CMake-28523d63ffc0e155bd7c32630d132f2c4418fd1c.tar.gz CMake-28523d63ffc0e155bd7c32630d132f2c4418fd1c.tar.bz2 |
Merge topic 'FindPostgreSQL-server-component'
8b066f1a65 FindPostgreSQL: Add server component
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !5680
-rw-r--r-- | Modules/FindPostgreSQL.cmake | 25 | ||||
-rw-r--r-- | Tests/FindPostgreSQL/Test/CMakeLists.txt | 2 |
2 files changed, 25 insertions, 2 deletions
diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index 911210f..147071a 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -30,6 +30,16 @@ This module will set the following variables in your project: 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. + #]=======================================================================] # ---------------------------------------------------------------------------- @@ -81,6 +91,9 @@ This module will set the following variables in your project: # # ---------------------------------------------------------------------------- +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.") @@ -244,10 +257,18 @@ if (PostgreSQL_INCLUDE_DIR) unset(pgsql_version_str) endif() +if("Server" IN_LIST PostgreSQL_FIND_COMPONENTS) + set(PostgreSQL_Server_FOUND TRUE) + if(NOT PostgreSQL_TYPE_INCLUDE_DIR) + set(PostgreSQL_Server_FOUND FALSE) + endif() +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 + HANDLE_COMPONENTS VERSION_VAR PostgreSQL_VERSION_STRING) set(PostgreSQL_FOUND ${POSTGRESQL_FOUND}) @@ -275,7 +296,7 @@ if(PostgreSQL_FOUND) if(PostgreSQL_TYPE_INCLUDE_DIR) list(APPEND PostgreSQL_INCLUDE_DIRS ${PostgreSQL_TYPE_INCLUDE_DIR}) endif() - set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} ) + set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR}) if (NOT TARGET PostgreSQL::PostgreSQL) add_library(PostgreSQL::PostgreSQL UNKNOWN IMPORTED) set_target_properties(PostgreSQL::PostgreSQL PROPERTIES @@ -287,3 +308,5 @@ if(PostgreSQL_FOUND) endif() mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR) + +cmake_policy(POP) diff --git a/Tests/FindPostgreSQL/Test/CMakeLists.txt b/Tests/FindPostgreSQL/Test/CMakeLists.txt index 374e147..1bc5c56 100644 --- a/Tests/FindPostgreSQL/Test/CMakeLists.txt +++ b/Tests/FindPostgreSQL/Test/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10) project(TestFindPostgreSQL C) include(CTest) -find_package(PostgreSQL REQUIRED) +find_package(PostgreSQL REQUIRED COMPONENTS Server) add_definitions(-DCMAKE_EXPECTED_POSTGRESQL_VERSION="${PostgreSQL_VERSION_STRING}") |