Vyacheslav
Vyacheslav

Reputation: 3244

How to tell cmake where ui file generated with autouic is

I have main window class includes:

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

Where ui_mainwindow.h is source file generated from mainwindow.ui file by cmake AUTOUIC option:

set(CMAKE_AUTOUIC ON)

But if I do my build in another folder called "build" and generated ui_mainwindow.h appears there:

cmake_qt_project\build\ui_mainwindow.h

How to fix the build to include ui_mainwindow.h from another directory or if there is no such possibility generating it in src/ dir?

Also I can not include it in source file as

 #include "build/ui_mainwindow.h"

I need to keep possibility to make build in any dir I want.

Upvotes: 6

Views: 4192

Answers (1)

DevSolar
DevSolar

Reputation: 70253

Add your build directory to the list of directories searched for include files:

include_directories( ${CMAKE_BINARY_DIR} )

Upvotes: 5

Related Questions