Skip to content
Permalink
Browse files

proj5: show proj version qgis was built with and the version it's run…

…ning with
  • Loading branch information
jef-n committed Feb 19, 2018
1 parent e5c9092 commit 39cb0fbfd00e15bf38a8a7ae764f5bd526fe44e9
Showing with 142 additions and 133 deletions.
  1. +57 −57 cmake/FindExpat.cmake
  2. +69 −66 cmake/FindProj.cmake
  3. +4 −0 src/app/CMakeLists.txt
  4. +12 −10 src/app/qgisapp.cpp
@@ -1,57 +1,57 @@
# Find Expat
# ~~~~~~~~~~
# Copyright (c) 2007, Martin Dobias <wonder.sk at gmail.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# CMake module to search for Expat library
# (library for parsing XML files)
#
# If it's found it sets EXPAT_FOUND to TRUE
# and following variables are set:
# EXPAT_INCLUDE_DIR
# EXPAT_LIBRARY

# FIND_PATH and FIND_LIBRARY normally search standard locations
# before the specified paths. To search non-standard paths first,
# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
# and then again with no specified paths to search the default
# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
# searching for the same item do nothing.
FIND_PATH(EXPAT_INCLUDE_DIR expat.h
"$ENV{LIB_DIR}/include/"
"$ENV{LIB_DIR}/include/expat"
c:/msys/local/include
NO_DEFAULT_PATH
)
FIND_PATH(EXPAT_INCLUDE_DIR expat.h)
#libexpat needed for msvc version
FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat PATHS
"$ENV{LIB_DIR}/lib"
c:/msys/local/lib
NO_DEFAULT_PATH
)
FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat)

IF (EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)
SET(EXPAT_FOUND TRUE)
ENDIF (EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)


IF (EXPAT_FOUND)

IF (NOT EXPAT_FIND_QUIETLY)
MESSAGE(STATUS "Found Expat: ${EXPAT_LIBRARY}")
ENDIF (NOT EXPAT_FIND_QUIETLY)

ELSE (EXPAT_FOUND)

IF (EXPAT_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Expat")
ELSE (EXPAT_FIND_REQUIRED)
IF (NOT EXPAT_FIND_QUIETLY)
MESSAGE(STATUS "Could not find Expat")
ENDIF (NOT EXPAT_FIND_QUIETLY)
ENDIF (EXPAT_FIND_REQUIRED)

ENDIF (EXPAT_FOUND)
# Find Expat
# ~~~~~~~~~~
# Copyright (c) 2007, Martin Dobias <wonder.sk at gmail.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# CMake module to search for Expat library
# (library for parsing XML files)
#
# If it's found it sets EXPAT_FOUND to TRUE
# and following variables are set:
# EXPAT_INCLUDE_DIR
# EXPAT_LIBRARY

# FIND_PATH and FIND_LIBRARY normally search standard locations
# before the specified paths. To search non-standard paths first,
# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
# and then again with no specified paths to search the default
# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
# searching for the same item do nothing.
FIND_PATH(EXPAT_INCLUDE_DIR expat.h
"$ENV{LIB_DIR}/include/"
"$ENV{LIB_DIR}/include/expat"
c:/msys/local/include
NO_DEFAULT_PATH
)
FIND_PATH(EXPAT_INCLUDE_DIR expat.h)
#libexpat needed for msvc version
FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat PATHS
"$ENV{LIB_DIR}/lib"
c:/msys/local/lib
NO_DEFAULT_PATH
)
FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat)

IF (EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)
SET(EXPAT_FOUND TRUE)
ENDIF (EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)


IF (EXPAT_FOUND)

IF (NOT EXPAT_FIND_QUIETLY)
MESSAGE(STATUS "Found Expat: ${EXPAT_LIBRARY}")
ENDIF (NOT EXPAT_FIND_QUIETLY)

ELSE (EXPAT_FOUND)

IF (EXPAT_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Expat")
ELSE (EXPAT_FIND_REQUIRED)
IF (NOT EXPAT_FIND_QUIETLY)
MESSAGE(STATUS "Could not find Expat")
ENDIF (NOT EXPAT_FIND_QUIETLY)
ENDIF (EXPAT_FIND_REQUIRED)

ENDIF (EXPAT_FOUND)
@@ -1,66 +1,69 @@
# Find Proj
# ~~~~~~~~~
# Copyright (c) 2007, Martin Dobias <wonder.sk at gmail.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# CMake module to search for Proj library
#
# If it's found it sets PROJ_FOUND to TRUE
# and following variables are set:
# PROJ_INCLUDE_DIR
# PROJ_LIBRARY

# FIND_PATH and FIND_LIBRARY normally search standard locations
# before the specified paths. To search non-standard paths first,
# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
# and then again with no specified paths to search the default
# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
# searching for the same item do nothing.

# try to use framework on mac
# want clean framework path, not unix compatibility path
IF (APPLE)
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_PATH(PROJ_INCLUDE_DIR PROJ/proj_api.h)
FIND_LIBRARY(PROJ_LIBRARY PROJ)
IF (PROJ_LIBRARY)
# FIND_PATH doesn't add "Headers" for a framework
SET (PROJ_INCLUDE_DIR ${PROJ_LIBRARY}/Headers CACHE PATH "Path to a file.")
ENDIF (PROJ_LIBRARY)
SET (CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_save} CACHE STRING "" FORCE)
ENDIF ()
ENDIF (APPLE)

FIND_PATH(PROJ_INCLUDE_DIR proj_api.h
"$ENV{INCLUDE}"
"$ENV{LIB_DIR}/include"
)

FIND_LIBRARY(PROJ_LIBRARY NAMES proj_i proj PATHS
"$ENV{LIB}"
"$ENV{LIB_DIR}/lib"
)

IF (PROJ_INCLUDE_DIR AND PROJ_LIBRARY)
SET(PROJ_FOUND TRUE)
ENDIF (PROJ_INCLUDE_DIR AND PROJ_LIBRARY)


IF (PROJ_FOUND)

IF (NOT PROJ_FIND_QUIETLY)
MESSAGE(STATUS "Found Proj: ${PROJ_LIBRARY}")
ENDIF (NOT PROJ_FIND_QUIETLY)

ELSE (PROJ_FOUND)

IF (PROJ_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Proj")
ENDIF (PROJ_FIND_REQUIRED)

ENDIF (PROJ_FOUND)
# Find Proj
# ~~~~~~~~~
# Copyright (c) 2007, Martin Dobias <wonder.sk at gmail.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# CMake module to search for Proj library
#
# If it's found it sets PROJ_FOUND to TRUE
# and following variables are set:
# PROJ_INCLUDE_DIR
# PROJ_LIBRARY

# FIND_PATH and FIND_LIBRARY normally search standard locations
# before the specified paths. To search non-standard paths first,
# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
# and then again with no specified paths to search the default
# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
# searching for the same item do nothing.

# try to use framework on mac
# want clean framework path, not unix compatibility path
IF (APPLE)
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_PATH(PROJ_INCLUDE_DIR PROJ/proj_api.h)
FIND_LIBRARY(PROJ_LIBRARY PROJ)
IF (PROJ_LIBRARY)
# FIND_PATH doesn't add "Headers" for a framework
SET (PROJ_INCLUDE_DIR ${PROJ_LIBRARY}/Headers CACHE PATH "Path to a file.")
ENDIF (PROJ_LIBRARY)
SET (CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_save} CACHE STRING "" FORCE)
ENDIF ()
ENDIF (APPLE)

FIND_PATH(PROJ_INCLUDE_DIR proj_api.h
"$ENV{INCLUDE}"
"$ENV{LIB_DIR}/include"
)

FIND_LIBRARY(PROJ_LIBRARY NAMES proj_i proj PATHS
"$ENV{LIB}"
"$ENV{LIB_DIR}/lib"
)

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 (NOT PROJ_FIND_QUIETLY)
MESSAGE(STATUS "Found Proj: ${PROJ_LIBRARY}")
ENDIF (NOT PROJ_FIND_QUIETLY)

ELSE (PROJ_FOUND)

IF (PROJ_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Proj")
ENDIF (PROJ_FIND_REQUIRED)

ENDIF (PROJ_FOUND)
@@ -497,6 +497,10 @@ IF (POSTGRES_FOUND)
ENDIF(HAVE_PGCONFIG)
ENDIF (POSTGRES_FOUND)

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

SET(IMAGE_RCCS ../../images/images.qrc)

QT5_ADD_RESOURCES(IMAGE_RCC_SRCS ${IMAGE_RCCS})
@@ -325,6 +325,9 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
//
#include <ogr_api.h>
#include <gdal_version.h>
#ifdef PROJ_HAS_INFO

This comment has been minimized.

Copy link
@slarosa

slarosa Mar 15, 2018

Member

building on MacOS with proj5 I get the following build error.

removing #ifdef PROJ_HAS_INFOcheck it builds fine, but I don't understand why it is not set correctly from FindProj.cmake

Build Error:

[ 71%] Building CXX object src/app/CMakeFiles/qgis_app.dir/qgisapp.cpp.o
/Users/slarosa/dev/qgis-src/QGIS/src/app/qgisapp.cpp:4174:5: error: unknown type name 'PJ_INFO'
    PJ_INFO info = proj_info();
    ^
/Users/slarosa/dev/qgis-src/QGIS/src/app/qgisapp.cpp:4174:20: error: use of undeclared identifier 'proj_info'
    PJ_INFO info = proj_info();
                   ^
2 errors generated.
make[2]: *** [src/app/CMakeFiles/qgis_app.dir/qgisapp.cpp.o] Error 1
make[1]: *** [src/app/CMakeFiles/qgis_app.dir/all] Error 2
#include <proj.h>
#endif
#include <proj_api.h>

//
@@ -4112,22 +4115,21 @@ void QgisApp::about()

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

#if PJ_VERSION >= 500
versionString += "<td>" + tr( "Compiled against PROJ" ) + "</td><td>" + QString::number( PJ_VERSION ) + "</td>";
versionString += "<td>" + tr( "Running against PROJ" ) + "</td><td>" + proj_info() + "</td>";
#else
versionString += "<td colspan=2>" + tr( "PROJ.4 Version" ) + "</td><td>" + QString::number( PJ_VERSION ) + "</td>";
#endif

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

versionString += "<td>" + tr( "QWT Version" ) + "</td><td>" + QWT_VERSION_STR + "</td>";
versionString += "<td>" + tr( "QScintilla2 Version" ) + "</td><td>" + QSCINTILLA_VERSION_STR + "</td>";

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

#if PJ_VERSION >= 500
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>";
#else
versionString += "<td>" + tr( "PROJ.4 Version" ) + "</td><td colspan=3>" + QString::number( PJ_VERSION ) + "</td>";
#endif

#ifdef QGISDEBUG
versionString += "<td colspan=2>" + tr( "This copy of QGIS writes debugging output." ) + "</td>";
versionString += "</tr><tr><td colspan=4>" + tr( "This copy of QGIS writes debugging output." ) + "</td>";
#endif

versionString += QLatin1String( "</tr></table></div></body></html>" );

0 comments on commit 39cb0fb

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