qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.36k stars 2.98k forks source link

Configure fails with PROJ version 9.4.0 #56885

Closed nilason closed 2 days ago

nilason commented 6 months ago

What is the bug or the crash?

Changes with PROJ 9.4.0, in particular https://github.com/OSGeo/PROJ/commit/efc6c95b6927c138cbb9696db1ed57ca04f512c6, causes configuration failure for QGIS. See log extract from a MacPorts build attempt:

...
:info:configure -- QGIS version: 3.34.4 Prizren (33404)
:info:configure -- Found Sqlite3: /opt/local/lib/libsqlite3.dylib
:info:configure CMake Warning at cmake/FindProj.cmake:21 (find_package):
:info:configure   Found package configuration file:
:info:configure     /opt/local/lib/proj9/lib/cmake/proj/proj-config.cmake
:info:configure   but it set PROJ_FOUND to FALSE so package "PROJ" is considered to be NOT
:info:configure   FOUND.  Reason given by package:
:info:configure   PROJ could not be found because dependency SQLite3 could not be found.
:info:configure Call Stack (most recent call first):
:info:configure   CMakeLists.txt:361 (find_package)
:info:configure -- Found Proj: 9.4.0 /opt/local/lib/proj9/lib/cmake/proj
:info:configure -- Found Geos: 3.12.1 /opt/local/lib/cmake/GEOS
:info:configure -- Found GDAL: 3.8.4 /opt/local/lib/cmake/gdal
:info:configure -- Found Spatialindex: /opt/local/lib/libspatialindex.dylib
:info:configure -- Found libzip: /opt/local/lib/libzip.dylib
:info:configure -- Found Sqlite3: /opt/local/lib/libsqlite3.dylib
:info:configure -- Found Protobuf: /opt/local/lib/libprotobuf.dylib
:info:configure -- Found zlib: /opt/local/lib/libz.dylib
:info:configure -- Found exiv2: /opt/local/lib/libexiv2.dylib
:info:configure -- Qt WebKit support enabled
:info:configure -- Using embedded laz-perf
:info:configure -- Found ZSTD: /opt/local/lib/libzstd.dylib
:info:configure -- Found PDAL: pdalcpp (2.6.3)
:info:configure -- Found Draco: /opt/local/lib/libdraco.dylib (1.5.7)
:info:configure -- Found Qt version: 5.15.12
:info:configure -- Found QScintilla2: /opt/local/libexec/qt5/lib/libqscintilla2_qt5.dylib (2.13.3)
:info:configure -- Found Qwt: /opt/local/libexec/qt5/lib/qwt.framework/Versions/Current/qwt (6.1.6)
:info:configure -- Found QtKeychain: /opt/local/lib/libqt5keychain.dylib
:info:configure -- Found QCA: /opt/local/libexec/qt5/lib/libqca-qt5.dylib (2.3.4)
:info:configure -- Found QCA OpenSSL plugin
:info:configure -- Pedantic compiler settings enabled
:info:configure -- Found Python executable: /opt/local/bin/python3.11 (version 3.11.8)
:info:configure -- Python library: /opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib
:info:configure -- Python site-packages: /opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages
:info:configure -- Found SIP version: 6.8.3
:info:configure -- Found PyQt5 version: 5.15.10
:info:configure -- Found QScintilla2 PyQt module: 2.14.1
:info:configure -- Could NOT find NetCDF (missing: NETCDF_LIBRARY NETCDF_INCLUDE_DIR) 
:info:configure -- Using PROJ >= 6 srs database.
:info:configure -- QtGamepad not enabled - disabling bindings for derived classes
:info:configure -- Ctest Binary Directory set to: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_gis_qgis3/qgis3-ltr/work/build/output/bin
:info:configure -- Configuring done
:info:configure CMake Error at src/core/CMakeLists.txt:2395 (target_link_libraries):
:info:configure   Target "qgis_core" links to:
:info:configure     PROJ::proj
:info:configure   but the target was not found.  Possible reasons include:
:info:configure     * There is a typo in the target name.
:info:configure     * A find_package call is missing for an IMPORTED target.
:info:configure     * An ALIAS target is missing.
:info:configure -- Generating done
:info:configure CMake Generate step failed.  Build files cannot be regenerated correctly.
...

This failure is caused by PROJ's change of proj-config.cmake to use find_dependency() instead of find_package() in combination with QGIS's custom FindSqlite.cmake.

I managed to address this configuration failure by by dropping the custom FindSqlite3.cmake to instead use the default CMake FindSQLite3.cmake (and change every SQLITE3_FOUND to SQLite3_FOUND, SQLITE3_INCLUDE_DIR to SQLite3_INCLUDE_DIRS and SQLITE3_LIBRARY to SQLite3_LIBRARIES).

Perhaps this is Mac specific, perhaps depends on CMake version, or depends on MacPorts' specifics?

Steps to reproduce the issue

  1. Try configure QGIS using CMake 3.24.4 with PDAL 9.4.0 (on Mac).
  2. Configure fails

Versions

Tried with:

Supported QGIS version

New profile

Additional context

No response

m-kuhn commented 5 months ago

Thanks, would you mind making a pull request to fix this? Ideally drop the SQLITE3_INCLUDE_DIR and replace SQLITE3_LIBRARY with SQLite::SQLite3

I am not sure what SQLITE3_FOUND is used for, but if it's just to print an error message it can easily be replaced by adding REQUIRED to the find_package call.

Simon-Lopez commented 4 days ago

As FindSQLite3 was introduced in CMake 3.14 this would require bump the cmake_minimum_required version from 3.12 to 3.14.

I don't think this is a big deal. Any opinion?

nilason commented 4 days ago

As FindSQLite3 was introduced in CMake 3.14 this would require bump the cmake_minimum_required version from 3.12 to 3.14.

Why not make that bump to 3.16? It is 5 years old. That is the new requirement for GDAL 3.9. It will, as far as I can see, not affect either latest version or the LTR on distributions like e.g. Debian or Fedora. Just a thought.

m-kuhn commented 4 days ago

I think it's acceptable, I would propose it in a PR and see if there are objections.

Simon-Lopez commented 4 days ago

Just to add a few info the FindSQLite3 script from CMake does not work on my platform (Windows + Cygwin). It seems it does not look for the sqlite_i library which comes via OSGeo4W's qgis-deps.

What I can do is propose a PR with modification of the qgis' cmake/FindSqlite3.cmake to have the same variables as the KitWare scripts and make the modifications in QGis CMakeLists.txt files so that they use the official cmake targets.

This would be compliant with an increase of the cmake_minimum_required version but does not require it.

m-kuhn commented 4 days ago

Just to add a few info the FindSQLite3 script from CMake does not work on my platform (Windows + Cygwin). It seems it does not look for the sqlite_i library which comes via OSGeo4W's qgis-deps.

What I can do is propose a PR with modification of the qgis' cmake/FindSqlite3.cmake to have the same variables as the KitWare scripts and make the modifications in QGis CMakeLists.txt files so that they use the official cmake targets.

This would be compliant with an increase of the cmake_minimum_required version but does not require it.

We already do this for several other components, that sounds good