使用QT Creator 12.0.2 开发软件纪实
使用CMake来编译QT的截图
CMakeLists如下
cmake_minimum_required(VERSION 3.5)
project(manipulator-listener 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)
find_package(Qt5 COMPONENTS Widgets LinguistTools REQUIRED)
set(TS_FILES manipulator-listener_zh_CN.ts)
add_executable(manipulator-listener
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
mainui.ui
mainui.cpp
mainui.h
canthread.cpp
canthread.h
ControlCAN.h
ControlCAN.lib
ControlCAN.dll
${TS_FILES}
)
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR})
target_link_libraries(manipulator-listener
PRIVATE Qt5::Widgets
# 添加 ControlCAN 的动态链接库
${CMAKE_SOURCE_DIR}/ControlCAN.lib
${CMAKE_SOURCE_DIR}/ControlCAN.dll
)
target_include_directories(manipulator-listener PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
#线程 固定配置
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -lpthread -Wl,--no-as-needed -g3 -Wall")
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})