Tuesday, February 12, 2008

Getting Qt linked in DGL

Question:
In DGL, more precisely the file DGLWindow.cpp, we modified the create() function and replaced it with a Qt implemention.

We have included other header files such as . So as needed we modified the header file accordingly. As you told us in your last mail, we will need to rebuild everything.

Usually to build and run a Qt applications we used to do these commands:
> qmake -project
> qmake
> make
> ./qt_application

What should we do to build the DGLWindow.cpp (with the Qt implementation). Should we change the Makefile or other files such as Makefile.am/Makefile.in.

Apparently the Makefile is generated by the "configure" command in the root directory of DGL. Should we change anything in the configure file?


=================================================================
Answer:
To get Qt linked in, you'll need to mess with the cmake configure files.
This is a bit of a project.

You'll find the file CMakeLists.txt in many directories. These files define
what cmake will use and where it'll look to find stuff.

This command will tell me the files that contain the word "producer":

> find . -name CMakeLists.txt | xargs grep -i producer | sed -e 's/:.*$//' | uniq
./dgl/DSOs/dgl/CMakeLists.txt
./dgl/DSOs/dosg/CMakeLists.txt
./dgl/programs/dgl/dgl-readSta
te/CMakeLists.txt
./dgl/programs/dgl/dgl-waitExec/CMakeLists.txt
./dgl/programs/dgl/dgl-navControl/CMakeLists.txt
./dgl/programs/dosg/dosg-bounds/CMakeLists.txt
./dgl/programs/dosg/dosg-fly/CMakeLists.txt
./dgl/programs/dosg/dosg-transform/CMakeLists.txt
./dgl/programs/dcoin/dcoin-fly/CMakeLists.txt
./dgl/lib/dgl/CMakeLists.txt
./dgl/lib/dosg/CMakeLists.txt
./dgl/lib/dcoin/CMakeLists.txt
./dgl/lib/dvtk/CMakeLists.txt
./dgl/CMakeLists.txt
./dgl/examples/CCallbackHelix/CMakeLists.txt
./dgl/examples/quad/CMakeLists.txt
./dgl/examples/dosgfly/CMakeLists.txt
./dgl/examples/coinload/CMakeLists.txt

This isn't as bad as it looks. dgl/CMakeLists.txt is probably where you
should start, as it defines how to find Producer. The rest should just use
it, and the changes should be fairly mechanical.

In dgl/CMakeLists.txt, look for Producer. Most of the heavy lifting is from
lines 208-263. The first part tells cmake a name to look for, "Producer",
"Producerd" if running Windows, and a series of directories to look at to
find it, both the library and the include files. It looks in a mixture of
environment variables and hard-coded paths. If Qt has some environment
variables that tell the system where to find its library and include files,
just use those. If Qt has a program you can run to find out this
information (like fltk does, later in the file) just use this.

Later in the file, lines 306 & 404, Producer is added to the OSG & VTK
list of include files. You can add Qt there instead.

In other CMakeLists.txt files, the Producer include file and library are
added to the compiler flags, so just replace them with the Qt equivalents.

After you change the CMakeLists.txt files, rerun cmake to generate new
Makefiles.

No comments: