forked from QuiteRSS/quiterss
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
161 lines (137 loc) · 3.69 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
cmake_minimum_required(VERSION 3.16)
set(TARGET_NAME "QuiteRSS")
project(${TARGET_NAME}
DESCRIPTION ${TARGET_NAME}
LANGUAGES CXX
)
# create revision file
execute_process(COMMAND git rev-list --count HEAD
OUTPUT_VARIABLE GIT_REV_COUNT
ERROR_QUIET)
if ("${GIT_REV_COUNT}" STREQUAL "")
set(GIT_REV_COUNT "0")
set(GIT_REV_HASH "")
else()
string(STRIP "${GIT_REV_COUNT}" ${GIT_REV_COUNT})
execute_process(COMMAND git rev-parse --short HEAD
OUTPUT_VARIABLE GIT_REV_HASH
ERROR_QUIET)
string(REGEX REPLACE "\n$" "" GIT_REV_HASH "${GIT_REV_HASH}")
set(GIT_REV_HASH "\"${GIT_REV_HASH}\"")
endif()
set(VERSION "#define VCS_REVISION ${GIT_REV_COUNT}")
set(HASH "#define VCS_SHORT_HASH ${GIT_REV_HASH}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/src/VersionRev.h "${VERSION}")
file(APPEND ${CMAKE_CURRENT_SOURCE_DIR}/src/VersionRev.h "${HASH}")
# qt setting
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# C++
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# find pacakge
set(QT5_MIN_VERSION 5.15.0)
find_package(Qt5 REQUIRED COMPONENTS
Core
Gui
Widgets
Sql
Multimedia
Xml
)
find_package(Qt5WebKitWidgets REQUIRED)
find_package(Qt5LinguistTools REQUIRED)
find_package(SQLite3 REQUIRED)
find_package(Qt5 COMPONENTS LinguistTools REQUIRED)
# output name
add_executable(${TARGET_NAME})
# complier and linker flags
set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -flto")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -flto")
set(CMAKE_CXX_FLAGS_DEBUG "-g3")
# target_compile_definitions(${TARGET_NAME} PUBLIC
# HAVE_QT5
# )
if (WIN32)
target_compile_definitions(${TARGET_NAME} PUBLIC
UNICODE
_UNICODE
WIN32
)
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-subsystem,windows")
set(CMAKE_CXX_FLAGS "-fno-keep-inline-dllexport")
endif (WIN32)
# libraries
target_link_libraries(${TARGET_NAME}
Qt::Core
Qt::Gui
Qt::Widgets
Qt::Sql
Qt::Multimedia
Qt::Xml
Qt5::WebKit
Qt5::WebKitWidgets
SQLite3
)
# qt resource file
target_sources(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/QuiteRSS.qrc)
target_sources(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/data/ca-bundle.qrc)
# windows resource file
if (WIN32)
execute_process(COMMAND windres --codepage=65001 -i ${CMAKE_CURRENT_SOURCE_DIR}/QuiteRSSApp.rc -o ${CMAKE_CURRENT_BINARY_DIR}/QuiteRSSApp.o --include-dir=./)
target_link_libraries(${TARGET_NAME}
${CMAKE_CURRENT_BINARY_DIR}/QuiteRSSApp.o
)
endif (WIN32)
# qt language file
set(LANG_TS
quiterss_ar
quiterss_bg
quiterss_cs
quiterss_de
quiterss_el_GR
quiterss_es
quiterss_fa
quiterss_fi
quiterss_fr
quiterss_gl
quiterss_hi
quiterss_hu
quiterss_it
quiterss_ja
quiterss_ko
quiterss_lt
quiterss_nl
quiterss_pl
quiterss_pt_BR
quiterss_pt_PT
quiterss_ro_RO
quiterss_ru
quiterss_sk
quiterss_sr
quiterss_sv
quiterss_tg_TJ
quiterss_tr
quiterss_uk
quiterss_vi
quiterss_zh_CN
quiterss_zh_TW
)
add_custom_target(build-time-make-directory ALL
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/lang)
foreach(ts ${LANG_TS})
add_custom_command(
POST_BUILD
TARGET ${TARGET_NAME}
COMMAND lrelease ${CMAKE_CURRENT_SOURCE_DIR}/lang/${ts}.ts -qm ${CMAKE_CURRENT_BINARY_DIR}/lang/${ts}.qm
)
endforeach(ts)
# source code
add_subdirectory(3rdparty/qtsingleapplication)
add_subdirectory(3rdparty/qupzilla)
add_subdirectory(3rdparty/qftp)
add_subdirectory(3rdparty/sqlitex)
add_subdirectory(src)