## Christoph Moench-Tegeder ([email protected]):
> Perhaps a better approach is to use
> these (with cmake's pkg_check_modules) if we cannot find proj via
> find_package? I'll check what could be done there.
OK, this works (for me). See attached - against 1.13.0 (the whole
cmake-patches-the-source can be reverted).
Explanations:
- first, we need to load FindPkgConfig
https://cmake.org/cmake/help/latest/module/FindPkgConfig.html
- if proj cannot be found by find_package() (N.B. is it still PROJ4
for proj >= 5.0?), check if proj can be found with pkg_search_module()
(pkg-config), keeping the PROJ4 prefix for the variables
- a few CMakeLists.txt have to be touched, as find_ppackage() will
fill PROJ4_LIBRARIES with the full path to libproj.so (e.g.
"/usr/local/lib/libproj.so") but pkg_search_module() gives us the
linker-style "-lproj" and we need to pass extra LDFLAGS.
I don't have a system with cmake-built libproj, so please test...
Regards,
Christoph
--
Spare Space
diff -Nru qmapshack-1.13.0.orig/CMakeLists.txt qmapshack-1.13.0/CMakeLists.txt
--- qmapshack-1.13.0.orig/CMakeLists.txt 2019-04-08 18:08:10.000000000 +0200
+++ qmapshack-1.13.0/CMakeLists.txt 2019-04-14 17:58:50.203914000 +0200
@@ -43,6 +43,7 @@
include(DefineCMakeDefaults)
include(DefineCompilerFlags)
include(DefineInstallationPaths)
+include(FindPkgConfig)
include(CPackConfig.cmake)
include(ConfigureChecks.cmake)
@@ -135,7 +136,13 @@
find_package(Qt5WebEngineWidgets REQUIRED)
find_package(Qt5Qml REQUIRED)
find_package(GDAL REQUIRED)
-find_package(PROJ4 REQUIRED)
+# if proj was build with autotools, it doesn't install the cmake files
+# but a pkg-config (.pc) file - so we have to check both (first cmake,
+# if that wasn't found pkg-config and fail hard if that doesn't work either)
+find_package(PROJ4)
+if (NOT PROJ4_FOUND)
+ pkg_search_module(PROJ4 REQUIRED proj)
+endif()
find_package(JPEG REQUIRED)
find_package(ROUTINO REQUIRED)
find_package(QuaZip5 REQUIRED)
diff -Nru qmapshack-1.13.0.orig/src/qmapshack/CMakeLists.txt qmapshack-1.13.0/src/qmapshack/CMakeLists.txt
--- qmapshack-1.13.0.orig/src/qmapshack/CMakeLists.txt 2019-04-08 17:33:43.000000000 +0200
+++ qmapshack-1.13.0/src/qmapshack/CMakeLists.txt 2019-04-14 17:55:07.310029000 +0200
@@ -891,7 +891,7 @@
Qt5::Positioning
${DBUS_LIB}
${GDAL_LIBRARIES}
- ${PROJ4_LIBRARIES}
+ ${PROJ4_LDFLAGS} ${PROJ4_LIBRARIES}
${ROUTINO_LIBRARIES}
${ALGLIB_LIBRARIES}
${QUAZIP_LIBRARIES}
diff -Nru qmapshack-1.13.0.orig/src/qmaptool/CMakeLists.txt qmapshack-1.13.0/src/qmaptool/CMakeLists.txt
--- qmapshack-1.13.0.orig/src/qmaptool/CMakeLists.txt 2019-04-08 17:33:47.000000000 +0200
+++ qmapshack-1.13.0/src/qmaptool/CMakeLists.txt 2019-04-14 17:55:07.310439000 +0200
@@ -247,7 +247,7 @@
Qt5::Widgets
Qt5::Network
${GDAL_LIBRARIES}
- ${PROJ4_LIBRARIES}
+ ${PROJ4_LDFLAGS} ${PROJ4_LIBRARIES}
)
if(APPLE)
diff -Nru qmapshack-1.13.0.orig/src/qmt_map2jnx/CMakeLists.txt qmapshack-1.13.0/src/qmt_map2jnx/CMakeLists.txt
--- qmapshack-1.13.0.orig/src/qmt_map2jnx/CMakeLists.txt 2019-04-08 17:33:49.000000000 +0200
+++ qmapshack-1.13.0/src/qmt_map2jnx/CMakeLists.txt 2019-04-14 17:55:07.310750000 +0200
@@ -46,7 +46,7 @@
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ENDIF(WIN32)
-TARGET_LINK_LIBRARIES(${APPLICATION_NAME} ${GDAL_LIBRARIES} ${PROJ4_LIBRARIES} ${JPEG_LIBRARIES})
+TARGET_LINK_LIBRARIES(${APPLICATION_NAME} ${GDAL_LIBRARIES} ${PROJ4_LDFLAGS} ${PROJ4_LIBRARIES} ${JPEG_LIBRARIES})
if(APPLE)
set_target_properties(${APPLICATION_NAME} PROPERTIES
diff -Nru qmapshack-1.13.0.orig/src/qmt_rgb2pct/CMakeLists.txt qmapshack-1.13.0/src/qmt_rgb2pct/CMakeLists.txt
--- qmapshack-1.13.0.orig/src/qmt_rgb2pct/CMakeLists.txt 2019-04-08 17:33:50.000000000 +0200
+++ qmapshack-1.13.0/src/qmt_rgb2pct/CMakeLists.txt 2019-04-14 17:55:07.311062000 +0200
@@ -95,7 +95,7 @@
target_link_libraries(${APPLICATION_NAME}
Qt5::Core
${GDAL_LIBRARIES}
- ${PROJ4_LIBRARIES}
+ ${PROJ4_LDFLAGS} ${PROJ4_LIBRARIES}
)
if(APPLE)
_______________________________________________
Qlandkartegt-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users