How can I debug this cmake issue to find out why a build works fine on one PC but fails on another?
On both PCs I cloned a repository as follows:
git clone --recurse-submodules https://github.com/iEvgeny/cctv-viewer.git
On first PC my cmake command runs perfectly. On second PC I get this:
cmake ../cctv-viewer -DCMAKE_INSTALL_PREFIX=/usr/local --debug-find-pkg=Qt6QuickCompiler -DQT_DEBUG_FIND_PACKAGE=ON
Running with debug output on for the 'find' commands for package(s) Qt6QuickCompiler.
-- Could NOT find Qt6QuickCompiler (missing: Qt6QuickCompiler_DIR)
CMake Debug Log at /usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake:167 (find_package):
The internally managed CMAKE_FIND_PACKAGE_REDIRECTS_DIR.
/home/scg/Dev/cctv-viewer_build/CMakeFiles/pkgRedirects
Paths specified by the find_package HINTS option.
none
Paths specified by the find_package PATHS option.
/usr/lib/x86_64-linux-gnu/cmake
find_package considered the following locations for Qt6QuickCompiler's
Config module:
/home/scg/Dev/cctv-viewer_build/CMakeFiles/pkgRedirects/Qt6QuickCompilerConfig.cmake
/home/scg/Dev/cctv-viewer_build/CMakeFiles/pkgRedirects/qt6quickcompiler-config.cmake
/usr/lib/x86_64-linux-gnu/cmake/Qt6QuickCompilerConfig.cmake
/usr/lib/x86_64-linux-gnu/cmake/qt6quickcompiler-config.cmake
The file was not found.
Call Stack (most recent call first):
CMakeLists.txt:140 (find_package)
CMake Error at CMakeLists.txt:140 (find_package):
Found package configuration file:
/usr/lib/x86_64-linux-gnu/cmake/Qt6/Qt6Config.cmake
but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
FOUND. Reason given by package:
Failed to find required Qt component "QuickCompiler".
Expected Config file at
"/usr/lib/x86_64-linux-gnu/cmake/Qt6QuickCompiler/Qt6QuickCompilerConfig.cmake"
does NOT exist
Configuring with --debug-find-pkg=Qt6QuickCompiler might reveal details why
the package was not found.
find_package search path values and other context for the last package that was not found:
CMAKE_MODULE_PATH: /usr/lib/x86_64-linux-gnu/cmake/Qt6;/usr/lib/x86_64-linux-gnu/cmake/Qt6/3rdparty/extra-cmake-modules/find-modules;/usr/lib/x86_64-linux-gnu/cmake/Qt6/3rdparty/kwin;/usr/lib/x86_64-linux-gnu/cmake/Qt6;/usr/lib/x86_64-linux-gnu/cmake/Qt6/3rdparty/extra-cmake-modules/find-modules;/usr/lib/x86_64-linux-gnu/cmake/Qt6/3rdparty/kwin
CMAKE_PREFIX_PATH:
$ENV{CMAKE_PREFIX_PATH}:
CMAKE_FIND_ROOT_PATH:
_qt_additional_packages_prefix_paths:
_qt_additional_host_packages_prefix_paths:
_qt_cmake_dir: /usr/lib/x86_64-linux-gnu/cmake
QT_HOST_PATH:
Qt6HostInfo_DIR:
Qt6_DIR: /usr/lib/x86_64-linux-gnu/cmake/Qt6
CMAKE_TOOLCHAIN_FILE: /usr/lib/qt6/bin/../../x86_64-linux-gnu/cmake/Qt6/qt.toolchain.cmake
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE:
CMAKE_SYSROOT:
$ENV{PATH}: /home/scg/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
From first glance at the the messages it would seem simple that the second PC is just missing QT6 QuickCompiler but I think the message is a bit confusing as on the first PC there is no such /usr/lib/x86_64-linux-gnu/cmake/Qt6QuickCompiler either, so I don't think it's that.
Both PCs I have installed various QT5 and QT6 prerequisite packages, I have compared the list of all sorts of qt and related packages between the two PCs and it all looks the same but something is obviously different. And I am now stuck with knowing how to identify the difference/s.
On the first PC it seems cmake is finding the correct QT5 and QT6 packages during the build but on the second PC it's not, despite having installed all the same QT5 and QT6 packages.
Both PCs are running Ubuntu 24.04.3 LTS
EDIT: This question was closed and I was asked to provide the following:
The desired behavior
I would like the cmake command to work successfully on both PCs. I want to find out why it does not work on one PC despite seemingly both PCs having the same QT5/QT6 packages installed.
A specific problem or error
I already provided that - the cmake error from the PC where the build does not work.
The shortest code necessary to reproduce the problem
I already provided that - a git clone command followed by a cmake. Of course it's not 100% reproducible as my entire problem is that it builds o.k. on one PC but fails on another.
find_package(Qt6QuickCompiler)succeed, CMake sets cache variableQt6QuickCompiler_DIRto the directory with its config script. So you may check that variable on your first PC (cache variables are stored inCMakeCache.txtfile in the build directory).QuickCompilerthen it only comes back with QT5QuickCompiler. In the make file it has this line where it looks for Qt6 and Qt5 packages:find_package(QT NAMES Qt6 Qt5 COMPONENTS ${QT_LINK_DEPENDENCIES} QuickCompiler LinguistTools REQUIRED)On the working PCQT_VERSION_MAJORis 5 after that, but on the non-working PC it is 6. Despite both PCs having QT5 and QT6 packages. So I think that is the key here. I can at least work around this now by just removingQt6from that makefile line...