[CMake] Why the ui_header.h can not be found in Qt project when I add a share lib?
Kermit Mei
kermit.mei at gmail.com
Tue Jan 20 12:36:24 EST 2009
Hello,I'm a novice for cmake. I'm trying to run a qt-project like this:
$ tree
.
|-- CMakeLists.txt
|-- build
|-- gui //I want creat a share lib here.
| |-- CMakeLists.txt
| |-- gotocelldialog.cpp
| |-- gotocelldialog.h
| `-- gotocelldialog.ui
`-- main.cpp
2 directories, 6 files
The CMakeLists.txt of the root is:
$ cat CMakeLists.txt
###################################
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT( GTC )
ADD_SUBDIRECTORY( gui )
INCLUDE_DIRECTORIES(${GTC_SOURCE_DIR}/gui)
LINK_DIRECTORIES(${GTC_BINARY_DIR}/gui)
ADD_DEFINITIONS( -Wall )
FIND_PACKAGE( Qt4 REQUIRED )
INCLUDE( ${QT_USE_FILE} )
SET( GTC_SRCS main.cpp )
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )
ADD_EXECUTABLE( gtc ${GTC_SRCS} )
SET(EXECUTABLE_OUT_PATH ${CMAKE_BINARY_DIR})
TARGET_LINK_LIBRARIES( gtc GUI )
#############END###############
And the /gui/CMakeLists.txt is like this:
$ cat gui/CMakeLists.txt
###################################
SET( GUI_SRCS
gotocelldialog.cpp
)
SET( GUI_MOC_HDRS
gotocelldialog.h
)
SET( GUI_UIS
gotocelldialog.ui
)
ADD_DEFINITIONS( -Wall )
FIND_PACKAGE( Qt4 REQUIRED )
INCLUDE( ${QT_USE_FILE} )
QT4_WRAP_UI( GUI_UI_HDRS ${SAMPLE_UIS} )
QT4_WRAP_CPP( GUI_MOC_SRCS ${GUI_MOC_HDRS} )
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} )
ADD_LIBRARY(GUI SHARED ${GUI_SRCS} ${GUI_MOC_SRCS} ${GUI_UI_HDRS} )
###########END##################
But, the "make" result is :
$ make
[ 25%] Generating moc_gotocelldialog.cxx
Scanning dependencies of target GUI
[ 50%] Building CXX object gui/CMakeFiles/GUI.dir/gotocelldialog.cpp.o
In file included from
/home/kermit/test/cmqt/gotocell/gui/gotocelldialog.cpp:3:
/home/kermit/test/cmqt/gotocell/gui/gotocelldialog.h:6:31: error:
ui_gotocelldialog.h: No such file or directory
In file included from
/home/kermit/test/cmqt/gotocell/gui/gotocelldialog.cpp:3:
/home/kermit/test/cmqt/gotocell/gui/gotocelldialog.h:8: error: ‘Ui’ has
not been declared
/home/kermit/test/cmqt/gotocell/gui/gotocelldialog.h:8: error: expected
`{' before ‘GoToCellDialog’
/home/kermit/test/cmqt/gotocell/gui/gotocelldialog.h:8: error: function
definition does not declare parameters
/home/kermit/test/cmqt/gotocell/gui/gotocelldialog.cpp:5: error: invalid
use of incomplete type ‘class GoToCellDialog’
/home/kermit/test/cmqt/gotocell/gui/gotocelldialog.h:8: error: forward
declaration of ‘class GoToCellDialog’
/home/kermit/test/cmqt/gotocell/gui/gotocelldialog.cpp:17: error:
invalid use of incomplete type ‘class GoToCellDialog’
/home/kermit/test/cmqt/gotocell/gui/gotocelldialog.h:8: error: forward
declaration of ‘class GoToCellDialog’
make[2]: *** [gui/CMakeFiles/GUI.dir/gotocelldialog.cpp.o] Error 1
make[1]: *** [gui/CMakeFiles/GUI.dir/all] Error 2
make: *** [all] Error 2
$
What's wrong with it? The source code is correct, and I can use qmake to
compile and run it.
Thank you, very muck!
Kermit
More information about the CMake
mailing list