Skip to content

Commit

Permalink
add missing version numbers to Mac framework detection
Browse files Browse the repository at this point in the history
  • Loading branch information
kyngchaos committed May 29, 2011
1 parent d61e6d5 commit 89e9958
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
14 changes: 13 additions & 1 deletion cmake/FindGDAL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# GDAL_INCLUDE_DIR = where to find headers


INCLUDE (@CMAKE_SOURCE_DIR@/cmake/MacPlistMacros.cmake)

IF(WIN32)

Expand Down Expand Up @@ -49,7 +50,18 @@ ELSE(WIN32)
IF (GDAL_LIBRARY)
# they're all the same in a framework
SET (GDAL_INCLUDE_DIR ${GDAL_LIBRARY}/Headers CACHE PATH "Path to a file.")
SET (GDAL_CONFIG ${GDAL_LIBRARY}/Programs/geos-config CACHE FILEPATH "Path to a program.")
# set GDAL_CONFIG to make later test happy, not used here, may not exist
SET (GDAL_CONFIG ${GDAL_LIBRARY}/unix/bin/gdal-config CACHE FILEPATH "Path to a program.")
# version in info.plist
GET_VERSION_PLIST (${GDAL_LIBRARY}/Resources/Info.plist GDAL_VERSION)
IF (NOT GDAL_VERSION)
MESSAGE (FATAL_ERROR "Could not determine GDAL version from framework.")
ENDIF (NOT GDAL_VERSION)
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1" GDAL_VERSION_MAJOR "${GDAL_VERSION}")
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\2" GDAL_VERSION_MINOR "${GDAL_VERSION}")
IF (GDAL_VERSION_MAJOR LESS 1 OR GDAL_VERSION_MINOR LESS 4)
MESSAGE (FATAL_ERROR "GDAL version is too old (${GDAL_VERSION}). Use 1.4.0 or higher.")
ENDIF (GDAL_VERSION_MAJOR LESS 1 OR GDAL_VERSION_MINOR LESS 4)
ENDIF (GDAL_LIBRARY)
SET (CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_save} CACHE STRING "" FORCE)
ENDIF ()
Expand Down
14 changes: 13 additions & 1 deletion cmake/FindGEOS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# GEOS_LIBRARY
#

INCLUDE (@CMAKE_SOURCE_DIR@/cmake/MacPlistMacros.cmake)

IF(WIN32)

Expand Down Expand Up @@ -54,7 +55,18 @@ ELSE(WIN32)
IF (GEOS_LIBRARY)
# they're all the same in a framework
SET (GEOS_INCLUDE_DIR ${GEOS_LIBRARY}/Headers CACHE PATH "Path to a file.")
SET (GEOS_CONFIG ${GEOS_LIBRARY}/Programs/geos-config CACHE FILEPATH "Path to a program.")
# set GEOS_CONFIG to make later test happy, not used here, may not exist
SET (GEOS_CONFIG ${GEOS_LIBRARY}/unix/bin/geos-config CACHE FILEPATH "Path to a program.")
# version in info.plist
GET_VERSION_PLIST (${GEOS_LIBRARY}/Resources/Info.plist GEOS_VERSION)
IF (NOT GEOS_VERSION)
MESSAGE (FATAL_ERROR "Could not determine GEOS version from framework.")
ENDIF (NOT GEOS_VERSION)
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1" GEOS_VERSION_MAJOR "${GEOS_VERSION}")
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\2" GEOS_VERSION_MINOR "${GEOS_VERSION}")
IF (GEOS_VERSION_MAJOR LESS 3)
MESSAGE (FATAL_ERROR "GEOS version is too old (${GEOS_VERSION}). Use 3.0.0 or higher.")
ENDIF (GEOS_VERSION_MAJOR LESS 3)
ENDIF (GEOS_LIBRARY)
SET (CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_save} CACHE STRING "" FORCE)
ENDIF ()
Expand Down
12 changes: 12 additions & 0 deletions cmake/MacPlistMacros.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Mac Plist Macros

FUNCTION (GET_VERSION_PLIST PLISTFILE OUTVAR)
SET (PVERSION "")
IF (EXISTS ${PLISTFILE})
FILE (READ "${PLISTFILE}" info_plist)
STRING (REGEX REPLACE "\n" "" info_plist "${info_plist}")
STRING (REGEX MATCH "<key>CFBundleShortVersionString</key>[ \t]*<string>([0-9\\.]*)</string>" PLISTVERSION "${info_plist}")
STRING (REGEX REPLACE "<key>CFBundleShortVersionString</key>[ \t]*<string>([0-9\\.]*)</string>" "\\1" PVERSION "${PLISTVERSION}")
ENDIF (EXISTS ${PLISTFILE})
SET (${OUTVAR} ${PVERSION} PARENT_SCOPE)
ENDFUNCTION (GET_VERSION_PLIST)

0 comments on commit 89e9958

Please sign in to comment.