-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
231 lines (200 loc) · 5.22 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
cmake_minimum_required(VERSION 3.16)
project(Supernote VERSION 0.1 LANGUAGES CXX C)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(WIN32)
set(app_icon_resource_windows "${CMAKE_CURRENT_SOURCE_DIR}/resource/supernote.rc")
endif()
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick Network LinguistTools)
qt_standard_project_setup(REQUIRES 6.5)
#指定库的路径
link_directories(CMAKE_CURRENT_SOURCE_DIR
./library/Note/lib/
./library/Docx/lib/
)
if(WIN32)
link_directories(CMAKE_CURRENT_SOURCE_DIR
./library/Myscript/lib/win-x64/
)
#指定库的头文件路径
set(IINK_INCLUDES ./library/Myscript/include)
endif()
set(Note_INCLUDES ./library/Note/include)
set(Docx_INCLUDES ./library/Docx/include)
if(WIN32)
set(include_files
./include/Utils.h
./include/Export.h
./include/FontMetricsProvider.h
./include/NoteView.h
./include/NoteInfo.h
./include/Update.h
./include/Download.h
./include/VersionInfo.h
./include/GetVersion.h
./include/MyCertificate.h
./include/RendererListener.h
./include/EditorListener.h
./include/AppManager.h
)
set(src_files
./src/Utils.cpp
./src/Export.cpp
./src/FontMetricsProvider.cpp
./src/NoteView.cpp
./src/NoteInfo.cpp
./src/Update.cpp
./src/Download.cpp
./src/VersionInfo.cpp
./src/GetVersion.cpp
./src/Main.cpp
./src/AppManager.cpp
)
else()
set(include_files
./include/Utils.h
./include/Export.h
./include/NoteView.h
./include/NoteInfo.h
./include/Update.h
./include/Download.h
./include/VersionInfo.h
./include/GetVersion.h
./include/AppManager.h
./include/MyCertificate.h
# ./include/FontMetricsProvider.h
# ./include/RendererListener.h
# ./include/EditorListener.h
)
set(src_files
./src/Utils.cpp
./src/Export.cpp
./src/NoteView.cpp
./src/NoteInfo.cpp
./src/Update.cpp
./src/Download.cpp
./src/VersionInfo.cpp
./src/GetVersion.cpp
./src/Main.cpp
./src/AppManager.cpp
# ./src/FontMetricsProvider.cpp
)
endif()
include_directories(
./include
)
set(qml_files
./layout/NoteWindow.qml
./layout/FooterView.qml
./layout/NoteMenuBar.qml
./layout/ExportView.qml
./layout/LangModel.qml
./layout/ExportSetting.qml
./layout/UpdateWindow.qml
./layout/LanguageModel.qml
)
set(qml_resource_files
./images/logo.png
./images/arrow_left.png
./images/arrow_right.png
./images/double_arrow_left.png
./images/double_arrow_right.png
)
set(ts_files
./translations/zh_CN.ts
./translations/en_US.ts
./translations/zh_TW.ts
./translations/ja_JP.ts
)
qt_add_executable(SupernoteApp
${include_files}
${src_files}
)
if(WIN32)
qt_add_executable(SupernoteApp
${app_icon_resource_windows}
)
endif()
#这里添加可以在C++中使用
qt_add_resources(SupernoteApp "doc"
PREFIX
"/"
FILES
doc/new_docx.docx
images/sn_icon.png
)
#set output path
set_source_files_properties(${ts_files}
PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/translations")
qt_add_translations(SupernoteApp
TS_FILES
${ts_files}
QM_FILES_OUTPUT_VARIABLE qm_files
)
#install qm
install(FILES ${qm_files} DESTINATION "translations")
#增加到资源文件
qt_add_resources(SupernoteApp "translations"
PREFIX "/"
BASE "${CMAKE_CURRENT_BINARY_DIR}/translations"
FILES "${qm_files}"
)
qt_add_qml_module(SupernoteApp
URI Supernote
VERSION 1.0
QML_FILES ${qml_files}
RESOURCES ${qml_resource_files}
)
#注意放置位置,靠前会报错要在qt_add_executable之后
target_include_directories(SupernoteApp PRIVATE
${Docx_INCLUDES}
${Note_INCLUDES}
${IINK_INCLUDES}
)
set_target_properties(SupernoteApp 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
)
#Currently, the recognition library is only available in the windows version
if(WIN32)
target_link_libraries(SupernoteApp PRIVATE
Qt6::Quick
Qt6::Network
iink
Note.dll
Docx.dll
)
else()
target_link_libraries(SupernoteApp PRIVATE
Qt6::Quick
Qt6::Network
libNote.so
libDocx.so
)
endif()
install(TARGETS SupernoteApp
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
#qt6_generate_deploy_qml_app_script(
# TARGET SupernoteApp
# OUTPUT_SCRIPT deploy_script
# NO_UNSUPPORTED_PLATFORM_ERROR
#)
#install(SCRIPT ${deploy_script})
#set(CMAKE_INSTALL_PREFIX "/home/ubuntu/work/build")
#set(CPACK_PACKAGE_NAME SupernoteApp)
#set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "My amazing application")
#set(CPACK_PACKAGE_VENDOR "My Company")
#set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
#set(CPACK_VERBATIM_VARIABLES ON)
#set(CPACK_PACKAGING_INSTALL_PREFIX "/home/ubuntu/work/build")
#set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Manfred Maintainer <mm@example.com>")
##set(CPACK_DEBIAN_PACKAGE_DEPENDS libc6 libstdc++6 libgcc-s1)
#include(CPack)