Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH

add the installation prefix of "qt5" to cmake_prefix_path or set "qt5_dir"
cmake search path
cmake_module_path
dcmake_prefix_path
cmake find_package not working
qt5_dir notfound cmake
cmake path
qt cmake add library

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.

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*

Ubuntu 18.04 - Add the installation prefix of "libcpprest-dev" to CMAKE_PREFIX_PATH #763. Closed. adamzerella opened this issue on May  Run ./b2 install --prefix=PREFIX where PREFIX is a directory where you want Boost.Build to be installed. Optionally, add PREFIX/bin to your PATH environment variable. If you are not using a Boost

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

How to Add the installation prefix of "Eigen3" to CMAKE_PREFIX_PATH or set "​Eigen3_DIR" to a directory containing one of the above files. cpprestsdk-config.cmake. Add the installation prefix of "cpprestsdk" to CMAKE_PREFIX_PATH or set "cpprestsdk_DIR" to a directory containing one of the above files. If "cpprestsdk" provides a separate development package or SDK, be sure it has been installed. I assure you I have installed libcpprest-dev on my system

I needed this on my macOS after Qt installation with brew install qt5:

export CMAKE_PREFIX_PATH=/usr/local/Cellar/qt5/5.7.0/

The easiest way to use CMake is to set the CMAKE_PREFIX_PATH environment variable to the install prefix of Qt 5. In this method: Could not find a package configuration file provided by "Eigen3" with any of the following names: Eigen3Config.cmake eigen3-config.cmake Add the installation prefix of "Eigen3" to CMAKE_PREFIX_PATH or set "Eigen3_DIR" to a directory containing one of the above files.

at an Ubuntu 16.04.4 LTS desktop the solution was

cmake .. -DMAKE_PREFIX_PATH=/usr/include/x86_64-linux-gnu/qt5

If “make install” is invoked or INSTALL is built, this directory is prepended The installation prefix is also added to CMAKE_SYSTEM_PREFIX_PATH so that  Hi, I am trying to make a subscriber program that listens to an installed package called roscopter. I know the topic and package name. In the CMakeLists i have included the package "roscopter" find_package(catkin REQUIRED COMPONENTS roscpp roscopter) However, when i run catkin_make it could not find the package.

For ubuntu: cmake -DCMAKE_PREFIX_PATH=/home/ryan/Qt/5.11.2/gcc_64 ..

/home/ryan/Qt/ is the Qt installation root path

list of directories specifying installation prefixes to be searched by the Each command will add appropriate subdirectories (like bin , lib , or include ) as  WARNING: DESTDIR may not be used on Windows because installation prefix usually contains a drive letter like in “C:/Program Files” which cannot be prepended with some other prefix. The installation prefix is also added to CMAKE_SYSTEM_PREFIX_PATH so that find_package, find_program, find_library, find_path, and find_file will search the prefix for other software.

Installing locally built applications with prefix /usr is a really bad idea as the files installed may easily overwrite files installed by package  On UNIX one can use the DESTDIR mechanism in order to relocate the whole installation. See DESTDIR for more information. The installation prefix is also added to CMAKE_SYSTEM_PREFIX_PATH so that find_package (), find_program () , find_library (), find_path (), and find_file () will search the prefix for other software.

Add the installation prefix of "galtoolslib" to CMAKE_PREFIX_PATH or set "​galtoolslib_DIR" to a directory containing one of the above files. If Add the installation prefix of “Qt5Widgets” to CMAKE_PREFIX_PATH - Wikitechy

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  If you find Prefix useful, check out Retrace, Stackify’s APM tool. Retrace takes it to a new level by combining your logs with lightweight code profiling. Get In Touch

Comments
  • Also, if you don't have QT on Ubuntu you can install it using sudo apt-get install qt5-default
  • Thank you! I have done that before and I'm still getting the same result. Maybe I should re-install QT from source. (I installed it with their .run package).
  • Sorry, I edited the post to give a correct answer. You don't need to compile Qt from source.
  • This is the best answer I think. I set CCMAKE_PREFIX_PATH to C:\Qt\Qt5.5.0\5.5\msvc2013_6 and it worked for me. Note that in QtCreator I did not need to do this. Apparently, QtCreator already takes care of this but if I use cmake independent of QtCreator I have to do this.
  • it worked really good answer. why did they gave you a minus i don't get it. the answer didn't work. but yours did
  • Maybe you could give +1 :) ... Well I think is because this answer is only for Windows, and it appears that the OP is using Linux. At the end the only change will be the path...
  • for unknown reasons with cmake 3.10. It has not worked, I had to export the variable in shell.
  • This was the solution for me running Ubuntu 16.04LTS