amigo421
amigo421

Reputation: 2541

How to configure cmake-based project for a build with Qt

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:

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

Upvotes: 2

Views: 2462

Answers (1)

SGaist
SGaist

Reputation: 928

You need to use CMAKE_PREFIX_PATH.

For example:

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

Upvotes: 2

Related Questions