Cockatrice: FindQt5 not provided for cmake

Created on 11 Jul 2014  路  25Comments  路  Source: Cockatrice/Cockatrice

I used Homebrew to install qt4 in the past.
I uninstalled qt4, installed qt5 and tried building with cmake; Error posted below:

CMake Warning at CMakeLists.txt:97 (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 /usr/local/Cellar/cmake/3.0.0/share/cmake/Modules/FindQt4.cmake:1316 (message):
  Found unsuitable Qt version "" from NOTFOUND, this code requires Qt 4.x
Call Stack (most recent call first):
  CMakeLists.txt:108 (FIND_PACKAGE)


-- Configuring incomplete, errors occurred!
OS - macOS

Most helpful comment

CMake bundles a FindQt4 module itself, but no FindQt5 module. The Qt5 cmake modules are provided by Qt5 itself, so you need to tell cmake where qt can be found:

cmake .. -DCMAKE_PREFIX_PATH=/usr/local/Cellar/qt5/5.3.1/

Relevant documentation from: http://qt-project.org/doc/qt-5/cmake-manual.html

In order for find_package to be successful, Qt 5 must be found below the CMAKE_PREFIX_PATH,
or the Qt5<Module>_DIR must be set in the CMake cache to the location of the Qt5WidgetsConfig.cmake file.
The easiest way to use CMake is to set the CMAKE_PREFIX_PATH environment variable to
the install prefix of Qt 5.

All 25 comments

CMake bundles a FindQt4 module itself, but no FindQt5 module. The Qt5 cmake modules are provided by Qt5 itself, so you need to tell cmake where qt can be found:

cmake .. -DCMAKE_PREFIX_PATH=/usr/local/Cellar/qt5/5.3.1/

Relevant documentation from: http://qt-project.org/doc/qt-5/cmake-manual.html

In order for find_package to be successful, Qt 5 must be found below the CMAKE_PREFIX_PATH,
or the Qt5<Module>_DIR must be set in the CMake cache to the location of the Qt5WidgetsConfig.cmake file.
The easiest way to use CMake is to set the CMAKE_PREFIX_PATH environment variable to
the install prefix of Qt 5.

Can we do that automatically when in qt5 mode?

Not really; we can only blindly add some default paths to CMAKE_PREFIX_PATH and hope that will suffice, as suggested here: http://stackoverflow.com/questions/15639781/how-to-find-qt5-cmake-module-on-windows
The worst part is that these paths include the Qt version number, so they're not definitive anyway: e.g.:

Osx, from homebrew: /usr/local/Cellar/qt5/5.3.1/
Osx, from Qt's official package: ~/Qt/5.3.1/clang_64/
Windows, from Qt's official package (msvc): c:\Qt\5.3.1\msvc2010_opengl\
Windows, from Qt's official package (mingw): c:\Qt\5.3.1\mingw482_32\

Arch Linux needs to pass the flag manually as well. I'll have to update the PKGBUILD in aur.

@ctrlaltca Do you think it's a good solution to take qt5's find script and stick it into cmake/ with FindQtMobility?

Alternately if we can configure the cmake script such that FindQt5 being missing automatically falls back to Qt4

A clarifications about finding qt4/qt5 using cmake: Qt4 provides no cmake configuration, so cmake bundles a FindQt4.cmake script to search Qt4 installations in default paths (like /usr/lib/, /usr/local/lib, etc...).
Qt5, instead, provides cmake support natively through Qt5Config.cmake scripts, so no official FindQt5.cmake module exists in cmake. We could write one, but that won't solve the problem of understanding where qt5 libraries are located anyway (and would probably be a suboptimal solution: qt5's modular cmake scripts are quite complicated).
Adding up the fact that Qt4 and Qt5 share library/framework names and that Qt4 is the most broadly used version, it's typical for linux distro (or packagers like homebrew) to avoid putting Qt5 in the common paths (like /usr/lib) to avoid overwriting Qt4.
Example, here's homebrew's reaction to the attempt of softlinking qt5 to /usr/local:

Lapidus:qt fab$ brew link qt5
Warning: qt5 is keg-only and must be linked with --force
Note that doing so can interfere with building software.

Another clarifications: currently the cmake script logic is (in pseudocode):

IF(NOT WITH_QT4)
    search_for_qt5()
ENDIF()

IF(Qt5 has been found)
    use_qt5()
ELSE()
  search_for_qt4()
  use_qt4_if_found()
ENDIF()

So, Qt4 is always searched and used unless a working Qt5 installation has been found (and the user can bypass Qt5 using the WITH_QT4 option).

On my system if I don't use WITH_QT4 cmake exits with the same failure as OP

Weird. On my 10.6.8 box with Qt4 installed the compiling works fine (or did last I checked).
I haven't tried to compile since you rolled in the Windows CMake Fixes.

From the symptoms it seems that just checking for Qt5 using:

FIND_PACKAGE(Qt5Widgets)

actually breaks FindQt4.cmake from working in your box.

This is what should happen (and actually happens in my box):

CMake Warning at CMakeLists.txt:97 (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.


-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - not found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - found
-- Looking for QT_MAC_USE_COCOA
-- Looking for QT_MAC_USE_COCOA - found
-- Found Qt4: /usr/local/bin/qmake (found suitable version "4.8.6", minimum required is "4.8.0") 
-- Found Qt 4.8.6

Cmake searches for Qt5 and fails, then checks for Qt4 and uses it.
I tested osx 10.9/cmake 3.0.0 and linux slackware 14.1 / cmake 2.8.12 and they both works.. i need to investigate this a bit further.
In the meanwhile, as a workaround, we could consider the idea of inverting the priorities: search Qt4 first and then Qt5; remove WITH_QT4 and add WITH_QT5.

Proposed workaround: https://github.com/ctrlaltca/Cockatrice/compare/master_qt4_first ; if this is a good solution for you, i will PR

@ZeldaZach bump

@Daenyth Ok, so I ran @ctrlaltca's "master_qt4_first" (4adda51) build using the command cmake .. -DWITH_QT5=1 and compiling failed.

Note: Both QT4 (v4.8.6) and QT5 (5.3.0) were installed.

Terminal Build Error
Error Log

That's the expected behavior of the "master_qt4_first" branch.
Since you forced the use of Qt5, but it has not ben found (Qt5 can't be found automatically, see the previous CMAKE_PREFIX_PATH discussion), cmake errors out.
Running cmake without "-DWITH_QT5=1" is supposed to find Qt4 and build fine, instead.

@ctrlaltca Ok, so I ran the program cmake .. -DCMAKE_PREFIX_PATH=/usr/local/Cellar/qt5/5.3.0/ -DWITH_QT5=1 and it succeeded

I think we can address this with documentation on the wiki. I need to see if I can configure travis to build it both ways.. yay combinatorial explosion of compile configurations!

I added a note to the wiki under the homebrew section

I am not a Cockatrice user, but I found this thread because I encountered the same problem on my own project, and this thread was very useful. My solution is to tell the user to run this command in the documentation:

cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix qt5)

This works for me, and it's simpler than the solution on the Cockatrice wiki:

QT5_DIR=$(brew info --installed qt5 | grep "^$(brew --cellar qt5)" | cut -d' ' -f1)
cmake .. ... -DCMAKE_PREFIX_PATH=$QT5_DIR/

Derp, yeah --prefix makes sense. Please feel free to update the wiki

It workes when installed qt5-default

HI My Name is Elifuraha Mtalo ([email protected])

I am trying to configure CloudCompare using the cmake-gui on Linux - 4.13.0-43-generic - x86_64 (Ubuntu 16.04) and I am unable to clear all the issues raised by the configuration program as shown in the attachment: Problens Configuring CloudCompare.pdf

For clarity I installed Qt5.9.1 successfully under /usr/local
After installing all the required libraries as shown here:

cmake-qt-gui installation

$ sudo apt-get install cmake-qt-gui

OpenGL Installation:

$ sudo apt-get update
$ sudo apt-get install freeglut3
$ sudo apt-get install freeglut3-dev
$ sudo apt-get install binutils-gold

Qt5.9.1 Installation

$ wget http://download.qt.io/official_releases/qt/5.9/5.9.1/qt-opensource-linux-x64-5.9.1.run
$ chmod +x qt-opensource-linux-x64-5.9.1.run
$ sudo ./qt-opensource-linux-x64-5.9.1.run

CloudCompare Installation:

$ cd CloudCompare
$ sudo cmake-gui

Configuration Issues Raised:
QT5_ROOT_PATH NOT FOUND
At5Widgets_DIR NOT COUND
Qt5PrintSupport_DIR NOT FOUND
Qt5Concurrent_DIR NOT FOUND
Qt5OpenGL_DIR NOT FOUND
...

I browsed the Qt5.9.1 installation directory tree and set the problematic parameters as follows:

QT5_ROOT_PATH = /usr/local/Qt5.9.1
Qt5Widgets_DIR = /usr/local/Qt5.9.1/5.9.1/gcc_64/lib/cmake/Qt5Widgets
Qt5PrintSupport_DIR = /usr/local/Qt5.9.1/5.9.1/gcc_64/lib/cmake/Qt5PrintSupport
Qt5Concurrent_DIR = /usr/local/Qt5.9.1/5.9.1/gcc_64/lib/cmake/Qt5Concurrent
Qt5OpenGL_DIR = /usr/local/Qt5.9.1/5.9.1/gcc_64/lib/cmake/Qt5OpenGL
Qt5OpenGLExtensions = /usr/local/Qt5.9.1/5.9.1/gcc_64/lib/cmake/Qt5OpenGLExtensions
Qt5Svg_DIR = /usr/local/Qt5.9.1/5.9.1/gcc_64/lib/cmake/Qt5Svg

After this the configuration program displayed a number of options and after checking the options
the configuration raised the following exceptions:
CGAL_DIR NOT FOUND
PDAL_DIR NOT FOUND

I unchecked the CGAL and PDAL plugins options but I still get the same issues raised.

Can any one help resolve this issue?

@mtalo This bug tracker is for the Cockatrice software, please ask the CloudCompare people for support

CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by "stg_msgs" with any
of the following names:

stg_msgsConfig.cmake
stg_msgs-config.cmake

I am a freshman to learn ros ,i don't know what means and how to solve this problem? can some graet man help me?

CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by "stg_msgs" with any
of the following names:
stg_msgsConfig.cmake
stg_msgs-config.cmake
I am a freshman to learn ros ,i don't know what means and how to solve this problem? can some graet man help me? @ctrlaltca @ @DavidEGrayson

@troyesivanyh this is the support page for a tabletop card game. You may want to ask for support in the correct place for the software you are trying to compile.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Thunderbeliever picture Thunderbeliever  路  6Comments

P-rus picture P-rus  路  6Comments

Assassinsquid picture Assassinsquid  路  4Comments

TheMasterpass picture TheMasterpass  路  4Comments

poixen picture poixen  路  4Comments