View Issue Details

IDProjectCategoryView StatusLast Update
0016828ScribusBuild Systempublic2022-08-12 13:07
Reportergoto_coder Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Platform64bitOSUbuntuOS Version22.04
Summary0016828: CMAKE_PREFIX_PATH silently shadowed by statement in CMakeLists_Dependencies.cmake
DescriptionSetting CMAKE_PREFIX_PATH on the command line seems to have no effect. A look into CMakeLists_Dependencies.cmake shows that the variable is set by the statement set(CMAKE_PREFIX_PATH "${QT_PREFIX}/lib/cmake"). This seems to overwrite the value supplied on the commandline. This happens without any notification to the user.

I checked this by inserting the statement message(CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}") right below set(CMAKE_PREFIX_PATH "${QT_PREFIX}/lib/cmake").

When not setting QT_PREFIX on the command line, the output was CMAKE_PREFIX_PATH="/lib/cmake", no matter whether I included -DCMAKE_PREFIX_PATH=… on the command line or not. This resulted in the error message that the Qt6Core library couldn't be found.

If QT_PREFIX was set to /opt/Qt/6.2.4/gcc_64/, the output was CMAKE_PREFIX_PATH="/opt/Qt/6.2.4/gcc_64//lib/cmake", which enabled cmake to find the directory, even despite the double slash.

Without setting QT_PREFIX explicitly, cmake can't find the Qt libraries (at least in my case). The problem is this: When searching the internet for the 'right' way to tell cmake about the location of the Qt libraries, you usually find that you should set CMAKE_PREFIX_PATH on the command line. But this won't work for Scribus, since the variable is shadowed. Another solution often encountered is to set a specific variable Qt<modulename>_DIR for any Qt module needed, which seems to do the trick but is cumbersome.

Also, when CMAKE_PREFIX_PATH is set on the command line, it will be listed with the given value in the resulting CMakeCache.txt. But since this value is apparently absolutely irrelevant, this can be misleading when searching for the reason why Qt's libraries can't be found. Setting QT_PREFIX only will not result in CMAKE_PREFIX_PATH being listed in the CMakeCache.txt.

I think the build system should print a warning, error, or explanation when CMAKE_PREFIX_PATH is set and/or QT_PREFIX is not set to prevent a lot of confusion by users trying to compile it from source. Or maybe only write to the variable, when it hasn't been set on the command line. Or rather append to it, instead of overwriting?

I'm not an experienced user of cmake, so all these observations have been made by experimenting with command line options and looking at the resulting files. I hope they are mostly correct.

N.B. 1: As far as I can see, the file BUILDING doesn't mention this behavior. Maybe the section about libraries in non-standard locations could be a good place to mention this?

N.B. 2: The wiki page https://wiki.scribus.net/canvas/CMake_Build_Options mentions QT_PREFIX, but only as relevant to to Qt5, which doesn't seem to be correct, since I need to set it with Qt6 too. So maybe it should be mentioned somewhere more prominent on that page?




Tagsbuild, CMake, Qt6
PatchNo

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2022-08-12 13:07 goto_coder New Issue
2022-08-12 13:07 goto_coder Tag Attached: build
2022-08-12 13:07 goto_coder Tag Attached: CMake
2022-08-12 13:07 goto_coder Tag Attached: Qt6