Qt, CMake and Visual Studio Behavior
I'm porting some of my Qt projects into
CMake to make them more flexible across different IDE's.
The only sad part with
CMake, when I generate
VS solution, it won't work amazingly as it works with the Qt VS Extension.
For example if I change a
.ui file, I'll need to rebuild the project in order to see the changes in the GUI in comparison to when I use the VS Extension generated project, it will identify the changes automatically and re-moc the class that owns the
.ui file without having to re-build the whole project.
If I look at the project configuration the VS Extension generates in the .vcxproj file, it would add
ItemDefinitionGroup some items as follows:
Probably this what gives the Qt VS Extension to identify how to treat each file, so if it's
QtUic, then it would check if any changes in the
.ui files are present, and if there are new changes, it would re-compile the ui file, then moc the class that belongs to the
.ui file and only then re-compile the actual class that owns the
In summary, is there any possible way to make CMake generate a project similar to one Qt VS Extension generated when I choose in CMake the VS generator? I'm guessing CMake doesn't support this internally, as they tend to abstract all this behavior to make all VS projects as generic as possible no matter what framework is used, but CMake does have flags to support Qt like:
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON)
So I'm assuming it wouldn't be much of a work to implement.
Probably my best bet is to fork CMake and re-implement this behavior myself? psuedo example:
if CMAKE_AUTOMOC == ON & CMAKE_VS_EXT == ON Do some custom changes to the .vcxproj file endif
Sorry for the long post, but any ideas and help would be greatly appreciated. Thanks!