如何在Windows上找到qt5 CMake模块 [英] How to find qt5 CMake module on windows

查看:1502
本文介绍了如何在Windows上找到qt5 CMake模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Windows上使用CMake做一个非常基本的Qt5应用程序。
我使用了 qt5的文档来使用CMake ,我的main.cpp文件只包含一个主函数。

I'm trying to make a very basic Qt5 application using CMake on windows. I used the documentation of qt5 to use CMake, and my main.cpp file just contains a main function.

我的CMakeLists.txt是:

My CMakeLists.txt is exactly :

cmake_minimum_required(VERSION 2.8.9)

project(testproject)

编辑解决方案

set (CMAKE_PREFIX_PATH "C:\\Qt\\Qt5.0.1\\5.0.1\\msvc2010\\")

end EDIT

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

# Find the QtWidgets library
find_package(Qt5Widgets)

# Tell CMake to create the helloworld executable
add_executable(helloworld hello.cpp)

# Use the Widgets module from Qt 5.
qt5_use_modules(helloworld Widgets)

在MSysGit bash中输入`$ cmake -G'Visual Studio 11

When in MSysGit bash I enter `$ cmake -G"Visual Studio 11"

p>

I get this output:

$ cmake -G"Visual Studio 11"
-- The C compiler identification is MSVC 17.0.60204.1
-- The CXX compiler identification is MSVC 17.0.60204.1
-- Check for working C compiler using: Visual Studio 11
-- Check for working C compiler using: Visual Studio 11 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 11
-- Check for working CXX compiler using: Visual Studio 11 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Warning at CMakeLists.txt:11 (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:17 (qt5_use_modules):
  Unknown CMake command "qt5_use_modules".


-- Configuring incomplete, errors occurred!

你有什么想法吗?

推荐答案

添加此问题解决了问题。

Adding this solves the problem.

set(CMAKE_PREFIX_PATHC:\\Qt\\Qt5.0.1\\5.0.1\\msvc2010\\)

我编辑了第一篇文章。

这篇关于如何在Windows上找到qt5 CMake模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆