【问题标题】:Integrating QT with CMAKE in Mac OS在 Mac OS 中将 QT 与 CMAKE 集成
【发布时间】:2020-05-14 14:25:08
【问题描述】:

我正在尝试将我的 QT 项目集成到我的 CLION 项目中。 在这种情况下,我遇到了 CMAKE 和 QT 集成的问题。 我的 CmakeList.txt 的内容是:

    cmake_minimum_required(VERSION 3.12)
project(BD2_PROYECTO_1)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_PREFIX_PATH "/Users/jonathanprieto/Qt5.13.0/5.13.0/")

find_package(Qt5Widgets REQUIRED)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

add_executable(BD2_PROYECTO_1 parser.cpp parser.h main.cpp statichashing.cpp statichashing.h randomfile.cpp randomfile.h record.cpp record.h transactions.cpp transactions.h ui/input.cpp ui/input.h ui/ui_dialog.h ui/mainwindow.h ui/mainwindow.cpp ui/mainwindow.ui ui/ui_input.ui ui/input.h ui/dialog.ui)
target_link_libraries(helloworld Qt5::Widgets)

但我收到以下错误:

CMake Error at CMakeLists.txt:8 (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.

有人可以帮我吗?

谢谢

【问题讨论】:

  • /Users/jonathanprieto/Qt5.13.0/5.13.0/lib/cmake 吗?如果是这样,that 应该是您的 CMAKE_PREFIX_PATH。另外,你可以通过brew 安装Qt 就好了。
  • 无关:find_package(Qt5 COMPONENTS Widgets REQUIRED) 允许您在需要时一次指定多个组件。
  • 我没有lib目录,只有clang_64、ios、src,还有很多版本的android。
  • 我找到了解决方案!路径是:/Users/jonathanprieto/Qt5.13.0/5.13.0/clang_64/lib/cmake

标签: c++ qt cmake


【解决方案1】:

经过一番尝试,我找到了解决问题的方法。 所以我发布我的 CMakeList.txt 代码以防你有同样的问题。

cmake_minimum_required(VERSION 3.12)
project(BD2_PROYECTO_1)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_PREFIX_PATH "/Users/jonathanprieto/Qt5.13.0/5.13.0/clang_64/lib/cmake")

find_package(Qt5 COMPONENTS Widgets REQUIRED)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

add_executable(BD2_PROYECTO_1 parser.cpp parser.h main.cpp statichashing.cpp statichashing.h randomfile.cpp randomfile.h record.cpp record.h transactions.cpp transactions.h ui/input.cpp ui/input.h ui/ui_dialog.h ui/mainwindow.h ui/mainwindow.cpp ui/mainwindow.ui ui/ui_input.ui ui/input.h ui/dialog.ui ui/input.ui)
target_link_libraries(BD2_PROYECTO_1 Qt5::Widgets)

希望对你有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-05
    • 1970-01-01
    • 2013-02-10
    • 2016-02-26
    • 2011-08-03
    • 2016-11-28
    相关资源
    最近更新 更多