Skip to content
Snippets Groups Projects
Commit 5fbe8c8c authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ENH: GeoTIFF version parsing

parent adac3852
No related branches found
No related tags found
No related merge requests found
......@@ -4,11 +4,32 @@
# GEOTIFF_FOUND - True if GEOTIFF found.
# GEOTIFF_INCLUDE_DIRS - where to find geotiff.h
# GEOTIFF_LIBRARIES - List of libraries to link when using GEOTIFF.
# GEOTIFF_VERSION - version string
# GEOTIFF_VERSION_MAJOR - version major number
# GEOTIFF_VERSION_MINOR - version minor number
# GEOTIFF_VERSION_PATCH - version patch number
# GEOTIFF_VERSION_NUMBER - version number ((major*100)+minor)*100+patch
#
find_path( GEOTIFF_INCLUDE_DIR geotiff.h
PATH_SUFFIXES geotiff libgeotiff )
if(EXISTS "${GEOTIFF_INCLUDE_DIR}/geotiff.h")
file(READ "${GEOTIFF_INCLUDE_DIR}/geotiff.h" _geotiff_h_CONTENTS)
string(REGEX REPLACE ".*# *define +LIBGEOTIFF_VERSION +([0-9])([0-9])([0-9])([0-9]).*" "\\1" GEOTIFF_VERSION_MAJOR "${_geotiff_h_CONTENTS}")
string(REGEX REPLACE ".*# *define +LIBGEOTIFF_VERSION +([0-9])([0-9])([0-9])([0-9]).*" "\\2" GEOTIFF_VERSION_MINOR "${_geotiff_h_CONTENTS}")
string(REGEX REPLACE ".*# *define +LIBGEOTIFF_VERSION +([0-9])([0-9])([0-9])([0-9]).*" "\\3" GEOTIFF_VERSION_PATCH "${_geotiff_h_CONTENTS}")
set(GEOTIFF_VERSION "${GEOTIFF_VERSION_MAJOR}.${GEOTIFF_VERSION_MINOR}.${GEOTIFF_VERSION_PATCH}")
math(EXPR GEOTIFF_VERSION_NUMBER
"((${GEOTIFF_VERSION_MAJOR})*100+${GEOTIFF_VERSION_MINOR})*100+${GEOTIFF_VERSION_PATCH}")
else()
if(NOT GEOTIFF_FIND_QUIETLY)
message(WARNING "geotiff.h not found !")
endif()
endif()
set( GEOTIFF_NAMES ${GEOTIFF_NAMES} geotiff_i geotiff libgeotiff_i libgeotiff )
find_library( GEOTIFF_LIBRARY NAMES ${GEOTIFF_NAMES} )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment