-
Notifications
You must be signed in to change notification settings - Fork 7
/
common.pri
175 lines (136 loc) · 4.47 KB
/
common.pri
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
PROJECT_ROOT_PATH = $${PWD}
CONFIG(debug, debug|release) {
BUILD_FLAG = debug
CONFIG *= warn_on
} else {
BUILD_FLAG = release
# Supress debug message
DEFINES *= QT_NO_DEBUG_OUTPUT # QT_NO_INFO_OUTPUT
}
APP_BINS = $${PROJECT_ROOT_PATH}/bin/$${BUILD_FLAG}
CONFIG *= c++11
CONFIG -= debug_and_release debug_and_release_target
# moc doesn't detect Q_OS_LINUX correctly, so add this to make it work
linux*:DEFINES *= __linux__
LANG_PATH = $${PROJECT_ROOT_PATH}/lang
# define locales for translation
LANG_LIST = pl ca de fi cs_CZ es nl ru
!CONFIG(staticlib) {
DESTDIR = $$APP_BINS
}
!defined(PREFIX, var) {
unix:PREFIX = /usr/local/
win32:PREFIX = $$(programfiles)
}
#------------------#
# Link modules #
#------------------#
contains(MODULES, kdiff3) {
INCLUDEPATH += $${PROJECT_ROOT_PATH}/3rdparty
LIBS += -L$$shadowed($${PROJECT_ROOT_PATH}/3rdparty/kdiff3)
LIBS += -lkdiff3
# QTextCodec in Qt6
greaterThan(QT_MAJOR_VERSION, 5): QT *= core5compat
}
contains(MODULES, qtsingleapplication) {
INCLUDEPATH += $${PROJECT_ROOT_PATH}/3rdparty/include
LIBS += -L$$shadowed($${PROJECT_ROOT_PATH}/3rdparty/qtsingleapplication)
LIBS += -lqtsingleapplication
}
contains(MODULES, addons) {
MODULES *= basic
INCLUDEPATH += $${PROJECT_ROOT_PATH}/addons/include
LIBS += -laddons
LIBS += -L$$shadowed($${PROJECT_ROOT_PATH}/addons)
}
contains(MODULES, GCodeShared) {
INCLUDEPATH += $${PROJECT_ROOT_PATH}/gcodeshared \
$${PROJECT_ROOT_PATH}/gcodeshared/include \
$$shadowed($${PROJECT_ROOT_PATH}/gcodeshared)
LIBS += -L$$shadowed($${PROJECT_ROOT_PATH}/gcodeshared)
LIBS += -lgcodeshared
}
contains(MODULES, GCodeWorkShop) {
INCLUDEPATH += $${PROJECT_ROOT_PATH}/gcodeworkshop/include
# LIBS += -L$$shadowed($${PROJECT_ROOT_PATH}/gcodeworkshop)
# LIBS += -lgcodeworkshop
}
contains(MODULES, GCodeFileServer) {
INCLUDEPATH += $${PROJECT_ROOT_PATH}/gcodefileserver
# LIBS += -L$$shadowed($${PROJECT_ROOT_PATH}/gcodefileserver)
# LIBS += -lgcodefileserver
}
contains(MODULES, basic) {
INCLUDEPATH += $${PROJECT_ROOT_PATH}/3rdparty/basic
LIBS += -L$$shadowed($${PROJECT_ROOT_PATH}/3rdparty/basic)
LIBS += -lbasic
}
#------------------#
# iwyu support #
#------------------#
contains(USE, check_iwyu) {
linux*:IWYU_FLAGS += -fPIE
IWYU_FLAGS += $(DEFINES) -w $(INCPATH)
for(include, IWYU_INCLUDES) {
IWYU_FLAGS += -I$$include
}
IWYU_EXTRA_FLAGS += -Xiwyu --max_line_length=120 -Xiwyu --mapping_file=$${PROJECT_ROOT_PATH}/tools/iwyu.imp
iwyu.output = ${QMAKE_FILE_BASE}.cpp.log
iwyu.commands = $${PROJECT_ROOT_PATH}/tools/iwyu_comp.sh $${IWYU_EXTRA_FLAGS} $${IWYU_FLAGS} ${QMAKE_FILE_NAME}
iwyu.input = SOURCES
iwyu.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += iwyu
}
#
# function findFiles(dir, basename)
# Returns a list of files with this basename.
# The function searches for dir and subdir recursively.
#
defineReplace(findFiles) {
dir = $$1
base_name = $$2
file_list = $$files($$dir/$$base_name)
path_list = $$files($$dir/*)
for(path, path_list) {
file_list += $$findFiles($$path, $$base_name)
}
return ($$file_list)
}
#
# function tsFiles(modulename, locales)
# Returns a list of files with this $${LANG_PATH}/modulename_lang.ts
# example :
# TARGET = bar
# LANG_PATH = lang
# LANG_LIST = pl fr de
# $$tsFiles(foo, ru en) returns lang/foo_ru.ts lang/foo_en.ts
# $$tsFiles(foo) returns lang/foo_pl.ts lang/foo_fr.ts lang/foo_de.ts
# $$tsFiles() returns lang/bar_pl.ts lang/bar_fr.ts lang/bar_de.ts
#
defineReplace(tsFiles) {
module_name = $$1
locales = $$2
!defined(1, var) {
module_name = $$TARGET
}
!defined(2, var) {
locales = $$LANG_LIST
}
for(lang, locales) {
file_list += $${LANG_PATH}/$${module_name}_$${lang}.ts
}
return ($$file_list)
}
defineReplace(getVersion) {
version_file = gcodeshared/include/version.h
!exists ($${PROJECT_ROOT_PATH}/$${version_file}): error(In function getVersion: File \"$${version_file}\" not found)
version_header = $$cat($${PROJECT_ROOT_PATH}/$${version_file}, lines)
for (str, version_header) {
sub_str=$$split(str, " ")
contains (sub_str, GCODEWORKSHOP_VERSION) {
ver_str=$$find(sub_str, '".*"')
!isEmpty(ver_str): return ($$split(ver_str, '"'))
}
}
error(In function getVersion: GCODEWORKSHOP_VERSION not found in $${version_file})
}