Hi there guys,<br><br>First off I&#39;m new to cmake (and c++ and qt too :-) ), so please bear this in mind.<br><br>I&#39;m having some trouble with my source tree layout, and don&#39;t know if I&#39;m doing this right.<br>

<br>I&#39;ll first explain what I&#39;ve done, and then tell you what&#39;s not working.<br><br>My source tree:<br><br>project<br>--&gt;build<br>--&gt;source<br>--&gt;--&gt;app<br>--&gt;--&gt;--&gt;main.cpp<br>--&gt;--&gt;--&gt;
CMakeLists.txt<br>--&gt;--&gt;gui<br>--&gt;--&gt;--&gt;mainwindow.h<br>--&gt;--&gt;--&gt;mainwindow.cpp<br>--&gt;--&gt;--&gt;mainwindow.ui<br>--&gt;--&gt;--&gt;CMakeLists.txt<br>--&gt;--&gt;CMakeLists.txt<br>--&gt;CMakeLists.txt

<br><br>Very straight forward, and logical way to layout my source files.&nbsp; I thought.<br><br>Now,
all the open source projects using cmake I found on the net mostly
throw all their source files into a single directory, so I couldn&#39;t
find a proper example for what I want really.
<br><br>The way I thought to do this is to build libraries from some
stuff (gui in this case), and then link this into the executable in app.<br><br>This does work, but maybe there&#39;s a more standard way to use cmake on such a source tree?
<br><br>The actual problem I&#39;m having is with includes:<br><br>ui_*.h
files get generated in the gui folder (the one in the build tree of
course), and the gui library gets built without problems.<br><br>The problem though is when including 
mainwindow.h from main.cpp in the app folder.&nbsp; Because mainwindow.h includes ui_mainwindow.h generated by QT4_WRAP_UI.<br><br>I do have,<br><br>INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} )<br><br>in
the CMakeLists.txt file building the gui library.&nbsp; And, like I said,
the gui library gets built fine, so it&#39;s picking up the ui_mainwindow.h
which is in the build tree and not in the source tree.<br><br>But,
when building the app executable, this isn&#39;t in the includes any more
and the compiler says it can&#39;t find ui_mainwindow.h&nbsp; (it&#39;s only looking
in the source tree I guess).
<br><br>I can solve this by adding,<br><br>INCLUDE_DIRECTORIES(${project<div id="mb_0">_BINARY_DIR}/source/gui)<br><br>in
the CMakeLists.txt file in the app folder, thus telling it again to go
look for the header in the build tree.&nbsp; Even though I already included
it earlier on when building the gui library, CMake seems to forget
this.
<br><br><br>Can some please explain to me what is the proper way of
using cmake (with Qt4) on more complex source trees, and why my way
isn&#39;t working properly.<br><br>Hope you&#39;re all having a great day.<br><br>Regards,
<br>cputter</div>