[CMake] How pass a -spec parameter to FindQt4.cmake?

Daniel Näslund dannas at dannas.name
Mon Jul 18 03:12:46 EDT 2011


Hi!

I'm trying to cross-compile a Qt-application for the powerpc platform.
CMake looks for the Qt libraries in the wrong place - it finds the host
libraries instead of the target libraries:

    Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as /usr/lib
    Warning: But QtCore couldn't be found.  Qt must NOT be installed
correctly, or it wasn't found for cross compiling.
    CMake Error at /usr/share/cmake-2.8/Modules/FindQt4.cmake:642 (MESSAGE):
      Could NOT find QtCore.  Check /tmp/tmp8VJ3jw/CMakeFiles/CMakeError.log for
      more details.
    Call Stack (most recent call first):
      CMakeLists.txt:60 (find_package)

My powerpc libs are located in /opt/env/ppc/usr/lib.

When I read FindQt4.cmake I see that CMake uses QMake for finding out
where the Qt libs reside using "qmake -query".

Is there an easy way to let CMake tell QMake about what platform we want
to build for? I've tried...

...Using an environment variable
    $ QMAKESPEC=qws/linux-powerpc-g++ cmake

...Using a shell wrappper
    $ cat <<END > ~/bin/qmake
    #!/bin/sh

    qmake -spec qws/linux-ppc-g++ -query $*
    END
    $ cmake

The environment variable didn't make any difference and the shell wrapper
failed since qmake didn't allow the -spec and -query flag to be passed
simultaneously.

All of the three resources below suggests that compiling my own version
of qmake is the way to go but to me it sounds a bit counter-intuitive;
why would cmake not allow me to pass a -spec parameter to qmake?

http://www.linuxjournal.com/content/cross-compiling-qt
http://www.cmake.org/pipermail/cmake/2010-June/037239.html
http://www.trinitydesktop.org/docs/qt4/qt-embedded-crosscompiling.html

--

Thanks,
Daniel Näslund


More information about the CMake mailing list