-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
153 lines (124 loc) · 3.83 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# cmake version
cmake_minimum_required(VERSION 3.10)
######### QT ##########
project(PRR VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(OpenCV REQUIRED)
find_package(OpenMP)
set(ORANGI_PI OFF)
if(WIN32)
set(CMAKE_PREFIX_PATH "D:/Qt/6.5.0/msvc2019_64")
else()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
endif()
message(STATUS "${OpenMP_CXX_FLAGS}")#set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets LinguistTools Multimedia MultimediaWidgets Mqtt)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets LinguistTools Multimedia MultimediaWidgets Mqtt)
include_directories({OpenCV_INCLUDE_DIRS})
set(TS_FILES ./src/qt/PRR_zh_CN.ts)
set(PROJECT_SOURCES
./src/qt/widget/terminal.h
./src/qt/widget/terminal.cpp
./src/qt/main.cpp
./src/qt/prr/prrwin.h
./src/qt/prr/prrwin.cpp
./src/qt/prr/prrwin.ui
./src/qt/imgset/imagesettings.h
./src/qt/imgset/imagesettings.cpp
./src/qt/imgset/imagesettings.ui
${TS_FILES}
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(PRR
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET PRR APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
if(ANDROID)
add_library(PRR SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(PRR
${PROJECT_SOURCES}
)
endif()
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()
# libraries variable
set(LIBS
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Multimedia
Qt${QT_VERSION_MAJOR}::MultimediaWidgets
Qt${QT_VERSION_MAJOR}::Mqtt
${OpenCV_LIBS}
)
if(ORANGI_PI)
set(LIBS
${LIBS}
wiringPi
wiringPiDev
pthread
m
crypt
)
endif()
if(WIN32)
set(LIBS
${LIBS}
OpenMP::OpenMP_CXX
)
endif()
target_link_libraries(PRR PRIVATE ${LIBS})
set_target_properties(PRR PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
install(TARGETS PRR
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(PRR)
endif()
######### CV ##########
set(CMAKE_AUTOUIC OFF)
set(CMAKE_AUTOMOC OFF)
set(CMAKE_AUTORCC OFF)
aux_source_directory(./test TEST_LIST)
# imgTest
add_executable(ImgTest ./src/cv/imgTest.cpp)
target_link_libraries(ImgTest ${OpenCV_LIBS})
# calibrate
add_executable(Calib ./src/cv/calibrate.cpp)
target_link_libraries(Calib ${OpenCV_LIBS})
# snippetTest
add_executable(Stest ${TEST_LIST})
target_link_libraries(Stest ${OpenCV_LIBS})
# Test
enable_testing()
add_test(
name Stest
command $<TARGET_FILE:snippetTest> #<TARGET_FILE:> 指代mytest这个目标的完整路径。
)
# Util
file(GLOB HEADERS ./src/cv/*.hpp)
source_group("Headers" FILES ${HEADERS})
add_library(Util ${HEADERS})
set_target_properties(Util PROPERTIES LINKER_LANGUAGE CXX)