How to tell cmake where the ui file created using autouic is

I have a main window class:

#include "mainwindow.h"
#include "ui_mainwindow.h"

Where ui_mainwindow.his the source file generated from the file mainwindow.uiusing cmake AUTOUIC:

set(CMAKE_AUTOUIC ON)

But if I create my assembly in another folder named "build" and it appears ui_mainwindow.h:

cmake_qt_project\build\ui_mainwindow.h

How to fix the assembly to include ui_mainwindow.hfrom another directory, or if this feature is not generated in src/dir?

Also I cannot include it in the source file as

 #include "build/ui_mainwindow.h"

I need to be able to build in any directory that I want.

+4
source share
1 answer

Add the assembly directory to the list of directories that searched for the included files:

include_directories( ${CMAKE_BINARY_DIR} )
+3
source

All Articles