CMake Automoc 错误 1 - 无法编译项目
CMake Automoc Error 1 - Can't compile project
我刚刚将我在 Qt5 中构建的项目移到了我的 CMake 项目树中。
我将项目导出到 CMake 目录中。但是,当我尝试构建项目时,编译器会给我以下错误:
[src/GUIconceptStudy/CMakeFiles/GUIconceptStudy_automoc] 错误 1
另请参阅以下打印屏幕:
还有 CMakeLists.txt 个文件如下:
cmake_minimum_required (VERSION 3.1)
project(GUIconceptStudy)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package( OpenCV REQUIRED )
find_package( Boost COMPONENTS system thread filesystem REQUIRED)
#find_package (sqlite3)
find_package(Qt5 REQUIRED COMPONENTS Core Quick)
###
### make sure we use c++11
###
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
###
###boost include stuff (required for all libcam)
###
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
find_package(Qt5Widgets)
find_package(Qt5PrintSupport)
#find all the qt UI stuff
file(GLOB UI
"ui/*.ui"
)
#make them into headers
qt5_wrap_ui (UI_HDRS ${UI})
###
### add all your non QT sources
###
# find all non ui sources
file(GLOB SRCS
"src/*.h"
"src/*.cpp"
"src/*.hpp"
)
# find all ui related sources
file(GLOB UI_SRCS
"ui/*.h"
"ui/*.cpp"
"ui/*.hpp"
)
###
### Add executables
###
add_executable(GUIconceptStudy main/main.cpp ui/qrc/res.qrc ${SRCS} ${UI_HDRS} ${UI_SRCS})
target_link_libraries (GUIconceptStudy Qt5::Widgets ${Boost_LIBRARIES} ${OpenCV_LIBS} Qt5::PrintSupport Qt5::Core Qt5::Quick)
###
### Add Library
###
add_library(GUIconceptStudy_lib SHARED ui/qrc/res.qrc ${SRCS} ${UI_HDRS} ${UI_SRCS})
target_link_libraries (GUIconceptStudy_lib Qt5::Widgets ${Boost_LIBRARIES} ${OpenCV_LIBS} Qt5::PrintSupport Qt5::Core Qt5::Quick)
在查看了不同的在线资源后,我找不到任何特别有用的东西。任何人都可以阐明问题所在吗?
这是在黑暗中拍摄的,但这很可能是由 set(CMAKE_INCLUDE_CURRENT_DIR ON)
失踪造成的。正如 documentation 中所说,它应该设置,因为生成的文件不在您的源目录中:
Generated moc_*.cpp and *.moc files are placed in the build directory so it is convenient to set the CMAKE_INCLUDE_CURRENT_DIR variable.
我看到人们犯的另一个错误是混合使用 Qt 处理管道。我已经在我的其他 . As it says in documentation on AUTOUIC
property 中提到了这一点,当启用此 属性 时,您不应该使用 qt5_wrap_ui
函数。
我刚刚将我在 Qt5 中构建的项目移到了我的 CMake 项目树中。 我将项目导出到 CMake 目录中。但是,当我尝试构建项目时,编译器会给我以下错误: [src/GUIconceptStudy/CMakeFiles/GUIconceptStudy_automoc] 错误 1
另请参阅以下打印屏幕:
还有 CMakeLists.txt 个文件如下:
cmake_minimum_required (VERSION 3.1)
project(GUIconceptStudy)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package( OpenCV REQUIRED )
find_package( Boost COMPONENTS system thread filesystem REQUIRED)
#find_package (sqlite3)
find_package(Qt5 REQUIRED COMPONENTS Core Quick)
###
### make sure we use c++11
###
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
###
###boost include stuff (required for all libcam)
###
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
find_package(Qt5Widgets)
find_package(Qt5PrintSupport)
#find all the qt UI stuff
file(GLOB UI
"ui/*.ui"
)
#make them into headers
qt5_wrap_ui (UI_HDRS ${UI})
###
### add all your non QT sources
###
# find all non ui sources
file(GLOB SRCS
"src/*.h"
"src/*.cpp"
"src/*.hpp"
)
# find all ui related sources
file(GLOB UI_SRCS
"ui/*.h"
"ui/*.cpp"
"ui/*.hpp"
)
###
### Add executables
###
add_executable(GUIconceptStudy main/main.cpp ui/qrc/res.qrc ${SRCS} ${UI_HDRS} ${UI_SRCS})
target_link_libraries (GUIconceptStudy Qt5::Widgets ${Boost_LIBRARIES} ${OpenCV_LIBS} Qt5::PrintSupport Qt5::Core Qt5::Quick)
###
### Add Library
###
add_library(GUIconceptStudy_lib SHARED ui/qrc/res.qrc ${SRCS} ${UI_HDRS} ${UI_SRCS})
target_link_libraries (GUIconceptStudy_lib Qt5::Widgets ${Boost_LIBRARIES} ${OpenCV_LIBS} Qt5::PrintSupport Qt5::Core Qt5::Quick)
在查看了不同的在线资源后,我找不到任何特别有用的东西。任何人都可以阐明问题所在吗?
这是在黑暗中拍摄的,但这很可能是由 set(CMAKE_INCLUDE_CURRENT_DIR ON)
失踪造成的。正如 documentation 中所说,它应该设置,因为生成的文件不在您的源目录中:
Generated moc_*.cpp and *.moc files are placed in the build directory so it is convenient to set the CMAKE_INCLUDE_CURRENT_DIR variable.
我看到人们犯的另一个错误是混合使用 Qt 处理管道。我已经在我的其他 AUTOUIC
property 中提到了这一点,当启用此 属性 时,您不应该使用 qt5_wrap_ui
函数。