I don't know a lot about cmake, I'm trying to build a client using cmake and Qt. Getting the following error:
CMake Error at alethzero/CMakeLists.txt:26 (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.
-- Configuring incomplete, errors occurred!
As far as I understand, I need to add the QT path to CMake. How do I do it? I have Qt installed in /home/user/Programs. All the explanations I find are "just do this or that". I need the exact Terminal commands so I can just learn how to do it in the future.
Thanks!
UPDATE: export CMAKE_PREFIX_PATH=/home/user/Programs did not help me.
Well, here you have a solution for Windows: How to find qt5 CMake module on windows
set (CMAKE_PREFIX_PATH "C:\\Qt\\Qt5.0.1\\5.0.1\\msvc2010\\")
For your environment, I think you will have to change the path where Qt is located...
Maybe this will help you:
https://github.com/Cockatrice/Cockatrice/issues/205
This is documented:
http://doc.qt.io/qt-5/cmake-manual.html
The easiest way to use CMake is to set the CMAKE_PREFIX_PATH
environment variable to the install prefix of Qt 5
Do this
export CMAKE_PREFIX_PATH=/home/user/Programs/<other_stuff>
where references the compiler etc, so that this complete path is valid:
/home/user/Programs/<other_stuff>/bin/qmake*
I needed this on my macOS after Qt installation with brew install qt5:
export CMAKE_PREFIX_PATH=/usr/local/Cellar/qt5/5.7.0/
For ubuntu:
cmake -DCMAKE_PREFIX_PATH=/home/ryan/Qt/5.11.2/gcc_64 ..
/home/ryan/Qt/ is the Qt installation root path
at an Ubuntu 16.04.4 LTS desktop the solution was
cmake .. -DMAKE_PREFIX_PATH=/usr/include/x86_64-linux-gnu/qt5
Related
I had my standalone installation of OpenCV on my Linux machine and it was running OK. I installed ROS (comes with its OpenCV) and today I cannot run my CMakeLists.txt in any of my OpenCV projects, getting the error of :
CMake Error at CMakeLists.txt:20 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
I am kinda sure this happened because some environment variable got changed however I don't know where to look at.
Could someone walk me through this?
Reinstalling OpenCV solved the problem for me, since it re-modified the Environment variable.
When I try to use cmake .., the Windows cmd points out an error:
CMake Error at CMakeLists.txt:15(find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MOUDLE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any of
the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been installed.
And I have searched many possible solutions online but it doesnt work...
For example:
write in command line cmake -DCMAKE_PREFIX_PATH="C:\OpenCV" ..
but it seems cmd doesnt know DCMAKE at all...
or cmake -DOpenCV_DIR="C:\OpenCV\build\x86\vc10\lib" .. also doesnt work.
I am not sure if those solutions are in Linux or Windows, because my computer is windows7 system... I think the error has explained how to fix it, which is
Add the installation prefix of "OpenCV" to CAMKE_PREFIX_PATH or set "OpenCV_DIR" to a directory containing one of the above files.
but I don't know exactly how to write the command code...
Please give me some hint...
A quick solution might be to edit the CMakeLists.txt to include the path for the OpenCV_DIR variable by adding the following line before the find_package(OpenCV REQUIRED):
set("OpenCV_DIR" "C:\OpenCV\build\x86\vc10\lib")
Folder containing the OpenCVConfig.cmake can also be found by:
find / -name "OpenCVConfig.cmake"
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
You need to use CMAKE_PREFIX_PATH.
For example:
cmake.exe -DCMAKE_PREFIX_PATH="C:/path/to/Qt/5.X/compiler/lib/cmake"
I'm trying to control raspberry pi camera via c++. I found api (raspicam), installed, checked. It works with an example provided by developer. Now I create my own project and got an error of CMakeLists:
CMake Error at CMakeLists.txt:3 (find_package):
By not providing "Findraspicam.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "raspicam",
but CMake did not find one.
Could not find a package configuration file provided by "raspicam" with any
of the following names:
raspicamConfig.cmake
raspicam-config.cmake
Add the installation prefix of "raspicam" to CMAKE_PREFIX_PATH or set
"raspicam_DIR" to a directory containing one of the above files. If
"raspicam" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
See also "/home/pi/raspicam/build/CMakeFiles/CMakeOutput.log".
And it is my CmakeLists.txt file:
make_minimum_required (VERSION 2.8)
project (raspicam_test)
find_package(raspicam REQUIRED)
add_executable (simpletest_raspicam simpletest_raspicam.cpp)
target_link_libraries (simpletest_raspicam ${raspicam_LIBS})
I just have started and already got a problem... Could you help please guys? :/
For those who used default instructions in the readme file of the raspicam (as of v 0.1.3, might differ in future):
you can also add
set(raspicam_DIR "/usr/local/lib/cmake")
to your cmake file before you use
find_package(raspicam REQUIRED)
That is when you have raspicamConfig.cmake at /usr/local/lib/cmake. If you did not have it at that directory, you can simply search your raspberry to find where it is or you can go to "build" folder in raspicam you used to install before. Then type sudo make install again, which will return "Up-to-date" message along with all a list of files and their locations, including raspicamConfig.cmake. Hope this helps to some.
This works for me.
$ brew install vcpkg
$ vcpkg install raspicam
$ vcpkg integrate install # get path
$ cmake -DCMAKE_TOOLCHAIN_FILE=/usr/local/Cellar/vcpkg/2021.05.12/libexec/scripts/buildsystems/vcpkg.cmake ..
My OS is Ubuntu. I would like to change from QT4 to QT5 in my project. The native package though is 4.x version in Ubuntu right now.
I have downloaded the Linux installer from QT homepage and installed QT5.4 under /opt/Qt/5.4/
This path is not found by
find_package (Qt5 REQUIRED)
I tried adding
set(CMAKE_MODULE_PATH "/opt/QT/5.4;${CMAKE_MODULE_PATH}")
to my CMAKELIST.txt but that does not help.
Where do I have to link, or am I using the wrong syntax?
Some edits after hint with calling:
cmake -DCMAKE_PREFIX_PATH=/opt/QT/5.4/gcc_64/ ../src/
I also have deleted the CMAKE_MODULE_PATH variable.
I still get the same error:
CMake Error at CMakeLists.txt:3 (find_package):
Found package configuration file:
/usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake
but it set Qt5_FOUND to FALSE so package "Qt5" is considered to be NOT
FOUND. Reason given by package:
The Qt5 package requires at least one component
I dont know why this is happening after reading https://blogs.kde.org/2008/12/12/how-get-cmake-find-what-you-want-it
. There it is stated, that the path will be searched before the default search directories. The path I used seems to be right now:
/opt/QT/5.4/gcc_64/
Adding subfolder gcc_64 must be right, as this subfolder has "lib", "include" ect as subfolders.
I remeber that I have called also
sudo apt-get install QT5-default
some time ago. This did not help, I needed the installer from QT. Although I removed qt5-default again to prevent cmake from finding the wrong package configuration file, the same error appears.
See discussion below, moved to here:
Cmake and QT5 - Include only takes one argument
You have to use the variable CMAKE_PREFIX_PATH, i.e. invoke
cmake -DCMAKE_PREFIX_PATH=/opt/QT/5.4 <path_to_source>
at the root of your build tree. Then you can use find_package(Qt5 ...) etc. See also the Qt5 cmake docs.
Rough distinction within you focus:
CMAKE_MODULE_PATH is for "general" inclusion of files and "FindXXX.cmake" files in find_package(... MODULE).
CMAKE_PREFIX_PATH has a special meaning in the context of find_package(... CONFIG).
After addition of new content
this is a new error and thus should require a new question. if you had that error before you'd have already found the Qt5 config.cmake file :-)
anyways, as the error tells you
The Qt5 package requires at least one component
you need to specify a component of the Qt5 package. As the cmake docs say, you need to use the find_package(Qt5 REQUIRED COMPONENTS Widgets Core ...) interface so that cmake (better: the logic of Qt5 FindQt5.cmake) knows what to look for. that will give you the targets Qt5::Widgets etc to use/link against.
i dont know if the syntax find_package(Qt5Widgets REQUIRED) works, could be equivalent.