无法建立使用Qt5Widgets的程式库

时间:2018-09-22 15:46:35

标签: ubuntu cmake qt5

我使用Ubuntu18。我尝试构建使用Qt5Widgets的assimp库,CMakeLists.txt包含以下行:

FIND_PACKAGE(Qt5Widgets QUIET)

我在系统中找不到“ FindQt5Widgets.cmake”或“ FindQt5.cmake”,但是Qt5的安装位置包含以下目录:

/home/user/Qt5/5.11.1/gcc_64/lib/cmake/Qt5Widgets

其中包含以下文件:

Qt5WidgetsConfig.cmake  
Qt5WidgetsConfigExtras.cmake  
Qt5WidgetsConfigVersion.cmake  
Qt5WidgetsMacros.cmake

我尝试设置CMAKE_PREFIX_PATH:

-DCMAKE_PREFIX_PATH=/home/user/Qt5/5.11.1/gcc_64/lib/cmake/Qt5Widgets

-DCMAKE_PREFIX_PATH=/home/user/Qt5/5.11.1/gcc_64

但没有帮助。

该如何解决?

编辑1

警告消息:

CMake Warning at CMakeLists.txt:439 (MESSAGE):
Build of assimp_qt_viewer is disabled.  Unsatisfied dendencies: Qt5 DevIL

CMakeLists.txt的一部分,导致此警告:

 FIND_PACKAGE(Qt5Widgets QUIET)
 FIND_PACKAGE(DevIL QUIET)
 FIND_PACKAGE(OpenGL QUIET)
 IF ( Qt5Widgets_FOUND AND IL_FOUND AND OPENGL_FOUND)
    ADD_SUBDIRECTORY( tools/assimp_qt_viewer/ )
 ELSE()
    SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "")
    IF (NOT Qt5_FOUND)
       SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} Qt5")
    ENDIF (NOT Qt5_FOUND)

    IF (NOT IL_FOUND)
       SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} DevIL")
    ENDIF (NOT IL_FOUND)

    IF (NOT OPENGL_FOUND)
       SET ( ASSIMP_QT_VIEWER_DEPENDENCIES "${ASSIMP_QT_VIEWER_DEPENDENCIES} OpengGL")
    ENDIF (NOT OPENGL_FOUND)

    MESSAGE (WARNING "Build of assimp_qt_viewer is disabled. Unsatisfied dendencies: ${ASSIMP_QT_VIEWER_DEPENDENCIES}") # Line 439
 ENDIF ( Qt5Widgets_FOUND AND IL_FOUND AND OPENGL_FOUND)

我将错误消息解释为Qt5_FOUNDIL_FOUND变量为假,这意味着对FIND_PACKAGE(Qt5Widgets QUIET)FIND_PACKAGE(DevIL QUIET)的调用已失败。搜索DevIL超出了给定问题的范围。

Edit2 修改后的FIND_PACKAGE:

FIND_PACKAGE(Qt5Widgets REQUIRED)

cmake .. 输出:

CMake Error at CMakeLists.txt:420 (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_PREFIX_PATH或Qt5Widgets_DIR),没有错误消息,但我仍然收到以下警告:

CMake Warning at CMakeLists.txt:439 (MESSAGE):
Build of assimp_qt_viewer is disabled.  Unsatisfied dendencies: Qt5 DevIL

0 个答案:

没有答案