I use custom build for moc'ing Qt headers.
- Go to project build options - Debug, "Custom variables" tab. Add target=Debug
Switch to Release configuration, add target=Release. Perform this step for all existing configurations. - Open Properties dialog for header that requires moc'ing (Add this file to project, it appears in "Headers" virtual folder). Go to "Build" tab, check "Compile file", uncheck "Link file".
- Go to "Advanced tab". Check "Use custom command to build this file"
cmd /C if not exist $file_dir\generatedFiles\$(TARGET_NAME) mkdir $file_dir\generatedFiles\$(TARGET_NAME)
moc $includes $file -o $file_dir\generatedFiles\$(TARGET_NAME)\moc_$file_name.cpp
(Command above is for Windows, for Linux use md for creating directory)
[/li]
- Press Ok and close dialog
- Right click on file and select "Build file"
- Right click on project and select "Add files...". Choose $(YOUR_SRC_PATH)\generatedFiles\$(TARGET_NAME)\moc_$(YOUR_FILE).cpp ( $(TARGET_NAME) - is name of currently selected configuration)
- Right click on moc_$(YOUR_FILE).cpp in project tree, select properties. Open "Build" tab, unckeck all targets, keep checked only currently selected. Close dialog.
- Select next project configuration, build moc_*.cpp, add it, and attach it to build with current configuration. Make this steps for all your configurations.
This is the way to tune up C::B build system to work like MSVC with Qt integrator.