3 # This module accepts the following environment variables:
5 # GDAL_DIR or GDAL_ROOT - Specify the location of GDAL
7 # This module defines the following CMake variables:
9 # GDAL_FOUND - True if libgdal is found
10 # GDAL_LIBRARY - A variable pointing to the GDAL library
11 # GDAL_INCLUDE_DIR - Where to find the headers
13 # $GDALDIR is an environment variable that would
14 # correspond to the ./configure --prefix=$GDAL_DIR
15 # used in building gdal.
17 # Created by Eric Wing. I'm not a gdal user, but OpenSceneGraph uses it
18 # for osgTerrain so I whipped this module together for completeness.
19 # I actually don't know the conventions or where files are typically
21 # Any real gdal users are encouraged to correct this (but please don't
22 # break the OS X framework stuff when doing so which is what usually seems
25 # This makes the presumption that you are include gdal.h like
29 FIND_PATH(GDAL_INCLUDE_DIR gdal.h
38 ~/Library/Frameworks/gdal.framework/Headers
39 /Library/Frameworks/gdal.framework/Headers
41 /opt/local # DarwinPorts
47 # Use gdal-config to obtain the library version (this should hopefully
48 # allow us to -lgdal1.x.y where x.y are correct version)
49 # For some reason, libgdal development packages do not contain
51 FIND_PROGRAM(GDAL_CONFIG gdal-config
58 /opt/local # DarwinPorts
64 exec_program(${GDAL_CONFIG} ARGS --libs OUTPUT_VARIABLE GDAL_CONFIG_LIBS)
66 string(REGEX MATCHALL "-l[^ ]+" _gdal_dashl ${GDAL_CONFIG_LIBS})
67 string(REGEX REPLACE "-l" "" _gdal_lib "${_gdal_dashl}")
68 string(REGEX MATCHALL "-L[^ ]+" _gdal_dashL ${GDAL_CONFIG_LIBS})
69 string(REGEX REPLACE "-L" "" _gdal_libpath "${_gdal_dashL}")
74 FIND_LIBRARY(GDAL_LIBRARY
75 NAMES ${_gdal_lib} gdal gdal_i gdal1.5.0 gdal1.4.0 gdal1.3.2 GDAL
80 PATH_SUFFIXES lib64 lib
89 include(FindPackageHandleStandardArgs)
90 FIND_PACKAGE_HANDLE_STANDARD_ARGS(GDAL DEFAULT_MSG GDAL_LIBRARY GDAL_INCLUDE_DIR)
92 set(GDAL_LIBRARIES ${GDAL_LIBRARY})
93 set(GDAL_INCLUDE_DIRS ${GDAL_INCLUDE_DIR})