2 # |
2 # |
3 |
3 |
4 PROJECT(bmsapp) |
4 PROJECT(bmsapp) |
5 CMAKE_MINIMUM_REQUIRED( VERSION 3.6 ) |
5 CMAKE_MINIMUM_REQUIRED( VERSION 3.6 ) |
6 SET(bmsapp_EXECUTABLE "bmsapp") |
6 SET(bmsapp_EXECUTABLE "bmsapp") |
7 MESSAGE( STATUS "Building bmsapp" ) |
|
8 |
7 |
9 # ===== Set application version ===== |
8 # ===== Set application version ===== |
10 |
9 |
11 SET( bmsapp_VERSION_MAJOR 0 ) |
10 SET( bmsapp_VERSION_MAJOR 0 ) |
12 SET( bmsapp_VERSION_MINOR 1 ) |
11 SET( bmsapp_VERSION_MINOR 1 ) |
13 SET( bmsapp_VERSION_PATCH 1 ) |
12 SET( bmsapp_VERSION_PATCH 1 ) |
14 |
13 |
15 # Compile flags |
14 # Compile flags |
16 |
15 |
|
16 option(BUILD_DESIGNER_PLUGINS "If on, you will only build and install the designer plugins." OFF) |
17 option(UPDATE_TRANSLATIONS "Enable rescanning sources to update .ts files" OFF) |
17 option(UPDATE_TRANSLATIONS "Enable rescanning sources to update .ts files" OFF) |
|
18 |
|
19 IF( ${BUILD_DESIGNER_PLUGINS} ) |
|
20 message(STATUS "Building designer plugins" ) |
|
21 ELSE() |
|
22 message(STATUS "Building bmsapp" ) |
|
23 ENDIF() |
18 |
24 |
19 # Automatically run moc on source files when necessary |
25 # Automatically run moc on source files when necessary |
20 set(CMAKE_AUTOMOC ON) |
26 set(CMAKE_AUTOMOC ON) |
21 set(CMAKE_AUTOUIC ON) |
27 set(CMAKE_AUTOUIC ON) |
22 set(CMAKE_AUTORCC ON) |
28 set(CMAKE_AUTORCC ON) |
23 |
29 |
|
30 SET(CMAKE_INCLUDE_CURRENT_DIR ON) |
|
31 |
24 SET( CMAKE_CXX_FLAGS_RELEASE "-Wall -ansi -pedantic -Wno-long-long -O2 -pipe" ) |
32 SET( CMAKE_CXX_FLAGS_RELEASE "-Wall -ansi -pedantic -Wno-long-long -O2 -pipe" ) |
25 SET( CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -pipe" ) |
33 SET( CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -pipe" ) |
26 |
34 |
27 # ===== Directories ===== |
35 # ===== Directories ===== |
28 |
36 |
38 |
46 |
39 SET( DATAPATH "${DATAROOTDIR}/${CMAKE_PROJECT_NAME}" ) |
47 SET( DATAPATH "${DATAROOTDIR}/${CMAKE_PROJECT_NAME}" ) |
40 SET( TARGETPATH ${BINDIR} ) |
48 SET( TARGETPATH ${BINDIR} ) |
41 SET( DOCPATH ${DOCDIR} ) |
49 SET( DOCPATH ${DOCDIR} ) |
42 |
50 |
|
51 SET( LIBPATH "$ENV{QT5DIR}" ) |
43 |
52 |
44 SET(ROOTDIR "${CMAKE_CURRENT_SOURCE_DIR}") |
53 SET(ROOTDIR "${CMAKE_CURRENT_SOURCE_DIR}") |
45 SET(SRCDIR "${ROOTDIR}/src") |
54 SET(SRCDIR "${ROOTDIR}/src") |
46 SET(UIDIR "${ROOTDIR}/ui") |
55 SET(UIDIR "${ROOTDIR}/ui") |
|
56 SET(DESIGNERDIR "${ROOTDIR}/designer") |
47 SET(DATADIR "${ROOTDIR}/data") |
57 SET(DATADIR "${ROOTDIR}/data") |
48 SET(TRANSLATIONSDIR "${ROOTDIR}/translations") |
58 SET(TRANSLATIONSDIR "${ROOTDIR}/translations") |
49 |
59 |
50 INCLUDE_DIRECTORIES(${SRCDIR}) |
60 INCLUDE_DIRECTORIES(${SRCDIR}) |
51 INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/src") # In case of out-of-source build. |
61 INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/src") # In case of out-of-source build. |
|
62 INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/designer") |
52 |
63 |
53 # ===== Find Qt5 ===== |
64 # ===== Find Qt5 ===== |
54 |
65 |
55 # Minimum versio 5.13 for debug messages. |
66 # Minimum versio 5.13 for debug messages. |
56 find_package(Qt5 5.13 REQUIRED COMPONENTS Core Widgets Network Sql LinguistTools PrintSupport WebSockets) |
67 find_package(Qt5 5.13 REQUIRED COMPONENTS Core Widgets Network Sql LinguistTools PrintSupport WebSockets) |
57 |
68 INCLUDE_DIRECTORIES(${Qt5Core_INCLUDE_DIRS}) |
58 # PrintSupport Xml LinguistTools |
69 INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS}) |
|
70 INCLUDE_DIRECTORIES(${Qt5Network_INCLUDE_DIRS}) |
|
71 INCLUDE_DIRECTORIES(${Qt5Sql_INCLUDE_DIRS}) |
|
72 INCLUDE_DIRECTORIES(${Qt5LinguistTools_INCLUDE_DIRS}) |
|
73 INCLUDE_DIRECTORIES(${Qt5PrintSupport_INCLUDE_DIRS}) |
|
74 INCLUDE_DIRECTORIES(${Qt5WebSockets_INCLUDE_DIRS}) |
|
75 |
|
76 # Xml |
59 |
77 |
60 # Some extra files for the "make clean" target. |
78 # Some extra files for the "make clean" target. |
61 SET_PROPERTY( |
79 SET_PROPERTY( |
62 DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
80 DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
63 PROPERTY ADDITIONAL_MAKE_CLEAN_FILES |
81 PROPERTY ADDITIONAL_MAKE_CLEAN_FILES |
77 # Outputs only in the build directory. |
95 # Outputs only in the build directory. |
78 CONFIGURE_FILE( src/config.in src/config.h ) |
96 CONFIGURE_FILE( src/config.in src/config.h ) |
79 |
97 |
80 # ===== All sources ===== |
98 # ===== All sources ===== |
81 |
99 |
82 set( SRCS |
100 IF( ${BUILD_DESIGNER_PLUGINS} ) |
|
101 |
|
102 ADD_DEFINITIONS(${QT_DEFINITIONS}) |
|
103 ADD_DEFINITIONS(-DQT_PLUGIN) |
|
104 ADD_DEFINITIONS(-DQT_NO_DEBUG) |
|
105 ADD_DEFINITIONS(-DQT_SHARED) |
|
106 |
|
107 INCLUDE_DIRECTORIES( |
|
108 ${QT_INCLUDE_DIR} |
|
109 ${SRCDIR} |
|
110 ) |
|
111 |
|
112 LINK_DIRECTORIES( |
|
113 ${QT_LIBRARY_DIR} |
|
114 ) |
|
115 |
|
116 set( SRC_FILES |
|
117 ${SRCDIR}/RangedSlider.cpp |
|
118 ${SRCDIR}/nulldateedit.cpp |
|
119 ) |
|
120 |
|
121 # By default only QtCore and QtGui are enabled |
|
122 SET( QT_USE_QTDESIGNER TRUE ) |
|
123 |
|
124 set( MOC_FILES |
|
125 ${SRCDIR}/RangedSlider.h |
|
126 ${SRCDIR}/nulldateedit.h |
|
127 ) |
|
128 |
|
129 set( PLUGIN_MOCS |
|
130 # designer/*.h |
|
131 ) |
|
132 |
|
133 set( PLUGIN_SRCS |
|
134 # designer/*.cpp |
|
135 ) |
|
136 |
|
137 add_library( bmsapp_plugins SHARED |
|
138 ${SRC_FILES} |
|
139 ${PLUGIN_SRCS} |
|
140 ${MOC_FILES} |
|
141 ${PLUGIN_MOCS} |
|
142 ) |
|
143 |
|
144 TARGET_LINK_LIBRARIES( bmsapp_plugins |
|
145 ${QT_LIBRARIES} |
|
146 ) |
|
147 |
|
148 ELSE() |
|
149 |
|
150 set( SRCS |
83 ${SRCDIR}/main.cpp |
151 ${SRCDIR}/main.cpp |
84 ${SRCDIR}/RecipesTree.cpp |
152 ${SRCDIR}/RecipesTree.cpp |
85 ${SRCDIR}/AboutDialog.cpp |
153 ${SRCDIR}/AboutDialog.cpp |
86 ${SRCDIR}/InventorySuppliers.cpp |
154 ${SRCDIR}/InventorySuppliers.cpp |
87 ${SRCDIR}/EditSupplier.cpp |
155 ${SRCDIR}/EditSupplier.cpp |
103 ${SRCDIR}/EditProfileMash.cpp |
171 ${SRCDIR}/EditProfileMash.cpp |
104 ${SRCDIR}/ProfileStyles.cpp |
172 ${SRCDIR}/ProfileStyles.cpp |
105 ${SRCDIR}/EditProfileStyle.cpp |
173 ${SRCDIR}/EditProfileStyle.cpp |
106 ${SRCDIR}/ProfileFerments.cpp |
174 ${SRCDIR}/ProfileFerments.cpp |
107 ${SRCDIR}/EditProfileFerment.cpp |
175 ${SRCDIR}/EditProfileFerment.cpp |
|
176 ${SRCDIR}/EditRecipe.cpp |
108 ${SRCDIR}/Setup.cpp |
177 ${SRCDIR}/Setup.cpp |
109 ${SRCDIR}/Utils.cpp |
178 ${SRCDIR}/Utils.cpp |
110 ${SRCDIR}/PrinterDialog.cpp |
179 ${SRCDIR}/PrinterDialog.cpp |
111 ${SRCDIR}/MainWindow.cpp |
180 ${SRCDIR}/MainWindow.cpp |
112 ${SRCDIR}/database/database.cpp |
181 ${SRCDIR}/database/database.cpp |
113 ${SRCDIR}/nulldateedit.cpp |
182 ${SRCDIR}/nulldateedit.cpp |
114 ) |
183 ) |
115 |
184 |
116 set( HDRS |
185 set( HDRS |
117 ${SRCDIR}/RecipesTree.h |
186 ${SRCDIR}/RecipesTree.h |
118 ${SRCDIR}/AboutDialog.h |
187 ${SRCDIR}/AboutDialog.h |
119 ${SRCDIR}/InventorySuppliers.h |
188 ${SRCDIR}/InventorySuppliers.h |
120 ${SRCDIR}/EditSupplier.h |
189 ${SRCDIR}/EditSupplier.h |
121 ${SRCDIR}/InventoryFermentables.h |
190 ${SRCDIR}/InventoryFermentables.h |
136 ${SRCDIR}/EditProfileMash.h |
205 ${SRCDIR}/EditProfileMash.h |
137 ${SRCDIR}/ProfileStyles.h |
206 ${SRCDIR}/ProfileStyles.h |
138 ${SRCDIR}/EditProfileStyle.h |
207 ${SRCDIR}/EditProfileStyle.h |
139 ${SRCDIR}/ProfileFerments.h |
208 ${SRCDIR}/ProfileFerments.h |
140 ${SRCDIR}/EditProfileFerment.h |
209 ${SRCDIR}/EditProfileFerment.h |
|
210 ${SRCDIR}/EditRecipe.h |
141 ${SRCDIR}/Setup.h |
211 ${SRCDIR}/Setup.h |
142 ${SRCDIR}/Utils.h |
212 ${SRCDIR}/Utils.h |
143 ${SRCDIR}/PrinterDialog.h |
213 ${SRCDIR}/PrinterDialog.h |
144 ${SRCDIR}/MainWindow.h |
214 ${SRCDIR}/MainWindow.h |
145 ${SRCDIR}/database/database.h |
215 ${SRCDIR}/database/database.h |
146 ${SRCDIR}/nulldateedit.h |
216 ${SRCDIR}/nulldateedit.h |
147 ) |
217 ) |
148 |
218 |
149 set( UIS |
219 set( UIS |
150 ${UIDIR}/AboutDialog.ui |
220 ${UIDIR}/AboutDialog.ui |
151 ${UIDIR}/EditSupplier.ui |
221 ${UIDIR}/EditSupplier.ui |
152 ${UIDIR}/EditFermentable.ui |
222 ${UIDIR}/EditFermentable.ui |
153 ${UIDIR}/EditHop.ui |
223 ${UIDIR}/EditHop.ui |
154 ${UIDIR}/EditYeast.ui |
224 ${UIDIR}/EditYeast.ui |
157 ${UIDIR}/EditEquipment.ui |
227 ${UIDIR}/EditEquipment.ui |
158 ${UIDIR}/EditProfileWater.ui |
228 ${UIDIR}/EditProfileWater.ui |
159 ${UIDIR}/EditProfileMash.ui |
229 ${UIDIR}/EditProfileMash.ui |
160 ${UIDIR}/EditProfileStyle.ui |
230 ${UIDIR}/EditProfileStyle.ui |
161 ${UIDIR}/EditProfileFerment.ui |
231 ${UIDIR}/EditProfileFerment.ui |
|
232 ${UIDIR}/EditRecipe.ui |
162 ${UIDIR}/MainWindow.ui |
233 ${UIDIR}/MainWindow.ui |
163 ) |
234 ) |
164 |
235 |
165 |
236 set( TS_FILES |
166 set( TS_FILES |
|
167 ${TRANSLATIONSDIR}/bmsapp_en.ts # English |
237 ${TRANSLATIONSDIR}/bmsapp_en.ts # English |
168 ${TRANSLATIONSDIR}/bmsapp_nl.ts # Dutch |
238 ${TRANSLATIONSDIR}/bmsapp_nl.ts # Dutch |
169 ) |
239 ) |
170 |
240 |
171 set( SOURCE_FILES |
241 set( SOURCE_FILES |
172 ${SRCS} |
242 ${SRCS} |
173 ${HDRS} |
243 ${HDRS} |
174 ${UIS} |
244 ${UIS} |
175 resources/icons.qrc |
245 resources/icons.qrc |
176 resources/qdarkstyle/theme/style.qrc |
246 resources/qdarkstyle/theme/style.qrc |
177 ) |
247 ) |
|
248 |
|
249 ENDIF() |
178 |
250 |
179 # ===== Build the application ===== |
251 # ===== Build the application ===== |
180 |
252 |
181 # Run with cmake -DUPDATE_TRANSLATIONS=ON .. |
253 IF( ${BUILD_DESIGNER_PLUGINS} ) |
182 # or cmake -DUPDATE_TRANSLATIONS=OFF .. |
254 |
183 |
255 ELSE() |
184 if(UPDATE_TRANSLATIONS) |
256 |
185 message("** parse sources for new translations") |
257 # Run with cmake -DUPDATE_TRANSLATIONS=ON .. |
186 qt5_create_translation(QM_FILES ${SOURCE_FILES} ${TS_FILES}) |
258 # or cmake -DUPDATE_TRANSLATIONS=OFF .. |
187 else() |
259 |
188 message("** update qm files") |
260 if(UPDATE_TRANSLATIONS) |
189 qt5_add_translation(QM_FILES ${TS_FILES}) |
261 message("** parse sources for new translations") |
190 endif() |
262 qt5_create_translation(QM_FILES ${SOURCE_FILES} ${TS_FILES}) |
191 |
263 else() |
192 SET( bmsapp_DESKTOP |
264 message("** update qm files") |
|
265 qt5_add_translation(QM_FILES ${TS_FILES}) |
|
266 endif() |
|
267 |
|
268 SET( bmsapp_DESKTOP |
193 ${ROOTDIR}/bmsapp.desktop |
269 ${ROOTDIR}/bmsapp.desktop |
194 ) |
270 ) |
195 |
271 |
196 |
272 add_executable(${bmsapp_EXECUTABLE} ${SOURCE_FILES} ${QM_FILES}) |
197 add_executable(${bmsapp_EXECUTABLE} ${SOURCE_FILES} ${QM_FILES}) |
273 target_link_libraries(${bmsapp_EXECUTABLE} Qt5::Core Qt5::Widgets Qt5::Network Qt5::Sql Qt5::PrintSupport Qt5::WebSockets) |
198 target_link_libraries(${bmsapp_EXECUTABLE} Qt5::Core Qt5::Widgets Qt5::Network Qt5::Sql Qt5::PrintSupport Qt5::WebSockets) |
274 |
199 |
275 # `make translations' |
200 # `make translations' |
276 add_custom_target(translations DEPENDS ${QM_FILES}) |
201 add_custom_target(translations DEPENDS ${QM_FILES}) |
277 ENDIF() |
202 |
|
203 |
278 |
204 # ===== Install the application ===== |
279 # ===== Install the application ===== |
205 |
280 |
206 install(TARGETS ${bmsapp_EXECUTABLE} |
281 IF( ${BUILD_DESIGNER_PLUGINS} ) |
|
282 |
|
283 INSTALL(TARGETS bmsapp_plugins |
|
284 DESTINATION "${LIBPATH}/plugins/designer" |
|
285 ) |
|
286 |
|
287 ELSE() |
|
288 |
|
289 install(TARGETS ${bmsapp_EXECUTABLE} |
207 RUNTIME DESTINATION bin |
290 RUNTIME DESTINATION bin |
208 ) |
291 ) |
209 |
292 |
210 INSTALL( FILES ${bmsapp_DESKTOP} |
293 INSTALL( FILES ${bmsapp_DESKTOP} |
211 DESTINATION "${DATAROOTDIR}/applications" |
294 DESTINATION "${DATAROOTDIR}/applications" |
212 ) |
295 ) |
|
296 |
|
297 ENDIF() |
|
298 |