Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

FindGDAL.cmake 4.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
  1. #
  2. # $Id$
  3. #
  4. # Locate gdal
  5. #
  6. # This module accepts the following environment variables:
  7. #
  8. # GDAL_DIR or GDAL_ROOT - Specify the location of GDAL
  9. #
  10. # This module defines the following CMake variables:
  11. #
  12. # GDAL_FOUND - True if libgdal is found
  13. # GDAL_LIBRARY - A variable pointing to the GDAL library
  14. # GDAL_INCLUDE_DIR - Where to find the headers
  15. #=============================================================================
  16. # Copyright 2007-2009 Kitware, Inc.
  17. #
  18. # Distributed under the OSI-approved BSD License (the "License");
  19. # see accompanying file Copyright.txt for details.
  20. #
  21. # This software is distributed WITHOUT ANY WARRANTY; without even the
  22. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  23. # See COPYING-CMAKE-SCRIPTS for more information.
  24. #=============================================================================
  25. # Note: this file is not an exact copy of the original file from Kitware.
  26. # It has been modified for the needs of GMT.
  27. #
  28. # $GDAL_DIR is an environment variable that would
  29. # correspond to the ./configure --prefix=$GDAL_DIR
  30. # used in building gdal.
  31. #
  32. # Created by Eric Wing. I'm not a gdal user, but OpenSceneGraph uses it
  33. # for osgTerrain so I whipped this module together for completeness.
  34. # I actually don't know the conventions or where files are typically
  35. # placed in distros.
  36. # Any real gdal users are encouraged to correct this (but please don't
  37. # break the OS X framework stuff when doing so which is what usually seems
  38. # to happen).
  39. # This makes the presumption that you are include gdal.h like
  40. #
  41. #include "gdal.h"
  42. if (DEFINED GDAL_ROOT AND NOT GDAL_ROOT)
  43. set (GDAL_LIBRARY "" CACHE INTERNAL "")
  44. set (GDAL_INCLUDE_DIR "" CACHE INTERNAL "")
  45. return()
  46. endif (DEFINED GDAL_ROOT AND NOT GDAL_ROOT)
  47. if (UNIX AND NOT GDAL_FOUND)
  48. # Use gdal-config to obtain the library version (this should hopefully
  49. # allow us to -lgdal1.x.y where x.y are correct version)
  50. # For some reason, libgdal development packages do not contain
  51. # libgdal.so...
  52. find_program (GDAL_CONFIG gdal-config
  53. HINTS
  54. ${GDAL_DIR}
  55. ${GDAL_ROOT}
  56. $ENV{GDAL_DIR}
  57. $ENV{GDAL_ROOT}
  58. PATH_SUFFIXES bin
  59. PATHS
  60. /sw # Fink
  61. /opt/local # DarwinPorts
  62. /opt/csw # Blastwave
  63. /opt
  64. /usr/local
  65. )
  66. if (GDAL_CONFIG)
  67. execute_process (COMMAND ${GDAL_CONFIG} --cflags
  68. ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
  69. OUTPUT_VARIABLE GDAL_CONFIG_CFLAGS)
  70. if (GDAL_CONFIG_CFLAGS)
  71. string (REGEX MATCHALL "-I[^ ]+" _gdal_dashI ${GDAL_CONFIG_CFLAGS})
  72. string (REGEX REPLACE "-I" "" _gdal_includepath "${_gdal_dashI}")
  73. string (REGEX REPLACE "-I[^ ]+" "" _gdal_cflags_other ${GDAL_CONFIG_CFLAGS})
  74. endif (GDAL_CONFIG_CFLAGS)
  75. execute_process (COMMAND ${GDAL_CONFIG} --libs
  76. ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
  77. OUTPUT_VARIABLE GDAL_CONFIG_LIBS)
  78. if (GDAL_CONFIG_LIBS)
  79. string (REGEX MATCHALL "-l[^ ]+" _gdal_dashl ${GDAL_CONFIG_LIBS})
  80. string (REGEX REPLACE "-l" "" _gdal_lib "${_gdal_dashl}")
  81. string (REGEX MATCHALL "-L[^ ]+" _gdal_dashL ${GDAL_CONFIG_LIBS})
  82. string (REGEX REPLACE "-L" "" _gdal_libpath "${_gdal_dashL}")
  83. endif (GDAL_CONFIG_LIBS)
  84. endif (GDAL_CONFIG)
  85. endif (UNIX AND NOT GDAL_FOUND)
  86. find_path (GDAL_INCLUDE_DIR gdal.h
  87. HINTS
  88. ${_gdal_includepath}
  89. ${GDAL_DIR}
  90. ${GDAL_ROOT}
  91. $ENV{GDAL_DIR}
  92. $ENV{GDAL_ROOT}
  93. PATH_SUFFIXES
  94. include/gdal
  95. include/GDAL
  96. include
  97. PATHS
  98. ~/Library/Frameworks/gdal.framework/Headers
  99. /Library/Frameworks/gdal.framework/Headers
  100. /sw # Fink
  101. /opt/local # DarwinPorts
  102. /opt/csw # Blastwave
  103. /opt
  104. /usr/local
  105. )
  106. find_library (GDAL_LIBRARY
  107. NAMES ${_gdal_lib} gdal gdal_i gdal1.5.0 gdal1.4.0 gdal1.3.2 GDAL
  108. HINTS
  109. ${GDAL_DIR}
  110. ${GDAL_ROOT}
  111. $ENV{GDAL_DIR}
  112. $ENV{GDAL_ROOT}
  113. ${_gdal_libpath}
  114. PATH_SUFFIXES lib
  115. PATHS
  116. ~/Library/Frameworks/gdal.framework
  117. /Library/Frameworks/gdal.framework
  118. /sw # Fink
  119. /opt/local # DarwinPorts
  120. /opt/csw # Blastwave
  121. /opt
  122. /usr/local
  123. )
  124. include (FindPackageHandleStandardArgs)
  125. find_package_handle_standard_args (GDAL DEFAULT_MSG GDAL_LIBRARY GDAL_INCLUDE_DIR)
  126. set (GDAL_LIBRARIES ${GDAL_LIBRARY})
  127. set (GDAL_INCLUDE_DIRS ${GDAL_INCLUDE_DIR})
  128. # vim: textwidth=78 noexpandtab tabstop=2 softtabstop=2 shiftwidth=2
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...