Skip to content

command line: CMake is picky about the placement of --build / --install / etc. arguments

(This report was tested using CMake 3.31.6 on Fedora 42, but AFAIK it's a general issue across all versions and certainly all platforms.)

Distributions of Qt6 include their qt-cmake script, a simple tool to ensure that a Qt project is configured from the correct installation of Qt. (For example, these two commands differ only in which directory the project discovers its Qt dependencies from:)

cd /my/project/directory
$HOME/Qt/6.9.2/gcc_64/bin/qt-cmake -B _build_qt69 -S .
$HOME/Qt/6.8.3/gcc_64/bin/qt-cmake -B _build_qt68 -S .

Qt does this by means of an injected -DCMAKE_TOOLCHAIN_FILE= argument to the cmake command, right up front. Which works fine for configuring — those two commands become, respectively (wrapped for readability):

cmake \
-DCMAKE_TOOLCHAIN_FILE=$HOME/Qt/6.9.2/gcc_64/bin/../lib/cmake/Qt6/qt.toolchain.cmake \
-B _build_qt69 -S .

cmake \
-DCMAKE_TOOLCHAIN_FILE=$HOME/Qt/6.8.3/gcc_64/bin/../lib/cmake/Qt6/qt.toolchain.cmake \
-B _build_qt68 -S .

...It doesn't work so well, however, for building the project, because it turns out cmake is picky about the placement of non-configure arguments.

# A command like this
$HOME/Qt/6.9.2/gcc_64/bin/qt-cmake --build _build_qt69

# Becomes this
cmake \
-DCMAKE_TOOLCHAIN_FILE=$HOME/Qt/6.9.2/gcc_64/bin/../lib/cmake/Qt6/qt.toolchain.cmake \
--build _build_qt69

...which results in this error:

$ $HOME/Qt/6.9.2/gcc_64/bin/qt-cmake --build _build_qt69
CMake Error: Unknown argument --build
CMake Error: Run 'cmake --help' for all supported options.

That's unfortunate, because it means users of qt-cmake can't just "treat it just like the CMake command", but rather have to take on the cognitive dissonance of running qt-cmake to configure a project, but then switch to just cmake for their remaining interactions with that configuration.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information