[Qt-interest] cmake: ui library?
Rui Maciel
rui.maciel at gmail.com
Tue Feb 14 02:55:29 CET 2012
Rui Maciel wrote:
> Due to this, I would like to organize the UI part of this project as a
> static library. With that in mind, I've added a CMakeLists.txt file to
> ~/src/ui, with the following content:
>
> <example ~/src/ui/CMakeLists.txt>
> INCLUDE(${QT_USE_FILE})
> ADD_DEFINITIONS(${QT_DEFINITIONS})
>
> set(libui_HEADERS
> # some headers with Qt code
> )
>
> set(libui_SOURCES
> # some sources which Qt code
> )
>
> set(libui_FORMS
> #some Qt forms
> )
> </example>
This CMakeLists.txt file was a bit broken. Here follows an updated version:
<example ~/src/ui/CMakeLists.txt>
set(ui_HEADERS
MainWindow.h++
# some other headers
)
set(ui_SOURCES
MainWindow.c++
# some other sources
)
set(ui_FORMS
MainWindow.ui
# some other forms
)
QT4_WRAP_CPP(ui_HEADERS_MOC ${ui_HEADERS})
QT4_WRAP_UI(ui_FORMS_HEADERS ${ui_FORMS})
add_library(ui STATIC ${ui_SOURCES} ${ui_HEADERS_MOC} ${ui_FORMS_HEADERS} )
</example>
Although this CMakeLists.txt file appears to be enough to create a static
library, the build process still fails. This time, the error is caused by
not including the path to the header files generated by uic. More
precisely, the error message is as follows:
<error message>
fatal error: ui_MainWindow.h: No such file or directory
</error message>
It appears that the solution to this problem is to include the path to the
ui_*.h files that are generated by uic. To do that, I've tried including
${CMAKE_CURRENT_BINARY_DIR} and "${PROJECT_BINARY_DIR}/src/ui", to no
success.
Does anyone happen to know how to include the directory where uic dumps the
header files?
Thanks in advance,
Rui Maciel
More information about the Qt-interest-old
mailing list