Skip to content

Commit

Permalink
Mac cmake update:
Browse files Browse the repository at this point in the history
cleaner framework detection;
optional bundle Qt/PyQt and libraries, and fixup paths

git-svn-id: http://svn.osgeo.org/qgis/trunk@14458 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
kyngchaos committed Oct 30, 2010
1 parent da26890 commit be17b00
Show file tree
Hide file tree
Showing 19 changed files with 929 additions and 237 deletions.
53 changes: 46 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ SET(COMPLETE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINO
SET(RELEASE_NAME "Trunk")
SET(PROJECT_VERSION ${COMPLETE_VERSION})
PROJECT(qgis${PROJECT_VERSION})
IF (APPLE)
SET(QGIS_APP_NAME "QGIS")
ELSE (APPLE)
SET(QGIS_APP_NAME "qgis")
ENDIF (APPLE)

# Note the version no is Mmmpp for Major/minor/patch, 0-padded, thus '10100' for 1.1.0
MATH(EXPR QGIS_VERSION_INT "${CPACK_PACKAGE_VERSION_MAJOR}*10000+${CPACK_PACKAGE_VERSION_MINOR}*100+${CPACK_PACKAGE_VERSION_PATCH}")
Expand Down Expand Up @@ -268,21 +273,51 @@ ELSE (WIN32)

IF (APPLE)
# for Mac OS X, everything is put inside an application bundle
SET (CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents/MacOS)
SET (QGIS_MACAPP_PREFIX ${CMAKE_INSTALL_PREFIX}/${QGIS_APP_NAME}.app/Contents)
SET (CMAKE_INSTALL_PREFIX ${QGIS_MACAPP_PREFIX}/MacOS)
# path for library references
SET (CMAKE_INSTALL_NAME_DIR @executable_path/lib)
# 4 bundling levels, each includes previous
# 0 nothing
# 1 Qt frameworks
# 2 non-system libraries, "standard"
# 3 non-system frameworks, "standalone"
SET (QGIS_MACAPP_BUNDLE 0 CACHE STRING "What to bundle into app package")
# if we have @loader_path, >=OSX 10.5 (darwin 9+)
IF (CMAKE_SYSTEM_VERSION VERSION_GREATER 9.0.0 OR CMAKE_SYSTEM_VERSION VERSION_EQUAL 9.0.0)
SET (OSX_HAVE_LOADERPATH 1)
ELSE ()
SET (OSX_HAVE_LOADERPATH 0)
ENDIF ()
#this will define ${APP_SERVICES_LIBRARY}
FIND_LIBRARY(APP_SERVICES_LIBRARY ApplicationServices )
ENDIF (APPLE)

# common for MAC and UNIX
SET (DEFAULT_BIN_SUBDIR bin)
SET (QGIS_BIN_SUBDIR_REV ..)
SET (DEFAULT_CGIBIN_SUBDIR fcgi-bin)
SET (QGIS_CGIBIN_SUBDIR_REV ..)
SET (DEFAULT_LIB_SUBDIR lib)
SET (QGIS_LIB_SUBDIR_REV ..)
SET (QGIS_FW_SUBDIR ../Frameworks)
SET (QGIS_FW_SUBDIR_REV ../MacOS)
SET (DEFAULT_DATA_SUBDIR ../Resources)
SET (QGIS_DATA_SUBDIR_REV ../MacOS)
SET (DEFAULT_LIBEXEC_SUBDIR lib/qgis)
SET (QGIS_LIBEXEC_SUBDIR_REV ../..)
SET (DEFAULT_PLUGIN_SUBDIR ../PlugIns/qgis)
SET (QGIS_PLUGIN_SUBDIR_REV ../../MacOS)
SET (DEFAULT_INCLUDE_SUBDIR include/qgis)

ELSE (APPLE)
# UNIX
SET (DEFAULT_BIN_SUBDIR bin)
SET (DEFAULT_CGIBIN_SUBDIR bin)
SET (DEFAULT_LIB_SUBDIR lib${LIB_SUFFIX})
SET (DEFAULT_DATA_SUBDIR share/qgis)
SET (DEFAULT_LIBEXEC_SUBDIR lib${LIB_SUFFIX}/qgis)
SET (DEFAULT_PLUGIN_SUBDIR lib${LIB_SUFFIX}/qgis/plugins)
SET (DEFAULT_INCLUDE_SUBDIR include/qgis)
ENDIF (APPLE)

ENDIF (WIN32)

Expand Down Expand Up @@ -334,7 +369,7 @@ SET (QGIS_INCLUDE_SUBDIR ${DEFAULT_INCLUDE_SUBDIR} CACHE STRING "Subdirectory wh

# mark *_SUBDIR variables as advanced as this is not something
# that an average user would use
MARK_AS_ADVANCED (QGIS_BIN_SUBDIR QGIS_LIB_SUBDIR QGIS_LIBEXEC_SUBDIR QGIS_DATA_SUBDIR QGIS_PLUGIN_SUBDIR QGIS_INCLUDE_SUBDIR)
MARK_AS_ADVANCED (QGIS_BIN_SUBDIR QGIS_CGIBIN_SUBDIR QGIS_LIB_SUBDIR QGIS_LIBEXEC_SUBDIR QGIS_DATA_SUBDIR QGIS_PLUGIN_SUBDIR QGIS_INCLUDE_SUBDIR)

# full paths for the installation
SET (QGIS_BIN_DIR ${QGIS_BIN_SUBDIR})
Expand Down Expand Up @@ -442,18 +477,22 @@ IF (ENABLE_TESTS)
SUBDIRS(tests)
ENDIF (ENABLE_TESTS)

IF (APPLE)
# must be last for install, so install_name_tool can do its work
SUBDIRS (mac)
ENDIF (APPLE)

#############################################################
# install stuff

INSTALL (FILES AUTHORS CONTRIBUTORS SPONSORS DONORS TRANSLATORS INSTALL CODING
DESTINATION ${QGIS_DATA_DIR}/doc)

# manual page - makes sense only on unix systems
IF (UNIX)
IF (UNIX AND NOT APPLE)
INSTALL (FILES qgis.1 qgis_help.1
DESTINATION ${QGIS_MANUAL_DIR}/man1)
ENDIF (UNIX)

ENDIF (UNIX AND NOT APPLE)

#############################################################
# Uninstall stuff see: http://www.vtk.org/Wiki/CMake_FAQ
Expand Down
168 changes: 91 additions & 77 deletions cmake/FindGDAL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,98 +38,112 @@ ELSE(WIN32)
IF(UNIX)

# try to use framework on mac
# want clean framework path, not unix compatibility path
IF (APPLE)
SET (GDAL_MAC_PATH /Library/Frameworks/GDAL.framework/Programs)
IF (CMAKE_FIND_FRAMEWORK MATCHES "FIRST"
OR CMAKE_FRAMEWORK_PATH MATCHES "ONLY"
OR NOT CMAKE_FIND_FRAMEWORK)
SET (CMAKE_FIND_FRAMEWORK_save ${CMAKE_FIND_FRAMEWORK} CACHE STRING "" FORCE)
SET (CMAKE_FIND_FRAMEWORK "ONLY" CACHE STRING "" FORCE)
FIND_LIBRARY(GDAL_LIBRARY GDAL)
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.")
ENDIF (GDAL_LIBRARY)
SET (CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_save} CACHE STRING "" FORCE)
ENDIF ()
ENDIF (APPLE)

SET(GDAL_CONFIG_PREFER_PATH "$ENV{GDAL_HOME}/bin" CACHE STRING "preferred path to GDAL (gdal-config)")
SET(GDAL_CONFIG_PREFER_FWTOOLS_PATH "$ENV{FWTOOLS_HOME}/bin_safe" CACHE STRING "preferred path to GDAL (gdal-config) from FWTools")
FIND_PROGRAM(GDAL_CONFIG gdal-config
${GDAL_CONFIG_PREFER_PATH}
${GDAL_CONFIG_PREFER_FWTOOLS_PATH}
${GDAL_MAC_PATH}
/usr/local/bin/
/usr/bin/
)
# MESSAGE("DBG GDAL_CONFIG ${GDAL_CONFIG}")
IF (NOT GDAL_INCLUDE_DIR AND NOT GDAL_LIBRARY AND NOT GDAL_CONFIG)
# didn't find OS X framework, and was not set by user
SET(GDAL_CONFIG_PREFER_PATH "$ENV{GDAL_HOME}/bin" CACHE STRING "preferred path to GDAL (gdal-config)")
SET(GDAL_CONFIG_PREFER_FWTOOLS_PATH "$ENV{FWTOOLS_HOME}/bin_safe" CACHE STRING "preferred path to GDAL (gdal-config) from FWTools")
FIND_PROGRAM(GDAL_CONFIG gdal-config
${GDAL_CONFIG_PREFER_PATH}
${GDAL_CONFIG_PREFER_FWTOOLS_PATH}
/usr/local/bin/
/usr/bin/
)
# MESSAGE("DBG GDAL_CONFIG ${GDAL_CONFIG}")

IF (GDAL_CONFIG)

## extract gdal version
EXEC_PROGRAM(${GDAL_CONFIG}
ARGS --version
OUTPUT_VARIABLE 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_CONFIG)

## extract gdal version
EXEC_PROGRAM(${GDAL_CONFIG}
ARGS --version
OUTPUT_VARIABLE 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}")

# MESSAGE("DBG GDAL_VERSION ${GDAL_VERSION}")
# MESSAGE("DBG GDAL_VERSION_MAJOR ${GDAL_VERSION_MAJOR}")
# MESSAGE("DBG GDAL_VERSION_MINOR ${GDAL_VERSION_MINOR}")
# MESSAGE("DBG GDAL_VERSION ${GDAL_VERSION}")
# MESSAGE("DBG GDAL_VERSION_MAJOR ${GDAL_VERSION_MAJOR}")
# MESSAGE("DBG GDAL_VERSION_MINOR ${GDAL_VERSION_MINOR}")

# check for gdal version
# version 1.2.5 is known NOT to be supported (missing CPL_STDCALL macro)
# According to INSTALL, 1.4.0+ is required
IF (GDAL_VERSION_MAJOR LESS 1 OR GDAL_VERSION_MINOR LESS 4)
# check for gdal version
# version 1.2.5 is known NOT to be supported (missing CPL_STDCALL macro)
# According to INSTALL, 1.4.0+ is required
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)

# set INCLUDE_DIR to prefix+include
EXEC_PROGRAM(${GDAL_CONFIG}
ARGS --prefix
OUTPUT_VARIABLE GDAL_PREFIX)
#SET(GDAL_INCLUDE_DIR ${GDAL_PREFIX}/include CACHE STRING INTERNAL)
FIND_PATH(GDAL_INCLUDE_DIR
gdal.h
${GDAL_PREFIX}/include/gdal
${GDAL_PREFIX}/include
/usr/local/include
/usr/include
)

## extract link dirs for rpath
EXEC_PROGRAM(${GDAL_CONFIG}
ARGS --libs
OUTPUT_VARIABLE GDAL_CONFIG_LIBS )

## split off the link dirs (for rpath)
## use regular expression to match wildcard equivalent "-L*<endchar>"
## with <endchar> is a space or a semicolon
STRING(REGEX MATCHALL "[-][L]([^ ;])+"
GDAL_LINK_DIRECTORIES_WITH_PREFIX
"${GDAL_CONFIG_LIBS}" )
ENDIF (GDAL_VERSION_MAJOR LESS 1 OR GDAL_VERSION_MINOR LESS 4)

# set INCLUDE_DIR to prefix+include
EXEC_PROGRAM(${GDAL_CONFIG}
ARGS --prefix
OUTPUT_VARIABLE GDAL_PREFIX)
#SET(GDAL_INCLUDE_DIR ${GDAL_PREFIX}/include CACHE STRING INTERNAL)
FIND_PATH(GDAL_INCLUDE_DIR
gdal.h
${GDAL_PREFIX}/include/gdal
${GDAL_PREFIX}/include
/usr/local/include
/usr/include
)

## extract link dirs for rpath
EXEC_PROGRAM(${GDAL_CONFIG}
ARGS --libs
OUTPUT_VARIABLE GDAL_CONFIG_LIBS )

## split off the link dirs (for rpath)
## use regular expression to match wildcard equivalent "-L*<endchar>"
## with <endchar> is a space or a semicolon
STRING(REGEX MATCHALL "[-][L]([^ ;])+"
GDAL_LINK_DIRECTORIES_WITH_PREFIX
"${GDAL_CONFIG_LIBS}" )
# MESSAGE("DBG GDAL_LINK_DIRECTORIES_WITH_PREFIX=${GDAL_LINK_DIRECTORIES_WITH_PREFIX}")

## remove prefix -L because we need the pure directory for LINK_DIRECTORIES
## remove prefix -L because we need the pure directory for LINK_DIRECTORIES

IF (GDAL_LINK_DIRECTORIES_WITH_PREFIX)
STRING(REGEX REPLACE "[-][L]" "" GDAL_LINK_DIRECTORIES ${GDAL_LINK_DIRECTORIES_WITH_PREFIX} )
ENDIF (GDAL_LINK_DIRECTORIES_WITH_PREFIX)

## split off the name
## use regular expression to match wildcard equivalent "-l*<endchar>"
## with <endchar> is a space or a semicolon
STRING(REGEX MATCHALL "[-][l]([^ ;])+"
GDAL_LIB_NAME_WITH_PREFIX
"${GDAL_CONFIG_LIBS}" )
IF (GDAL_LINK_DIRECTORIES_WITH_PREFIX)
STRING(REGEX REPLACE "[-][L]" "" GDAL_LINK_DIRECTORIES ${GDAL_LINK_DIRECTORIES_WITH_PREFIX} )
ENDIF (GDAL_LINK_DIRECTORIES_WITH_PREFIX)

## split off the name
## use regular expression to match wildcard equivalent "-l*<endchar>"
## with <endchar> is a space or a semicolon
STRING(REGEX MATCHALL "[-][l]([^ ;])+"
GDAL_LIB_NAME_WITH_PREFIX
"${GDAL_CONFIG_LIBS}" )
# MESSAGE("DBG GDAL_LIB_NAME_WITH_PREFIX=${GDAL_LIB_NAME_WITH_PREFIX}")


## remove prefix -l because we need the pure name
## remove prefix -l because we need the pure name

IF (GDAL_LIB_NAME_WITH_PREFIX)
STRING(REGEX REPLACE "[-][l]" "" GDAL_LIB_NAME ${GDAL_LIB_NAME_WITH_PREFIX} )
ENDIF (GDAL_LIB_NAME_WITH_PREFIX)

IF (APPLE)
SET(GDAL_LIBRARY ${GDAL_LINK_DIRECTORIES}/lib${GDAL_LIB_NAME}.dylib CACHE STRING INTERNAL)
ELSE (APPLE)
SET(GDAL_LIBRARY ${GDAL_LINK_DIRECTORIES}/lib${GDAL_LIB_NAME}.so CACHE STRING INTERNAL)
ENDIF (APPLE)
IF (GDAL_LIB_NAME_WITH_PREFIX)
STRING(REGEX REPLACE "[-][l]" "" GDAL_LIB_NAME ${GDAL_LIB_NAME_WITH_PREFIX} )
ENDIF (GDAL_LIB_NAME_WITH_PREFIX)

IF (APPLE)
SET(GDAL_LIBRARY ${GDAL_LINK_DIRECTORIES}/lib${GDAL_LIB_NAME}.dylib CACHE STRING INTERNAL)
ELSE (APPLE)
SET(GDAL_LIBRARY ${GDAL_LINK_DIRECTORIES}/lib${GDAL_LIB_NAME}.so CACHE STRING INTERNAL)
ENDIF (APPLE)

ELSE(GDAL_CONFIG)
MESSAGE("FindGDAL.cmake: gdal-config not found. Please set it manually. GDAL_CONFIG=${GDAL_CONFIG}")
ENDIF(GDAL_CONFIG)

ELSE(GDAL_CONFIG)
MESSAGE("FindGDAL.cmake: gdal-config not found. Please set it manually. GDAL_CONFIG=${GDAL_CONFIG}")
ENDIF(GDAL_CONFIG)
ENDIF (NOT GDAL_INCLUDE_DIR AND NOT GDAL_LIBRARY AND NOT GDAL_CONFIG)
ENDIF(UNIX)
ENDIF(WIN32)

Expand Down
Loading

0 comments on commit be17b00

Please sign in to comment.