[Cmake] "make install" fails on QT_WRAP_CPP moc header file

Brad King brad . king at kitware . com
Tue, 7 Oct 2003 17:37:56 -0400 (EDT)


On Tue, 7 Oct 2003, David Thompson wrote:

> The following code in CMakeLists.txt will cause make to die with the
> complaint that moc_qBlah.h does not exist. Of course, that file
> shouldn't exist because moc_qBlah.cxx is not a class -- it's  a partial
> implementation of the qBlah.h with the rest of the implementation in
> qBlah.cxx. How should one specify C++ implementation files that don't
> have an associated header? I didn't see any appropriate
> SET_SOURCE_FILES_PROPERTIES property.
>
> ...
> SET( GuiLibSrcs qBlah.cxx )
> SET( GuiLibMocHeaders qBlah.h )
> # Do wrap Qt header files
> QT_WRAP_CPP( GuiLib GuiLibSrcs GuiLibMocHeaders )
> SET_SOURCE_FILES_PROPERTIES( ${GuiLibSrcs} GENERATED )
> # Don't wrap in Tcl/Python
> SET_SOURCE_FILES_PROPERTIES( ${GuiLibSrcs} WRAP_EXCLUDE )

FYI, the WRAP_EXCLUDE property isn't used unless VTK_WRAP_TCL is called
with the source file.

> SET( Gui_SRCS ${Gui_SRCS} ${GuiLibSrcs} )
> ADD_LIBRARY( Gui ${Gui_SRCS} )
> INSTALL_FILES ( /include/Gui .h ${Gui_SRCS} )
                                    ^^^^^^^^

This INSTALL_FILES command tells cmake to look for a .h file for every
source file in Gui_SRCS.  If you don't want to look for moc_qBlah.h, then
don't pass moc_qBlah.cxx to INSTALL_FILES.  You can probably change the
code to look like this:

SET( GuiLibSrcs qBlah.cxx )
SET( GuiLibMocHeaders qBlah.h )
QT_WRAP_CPP( GuiLib GuiLibMocSrcs GuiLibMocHeaders )
SET_SOURCE_FILES_PROPERTIES( ${GuiLibMocSrcs} GENERATED )
ADD_LIBRARY( Gui ${GuiLibSrcs} ${GuiLibMocSrcs} )
INSTALL_FILES ( /include/Gui .h ${GuiLibSrcs} )

-Brad