When cross compiling, only some the qmake queries are actually used.  

Finding the rest just works if subdirs in the Qt installation weren't given 
different values when running Qt's configure script (e.g. --libdir=mylib or 
--libdir=lib/qt4).

So, the root of the Qt installation needs to be given in the toolchain file.  
Is /opt/env/lenny-ppc/usr/lib/qt4 the root of the installation, or the location 
of the libraries?  In either case, it won't be searched unless you put that in 
your toolchain file.  The standard cross compile find variables are the global 
variables you can setto help find Qt.

Then, if you need to help it some more, you may set the path to the QtCore 
library manually, or other variables manually.

If lib/qt4 is another path that should be searched automatically, let us know, 
and we can add it to FindQt4.cmake.

Clint

----- Reply message -----
From: "Daniel Näslund" <[email protected]>
Date: Mon, Jul 18, 2011 11:50 am
Subject: [CMake] How pass a -spec parameter to FindQt4.cmake?
To: "[email protected]" <[email protected]>
Cc: <[email protected]>


On Mon, Jul 18, 2011 at 07:23:26AM -0700, [email protected] wrote:
> What version of cmake are you using? 

$ cmake --version
cmake version 2.8.4

> And since you are cross-compiling, what does your toolchain file for
> cmake look like?  

The contents of my toolchain.cmake file:

    set(CMAKE_SYSTEM_NAME Linux)
    set(CROSSPREFIX /opt/crosstool/gcc-4.2.0-glibc-2.5/powerpc-603-linux-gnu)

    set(CMAKE_C_COMPILER   ${CROSSPREFIX}/bin/powerpc-603-linux-gnu-gcc)
    set(CMAKE_CXX_COMPILER ${CROSSPREFIX}/bin/powerpc-603-linux-gnu-g++)
    set(CMAKE_LINKER       ${CROSSPREFIX}/bin/powerpc-603-linux-gnu-ld)

    set(CMAKE_FIND_ROOT_PATH ${CROSSPREFIX}/lib
                             /opt/env/lenny-ppc/lib
                             /opt/env/lenny-ppc/usr/lib)

    set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
    set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

The part of my CMakeLists.txt that tries to find a Qt installation:

    if (USE_QT)
        message(STATUS "Build support for QT is enabled.")
        find_package(Qt4 4.4 COMPONENTS QtCore QtDbus REQUIRED)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_QT")
        include(${QT_USE_FILE})
    else()
        message(STATUS "Build support for QT is disabled.")
    endif (HAS_QT)

> Did you add a find path in that file for your powerpc libs?  

Since the libs are located in /opt/env/lenny-ppc/usr/lib/qt4 I expect
that this line taken from the toolchain file above is sufficient:

    set(CMAKE_FIND_ROOT_PATH ${CROSSPREFIX}/lib
                             /opt/env/lenny-ppc/lib
                             /opt/env/lenny-ppc/usr/lib)

> The spec file only applies on qmake generated makefiles, which is not
> happening when using cmake.  

Ah, 

> And you do not need to build your own qmake.

Ok. But I don't see how I can make qmake return the right information.
Here's the function in FindQt4.cmake that is used for querying qmake:

    function(_QT4_QUERY_QMAKE VAR RESULT)
      exec_program(${QT_QMAKE_EXECUTABLE} ARGS "-query ${VAR}" RETURN_VALUE 
return_code OUTPUT_VARIABLE output )
      if(NOT return_code)
        file(TO_CMAKE_PATH "${output}" output)
        set(${RESULT} ${output} PARENT_SCOPE)
      endif(NOT return_code)
    endfunction(_QT4_QUERY_QMAKE)

I don't see anywhere that it relies upon some variable that I can change
in order to have it point at the target Qt4 installation. Is there some
global variable involved for setting the base directory or something
similar?

Daniel
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to