On 2009-03-03 14:13-0000 Alban Rochel wrote:
> Andrew Ross wrote:
>> On Tue, Mar 03, 2009 at 01:19:45PM +0000, Alban Rochel wrote:
>>> Dear all,
>>>
>>> I am currently working on the delivery of various Qt-based drivers for
>>> plplot, based on our own version of these drivers in our QSAS software.
>>>
>>> Unfortunately, none of us in the team has knowledge in cmake, and
>>> although I've managed to do most of what I wanted, I'm still stuck on
>>> one point, and I would appreciate some help.
>>>
>>> The Qt library somehow extends the C++ language by adding keywords in
>>> the class declarations (in my case in qt.h). A qt.moc file has to be
>>> generated from this file using the Qt moc software, converting the Qt
>>> keywords to C++ implementations.
>>>
>>> Thus, before compiling my qt.cpp implementation, I have to produce a
>>> qt.moc file from qt.h. The QT4_GENERATE_MOC macro is supposed to do
>>> that, but I haven't found exactly where to put this call.
>>>
>>> I've added it in drivers-finish.cmake, as follows:
>>> elseif(DRIVER STREQUAL "qt")
>>> FIND_PACKAGE(Qt4)
>>> INCLUDE(${QT_USE_FILE})
>>> QT4_GENERATE_MOC(qt.h qt.moc)
>>> set(${DRIVER}_SOURCE
>>> ${CMAKE_SOURCE_DIR}/drivers/${DRIVER}.cpp
>>> ${${DRIVER}_SOURCE}
>>> But the qt.moc file is nowhere to be found. Maybe it should rather go
>>> somewhere in drivers/CMakeLists.txt? Or cmake/modules/qt.cmake?
>>>
>>> Any information would be welcome. Of course feel free to ask me for any
>>> detail I would have omitted.
>>
>> Alban,
>>
>> I've not used the cmake qt support, but from what you have said I assume
>> that qt.h is an include file supplied by you for the qt driver. Is this in
>> the drivers directory? If so then I suspect your QT4_GENERATE_MOC command
>> wants to go in drivers/CMakeLists.txt.
>>
>> Generally the CMakeLists.txt command contains the instructions for building
>> the targets in that directory. In this case running moc on the header file
>> is part of the build processess, like compiling the source, so should go
>> there.
>>
>> Files in the cmake/modules directory are cmake files which are used in
>> configuring plplot, testing for available compilers / headers / libraries
>> etc. What you probably need is a new file in cmake/modules/ which checks for
>> the qt libraries and sets the cmake configuration variables accordingly.
>> You can probably base it on one of the existing drivers. The code in
>> drivers/CMakeLists.txt will then actually do the building of the qt
>> driver based on these configuration variables.
>>
>> If you can get something which works, then Alan or I would be happy to tidy
>> it up into plplot "style" such as it is or help with the cmake support.
>>
>> Thanks
>>
>> Andrew
>
> Andrew,
>
> Thanks for your quick answer, I'll try and put it in
> drivers/CMakeLists.txt and see how this works.
I am entering the conversation late because of time zones, but I second
everything that Andrew said above. I would also like to add some CMake
advice about how to deal with the Qt stuff based on my experience with
non-Qt CMake and what I just read in the documentation (including some
informal documentation I found with google).
First, QT4_GENERATE_MOC is pretty low level. It makes a custom rule, but
from my experience, the results of custom rules have to be specifically
hooked up with build targets via a custom_target and setting all the
chain of file-level and target-level dependencies right.
So QT4_GENERATE_MOC would be complicated to use, but fortunately, the
documentation for it implies for normal use you should be using QT4_WRAP_CPP
instead which appears to be higher level. The official documentation of
that command is a little vague but a google search found
http://www.mail-archive.com/cmake%40cmake.org/msg18900.html
which gives a simple example of using that macro.
So from that example, here is what I would recommend in drivers/CMakeLists.txt
(note lower- and upper-case command names are interchangeable so I
have lower-cased the macro name to be consistent with the rest
of the PLplot build-system style.)
if(SOURCE_ROOT_NAME STREQUAL "qt")
qt4_wrap_cpp(QT_MOC_OUTFILES ${CMAKE_CURRENT_SOURCE_DIR}/qt.h)
# Temporary debugging message.
message("QT_MOC_OUTFILES = ${QT_MOC_OUTFILES}")
add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE}
${QT_MOC_OUTFILES})
else(SOURCE_ROOT_NAME STREQUAL "qt")
add_library(${SOURCE_ROOT_NAME} MODULE ${${SOURCE_ROOT_NAME}_SOURCE})
endif(SOURCE_ROOT_NAME STREQUAL "qt")
If that advice doesn't work, then I would be willing to play a bit with what
you have now to see if I could get the build to work.
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Plplot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-devel