Osx cmake构建Qt5项目

时间:2014-04-13 01:46:36

标签: macos qt build cmake qt5

我正在尝试使用cmake构建一个Qt5项目,但我现在一直有同样的错误:

CMake Error at /Users/guillaume/Qt/5.2.1/android_x86/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:16 (message):
Failed to find "GLESv2" in "" with CMAKE_CXX_LIBRARY_ARCHITECTURE "".
Call Stack (most recent call first):
/Users/guillaume/Qt/5.2.1/android_x86/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:51 (_qt5gui_find_extra_libs)
/Users/guillaume/Qt/5.2.1/android_x86/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:143 (include)
/Users/guillaume/Qt/5.2.1/clang_64/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:88 (find_package)
/Users/guillaume/Qt/5.2.1/clang_64/lib/cmake/Qt5/Qt5Config.cmake:26 (find_package)
CMakeLists.txt:17 (find_package)

似乎是QtWidget中的find_package(Qt5Gui ..)使用androidx86路径而不是clang_64路径,但我不知道为什么即使使用NO_DEFAULT_PATH选项也不会使用clang_64路径..任何帮助或工作cmake文件将不胜感激 [编辑更新]
这是我的CMakeList.txt。我的cmake版本是2.8.12.2:

#YCStats CmakeList.txt
cmake_minimum_required(VERSION 2.8.8)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
set(GCC_COVERAGE_LINK)
project(YCStats)
set( CMAKE_INCLUDE_CURRENT_DIR ON )
set( CMAKE_AUTOMOC ON)
set(QT5_PATH $ENV{HOME}/Qt/5.2.1/clang_64/ CACHE PATH "Path to Qt5")
set(QT5_MODULE_PATH ${QT5_PATH}/lib/cmake)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QT5_MODULE_PATH})
find_package( Qt5Widgets)
find_package( OpenCV REQUIRED )
find_package( FFMPEG REQUIRED )
find_package( TESS REQUIRED )
include_directories(
    ${FFMPEG_INCLUDE_DIR}
    ${TESS_INCLUDE_DIR}
)
file(
    GLOB_RECURSE
    source_files
    src/*.cpp
)
file(
    GLOB_RECURSE
    header_files
    src/*.h
)
add_executable(
    YCStats.x
    ${source_files}
    ${header_files}
)
target_link_libraries(
    YCStats.x
    ${OpenCV_LIBS}
    ${FFMPEG_LIBRARIES}
    ${TESS_LIBRARIES}
)
qt5_use_modules(YCStats.x Widgets)

编辑2:解决方案

最后,我设法构建它并通过在发出find_package()的每个错误之前设置行集(Qt5 $ {_ module_dep} _DIR“”)来使其工作(在Qt5WidgetsConfig.cmake,Qt5CoreConfig.cmake ...中)。它似乎允许NO_DEFAULT_PATH正常工作。对于遇到相同问题的人,如果您的cmake工作但是在使用make命令时出现错误路径的警告,则应将上述set()命令放在相应的文件中:Qt5“CoresspondingModule”Config.cmake
ps:我还要用以下方法更改相关的find_package:

find_package(Qt5${_module_dep}
                5.2.1 ${_Qt5Widgets_FIND_VERSION_EXACT}
                ${_Qt5Widgets_DEPENDENCIES_FIND_QUIET}
                ${_Qt5Widgets_FIND_DEPENDENCIES_REQUIRED}
                PATHS "${CMAKE_CURRENT_LIST_DIR}/../Qt5${_module_dep}" 
                NO_DEFAULT_PATH
            ) 

注意我使用的新路径。

1 个答案:

答案 0 :(得分:0)

请参阅我更新的CMakeList.txt和 edit2:SOLUTION