Re: [CMake] How pass a -spec parameter to FindQt4.cmake?
On Thursday, July 21, 2011 11:48:04 pm Daniel Näslund wrote: On Thu, Jul 21, 2011 at 7:00 PM, clin...@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 ___ 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
Re: [CMake] How pass a -spec parameter to FindQt4.cmake?
- Original Message - Hi Clint and thanks for your advices (sorry about the delayed answer), On Tue, Jul 19, 2011 at 1:33 AM, clin...@elemtech.com clin...@elemtech.com wrote: 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. I included /opt/env/lenny-ppc/usr/share/qt4 (which I belive to be the root of the Qt installation) in CMAKE_FIND_ROOT_PATH but the Qt libraries still wasn't detected. Then, if you need to help it some more, you may set the path to the QtCore library manually, or other variables manually. 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) And I would have thought it can find QtCore if /opt/env/lenny-ppc/usr was given as a find root. No? Clint ___ 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
Re: [CMake] How pass a -spec parameter to FindQt4.cmake?
On Thu, Jul 21, 2011 at 7:00 PM, clin...@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. 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. 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. 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
Re: [CMake] How pass a -spec parameter to FindQt4.cmake?
What version of cmake are you using? And since you are cross-compiling, what does your toolchain file for cmake look like? Did you add a find path in that file for your powerpc libs? The spec file only applies on qmake generated makefiles, which is not happening when using cmake. And you do not need to build your own qmake. Clint - Reply message - From: Daniel Näslund dan...@dannas.name Date: Mon, Jul 18, 2011 12:12 am Subject: [CMake] How pass a -spec parameter to FindQt4.cmake? To: cmake@cmake.org 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 ___ 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 ___ 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
Re: [CMake] How pass a -spec parameter to FindQt4.cmake?
On Mon, Jul 18, 2011 at 07:23:26AM -0700, clin...@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 ___ 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
Re: [CMake] How pass a -spec parameter to FindQt4.cmake?
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 dan...@dannas.name Date: Mon, Jul 18, 2011 11:50 am Subject: [CMake] How pass a -spec parameter to FindQt4.cmake? To: clin...@elemtech.com clin...@elemtech.com Cc: cmake@cmake.org On Mon, Jul 18, 2011 at 07:23:26AM -0700, clin...@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 ___ 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