[CMake] How pass a -spec parameter to FindQt4.cmake?
Clinton Stimpson
clinton at elemtech.com
Fri Jul 22 14:41:35 EDT 2011
On Thursday, July 21, 2011 11:48:04 pm Daniel Näslund wrote:
> On Thu, Jul 21, 2011 at 7:00 PM, <clinton at elemtech.com> wrote:
> >> Managed to compile and link when I added the following snippet to the
> >> toolchain file:
> >>
> >> set(QT_HEADERS_DIR /opt/env/lenny-ppc/usr/lib)
> >> set(QT_LIBRARY_DIR /opt/env/lenny-ppc/usr/include/qt4)
> >>
> >> set(QT_QTCORE_LIBRARY /opt/env/lenny-ppc/usr/lib/libQtCore.so)
> >> set(QT_QTCORE_LIBRARY_RELEASE
> >> /opt/env/lenny-ppc/usr/lib/libQtCore.so)
> >> set(QT_QTCORE_INCLUDE_DIR /opt/env/lenny-ppc/usr/include/qt4)
> >>
> >> set(QT_QTDBUS_LIBRARY /opt/env/lenny-ppc/usr/lib/libQtDBus.so)
> >> set(QT_QTDBUS_LIBRARY_RELEASE
> >> /opt/env/lenny-ppc/usr/lib/libQtDBus.so)
> >> set(QT_QTDBUS_INCLUDE_DIR /opt/env/lenny-ppc/usr/include/qt4)
> >>
> >> set(QT_QTXML_LIBRARY /opt/env/lenny-ppc/usr/lib/libQtXml.so)
> >> set(QT_QTXML_LIBRARY_RELEASE
> >> /opt/env/lenny-ppc/usr/lib/libQtXml.so)
> >> set(QT_QTXML_INCLUDE_DIR /opt/env/lenny-ppc/usr/include/qt4)
> >>
> >> Would have been nice if I didn't have to set those paths explicitely.
> >> Will continue the digging.
> >
> > Does it work if you only specify just this:
> > set(QT_HEADERS_DIR /opt/env/lenny-ppc/usr/include/qt4)
> > set(QT_QTCORE_LIBRARY_RELEASE
> > /opt/env/lenny-ppc/usr/lib/libQtCore.so)
>
> Unfortunately no. I get:
>
> 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/tmpMm5uhv/CMakeFiles/CMakeError.log for more details.
Ok then perhaps you'll need a newer cmake for it to work.
I looked again and it should actually be as simple as:
set(QT_QTCORE_INCLUDE_DIR /opt/env/lenny-ppc/usr/include/qt4)
set(QT_QTCORE_LIBRARY_RELEASE /opt/env/lenny-ppc/usr/lib/libQtCore.so)
and the others should be found based on that.
>
> > And I would have thought it can find QtCore if /opt/env/lenny-ppc/usr
> > was given as a find root. No?
>
> Adding /opt/env/lenny-ppc/usr causes Pkg-config to choke:
>
> -- checking for module 'ecco-sqlite-1.12'
> /opt/env/lenny-ppc/usr/bin/pkg-config: 1: Syntax error: "(" unexpected
> -- package 'ecco-sqlite-1.12' not found
> CMake Error at
> /usr/share/cmake-2.8/Modules/FindPkgConfig.cmake:266 (message):
> A required package was not found
> Call Stack (most recent call first):
> /usr/share/cmake-2.8/Modules/FindPkgConfig.cmake:320
> (_pkg_check_modules_internal)
> CMakeLists.txt:51 (pkg_check_modules)
>
> This happens for each of the libraries we're trying to detect with
> PkgConfig.
Ok, then it looks like the PkgConfig stuff needs fixed as well.
>
> Adding /opt/env/lenny-ppc/usr/share/qt4 to CMAKE_FIND_ROOT_PATH gives:
>
> -- Found Qt-Version 4.6.3 (using /usr/bin/qmake)
> CMake Error: The following variables are used in this project, but
> they are set to NOTFOUND.
> Please set them or make sure they are set and tested correctly in the
> CMake files:
> QT_QTCORE_INCLUDE_DIR (ADVANCED)
> used as include directory in directory /home/dannas/bigsister_775
>
> Trying to prefix the PATH enviroment variable with
> /opt/env/lenny-ppc/usr/share/qt4 gives the same result.
Ok, I think the following will fix that by automatically finding the headers if
Qt was configured with "-headerdir include/qt4"
--- a/Modules/FindQt4.cmake
+++ b/Modules/FindQt4.cmake
@@ -620,7 +620,7 @@ IF (QT_QMAKE_EXECUTABLE AND QTVERSION)
SET(QT_QTCORE_INCLUDE_DIR NOTFOUND)
FIND_PATH(QT_QTCORE_INCLUDE_DIR QtCore
HINTS ${qt_headers} ${QT_LIBRARY_DIR}
- PATH_SUFFIXES QtCore
+ PATH_SUFFIXES QtCore qt4/QtCore
)
With that patch, and you adding /opt/env/lenny-ppc/usr to
CMAKE_FIND_ROOT_PATH, then Qt will be found without you helping it (that is if
the PkgConfig thing gets fixed too).
--
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com
More information about the CMake
mailing list