Hi folks,<div><br></div><div>I have the following directory structure:</div><div><br></div><div>./Application</div><div>./Application/GUI.ui</div><div>./Application/GUI.cpp</div><div>./Application/GUI.qrc</div><div>./Application/GUI.h</div>
<div>./test</div><div>./test/gui</div><div>./test/gui/main.cpp</div><div>./test/gui/CMakeLists.txt</div><div><br></div><div>and creating a build directory under ./test/gui which I run cmake as &quot;cmake ..&quot;.</div><div>
<br></div><div>There are two problems I am facing with;</div><div><br></div><div>1. When I run cmake it creates a directory; test/Application, which shouldn&#39;t create I suppose.</div><div>2. When I run make it gives an error and exits;</div>
<div><div><br></div><div>$ make</div><div>[ 14%] Generating ui_GUI.h</div><div>File &#39;/home/emre/tmp/cmake_qt/Application/GUI.h&#39; is not valid</div><div>make[2]: *** [ui_GUI.h] Error 1</div><div>make[1]: *** [CMakeFiles/test_im_gui.dir/all] Error 2</div>
<div>make: *** [all] Error 2</div><div>$ _</div><div><br></div><div>Here is my CMakeLists.txt file (which I copied from a tutorial found on the web):</div><div><br></div><div>=====================================================================<br>
</div><div><div>CMAKE_MINIMUM_REQUIRED(VERSION 2.6)</div><div><br></div><div># Set project&#39;s name</div><div>PROJECT(sample)</div><div><br></div><div># with SET() command you can change variables or define new ones</div>
<div># here we define SAMPLE_SRCS variable that contains a list of</div><div># all .cpp files</div><div># note that we don&#39;t need \ at the end of line</div><div>SET(SAMPLE_SRCS</div><div>&nbsp;&nbsp; &nbsp;main.cpp</div><div>&nbsp;&nbsp; &nbsp;../../Application/GUI.cpp</div>
<div>)</div><div><br></div><div># another list, this time it includes all header files that should be treated</div><div># with moc</div><div>SET(SAMPLE_MOC_HDRS</div><div>&nbsp;&nbsp; &nbsp;../../Application/GUI.h</div><div>)</div><div>
<br></div><div># some .ui files</div><div>SET(SAMPLE_UIS</div><div>&nbsp;&nbsp; &nbsp;../../Application/GUI.ui</div><div>)</div><div><br></div><div># and finally a resource file</div><div>SET(SAMPLE_RCS</div><div>&nbsp;&nbsp; &nbsp;../../Application/GUI.qrc</div>
<div>)</div><div><br></div><div># enable warnings</div><div>ADD_DEFINITIONS(-Wall)</div><div><br></div><div># this command finds Qt4 libraries and sets all required variables</div><div># note that it&#39;s Qt4, not QT4 or qt4</div>
<div>FIND_PACKAGE(Qt4 REQUIRED)</div><div><br></div><div># add some useful macros and variables</div><div># (QT_USE_FILE is a variable defined by FIND_PACKAGE(Qt4) that contains a path</div><div># to CMake script)</div><div>
INCLUDE (${QT_USE_FILE})</div><div><br></div><div># this command will generate rules that will run rcc on all files from</div><div># SAMPLE_RCS in result SAMPLE_RC_SRCS variable will contain paths</div><div># to files produced by rcc</div>
<div>QT4_ADD_RESOURCES(SAMPLE_RC_SRCS ${SAMPLE_RCS})</div><div><br></div><div># this will run uic on .ui files</div><div>QT4_WRAP_UI(SAMPLE_UI_HDRS ${SAMPLE_MOC_HDRS})</div><div><br></div><div># and finally this will run moc</div>
<div>QT4_WRAP_CPP(SAMPLE_MOC_SRCS ${SAMPLE_MOC_HDRS})</div><div><br></div><div># we need this to be able to include headers produced by uic in our code</div><div># (CMAKE_BINARY_DIR holds a path to the build directory, while</div>
<div># INCLUDE_DIRECTORIES() wordks just like INCLUDEPATH from qmake)</div><div>INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )</div><div><br></div><div># here we instruct CMake to build &quot;sample&quot; executable from all of the</div>
<div># source files</div><div>ADD_EXECUTABLE(sample ${SAMPLE_SRCS} ${SAMPLE_MOC_SRCS}</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ${SAMPLE_RC_SRCS} ${SAMPLE_UI_HDRS})</div><div><br></div><div># last thing we have to do is to tell CMake what libraries our executable needs,</div>
<div># luckily FIND_PACKAGE prepared QT_LIBRARIES variable for us</div><div>TARGET_LINK_LIBRARIES(sample ${QT_LIBRARIES})</div><div>=====================================================================</div></div><div><br>
</div><div>Platform information:</div><div><br></div><div>OS: Ubuntu 8.10<br></div><div>cmake version 2.6-patch 0</div><div><br></div><div>I&#39;m also attaching a test case to create the problem.</div><div><br></div><div>
What am I doing wrong and how can I make it compile?</div><div><br></div><div>Any help is appreciated.</div><div><br></div><div>Thanks,</div><div><br></div><div>emre</div></div>