qt与cmake运行失败

问题描述

我试图用cmake创建一个qt项目。构建成功,但是当我尝试运行它时,它给出了error :-1: error: [CMakeFiles/untitled_autogen.dir/build.make:95: CMakeFiles/untitled_autogen.dir/depend] Error 1。 使用qmake解决了该问题,但我想使用cmake,以便可以与其他编辑器/ IDE一起使用该项目。

我的cmakelist文件如下所示。


project(untitled LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

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

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_required ON)

# QtCreator supports the following variables for Android,which are identical to qmake Android variables.
# Check http://doc.qt.io/qt-5/deployment-android.html for more @R_10_4045@ion.
# They need to be set before the find_package(Qt5 ...) call.

#if(ANDROID)
#    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
#    if (ANDROID_ABI STREQUAL "armeabi-v7a")
#        set(ANDROID_EXTRA_LIBS
#            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
#            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
#    endif()
#endif()

find_package(Qt5 COMPONENTS Widgets required)

if(ANDROID)
  add_library(untitled SHARED
    main.cpp
    mainwindow.cpp
    mainwindow.h
    mainwindow.ui
  )
else()
  add_executable(untitled
    main.cpp
    mainwindow.cpp
    mainwindow.h
    mainwindow.ui
  )
endif()

target_link_libraries(untitled PRIVATE Qt5::Widgets)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)