In a Qt project on Windows with set(CMAKE_AUTOUIC ON) and using the Ninja generator I experience that if a foo.ui is touched I need to build twice with Ninja. The first time ui_foo.h is produced. The second time foo.cpp is compiled (presumably because ui_foo.h is updated) and the program linked. With MinGW Makefiles foo.cpp is compiled the first time around. This is with CMake 3.7.2. This has been reproduced on Linux as well on master.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
Activity
Sort or filter
Newest first
Oldest first
Show all activity
Show comments only
Show history only
Brad Kingchanged title from Ninja generator needs two passes to correct build Qt project to AUTOUIC: Ninja generator needs two passes to correct build Qt project
changed title from Ninja generator needs two passes to correct build Qt project to AUTOUIC: Ninja generator needs two passes to correct build Qt project
Øystein Wallechanged title from AUTOUIC: Ninja generator needs two passes to correct build Qt project to AUTOUIC: Ninja needs two passes to correctly build Qt project
changed title from AUTOUIC: Ninja generator needs two passes to correct build Qt project to AUTOUIC: Ninja needs two passes to correctly build Qt project
The main_autogen/include/ui_mainwindow.h file needs to be listed as an output of the build statement that generates it. Inside CMake's source this means the autogen infrastructure needs to list it as an output (or perhaps byproduct if it is meant to be copy-if-different) of the relevant custom command.
Given the .ui file is listen in the target sources, we can compute the (default) ui_*.h file position. The ui_*.h file then can be appended to the outputs of the _autogen target (like @brad.king suggested). I tried this and it seems to work. It has limitations though.
the (changing) .ui file must be listed in the target sources (not a too unreasonable demand IMO)
the ui_*.h must be included as #include "ui_*.h" without a path like
#include "<some>/<path>/ui_*.h"
We might address the <some>/<path> scenario by introducing a .ui source file property AUTOUIC_BUILD_PATH that must be set to <some>/<path>. This is an viable but uncomfortable solution because the user would have to add information that technically is available in the sources already. Only it isn't at configuration time or at least it isn't static since <some>/<path> might change.