cmake not finding Qt4

后端 未结 5 1955
盖世英雄少女心
盖世英雄少女心 2021-02-19 18:32

Since 4.8.0 is out, I\'ve reinstalled Qt, and now I want to use cmake too. To make cmake work, I remember having to add the mingw bin folder (QtSDK\\Desktop\\Qt\\4.7.3

相关标签:
5条回答
  • So, I found out what was the problem, and I think I should have known before. I simply added C:\QtSDK\Desktop\Qt\4.8.0\msvc2010\bin to my PATH variable. It may be useful to note that, in a default 4.8.0 install, qmake is located in C:\QtSDK\Desktop\Qt\4.8.0\msvc2010\bin as opposed to C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin in 4.7.3. Notice the difference; msvc2010 vs mingw. It's actually glaringly obvious, as msvc2010 was the only folder in that directory.

    I didn't try skyhisi's answer as it was no longer needed, but I'm guessing that it's another correct (if not better) way to make cmake work.

    0 讨论(0)
  • 2021-02-19 19:17

    I had the same problem and I solved providing the path to qmake,

     QT_QMAKE_EXECUTABLE   /opt/qt-4.8.7/bin/qmake
    

    On Mac, while the binaries are saved in /usr/local/Trolltech/Qt-4.8.7/bin the required qmake required as value of QT_QMAKE_EXECUTABLE is, for my OS, stored in the path /opt/qt-4.8.7/bin/qmake . Hope this help as well.

    0 讨论(0)
  • 2021-02-19 19:21

    Just ran into the same problem... Take a look into findQt4.cmake

    FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 qmake-mac PATHS
       "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
       "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
       "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin"
       $ENV{QTDIR}/bin
       DOC "The qmake executable for the Qt installation to use")
    

    You can either alter registry keys, or, I personally prefer deleting all those keys altogether and modify $ENV{QTDIR} variable. Good luck.

    0 讨论(0)
  • 2021-02-19 19:24

    You just need to set the path to qmake in QT_QMAKE_EXECUTABLE, and then cmake can use qmake -query to find all the other paths it needs (similar to pkg-config on Linux).

    Steps for building a project using Qt and CMake usually are:

    1. Check out / create project source folder
    2. Create build folder outside the project folder
    3. Start Qt command prompt / cmd and cd into build folder e.g. cd build\project
    4. Run cmake or cmake-gui passing path to source folder e.g. cmake-gui ..\..\source\project
    5. Set any variables, such as QT_QMAKE_EXECUTABLE and CMAKE_BUILD_TYPE
    6. Run your build tool, or run cmake --build .
    0 讨论(0)
  • 2021-02-19 19:28

    I had this problem for a slightly different reason. Maybe this will help someone else:

    I uninstalled Qt 4.8.3 and then installed qt 4.8.4. Based on Slava's answer I discovered that CMake is getting the value of $(qt_install_version} from:

    [HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\DefaultVersion]
    

    This was still set to 4.8.3 even though all the other registry entries were updated to 4.8.4. Changing the value of the DefaultVersion key to 4.8.4 fixed the problem for me.

    0 讨论(0)
提交回复
热议问题