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

Daniel Näslund dannas at dannas.name
Mon Jul 18 14:50:39 EDT 2011


On Mon, Jul 18, 2011 at 07:23:26AM -0700, clinton at elemtech.com 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


More information about the CMake mailing list