Skip to content
Permalink
Browse files

More flexible proj version handling

Sponsored by ICSM
  • Loading branch information
nyalldawson committed Mar 18, 2019
1 parent 41e0c01 commit ad7e8eac74996e2474c5515c3d4609a1a00be1d1
Showing with 14 additions and 19 deletions.
  1. +12 −13 cmake/FindProj.cmake
  2. +0 −4 src/app/CMakeLists.txt
  3. +2 −2 src/app/qgisapp.cpp
@@ -50,23 +50,22 @@ IF (PROJ_INCLUDE_DIR AND PROJ_LIBRARY)
SET(PROJ_FOUND TRUE)
ENDIF (PROJ_INCLUDE_DIR AND PROJ_LIBRARY)


IF (PROJ_FOUND)
# This macro checks if the symbol exists
include(CheckLibraryExists)
check_library_exists("${PROJ_LIBRARY}" proj_info "" PROJ_HAS_INFO)

IF (EXISTS ${PROJ_INCLUDE_DIR}/proj.h)
FILE(READ ${PROJ_INCLUDE_DIR}/proj.h proj_version)
STRING(REGEX REPLACE "^.*PROJ_VERSION_MAJOR +([0-9]+).*$" "\\1" PROJ_VERSION_MAJOR "${proj_version}")
STRING(REGEX REPLACE "^.*PROJ_VERSION_MINOR +([0-9]+).*$" "\\1" PROJ_VERSION_MINOR "${proj_version}")
STRING(REGEX REPLACE "^.*PROJ_VERSION_PATCH +([0-9]+).*$" "\\1" PROJ_VERSION_PATCH "${proj_version}")
STRING(CONCAT PROJ_VERSION_STR "(" ${PROJ_VERSION_MAJOR} "." ${PROJ_VERSION_MINOR} "." ${PROJ_VERSION_PATCH} ")")
ELSE(EXISTS)
SET(PROJ_VERSION_MAJOR 4)
ENDIF (EXISTS)
IF (NOT PROJ_FIND_QUIETLY)
IF (PROJ_HAS_INFO)
FILE(READ ${PROJ_INCLUDE_DIR}/proj.h proj_version)
STRING(REGEX REPLACE "^.*PROJ_VERSION_MAJOR +([0-9]+).*$" "\\1" PROJ_VERSION_MAJOR "${proj_version}")
STRING(REGEX REPLACE "^.*PROJ_VERSION_MINOR +([0-9]+).*$" "\\1" PROJ_VERSION_MINOR "${proj_version}")
STRING(REGEX REPLACE "^.*PROJ_VERSION_PATCH +([0-9]+).*$" "\\1" PROJ_VERSION_PATCH "${proj_version}")
STRING(CONCAT PROJ_VERSION_STR "(" ${PROJ_VERSION_MAJOR} "." ${PROJ_VERSION_MINOR} "." ${PROJ_VERSION_PATCH} ")")
ENDIF (PROJ_HAS_INFO)
MESSAGE(STATUS "Found Proj: ${PROJ_LIBRARY} ${PROJ_VERSION_STR}")
MESSAGE(STATUS "Found Proj: ${PROJ_LIBRARY} version ${PROJ_VERSION_MAJOR} ${PROJ_VERSION_STR}")
ENDIF (NOT PROJ_FIND_QUIETLY)

ADD_DEFINITIONS(-DPROJ_VERSION_MAJOR=${PROJ_VERSION_MAJOR})

ELSE (PROJ_FOUND)

IF (PROJ_FIND_REQUIRED)
@@ -581,10 +581,6 @@ IF (POSTGRES_FOUND)
ENDIF(HAVE_PGCONFIG)
ENDIF (POSTGRES_FOUND)

IF (PROJ_HAS_INFO)
ADD_DEFINITIONS(-DPROJ_HAS_INFO)
ENDIF (PROJ_HAS_INFO)

# Test data dir for QgsAppScreenShots
ADD_DEFINITIONS(-DTEST_DATA_DIR="${TEST_DATA_DIR}")

@@ -352,7 +352,7 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
//
#include <ogr_api.h>
#include <gdal_version.h>
#ifdef PROJ_HAS_INFO
#if PROJ_VERSION_MAJOR > 4
#include <proj.h>
#endif
#ifndef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
@@ -4509,7 +4509,7 @@ void QgisApp::about()

versionString += QLatin1String( "</tr><tr>" );

#ifdef PROJ_HAS_INFO
#if PROJ_VERSION_MAJOR > 4
PJ_INFO info = proj_info();
versionString += "<td>" + tr( "Compiled against PROJ" ) + "</td><td>" + QString::number( PJ_VERSION ) + "</td>";
versionString += "<td>" + tr( "Running against PROJ" ) + "</td><td>" + info.version + "</td>";

0 comments on commit ad7e8ea

Please sign in to comment.
You can’t perform that action at this time.