mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
Merge topic 'patch-FindPostgreSQL-version'
4d4d10e95d
FindPostgreSQL: Add PostgreSQL_VERSION
Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Vito Gamberini <vito.gamberini@kitware.com>
Merge-request: !10987
This commit is contained in:
@@ -6,3 +6,7 @@ Find Modules
|
||||
|
||||
* The :module:`FindBZip2` module now provides a ``BZip2_VERSION`` result
|
||||
variable. The ``BZIP2_VERSION`` result variable is deprecated.
|
||||
|
||||
* The :module:`FindPostgreSQL` module now provides a ``PostgreSQL_VERSION``
|
||||
result variable. The ``PostgreSQL_VERSION_STRING`` result variable is
|
||||
deprecated.
|
||||
|
@@ -6,7 +6,11 @@ FindPostgreSQL
|
||||
--------------
|
||||
|
||||
Finds the PostgreSQL installation - the client library (``libpq``) and
|
||||
optionally the server.
|
||||
optionally the server:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
find_package(PostgreSQL [<version>] [...])
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
@@ -28,14 +32,21 @@ This module defines the following variables:
|
||||
``PostgreSQL_FOUND``
|
||||
Boolean indicating whether the minimum required version and components of
|
||||
PostgreSQL have been found.
|
||||
|
||||
``PostgreSQL_VERSION``
|
||||
.. versionadded:: 4.2
|
||||
|
||||
The version of PostgreSQL found.
|
||||
|
||||
``PostgreSQL_LIBRARIES``
|
||||
The PostgreSQL libraries needed for linking.
|
||||
|
||||
``PostgreSQL_INCLUDE_DIRS``
|
||||
The include directories containing PostgreSQL headers.
|
||||
|
||||
``PostgreSQL_LIBRARY_DIRS``
|
||||
The directories containing PostgreSQL libraries.
|
||||
``PostgreSQL_VERSION_STRING``
|
||||
The version of PostgreSQL found.
|
||||
|
||||
``PostgreSQL_TYPE_INCLUDE_DIR``
|
||||
The include directory containing PostgreSQL server headers.
|
||||
|
||||
@@ -51,6 +62,17 @@ This module supports the following additional components:
|
||||
``PostgreSQL_TYPE_INCLUDE_DIR`` variable is set regardless of whether this
|
||||
component is specified in the ``find_package()`` call.
|
||||
|
||||
Deprecated Variables
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The following variables are provided for backward compatibility:
|
||||
|
||||
``PostgreSQL_VERSION_STRING``
|
||||
.. deprecated:: 4.2
|
||||
Superseded by the ``PostgreSQL_VERSION``.
|
||||
|
||||
The version of PostgreSQL found.
|
||||
|
||||
Examples
|
||||
^^^^^^^^
|
||||
|
||||
@@ -288,14 +310,16 @@ if (PostgreSQL_INCLUDE_DIR)
|
||||
math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000")
|
||||
math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000 / 100")
|
||||
math(EXPR _PostgreSQL_patch_version "${_PostgreSQL_VERSION_NUM} % 100")
|
||||
set(PostgreSQL_VERSION_STRING "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}.${_PostgreSQL_patch_version}")
|
||||
set(PostgreSQL_VERSION "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}.${_PostgreSQL_patch_version}")
|
||||
set(PostgreSQL_VERSION_STRING "${PostgreSQL_VERSION}")
|
||||
unset(_PostgreSQL_major_version)
|
||||
unset(_PostgreSQL_minor_version)
|
||||
unset(_PostgreSQL_patch_version)
|
||||
else ()
|
||||
math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000")
|
||||
math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000")
|
||||
set(PostgreSQL_VERSION_STRING "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}")
|
||||
set(PostgreSQL_VERSION "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}")
|
||||
set(PostgreSQL_VERSION_STRING "${PostgreSQL_VERSION}")
|
||||
unset(_PostgreSQL_major_version)
|
||||
unset(_PostgreSQL_minor_version)
|
||||
endif ()
|
||||
@@ -306,7 +330,8 @@ if (PostgreSQL_INCLUDE_DIR)
|
||||
REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
|
||||
if(pgsql_version_str)
|
||||
string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*"
|
||||
"\\1" PostgreSQL_VERSION_STRING "${pgsql_version_str}")
|
||||
"\\1" PostgreSQL_VERSION "${pgsql_version_str}")
|
||||
set(PostgreSQL_VERSION_STRING "${PostgreSQL_VERSION}")
|
||||
break()
|
||||
endif()
|
||||
endif()
|
||||
@@ -328,7 +353,7 @@ include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(PostgreSQL
|
||||
REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR
|
||||
HANDLE_COMPONENTS
|
||||
VERSION_VAR PostgreSQL_VERSION_STRING)
|
||||
VERSION_VAR PostgreSQL_VERSION)
|
||||
|
||||
function(__postgresql_import_library _target _var _config)
|
||||
if(_config)
|
||||
|
@@ -121,7 +121,7 @@ foreach(
|
||||
JPEG
|
||||
LibArchive LIBLZMA
|
||||
OPENSCENEGRAPH
|
||||
Protobuf
|
||||
PostgreSQL Protobuf
|
||||
Ruby RUBY
|
||||
SWIG
|
||||
ZLIB
|
||||
|
@@ -4,7 +4,7 @@ include(CTest)
|
||||
|
||||
find_package(PostgreSQL REQUIRED COMPONENTS Server)
|
||||
|
||||
add_definitions(-DCMAKE_EXPECTED_POSTGRESQL_VERSION="${PostgreSQL_VERSION_STRING}")
|
||||
add_definitions(-DCMAKE_EXPECTED_POSTGRESQL_VERSION="${PostgreSQL_VERSION}")
|
||||
|
||||
add_executable(test_tgt main.c)
|
||||
target_link_libraries(test_tgt PostgreSQL::PostgreSQL)
|
||||
|
Reference in New Issue
Block a user