web-dev-qa-db-fra.com

cmake ne trouve pas qt 5.1.1

Je viens d'installer le Qt 5.1.1 pour Windows 32 bits (MinGW 4.8, OpenGL) et j'ai essayé de l'ajouter à mon cmake. Mais CMake ne veut tout simplement pas le trouver et je ne sais pas pourquoi. Qu'est-ce que je rate? Dois-je définir une variable d'environnement ou quelque chose?

Voici mon cmake:

cmake_minimum_required( VERSION 2.8.11 )
PROJECT(Blemmer)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Detect and add SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" ${CMAKE_MODULE_PATH})

set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
find_package(SFML REQUIRED system window graphics network audio)
# The QUIET option disables messages if the package cannot be found. 
FIND_PACKAGE(Qt5Widgets) 
add_subdirectory(Entity)
add_subdirectory(Engine)
add_subdirectory(Game)
add_executable(Blemmer main.cpp)

include_directories(${SFML_INCLUDE_DIR} ${PROJECT_SOURCE_DIR})
target_link_libraries(Blemmer ${SFML_LIBRARIES} Game Engine Qt5::Widgets)

et voici la sortie de cmake-gui:

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.
12
Amazonasmann

Vous devez définir CMAKE_PREFIX_PATH sur l'installation de Qt.

Voir http://doc.qt.io/qt-5/cmake-manual.html

16
lpapp

J'ai réussi à construire mon interface graphique sur MacOSX 10.10 en exportant des variables d'environnement Linux

$ brew install qt5
$ ls /usr/local/opt/qt5/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake
$ /usr/local/opt/qt5/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake
$ export CMAKE_PREFIX_PATH=/usr/local/opt/qt5/
$ cd ./build
$ cmake ../CMakeLists.txt
$ make -j8

Acroding to http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_PREFIX_PATH.html , la fonction cmake FIND_LIBRARY () va appends /lib to each of the directories. C'est fait.

17
micfan

Fixé avec ce qui suit dans un CMakeLists.txt fichier:

set(CMAKE_PREFIX_PATH $ENV{HOME}/Qt5.5.0/5.5/gcc_64)

Pour moi, le contexte a fini par quelque chose comme:

# Ubuntu 14.04 LTS, CMake 2.8.12.2
wget http://download.qt.io/official_releases/qt/5.5/5.5.0/qt-opensource-linux-x64-5.5.0.run
chmod u+x qt-opensource-linux-x64-5.5.0.run
./qt-opensource-linux-x64-5.5.0.run
# Follow GUI prompts, installed to default location
5
pzrq