2007-12-21 04:59:44 +03:00
|
|
|
# Locate gdal
|
2009-01-31 09:50:40 +03:00
|
|
|
#
|
|
|
|
# This module accepts the following environment variables:
|
|
|
|
#
|
|
|
|
# GDAL_DIR or GDAL_ROOT - Specify the location of GDAL
|
|
|
|
#
|
|
|
|
# This module defines the following CMake variables:
|
|
|
|
#
|
|
|
|
# GDAL_FOUND - True if libgdal is found
|
|
|
|
# GDAL_LIBRARY - A variable pointing to the GDAL library
|
|
|
|
# GDAL_INCLUDE_DIR - Where to find the headers
|
2009-09-28 19:45:50 +04:00
|
|
|
|
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2007-2009 Kitware, Inc.
|
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
2010-08-07 04:48:47 +04:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 19:45:50 +04:00
|
|
|
# License text for the above reference.)
|
|
|
|
|
2007-12-21 04:59:44 +03:00
|
|
|
#
|
|
|
|
# $GDALDIR is an environment variable that would
|
|
|
|
# correspond to the ./configure --prefix=$GDAL_DIR
|
|
|
|
# used in building gdal.
|
|
|
|
#
|
|
|
|
# Created by Eric Wing. I'm not a gdal user, but OpenSceneGraph uses it
|
|
|
|
# for osgTerrain so I whipped this module together for completeness.
|
|
|
|
# I actually don't know the conventions or where files are typically
|
|
|
|
# placed in distros.
|
|
|
|
# Any real gdal users are encouraged to correct this (but please don't
|
|
|
|
# break the OS X framework stuff when doing so which is what usually seems
|
|
|
|
# to happen).
|
|
|
|
|
|
|
|
# This makes the presumption that you are include gdal.h like
|
2009-01-31 09:50:40 +03:00
|
|
|
#
|
|
|
|
#include "gdal.h"
|
2007-12-21 04:59:44 +03:00
|
|
|
|
|
|
|
FIND_PATH(GDAL_INCLUDE_DIR gdal.h
|
2008-06-10 00:04:06 +04:00
|
|
|
HINTS
|
2009-01-31 09:50:40 +03:00
|
|
|
$ENV{GDAL_DIR}
|
|
|
|
$ENV{GDAL_ROOT}
|
|
|
|
PATH_SUFFIXES
|
|
|
|
include/gdal
|
|
|
|
include/GDAL
|
|
|
|
include
|
2007-12-21 04:59:44 +03:00
|
|
|
PATHS
|
2009-01-31 09:50:40 +03:00
|
|
|
~/Library/Frameworks/gdal.framework/Headers
|
|
|
|
/Library/Frameworks/gdal.framework/Headers
|
|
|
|
/sw # Fink
|
|
|
|
/opt/local # DarwinPorts
|
|
|
|
/opt/csw # Blastwave
|
|
|
|
/opt
|
2007-12-21 04:59:44 +03:00
|
|
|
)
|
|
|
|
|
2009-01-31 09:50:40 +03:00
|
|
|
IF(UNIX)
|
|
|
|
# Use gdal-config to obtain the library version (this should hopefully
|
|
|
|
# allow us to -lgdal1.x.y where x.y are correct version)
|
|
|
|
# For some reason, libgdal development packages do not contain
|
|
|
|
# libgdal.so...
|
|
|
|
FIND_PROGRAM(GDAL_CONFIG gdal-config
|
|
|
|
HINTS
|
|
|
|
$ENV{GDAL_DIR}
|
|
|
|
$ENV{GDAL_ROOT}
|
|
|
|
PATH_SUFFIXES bin
|
|
|
|
PATHS
|
|
|
|
/sw # Fink
|
|
|
|
/opt/local # DarwinPorts
|
|
|
|
/opt/csw # Blastwave
|
|
|
|
/opt
|
|
|
|
)
|
|
|
|
|
|
|
|
if(GDAL_CONFIG)
|
|
|
|
exec_program(${GDAL_CONFIG} ARGS --libs OUTPUT_VARIABLE GDAL_CONFIG_LIBS)
|
|
|
|
if(GDAL_CONFIG_LIBS)
|
|
|
|
string(REGEX MATCHALL "-l[^ ]+" _gdal_dashl ${GDAL_CONFIG_LIBS})
|
|
|
|
string(REGEX REPLACE "-l" "" _gdal_lib "${_gdal_dashl}")
|
|
|
|
string(REGEX MATCHALL "-L[^ ]+" _gdal_dashL ${GDAL_CONFIG_LIBS})
|
|
|
|
string(REGEX REPLACE "-L" "" _gdal_libpath "${_gdal_dashL}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2007-12-21 04:59:44 +03:00
|
|
|
FIND_LIBRARY(GDAL_LIBRARY
|
2009-01-31 09:50:40 +03:00
|
|
|
NAMES ${_gdal_lib} gdal gdal_i gdal1.5.0 gdal1.4.0 gdal1.3.2 GDAL
|
2008-06-10 00:04:06 +04:00
|
|
|
HINTS
|
2009-01-31 09:50:40 +03:00
|
|
|
$ENV{GDAL_DIR}
|
|
|
|
$ENV{GDAL_ROOT}
|
|
|
|
${_gdal_libpath}
|
2007-12-21 04:59:44 +03:00
|
|
|
PATH_SUFFIXES lib64 lib
|
|
|
|
PATHS
|
|
|
|
/sw
|
|
|
|
/opt/local
|
|
|
|
/opt/csw
|
|
|
|
/opt
|
|
|
|
/usr/freeware
|
|
|
|
)
|
|
|
|
|
2009-01-31 09:50:40 +03:00
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GDAL DEFAULT_MSG GDAL_LIBRARY GDAL_INCLUDE_DIR)
|
2007-12-21 04:59:44 +03:00
|
|
|
|
2009-01-31 09:50:40 +03:00
|
|
|
set(GDAL_LIBRARIES ${GDAL_LIBRARY})
|
|
|
|
set(GDAL_INCLUDE_DIRS ${GDAL_INCLUDE_DIR})
|