GDALSupport.cmake 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. # ------------------------------------------------------------------------------
  2. # GDAL support for CloudCompare
  3. # ------------------------------------------------------------------------------
  4. option( OPTION_USE_GDAL "Build with GDAL support" OFF )
  5. if( ${OPTION_USE_GDAL} )
  6. find_package( GDAL REQUIRED )
  7. if ( NOT GDAL_FOUND )
  8. message( SEND_ERROR "GDAL package not found" )
  9. else()
  10. target_include_directories( ${PROJECT_NAME} PUBLIC ${GDAL_INCLUDE_DIR} )
  11. if( WIN32 )
  12. set( GDAL_BIN_DIR ${GDAL_INCLUDE_DIR}/../bin CACHE PATH "GDAL DLLs folder" )
  13. endif()
  14. endif()
  15. endif()
  16. # Link project with GDAL library
  17. function( target_link_GDAL ) # ARGV0 = project name
  18. if( NOT GDAL_FOUND )
  19. message( FATAL_ERROR "GDAL package not found" )
  20. endif()
  21. target_link_libraries( ${ARGV0} ${GDAL_LIBRARY} )
  22. target_compile_definitions( ${ARGV0} PUBLIC CC_GDAL_SUPPORT )
  23. if( WIN32 )
  24. #install DLLs
  25. message( STATUS "Looking for GDAL DLLs in: " ${GDAL_BIN_DIR} )
  26. file( GLOB GDAL_DLL_FILES ${GDAL_BIN_DIR}/gdal*.dll )
  27. #message( ${GDAL_DLL_FILES} )
  28. message( STATUS "GDAL VERSION: " ${GDAL_VERSION} )
  29. if (GDAL_VERSION EQUAL 3.2)
  30. set ( GDAL_DEP_DLL_FILES ${GDAL_BIN_DIR}/xerces-c_3_2.dll
  31. ${GDAL_BIN_DIR}/libexpat.dll
  32. ${GDAL_BIN_DIR}/LIBPQ.dll
  33. ${GDAL_BIN_DIR}/hdf.dll
  34. ${GDAL_BIN_DIR}/mfhdf.dll
  35. ${GDAL_BIN_DIR}/cfitsio.dll
  36. ${GDAL_BIN_DIR}/libjpeg.dll
  37. ${GDAL_BIN_DIR}/netcdf.dll
  38. ${GDAL_BIN_DIR}/geotiff.dll
  39. ${GDAL_BIN_DIR}/tiff.dll
  40. ${GDAL_BIN_DIR}/proj_8_0.dll
  41. ${GDAL_BIN_DIR}/sqlite3.dll
  42. ${GDAL_BIN_DIR}/spatialite.dll
  43. ${GDAL_BIN_DIR}/geos_c.dll
  44. ${GDAL_BIN_DIR}/hdf5.dll
  45. ${GDAL_BIN_DIR}/hdf5_cpp.dll
  46. ${GDAL_BIN_DIR}/libkea.dll
  47. ${GDAL_BIN_DIR}/libcurl.dll
  48. ${GDAL_BIN_DIR}/libpng16.dll
  49. ${GDAL_BIN_DIR}/openjp2.dll
  50. ${GDAL_BIN_DIR}/poppler.dll
  51. ${GDAL_BIN_DIR}/iconv.dll
  52. ${GDAL_BIN_DIR}/libwebp.dll
  53. ${GDAL_BIN_DIR}/tiledb.dll
  54. ${GDAL_BIN_DIR}/freexl.dll
  55. ${GDAL_BIN_DIR}/libssl-1_1-x64.dll
  56. ${GDAL_BIN_DIR}/libcrypto-1_1-x64.dll
  57. ${GDAL_BIN_DIR}/gssapi64.dll
  58. ${GDAL_BIN_DIR}/xdr.dll
  59. ${GDAL_BIN_DIR}/hdf5_hl.dll
  60. ${GDAL_BIN_DIR}/zip.dll
  61. ${GDAL_BIN_DIR}/zlib.dll
  62. ${GDAL_BIN_DIR}/liblzma.dll
  63. ${GDAL_BIN_DIR}/zstd.dll
  64. ${GDAL_BIN_DIR}/libxml2.dll
  65. ${GDAL_BIN_DIR}/charset.dll
  66. ${GDAL_BIN_DIR}/geos.dll
  67. ${GDAL_BIN_DIR}/libssh2.dll
  68. ${GDAL_BIN_DIR}/freetype.dll
  69. ${GDAL_BIN_DIR}/aws-cpp-sdk-s3.dll
  70. ${GDAL_BIN_DIR}/aws-cpp-sdk-core.dll
  71. ${GDAL_BIN_DIR}/aws-cpp-sdk-identity-management.dll
  72. ${GDAL_BIN_DIR}/libbz2.dll
  73. ${GDAL_BIN_DIR}/liblz4.dll
  74. ${GDAL_BIN_DIR}/krb5_64.dll
  75. ${GDAL_BIN_DIR}/comerr64.dll
  76. ${GDAL_BIN_DIR}/k5sprt64.dll
  77. ${GDAL_BIN_DIR}/aws-c-event-stream.dll
  78. ${GDAL_BIN_DIR}/aws-c-common.dll
  79. ${GDAL_BIN_DIR}/aws-cpp-sdk-cognito-identity.dll
  80. ${GDAL_BIN_DIR}/aws-cpp-sdk-sts.dll
  81. ${GDAL_BIN_DIR}/aws-checksums.dll
  82. # for pdal
  83. ${GDAL_BIN_DIR}/laszip3.dll
  84. )
  85. elseif (GDAL_VERSION EQUAL 3.3)
  86. set ( GDAL_DEP_DLL_FILES ${GDAL_BIN_DIR}/xerces-c_3_2.dll
  87. ${GDAL_BIN_DIR}/cfitsio.dll
  88. ${GDAL_BIN_DIR}/freexl.dll
  89. ${GDAL_BIN_DIR}/geos.dll
  90. ${GDAL_BIN_DIR}/geos_c.dll
  91. ${GDAL_BIN_DIR}/iconv-2.dll
  92. ${GDAL_BIN_DIR}/hdf5.dll
  93. ${GDAL_BIN_DIR}/hdf5_cpp.dll
  94. ${GDAL_BIN_DIR}/hdf5_hl.dll
  95. ${GDAL_BIN_DIR}/hdf.dll
  96. ${GDAL_BIN_DIR}/libcrypto-1_1-x64.dll
  97. ${GDAL_BIN_DIR}/libcurl.dll
  98. ${GDAL_BIN_DIR}/libexpat.dll
  99. ${GDAL_BIN_DIR}/libkea.dll
  100. ${GDAL_BIN_DIR}/libmysql.dll
  101. ${GDAL_BIN_DIR}/libpq.dll
  102. ${GDAL_BIN_DIR}/libpng16.dll
  103. ${GDAL_BIN_DIR}/libssl-1_1-x64.dll
  104. ${GDAL_BIN_DIR}/libxml2.dll
  105. ${GDAL_BIN_DIR}/mfhdf.dll
  106. ${GDAL_BIN_DIR}/netcdf.dll
  107. ${GDAL_BIN_DIR}/openjp2.dll
  108. ${GDAL_BIN_DIR}/ogdi.dll
  109. ${GDAL_BIN_DIR}/proj_7_2.dll
  110. ${GDAL_BIN_DIR}/spatialite.dll
  111. ${GDAL_BIN_DIR}/sqlite3.dll
  112. ${GDAL_BIN_DIR}/szip.dll
  113. ${GDAL_BIN_DIR}/tiff.dll
  114. ${GDAL_BIN_DIR}/xdr.dll
  115. ${GDAL_BIN_DIR}/zlib.dll
  116. ${GDAL_BIN_DIR}/zstd.dll
  117. # for pdal
  118. #${GDAL_BIN_DIR}/laszip3.dll
  119. )
  120. elseif (GDAL_VERSION EQUAL 3.4)
  121. set ( GDAL_DEP_DLL_FILES ${GDAL_BIN_DIR}/xerces-c_3_2.dll
  122. ${GDAL_BIN_DIR}/libexpat.dll
  123. ${GDAL_BIN_DIR}/LIBPQ.dll
  124. ${GDAL_BIN_DIR}/hdf.dll
  125. ${GDAL_BIN_DIR}/mfhdf.dll
  126. ${GDAL_BIN_DIR}/cfitsio.dll
  127. ${GDAL_BIN_DIR}/libjpeg.dll
  128. ${GDAL_BIN_DIR}/netcdf.dll
  129. ${GDAL_BIN_DIR}/geotiff.dll
  130. ${GDAL_BIN_DIR}/tiff.dll
  131. ${GDAL_BIN_DIR}/proj_9_0.dll
  132. ${GDAL_BIN_DIR}/sqlite3.dll
  133. ${GDAL_BIN_DIR}/spatialite.dll
  134. ${GDAL_BIN_DIR}/geos_c.dll
  135. ${GDAL_BIN_DIR}/hdf5.dll
  136. ${GDAL_BIN_DIR}/hdf5_cpp.dll
  137. ${GDAL_BIN_DIR}/libkea.dll
  138. ${GDAL_BIN_DIR}/libcurl.dll
  139. ${GDAL_BIN_DIR}/libpng16.dll
  140. ${GDAL_BIN_DIR}/openjp2.dll
  141. ${GDAL_BIN_DIR}/iconv.dll
  142. ${GDAL_BIN_DIR}/tiledb.dll
  143. ${GDAL_BIN_DIR}/freexl.dll
  144. ${GDAL_BIN_DIR}/libssl-1_1-x64.dll
  145. ${GDAL_BIN_DIR}/libcrypto-1_1-x64.dll
  146. ${GDAL_BIN_DIR}/gssapi64.dll
  147. ${GDAL_BIN_DIR}/xdr.dll
  148. ${GDAL_BIN_DIR}/hdf5_hl.dll
  149. ${GDAL_BIN_DIR}/zip.dll
  150. ${GDAL_BIN_DIR}/zlib.dll
  151. ${GDAL_BIN_DIR}/liblzma.dll
  152. ${GDAL_BIN_DIR}/zstd.dll
  153. ${GDAL_BIN_DIR}/libxml2.dll
  154. ${GDAL_BIN_DIR}/charset.dll
  155. ${GDAL_BIN_DIR}/geos.dll
  156. ${GDAL_BIN_DIR}/libssh2.dll
  157. ${GDAL_BIN_DIR}/freetype.dll
  158. ${GDAL_BIN_DIR}/libbz2.dll
  159. ${GDAL_BIN_DIR}/liblz4.dll
  160. ${GDAL_BIN_DIR}/krb5_64.dll
  161. ${GDAL_BIN_DIR}/comerr64.dll
  162. ${GDAL_BIN_DIR}/k5sprt64.dll
  163. ${GDAL_BIN_DIR}/libdeflate.dll
  164. ${GDAL_BIN_DIR}/jbig.dll
  165. ${GDAL_BIN_DIR}/Lerc.dll
  166. ${GDAL_BIN_DIR}/poppler.dll
  167. ${GDAL_BIN_DIR}/libwebp.dll
  168. ${GDAL_BIN_DIR}/lcms2.dll
  169. # for pdal
  170. #${GDAL_BIN_DIR}/laszip3.dll
  171. )
  172. elseif (GDAL_VERSION_3)
  173. set ( GDAL_DEP_DLL_FILES ${GDAL_BIN_DIR}/ogdi.dll
  174. ${GDAL_BIN_DIR}/expat.dll
  175. ${GDAL_BIN_DIR}/libpq.dll
  176. ${GDAL_BIN_DIR}/szip.dll
  177. ${GDAL_BIN_DIR}/netcdf.dll
  178. ${GDAL_BIN_DIR}/sqlite3.dll
  179. ${GDAL_BIN_DIR}/spatialite.dll
  180. ${GDAL_BIN_DIR}/libmysql.dll
  181. ${GDAL_BIN_DIR}/geos.dll
  182. ${GDAL_BIN_DIR}/geos_c.dll
  183. ${GDAL_BIN_DIR}/libcurl.dll
  184. ${GDAL_BIN_DIR}/libpng16.dll
  185. ${GDAL_BIN_DIR}/liblzma.dll
  186. ${GDAL_BIN_DIR}/openjp2.dll
  187. ${GDAL_BIN_DIR}/proj_6_3.dll
  188. ${GDAL_BIN_DIR}/zstd.dll
  189. ${GDAL_BIN_DIR}/iconv-2.dll
  190. ${GDAL_BIN_DIR}/iconv.dll
  191. ${GDAL_BIN_DIR}/freexl.dll
  192. ${GDAL_BIN_DIR}/zlib1.dll
  193. ${GDAL_BIN_DIR}/libssl-1_1-x64.dll
  194. ${GDAL_BIN_DIR}/libcrypto-1_1-x64.dll
  195. ${GDAL_BIN_DIR}/hdf5_hl.dll
  196. ${GDAL_BIN_DIR}/hdf5.dll
  197. ${GDAL_BIN_DIR}/libxml2.dll
  198. ${GDAL_BIN_DIR}/lwgeom.dll
  199. ${GDAL_BIN_DIR}/xerces-c_3_2.dll
  200. )
  201. else()
  202. set ( GDAL_DEP_DLL_FILES ${GDAL_BIN_DIR}/expat.dll
  203. ${GDAL_BIN_DIR}/libpq.dll
  204. ${GDAL_BIN_DIR}/szip.dll
  205. ${GDAL_BIN_DIR}/netcdf.dll
  206. ${GDAL_BIN_DIR}/sqlite3.dll
  207. ${GDAL_BIN_DIR}/spatialite.dll
  208. ${GDAL_BIN_DIR}/libmysql.dll
  209. ${GDAL_BIN_DIR}/geos.dll
  210. ${GDAL_BIN_DIR}/geos_c.dll
  211. ${GDAL_BIN_DIR}/libcurl.dll
  212. ${GDAL_BIN_DIR}/openjp2.dll
  213. ${GDAL_BIN_DIR}/proj.dll
  214. ${GDAL_BIN_DIR}/iconv.dll
  215. ${GDAL_BIN_DIR}/freexl.dll
  216. ${GDAL_BIN_DIR}/zlib1.dll
  217. ${GDAL_BIN_DIR}/hdf5_hl.dll
  218. ${GDAL_BIN_DIR}/hdf5.dll
  219. ${GDAL_BIN_DIR}/libxml2.dll
  220. ${GDAL_BIN_DIR}/xerces-c_3_1.dll
  221. ${GDAL_BIN_DIR}/ssleay32.dll
  222. ${GDAL_BIN_DIR}/libeay32.dll
  223. )
  224. endif()
  225. #message( STATUS ${GDAL_DLL_FILES} )
  226. #message( STATUS ${GDAL_DEP_DLL_FILES} )
  227. copy_files("${GDAL_DLL_FILES}" "${CLOUDCOMPARE_DEST_FOLDER}" 1 ) #mind the quotes!
  228. copy_files("${GDAL_DEP_DLL_FILES}" "${CLOUDCOMPARE_DEST_FOLDER}" 1 ) #mind the quotes!
  229. if (${OPTION_BUILD_CCVIEWER})
  230. copy_files("${GDAL_DLL_FILES}" "${CCVIEWER_DEST_FOLDER}" 1 ) #mind the quotes!
  231. copy_files("${GDAL_DEP_DLL_FILES}" "${CCVIEWER_DEST_FOLDER}" 1 ) #mind the quotes!
  232. endif()
  233. endif()
  234. endfunction()