Skip to content

Fix Qt and libcaesium detection in CMakeLists.txt - #392

Merged
Lymphatus merged 4 commits into
Lymphatus:mainfrom
doronbehar:fix/qt-and-libcaesium-detection
Oct 5, 2026
Merged

Lymphatus merged 4 commits into
Lymphatus:mainfrom
doronbehar:fix/qt-and-libcaesium-detection

Conversation

@doronbehar

Copy link
Copy Markdown
Contributor

Found while packaging this project for nixpkgs, where the build must use a system-installed libcaesium with no network/git access available during the build. See individual commits for details on each fix.

This check assumes the only way CMake can find Qt is via an explicitly
set CMAKE_PREFIX_PATH (as an env var or cache variable), which isn't
true in general: a build system can locate Qt6Config.cmake through
other legitimate channels (Qt6_DIR, CMAKE_MODULE_PATH, a default
system prefix, or a package-manager-specific search path mechanism)
without CMAKE_PREFIX_PATH ever being set.

The following find_package(QT NAMES Qt6 Qt5 ... REQUIRED) call already
fails loudly and clearly if Qt truly can't be found, making this
earlier check both redundant and a source of false negatives.
ExternalProject_Add(libcaesium ...) and the matching add_dependencies()
ran unconditionally, even though it's only meant to be a fallback for
when find_library(LIBCAESIUM caesium) fails to find an existing system
library. The install() rules further down are already correctly gated
behind `if (NOT LIBCAESIUM)`.

As written, every build attempts to git-clone and cargo-build
libcaesium, which fails outright in network- or git-less build
environments (e.g. sandboxed package builds) even when a system
libcaesium is readily available.
The Linux target_link_libraries() call only linked the "caesium"
library when LIBCAESIUM was NOT found (i.e. only in the cargo-built
fallback case, relying on the earlier link_directories() pointing at
the ExternalProject's cargo target dir). When a system libcaesium IS
found via find_library(LIBCAESIUM caesium), it was never linked in at
all, leading to undefined references to c_compress/c_compress_to_size
at link time.

Link against the full path returned by find_library() in that case.
MainWindow declares a QElapsedTimer member (compressionTimer) without
including <QElapsedTimer>, relying on it being pulled in transitively
by another Qt header. This is fragile and breaks with some Qt/stdlib
header configurations, failing with "'QElapsedTimer' does not name a
type".
@Lymphatus
Lymphatus merged commit 8d65c4a into Lymphatus:main Oct 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants