Skip to content

Commit 39cb0fb

Browse files
committedFeb 19, 2018
proj5: show proj version qgis was built with and the version it's running with
1 parent e5c9092 commit 39cb0fb

File tree

4 files changed

+142
-133
lines changed

4 files changed

+142
-133
lines changed
 

‎cmake/FindExpat.cmake

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
1-
# Find Expat
2-
# ~~~~~~~~~~
3-
# Copyright (c) 2007, Martin Dobias <wonder.sk at gmail.com>
4-
# Redistribution and use is allowed according to the terms of the BSD license.
5-
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
6-
#
7-
# CMake module to search for Expat library
8-
# (library for parsing XML files)
9-
#
10-
# If it's found it sets EXPAT_FOUND to TRUE
11-
# and following variables are set:
12-
# EXPAT_INCLUDE_DIR
13-
# EXPAT_LIBRARY
14-
15-
# FIND_PATH and FIND_LIBRARY normally search standard locations
16-
# before the specified paths. To search non-standard paths first,
17-
# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
18-
# and then again with no specified paths to search the default
19-
# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
20-
# searching for the same item do nothing.
21-
FIND_PATH(EXPAT_INCLUDE_DIR expat.h
22-
"$ENV{LIB_DIR}/include/"
23-
"$ENV{LIB_DIR}/include/expat"
24-
c:/msys/local/include
25-
NO_DEFAULT_PATH
26-
)
27-
FIND_PATH(EXPAT_INCLUDE_DIR expat.h)
28-
#libexpat needed for msvc version
29-
FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat PATHS
30-
"$ENV{LIB_DIR}/lib"
31-
c:/msys/local/lib
32-
NO_DEFAULT_PATH
33-
)
34-
FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat)
35-
36-
IF (EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)
37-
SET(EXPAT_FOUND TRUE)
38-
ENDIF (EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)
39-
40-
41-
IF (EXPAT_FOUND)
42-
43-
IF (NOT EXPAT_FIND_QUIETLY)
44-
MESSAGE(STATUS "Found Expat: ${EXPAT_LIBRARY}")
45-
ENDIF (NOT EXPAT_FIND_QUIETLY)
46-
47-
ELSE (EXPAT_FOUND)
48-
49-
IF (EXPAT_FIND_REQUIRED)
50-
MESSAGE(FATAL_ERROR "Could not find Expat")
51-
ELSE (EXPAT_FIND_REQUIRED)
52-
IF (NOT EXPAT_FIND_QUIETLY)
53-
MESSAGE(STATUS "Could not find Expat")
54-
ENDIF (NOT EXPAT_FIND_QUIETLY)
55-
ENDIF (EXPAT_FIND_REQUIRED)
56-
57-
ENDIF (EXPAT_FOUND)
1+
# Find Expat
2+
# ~~~~~~~~~~
3+
# Copyright (c) 2007, Martin Dobias <wonder.sk at gmail.com>
4+
# Redistribution and use is allowed according to the terms of the BSD license.
5+
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
6+
#
7+
# CMake module to search for Expat library
8+
# (library for parsing XML files)
9+
#
10+
# If it's found it sets EXPAT_FOUND to TRUE
11+
# and following variables are set:
12+
# EXPAT_INCLUDE_DIR
13+
# EXPAT_LIBRARY
14+
15+
# FIND_PATH and FIND_LIBRARY normally search standard locations
16+
# before the specified paths. To search non-standard paths first,
17+
# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
18+
# and then again with no specified paths to search the default
19+
# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
20+
# searching for the same item do nothing.
21+
FIND_PATH(EXPAT_INCLUDE_DIR expat.h
22+
"$ENV{LIB_DIR}/include/"
23+
"$ENV{LIB_DIR}/include/expat"
24+
c:/msys/local/include
25+
NO_DEFAULT_PATH
26+
)
27+
FIND_PATH(EXPAT_INCLUDE_DIR expat.h)
28+
#libexpat needed for msvc version
29+
FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat PATHS
30+
"$ENV{LIB_DIR}/lib"
31+
c:/msys/local/lib
32+
NO_DEFAULT_PATH
33+
)
34+
FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat)
35+
36+
IF (EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)
37+
SET(EXPAT_FOUND TRUE)
38+
ENDIF (EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)
39+
40+
41+
IF (EXPAT_FOUND)
42+
43+
IF (NOT EXPAT_FIND_QUIETLY)
44+
MESSAGE(STATUS "Found Expat: ${EXPAT_LIBRARY}")
45+
ENDIF (NOT EXPAT_FIND_QUIETLY)
46+
47+
ELSE (EXPAT_FOUND)
48+
49+
IF (EXPAT_FIND_REQUIRED)
50+
MESSAGE(FATAL_ERROR "Could not find Expat")
51+
ELSE (EXPAT_FIND_REQUIRED)
52+
IF (NOT EXPAT_FIND_QUIETLY)
53+
MESSAGE(STATUS "Could not find Expat")
54+
ENDIF (NOT EXPAT_FIND_QUIETLY)
55+
ENDIF (EXPAT_FIND_REQUIRED)
56+
57+
ENDIF (EXPAT_FOUND)

‎cmake/FindProj.cmake

Lines changed: 69 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,69 @@
1-
# Find Proj
2-
# ~~~~~~~~~
3-
# Copyright (c) 2007, Martin Dobias <wonder.sk at gmail.com>
4-
# Redistribution and use is allowed according to the terms of the BSD license.
5-
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
6-
#
7-
# CMake module to search for Proj library
8-
#
9-
# If it's found it sets PROJ_FOUND to TRUE
10-
# and following variables are set:
11-
# PROJ_INCLUDE_DIR
12-
# PROJ_LIBRARY
13-
14-
# FIND_PATH and FIND_LIBRARY normally search standard locations
15-
# before the specified paths. To search non-standard paths first,
16-
# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
17-
# and then again with no specified paths to search the default
18-
# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
19-
# searching for the same item do nothing.
20-
21-
# try to use framework on mac
22-
# want clean framework path, not unix compatibility path
23-
IF (APPLE)
24-
IF (CMAKE_FIND_FRAMEWORK MATCHES "FIRST"
25-
OR CMAKE_FRAMEWORK_PATH MATCHES "ONLY"
26-
OR NOT CMAKE_FIND_FRAMEWORK)
27-
SET (CMAKE_FIND_FRAMEWORK_save ${CMAKE_FIND_FRAMEWORK} CACHE STRING "" FORCE)
28-
SET (CMAKE_FIND_FRAMEWORK "ONLY" CACHE STRING "" FORCE)
29-
#FIND_PATH(PROJ_INCLUDE_DIR PROJ/proj_api.h)
30-
FIND_LIBRARY(PROJ_LIBRARY PROJ)
31-
IF (PROJ_LIBRARY)
32-
# FIND_PATH doesn't add "Headers" for a framework
33-
SET (PROJ_INCLUDE_DIR ${PROJ_LIBRARY}/Headers CACHE PATH "Path to a file.")
34-
ENDIF (PROJ_LIBRARY)
35-
SET (CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_save} CACHE STRING "" FORCE)
36-
ENDIF ()
37-
ENDIF (APPLE)
38-
39-
FIND_PATH(PROJ_INCLUDE_DIR proj_api.h
40-
"$ENV{INCLUDE}"
41-
"$ENV{LIB_DIR}/include"
42-
)
43-
44-
FIND_LIBRARY(PROJ_LIBRARY NAMES proj_i proj PATHS
45-
"$ENV{LIB}"
46-
"$ENV{LIB_DIR}/lib"
47-
)
48-
49-
IF (PROJ_INCLUDE_DIR AND PROJ_LIBRARY)
50-
SET(PROJ_FOUND TRUE)
51-
ENDIF (PROJ_INCLUDE_DIR AND PROJ_LIBRARY)
52-
53-
54-
IF (PROJ_FOUND)
55-
56-
IF (NOT PROJ_FIND_QUIETLY)
57-
MESSAGE(STATUS "Found Proj: ${PROJ_LIBRARY}")
58-
ENDIF (NOT PROJ_FIND_QUIETLY)
59-
60-
ELSE (PROJ_FOUND)
61-
62-
IF (PROJ_FIND_REQUIRED)
63-
MESSAGE(FATAL_ERROR "Could not find Proj")
64-
ENDIF (PROJ_FIND_REQUIRED)
65-
66-
ENDIF (PROJ_FOUND)
1+
# Find Proj
2+
# ~~~~~~~~~
3+
# Copyright (c) 2007, Martin Dobias <wonder.sk at gmail.com>
4+
# Redistribution and use is allowed according to the terms of the BSD license.
5+
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
6+
#
7+
# CMake module to search for Proj library
8+
#
9+
# If it's found it sets PROJ_FOUND to TRUE
10+
# and following variables are set:
11+
# PROJ_INCLUDE_DIR
12+
# PROJ_LIBRARY
13+
14+
# FIND_PATH and FIND_LIBRARY normally search standard locations
15+
# before the specified paths. To search non-standard paths first,
16+
# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
17+
# and then again with no specified paths to search the default
18+
# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
19+
# searching for the same item do nothing.
20+
21+
# try to use framework on mac
22+
# want clean framework path, not unix compatibility path
23+
IF (APPLE)
24+
IF (CMAKE_FIND_FRAMEWORK MATCHES "FIRST"
25+
OR CMAKE_FRAMEWORK_PATH MATCHES "ONLY"
26+
OR NOT CMAKE_FIND_FRAMEWORK)
27+
SET (CMAKE_FIND_FRAMEWORK_save ${CMAKE_FIND_FRAMEWORK} CACHE STRING "" FORCE)
28+
SET (CMAKE_FIND_FRAMEWORK "ONLY" CACHE STRING "" FORCE)
29+
#FIND_PATH(PROJ_INCLUDE_DIR PROJ/proj_api.h)
30+
FIND_LIBRARY(PROJ_LIBRARY PROJ)
31+
IF (PROJ_LIBRARY)
32+
# FIND_PATH doesn't add "Headers" for a framework
33+
SET (PROJ_INCLUDE_DIR ${PROJ_LIBRARY}/Headers CACHE PATH "Path to a file.")
34+
ENDIF (PROJ_LIBRARY)
35+
SET (CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_save} CACHE STRING "" FORCE)
36+
ENDIF ()
37+
ENDIF (APPLE)
38+
39+
FIND_PATH(PROJ_INCLUDE_DIR proj_api.h
40+
"$ENV{INCLUDE}"
41+
"$ENV{LIB_DIR}/include"
42+
)
43+
44+
FIND_LIBRARY(PROJ_LIBRARY NAMES proj_i proj PATHS
45+
"$ENV{LIB}"
46+
"$ENV{LIB_DIR}/lib"
47+
)
48+
49+
IF (PROJ_INCLUDE_DIR AND PROJ_LIBRARY)
50+
SET(PROJ_FOUND TRUE)
51+
ENDIF (PROJ_INCLUDE_DIR AND PROJ_LIBRARY)
52+
53+
54+
IF (PROJ_FOUND)
55+
# This macro checks if the symbol exists
56+
include(CheckLibraryExists)
57+
check_library_exists("${PROJ_LIBRARY}" proj_info "" PROJ_HAS_INFO)
58+
59+
IF (NOT PROJ_FIND_QUIETLY)
60+
MESSAGE(STATUS "Found Proj: ${PROJ_LIBRARY}")
61+
ENDIF (NOT PROJ_FIND_QUIETLY)
62+
63+
ELSE (PROJ_FOUND)
64+
65+
IF (PROJ_FIND_REQUIRED)
66+
MESSAGE(FATAL_ERROR "Could not find Proj")
67+
ENDIF (PROJ_FIND_REQUIRED)
68+
69+
ENDIF (PROJ_FOUND)

‎src/app/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,10 @@ IF (POSTGRES_FOUND)
497497
ENDIF(HAVE_PGCONFIG)
498498
ENDIF (POSTGRES_FOUND)
499499

500+
IF (PROJ_HAS_INFO)
501+
ADD_DEFINITIONS(-DPROJ_HAS_INFO)
502+
ENDIF (PROJ_HAS_INFO)
503+
500504
SET(IMAGE_RCCS ../../images/images.qrc)
501505

502506
QT5_ADD_RESOURCES(IMAGE_RCC_SRCS ${IMAGE_RCCS})

‎src/app/qgisapp.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
325325
//
326326
#include <ogr_api.h>
327327
#include <gdal_version.h>
328+
#ifdef PROJ_HAS_INFO

Comment on line R328

slarosa commented on Mar 15, 2018

@slarosa
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
Code has comments. Press enter to view.
329+
#include <proj.h>
330+
#endif
328331
#include <proj_api.h>
329332

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

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

4115-
#if PJ_VERSION >= 500
4116-
versionString += "<td>" + tr( "Compiled against PROJ" ) + "</td><td>" + QString::number( PJ_VERSION ) + "</td>";
4117-
versionString += "<td>" + tr( "Running against PROJ" ) + "</td><td>" + proj_info() + "</td>";
4118-
#else
4119-
versionString += "<td colspan=2>" + tr( "PROJ.4 Version" ) + "</td><td>" + QString::number( PJ_VERSION ) + "</td>";
4120-
#endif
4121-
4122-
versionString += QLatin1String( "</tr><tr>" );
4123-
41244118
versionString += "<td>" + tr( "QWT Version" ) + "</td><td>" + QWT_VERSION_STR + "</td>";
41254119
versionString += "<td>" + tr( "QScintilla2 Version" ) + "</td><td>" + QSCINTILLA_VERSION_STR + "</td>";
41264120

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

4123+
#if PJ_VERSION >= 500
4124+
PJ_INFO info = proj_info();
4125+
versionString += "<td>" + tr( "Compiled against PROJ" ) + "</td><td>" + QString::number( PJ_VERSION ) + "</td>";
4126+
versionString += "<td>" + tr( "Running against PROJ" ) + "</td><td>" + info.version + "</td>";
4127+
#else
4128+
versionString += "<td>" + tr( "PROJ.4 Version" ) + "</td><td colspan=3>" + QString::number( PJ_VERSION ) + "</td>";
4129+
#endif
4130+
41294131
#ifdef QGISDEBUG
4130-
versionString += "<td colspan=2>" + tr( "This copy of QGIS writes debugging output." ) + "</td>";
4132+
versionString += "</tr><tr><td colspan=4>" + tr( "This copy of QGIS writes debugging output." ) + "</td>";
41314133
#endif
41324134

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

0 commit comments

Comments
 (0)
Please sign in to comment.