diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2018-10-31 18:48:15 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-11-01 17:16:37 (GMT) |
commit | 22ba9b6a328a0eea77559b2d607fe8d525445812 (patch) | |
tree | 962e8435dcf4486b28ab383e5d6f17d7550cc01d /Modules/FindGDAL.cmake | |
parent | 525ff0c3bc1f625756337c2ae724a58ec93ba4d1 (diff) | |
download | CMake-22ba9b6a328a0eea77559b2d607fe8d525445812.zip CMake-22ba9b6a328a0eea77559b2d607fe8d525445812.tar.gz CMake-22ba9b6a328a0eea77559b2d607fe8d525445812.tar.bz2 |
FindGDAL: set the GDAL_VERSION
Diffstat (limited to 'Modules/FindGDAL.cmake')
-rw-r--r-- | Modules/FindGDAL.cmake | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Modules/FindGDAL.cmake b/Modules/FindGDAL.cmake index 5dd9335..8522f9b 100644 --- a/Modules/FindGDAL.cmake +++ b/Modules/FindGDAL.cmake @@ -24,6 +24,8 @@ This module will set the following variables in your project: Include directories for GDAL headers. ``GDAL_LIBRARIES`` Libraries to link to GDAL. +``GDAL_VERSION`` + The version of GDAL found. Cache variables ^^^^^^^^^^^^^^^ @@ -138,8 +140,19 @@ find_library(GDAL_LIBRARY PATH_SUFFIXES lib ) +if (EXISTS "${GDAL_INCLUDE_DIR}/gdal_version.h") + file(STRINGS "${GDAL_INCLUDE_DIR}/gdal_version.h" _gdal_version + REGEX "GDAL_RELEASE_NAME") + string(REGEX REPLACE ".*\"\(.*\)\"" "\\1" GDAL_VERSION "${_gdal_version}") + unset(_gdal_version) +else () + set(GDAL_VERSION GDAL_VERSION-NOTFOUND) +endif () + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GDAL DEFAULT_MSG GDAL_LIBRARY GDAL_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GDAL + VERSION_VAR GDAL_VERSION + REQUIRED_VARS GDAL_LIBRARY GDAL_INCLUDE_DIR) if (GDAL_FOUND AND NOT TARGET GDAL::GDAL) add_library(GDAL::GDAL UNKNOWN IMPORTED) |