summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2018-10-31 15:05:01 (GMT)
committerBrad King <brad.king@kitware.com>2018-11-01 17:16:36 (GMT)
commit87324b9b6a1f29a25c96149e165e99bebe750ef5 (patch)
tree21943ed851764670d20dac76ed1ff272c90fd55f
parentdfb3f58f79b05dfe7840373aa08a86204c94f33b (diff)
downloadCMake-87324b9b6a1f29a25c96149e165e99bebe750ef5.zip
CMake-87324b9b6a1f29a25c96149e165e99bebe750ef5.tar.gz
CMake-87324b9b6a1f29a25c96149e165e99bebe750ef5.tar.bz2
FindGDAL: add an imported target
-rw-r--r--Help/release/dev/FindGDAL-target.rst4
-rw-r--r--Modules/FindGDAL.cmake13
2 files changed, 17 insertions, 0 deletions
diff --git a/Help/release/dev/FindGDAL-target.rst b/Help/release/dev/FindGDAL-target.rst
new file mode 100644
index 0000000..b121a72
--- /dev/null
+++ b/Help/release/dev/FindGDAL-target.rst
@@ -0,0 +1,4 @@
+FindGDAL-target
+---------------
+
+* The :module:`FindGDAL` module now provides an imported target.
diff --git a/Modules/FindGDAL.cmake b/Modules/FindGDAL.cmake
index 9c989b8..5dd9335 100644
--- a/Modules/FindGDAL.cmake
+++ b/Modules/FindGDAL.cmake
@@ -7,6 +7,12 @@ FindGDAL
Find GDAL.
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``GDAL::GDAL``
+if GDAL has been found.
+
Result Variables
^^^^^^^^^^^^^^^^
@@ -135,5 +141,12 @@ find_library(GDAL_LIBRARY
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GDAL DEFAULT_MSG GDAL_LIBRARY GDAL_INCLUDE_DIR)
+if (GDAL_FOUND AND NOT TARGET GDAL::GDAL)
+ add_library(GDAL::GDAL UNKNOWN IMPORTED)
+ set_target_properties(GDAL::GDAL PROPERTIES
+ IMPORTED_LOCATION "${GDAL_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${GDAL_INCLUDE_DIR}")
+endif ()
+
set(GDAL_LIBRARIES ${GDAL_LIBRARY})
set(GDAL_INCLUDE_DIRS ${GDAL_INCLUDE_DIR})