FindGDAL.cmake 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # Locate gdal
  2. # This module defines
  3. # GDAL_LIBRARY
  4. # GDAL_FOUND, if false, do not try to link to gdal
  5. # GDAL_INCLUDE_DIR, where to find the headers
  6. #
  7. # $GDALDIR is an environment variable that would
  8. # correspond to the ./configure --prefix=$GDAL_DIR
  9. # used in building gdal.
  10. #
  11. # Created by Eric Wing. I'm not a gdal user, but OpenSceneGraph uses it
  12. # for osgTerrain so I whipped this module together for completeness.
  13. # I actually don't know the conventions or where files are typically
  14. # placed in distros.
  15. # Any real gdal users are encouraged to correct this (but please don't
  16. # break the OS X framework stuff when doing so which is what usually seems
  17. # to happen).
  18. # This makes the presumption that you are include gdal.h like
  19. # #include "gdal.h"
  20. FIND_PATH(GDAL_INCLUDE_DIR gdal.h
  21. $ENV{GDAL_DIR}
  22. NO_DEFAULT_PATH
  23. PATH_SUFFIXES include
  24. )
  25. FIND_PATH(GDAL_INCLUDE_DIR gdal.h
  26. PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
  27. NO_DEFAULT_PATH
  28. PATH_SUFFIXES include
  29. )
  30. FIND_PATH(GDAL_INCLUDE_DIR gdal.h
  31. PATHS
  32. ~/Library/Frameworks/gdal.framework/Headers
  33. /Library/Frameworks/gdal.framework/Headers
  34. /usr/local/include/gdal
  35. /usr/local/include/GDAL
  36. /usr/local/include
  37. /usr/include/gdal
  38. /usr/include/GDAL
  39. /usr/include
  40. /sw/include/gdal
  41. /sw/include/GDAL
  42. /sw/include # Fink
  43. /opt/local/include/gdal
  44. /opt/local/include/GDAL
  45. /opt/local/include # DarwinPorts
  46. /opt/csw/include/gdal
  47. /opt/csw/include/GDAL
  48. /opt/csw/include # Blastwave
  49. /opt/include/gdal
  50. /opt/include/GDAL
  51. /opt/include
  52. )
  53. FIND_LIBRARY(GDAL_LIBRARY
  54. NAMES gdal GDAL
  55. PATHS
  56. $ENV{GDAL_DIR}
  57. NO_DEFAULT_PATH
  58. PATH_SUFFIXES lib64 lib
  59. )
  60. FIND_LIBRARY(GDAL_LIBRARY
  61. NAMES gdal GDAL
  62. PATHS ${CMAKE_PREFIX_PATH} # Unofficial: We are proposing this.
  63. NO_DEFAULT_PATH
  64. PATH_SUFFIXES lib64 lib
  65. )
  66. FIND_LIBRARY(GDAL_LIBRARY
  67. NAMES gdal GDAL
  68. PATHS
  69. ~/Library/Frameworks
  70. /Library/Frameworks
  71. /usr/local
  72. /usr
  73. /sw
  74. /opt/local
  75. /opt/csw
  76. /opt
  77. /usr/freeware
  78. [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;GDAL_ROOT]/lib
  79. PATH_SUFFIXES lib64 lib
  80. )
  81. SET(GDAL_FOUND "NO")
  82. IF(GDAL_LIBRARY AND GDAL_INCLUDE_DIR)
  83. SET(GDAL_FOUND "YES")
  84. ENDIF(GDAL_LIBRARY AND GDAL_INCLUDE_DIR)