0
votes

here is a doc about that, but it doesn't look correct for me , so I've copied cmake instructions into my cmakelists.txt and it doesn't work. it's clear why it doesn't work - because there is no one instruction how to search qt:

I suppose two cases:

  • some additional cmake instructions requires to set
  • some environment variables should be set

but nothing about that.

the instruction :

find_package(Qt5Widgets)

refers to extra cmake script from qt kit , isn't it? I see the directory with that name (annd contains *.cmake scripts but another names) but there is no the script with this name

these are the only .cmake files with qt in names in cmake 3.6 :

cmake-3.6\Modules\DeployQt4.cmake
cmake-3.6\Modules\FindosgQt.cmake
cmake-3.6\Modules\FindQt.cmake
cmake-3.6\Modules\FindQt3.cmake
cmake-3.6\Modules\FindQt4.cmake
cmake-3.6\Modules\Qt4ConfigDependentSettings.cmake
cmake-3.6\Modules\Qt4Macros.cmake
cmake-3.6\Modules\UseQt4.cmake

===================

C:\dev\tools\CLion.RC\bin\cmake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\dev\workspace\algolist.v2 CMake Warning at CMakeLists.txt:14 (find_package): By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5Widgets", but CMake did not find one.

Could not find a package configuration file provided by "Qt5Widgets" with any of the following names:

Qt5WidgetsConfig.cmake
qt5widgets-config.cmake

Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or set "Qt5Widgets_DIR" to a directory containing one of the above files. If "Qt5Widgets" provides a separate development package or SDK, be sure it has been installed.

CMake Error at CMakeLists.txt:20 (target_link_libraries): Cannot specify link libraries for target "helloworld" which is not built by
this project.

-- Configuring incomplete, errors occurred! See also "C:/dev/workspace/algolist.v2/cmake-build-debug/CMakeFiles/CMakeOutput.log".

seems it found Qt5Widgets, but absolutely not clear how it does this... so it looks for cmake files inside Qt5Widgets folder, in Qt kit. I can add this folder to the path but I don't think this is a valid way, because there is a lot of subfolders with cmake files


Qt5.8 beta, built with MinGW, Win10, cmake 3.6

1
because there is no one instruction how to search qt On windows you need to set QT_CMAKE_PATH in cmake-gui to the location of the root of the Qt cmake files when it can't find Qt (which it never does for me bcause I don't install this in Program Files). If you built Qt from source the folder is the qtbase\lib\cmake folder.drescherjm
Qt5WidgetsConfig.cmake is the file that is needed for this find_package(Qt5Widgets)drescherjm
thank you, but it didn't help me, let me update the questionamigo421
these are the only .cmake files with qt in names in cmake 3.6 That is correct. The locations of the .cmake files you need are included in Qt5 and are not part of CMake itself.drescherjm
but it didn't help me You did not seem to open cmake-gui and set the variable that I told you to set. When you do this make sure your source and build folders for your project are correct in cmake-gui.drescherjm

1 Answers

1
votes

You need to use CMAKE_PREFIX_PATH.

For example:

cmake.exe -DCMAKE_PREFIX_PATH="C:/path/to/Qt/5.X/compiler/lib/cmake"