mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 22:37:30 +08:00
FindPostgreSQL: Add PostgreSQL_VERSION
This deprecates the PostgreSQL_VERSION_STRING result variable. Issue: #27088
This commit is contained in:
@@ -3,3 +3,7 @@ Find Modules
|
|||||||
|
|
||||||
* The :module:`FindBZip2` module now provides a ``BZip2_VERSION`` result
|
* The :module:`FindBZip2` module now provides a ``BZip2_VERSION`` result
|
||||||
variable. The ``BZIP2_VERSION`` result variable is deprecated.
|
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
|
Finds the PostgreSQL installation - the client library (``libpq``) and
|
||||||
optionally the server.
|
optionally the server:
|
||||||
|
|
||||||
|
.. code-block:: cmake
|
||||||
|
|
||||||
|
find_package(PostgreSQL [<version>] [...])
|
||||||
|
|
||||||
Imported Targets
|
Imported Targets
|
||||||
^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^
|
||||||
@@ -28,14 +32,21 @@ This module defines the following variables:
|
|||||||
``PostgreSQL_FOUND``
|
``PostgreSQL_FOUND``
|
||||||
Boolean indicating whether the minimum required version and components of
|
Boolean indicating whether the minimum required version and components of
|
||||||
PostgreSQL have been found.
|
PostgreSQL have been found.
|
||||||
|
|
||||||
|
``PostgreSQL_VERSION``
|
||||||
|
.. versionadded:: 4.2
|
||||||
|
|
||||||
|
The version of PostgreSQL found.
|
||||||
|
|
||||||
``PostgreSQL_LIBRARIES``
|
``PostgreSQL_LIBRARIES``
|
||||||
The PostgreSQL libraries needed for linking.
|
The PostgreSQL libraries needed for linking.
|
||||||
|
|
||||||
``PostgreSQL_INCLUDE_DIRS``
|
``PostgreSQL_INCLUDE_DIRS``
|
||||||
The include directories containing PostgreSQL headers.
|
The include directories containing PostgreSQL headers.
|
||||||
|
|
||||||
``PostgreSQL_LIBRARY_DIRS``
|
``PostgreSQL_LIBRARY_DIRS``
|
||||||
The directories containing PostgreSQL libraries.
|
The directories containing PostgreSQL libraries.
|
||||||
``PostgreSQL_VERSION_STRING``
|
|
||||||
The version of PostgreSQL found.
|
|
||||||
``PostgreSQL_TYPE_INCLUDE_DIR``
|
``PostgreSQL_TYPE_INCLUDE_DIR``
|
||||||
The include directory containing PostgreSQL server headers.
|
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
|
``PostgreSQL_TYPE_INCLUDE_DIR`` variable is set regardless of whether this
|
||||||
component is specified in the ``find_package()`` call.
|
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
|
Examples
|
||||||
^^^^^^^^
|
^^^^^^^^
|
||||||
|
|
||||||
@@ -288,14 +310,16 @@ if (PostgreSQL_INCLUDE_DIR)
|
|||||||
math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000")
|
math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000")
|
||||||
math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000 / 100")
|
math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000 / 100")
|
||||||
math(EXPR _PostgreSQL_patch_version "${_PostgreSQL_VERSION_NUM} % 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_major_version)
|
||||||
unset(_PostgreSQL_minor_version)
|
unset(_PostgreSQL_minor_version)
|
||||||
unset(_PostgreSQL_patch_version)
|
unset(_PostgreSQL_patch_version)
|
||||||
else ()
|
else ()
|
||||||
math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000")
|
math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000")
|
||||||
math(EXPR _PostgreSQL_minor_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_major_version)
|
||||||
unset(_PostgreSQL_minor_version)
|
unset(_PostgreSQL_minor_version)
|
||||||
endif ()
|
endif ()
|
||||||
@@ -306,7 +330,8 @@ if (PostgreSQL_INCLUDE_DIR)
|
|||||||
REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
|
REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
|
||||||
if(pgsql_version_str)
|
if(pgsql_version_str)
|
||||||
string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*"
|
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()
|
break()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@@ -328,7 +353,7 @@ include(FindPackageHandleStandardArgs)
|
|||||||
find_package_handle_standard_args(PostgreSQL
|
find_package_handle_standard_args(PostgreSQL
|
||||||
REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR
|
REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR
|
||||||
HANDLE_COMPONENTS
|
HANDLE_COMPONENTS
|
||||||
VERSION_VAR PostgreSQL_VERSION_STRING)
|
VERSION_VAR PostgreSQL_VERSION)
|
||||||
|
|
||||||
function(__postgresql_import_library _target _var _config)
|
function(__postgresql_import_library _target _var _config)
|
||||||
if(_config)
|
if(_config)
|
||||||
|
@@ -120,7 +120,7 @@ foreach(
|
|||||||
JPEG
|
JPEG
|
||||||
LibArchive LIBLZMA
|
LibArchive LIBLZMA
|
||||||
OPENSCENEGRAPH
|
OPENSCENEGRAPH
|
||||||
Protobuf
|
PostgreSQL Protobuf
|
||||||
Ruby RUBY
|
Ruby RUBY
|
||||||
SWIG
|
SWIG
|
||||||
ZLIB
|
ZLIB
|
||||||
|
@@ -4,7 +4,7 @@ include(CTest)
|
|||||||
|
|
||||||
find_package(PostgreSQL REQUIRED COMPONENTS Server)
|
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)
|
add_executable(test_tgt main.c)
|
||||||
target_link_libraries(test_tgt PostgreSQL::PostgreSQL)
|
target_link_libraries(test_tgt PostgreSQL::PostgreSQL)
|
||||||
|
Reference in New Issue
Block a user