Initial Linux Qt OpenCV project
This commit is contained in:
58
CMakeLists.txt
Normal file
58
CMakeLists.txt
Normal file
@@ -0,0 +1,58 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
|
||||
project(chengnan VERSION 0.1.0 LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC OFF)
|
||||
|
||||
# 本项目目标为 Linux 本地构建。Windows 工具链文件仅作为历史参考,不参与构建。
|
||||
if (WIN32)
|
||||
message(FATAL_ERROR "chengnan 当前按 README 要求只支持 Linux 构建,请不要使用 Windows 编译工具链。")
|
||||
endif()
|
||||
|
||||
find_package(Qt6 QUIET COMPONENTS Widgets Concurrent)
|
||||
if (NOT Qt6_FOUND)
|
||||
find_package(Qt5 REQUIRED COMPONENTS Widgets Concurrent)
|
||||
endif()
|
||||
|
||||
find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs)
|
||||
|
||||
set(PROJECT_SOURCES
|
||||
app/src/main.cpp
|
||||
app/src/MainWindow.cpp
|
||||
app/src/ImageView.cpp
|
||||
app/src/ImageConverter.cpp
|
||||
app/src/ImageProcessor.cpp
|
||||
app/src/ImageWorker.cpp
|
||||
|
||||
app/include/MainWindow.h
|
||||
app/include/ImageView.h
|
||||
app/include/ImageConverter.h
|
||||
app/include/ImageProcessor.h
|
||||
app/include/ImageWorker.h
|
||||
)
|
||||
|
||||
if (Qt6_FOUND)
|
||||
qt_add_executable(chengnan ${PROJECT_SOURCES})
|
||||
target_link_libraries(chengnan PRIVATE Qt6::Widgets Qt6::Concurrent ${OpenCV_LIBS})
|
||||
else()
|
||||
add_executable(chengnan ${PROJECT_SOURCES})
|
||||
target_link_libraries(chengnan PRIVATE Qt5::Widgets Qt5::Concurrent ${OpenCV_LIBS})
|
||||
endif()
|
||||
|
||||
target_include_directories(chengnan PRIVATE
|
||||
${OpenCV_INCLUDE_DIRS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/app/include
|
||||
)
|
||||
|
||||
target_compile_definitions(chengnan PRIVATE
|
||||
QT_NO_KEYWORDS
|
||||
CHENGNAN_APP_VERSION="${PROJECT_VERSION}"
|
||||
)
|
||||
|
||||
target_compile_options(chengnan PRIVATE -Wall -Wextra -Wpedantic)
|
||||
|
||||
install(TARGETS chengnan RUNTIME DESTINATION bin)
|
||||
Reference in New Issue
Block a user