forked from Brewtarget/brewtarget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
748 lines (650 loc) · 29.3 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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
#
# CMakeLists.txt is part of Brewtarget, and is Copyright the following
# authors 2009-2022
# - Chris Pavetto <[email protected]>
# - Dan Cavanagh <[email protected]>
# - Daniel Moreno <[email protected]>
# - Daniel Pettersson <[email protected]>
# - Kregg Kemper <[email protected]>
# - Matt Young <[email protected]>
# - Maxime Lavigne (malavv) <[email protected]>
# - Mik Firestone <[email protected]>
# - Philip Greggory Lee <[email protected]>
# - Robby Workman <[email protected]>
# - Théophane Martin <[email protected]>
#
# Brewtarget is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Brewtarget is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# See also src/CMakeLists.txt
#
#================================================= CMake Configuration =================================================
cmake_minimum_required(VERSION 3.16)
cmake_policy(VERSION 3.16)
# Ensure we are using modern behaviour of the project command (introduced in CMake 3.0) which enables setting version
# numbers via it (rather than manually setting individual major/minor/patch vars).
cmake_policy(SET CMP0048 NEW)
#============================================== Project name and Version ===============================================
project(brewtarget VERSION 2.4.0 LANGUAGES CXX)
message(STATUS "Building " ${PROJECT_NAME} " version " ${PROJECT_VERSION})
message(STATUS "PROJECT_SOURCE_DIR is " ${PROJECT_SOURCE_DIR})
# Creates a Makefile.
# NOTE: cmake . -DCMAKE_INSTALL_PREFIX=/tmp/blah && make DESTDIR=/foo
# will install to /foo/tmp/blah.
# Where the binary goes.
IF( APPLE )
# Use capital letters. Don't question the APPLE.
SET(brewtarget_EXECUTABLE "Brewtarget")
ELSE()
SET(brewtarget_EXECUTABLE "brewtarget")
ENDIF()
#=============================Installation Components==========================
# For architecture-independent data
SET( DATA_INSTALL_COMPONENT "Data" )
# For architecture-dependent binaries
SET( RUNTIME_INSTALL_COMPONENT "Runtime" )
# `make install-data` or `make install-runtime`
ADD_CUSTOM_TARGET(
install-data
COMMAND "${CMAKE_COMMAND}"
-DCOMPONENT=${DATA_INSTALL_COMPONENT}
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
ADD_CUSTOM_TARGET(
install-runtime
DEPENDS ${brewtarget_EXECUTABLE}
COMMAND "${CMAKE_COMMAND}"
-DCOMPONENT=${RUNTIME_INSTALL_COMPONENT}
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
)
#===================================Options====================================
OPTION( BUILD_DESIGNER_PLUGINS
"If on, you will only build and install the designer plugins."
OFF )
OPTION( DO_RELEASE_BUILD
"If on, will do a release build. Otherwise, debug build."
OFF )
OPTION( NO_MESSING_WITH_FLAGS
"On means do not add any build flags whatsoever. May override other options."
OFF )
# Do this right off the bat
ENABLE_TESTING()
#==============================Bundle Settings================================
SET( MACOSX_BUNDLE_BUNDLE_NAME "Brewtarget" )
#SET( MACOSX_BUNDLE_GUI_IDENTIFIER )
#SET( MACOSX_BUNDLE_INFO_STRING )
#SET( MACOSX_BUNDLE_BUNDLE_VERSION )
#SET( MACOSX_BUNDLE_SHORT_VERSION_STRING )
SET( MACOSX_BUNDLE_LONG_VERSION_STRING ${brewtarget_VERSION_STRING} )
SET( MACOSX_BUNDLE_ICON_FILE "BrewtargetIcon.icns" )
SET( MACOSX_BUNDLE_COPYRIGHT "GPLv3" )
#==============================Compile flags===================================
set( CMAKE_EXPORT_COMPILE_COMMANDS ON)
# We need C++17 or later for nested namespaces (and C++11 or later for lambdas)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
IF( NOT ${NO_MESSING_WITH_FLAGS} )
IF( CMAKE_COMPILER_IS_GNUCXX )
SET( CMAKE_CXX_FLAGS_RELEASE "-Wall -ansi -pedantic -Wno-long-long -O2" )
SET( CMAKE_CXX_FLAGS_DEBUG "-Wall -g3" )
ENDIF()
# Speed up compilation if using gcc.
IF( UNIX AND NOT APPLE )
SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -pipe" )
SET( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pipe" )
ENDIF()
ENDIF()
#====================================================Set build type=====================================================
# We might always to tell the compiler to include debugging information (eg via the -g option on gcc). It makes the
# binaries slightly bigger on Linux, but helps greatly in analysing core dumps etc. (In closed-source projects people
# sometimes turn it off for release builds to make it harder to reverse engineer the software, but obviously that's not
# an issue for us.)
#
# However, setting CMAKE_BUILD_TYPE to "Debug", also changes other things, such as the default location for connfig
# files, which we don't want on a release build, so we would probably need to set compiler flags directly.
#
# .:TBD:. Investigate whether setting CMAKE_BUILD_TYPE to "RelWithDebInfo" does what we want.
#
IF( ${DO_RELEASE_BUILD} )
SET(CMAKE_BUILD_TYPE "Release")
ELSE()
SET(CMAKE_BUILD_TYPE "Debug")
ENDIF()
IF( APPLE AND NOT CMAKE_OSX_ARCHITECTURES )
SET( CMAKE_OSX_ARCHITECTURES x86_64 ) # Build intel 64-bit binary.
#SET( CMAKE_OSX_ARCHITECTURES i386 x86_64 ) # Build intel binary.
#SET( CMAKE_OSX_ARCHITECTURES ppc i386 ppc64 x86_64 ) # Build universal binary.
ENDIF()
#============================Directories=======================================
SET(ROOTDIR "${CMAKE_CURRENT_SOURCE_DIR}")
SET(SRCDIR "${ROOTDIR}/src")
SET(UIDIR "${ROOTDIR}/ui")
SET(DATADIR "${ROOTDIR}/data")
SET(TRANSLATIONSDIR "${ROOTDIR}/translations")
SET(WINDIR "${ROOTDIR}/win")
INCLUDE_DIRECTORIES(${SRCDIR})
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/src") # In case of out-of-source build.
INCLUDE_DIRECTORIES("${CMAKE_BINARY_DIR}/QtDesignerPlugins")
# Custom cmake modules.
SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules" )
#==============================OS-specific Commands============================
IF( UNIX )
SET( RM_COMMAND "rm" )
SET( RM_ARGS "-f" )
ELSEIF( WIN32 )
SET( RM_COMMAND "del" )
SET( RM_ARGS "" )
ENDIF()
#==================================Find Qt5====================================
# The minimum QT5 version we need. Keep as low as necessary.
# Note that if you change this, you need to make corresponding changes to the .github/workflows/*.yml files so that
# GitHub uses the appropriate version of Qt for the automated builds.
#
# For the moment, max version we can have here is 5.9.5, because that's what Ubuntu 18.04 topped out at
SET(QT5_MIN_VERSION 5.9.5)
# Automatically run moc on source files when necessary
SET(CMAKE_AUTOMOC ON)
# As moc files are generated in the binary dir, tell CMake
# to always look for includes there:
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
FIND_PACKAGE(Qt5Core ${QT5_MIN_VERSION} REQUIRED)
INCLUDE_DIRECTORIES(${Qt5Core_INCLUDE_DIRS})
FIND_PACKAGE(Qt5Widgets ${QT5_MIN_VERSION} REQUIRED)
INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS})
FIND_PACKAGE(Qt5Network ${QT5_MIN_VERSION} REQUIRED)
INCLUDE_DIRECTORIES(${Qt5Network_INCLUDE_DIRS})
FIND_PACKAGE(Qt5PrintSupport ${QT5_MIN_VERSION} REQUIRED)
INCLUDE_DIRECTORIES(${Qt5PrintSupport_INCLUDE_DIRS})
FIND_PACKAGE(Qt5Sql ${QT5_MIN_VERSION} REQUIRED)
INCLUDE_DIRECTORIES(${Qt5Sql_INCLUDE_DIRS})
# This is required to make the deploy scripts pick up the svg plugins
FIND_PACKAGE(Qt5Svg ${QT5_MIN_VERSION} REQUIRED)
INCLUDE_DIRECTORIES(${Qt5Svg_INCLUDE_DIRS})
FIND_PACKAGE(Qt5Xml ${QT5_MIN_VERSION} REQUIRED)
INCLUDE_DIRECTORIES(${Qt5Xml_INCLUDE_DIRS})
FIND_PACKAGE(Qt5Multimedia ${QT5_MIN_VERSION} REQUIRED)
INCLUDE_DIRECTORIES(${Qt5Multimedia_INCLUDE_DIRS})
FIND_PACKAGE(Qt5Test ${QT5_MIN_VERSION} REQUIRED)
INCLUDE_DIRECTORIES(${Qt5Test_INCLUDE_DIRS})
FIND_PACKAGE(Qt5LinguistTools ${QT5_MIN_VERSION} REQUIRED)
INCLUDE_DIRECTORIES(${Qt5LinguistTools_INCLUDE_DIRS})
# Fuckin Qt5 requires -fPIC if Qt5 itself was built with -fPIC
IF(Qt5_POSITION_INDEPENDENT_CODE)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
ENDIF()
# Uncomment the following line to show what version of Qt is actually being used
message(STATUS "Using Qt version " ${Qt5Core_VERSION})
MESSAGE( STATUS "CMAKE_SYSTEM_INCLUDE_PATH: ${CMAKE_SYSTEM_INCLUDE_PATH}" )
# Some extra files for the "make clean" target.
SET_PROPERTY(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
".*~$" # Kate backup files.
"CMakeLists.txt.user" # From QtCreator I think.
"CPackConfig.cmake"
"CPackSourceConfig.cmake"
)
#======================================================Find Boost=======================================================
# Boost is a collection of separate libraries, some, but not all, of which are header-only. We only specify the Boost
# libraries that we actually use.
#
# On Linux, there are cases where we need a more recent version of a Boost library than is readily-available in system-
# supplied packages. I haven't found a slick way to solve this in CMake, though https://github.com/Orphis/boost-cmake
# looks promising. (For header-only Boost libraries, you might think it would be relatively painless to pull them in
# from where they are hosted on GitHub (see https://github.com/boostorg), but this is not the case. AFAICT you can't
# easily pull a specific release, and just pulling master doesn't guarantee that everything compiles.) So, anyway, on
# Debian-based distros of Linux, such as Ubuntu, you need to do the following to install Boost 1.79 in place of whatever
# (if anything) is already installed:
#
# $ sudo apt remove boost-all-dev
# $ cd ~
# $ mkdir boost-tmp
# $ cd boost-tmp
# $ wget https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.bz2
# $ tar --bzip2 -xf boost_1_79_0.tar.bz2
# $ cd boost_1_79_0
# $ ./bootstrap.sh --prefix=/usr
# $ sudo ./b2 install
# $ cd ../..
# $ sudo rm -rf boost-tmp
#
# (Obviously if you want to make the necessary change to install an even more recent version than Boost 1.79 then that
# should be fine.)
#
# We do the same in .github/workflows/linux-ubuntu.yml to make GitHub automated builds work.
#
# ************************
# *** Boost Stacktrace ***
# ************************
#
# We use this for diagnostics. In certain error cases it's very helpful to be able to log the call stack.
#
# On Windows, using MSYS2, the mingw-w64-boost packages do not include libboost_stacktrace_backtrace, but
# https://www.boost.org/doc/libs/1_76_0/doc/html/stacktrace/configuration_and_build.html suggests it is not required
# (because on Windows, if you have libbacktrace installed, you can set BOOST_STACKTRACE_USE_BACKTRACE in header-only
# mode).
#
# .:TODO:. Not sure how to get libboost_stacktrace_backtrace installed on Mac. It doesn't seem to be findable by
# CMake after installing Boost via Homebrew (https://brew.sh/). For the moment, skip trying to use
# libboost_stacktrace_backtrace on Mac
#
# .:TODO:. So far don't have stacktraces working properly on Windows (everything shows as register_frame_ctor), so
# that needs some more investigation. (It could be that it's a bug in Boost, at least according to
# https://stackoverflow.com/questions/54333608/boost-stacktrace-not-demangling-names-when-cross-compiled)
IF(WIN32)
FIND_PACKAGE(Boost REQUIRED)
ELSEIF(APPLE)
FIND_PACKAGE(Boost REQUIRED)
ELSE()
# TBD Some users report problems getting CMake to find libboost_stacktrace_backtrace on Ubuntu and Gentoo, so disable it
# for now and fallback to the header-only version
#FIND_PACKAGE(Boost REQUIRED COMPONENTS stacktrace_backtrace)
FIND_PACKAGE(Boost REQUIRED)
ENDIF()
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
# Uncomment the next two lines if you want to find where Boost headers and DLLs are on your system
#message( "Boost include directories: " ${Boost_INCLUDE_DIRS} )
#message( "Boost libraries: " ${Boost_LIBRARIES} )
#===============================Find Xerces-C++================================
# CMake already knows how to find and configure Xerces-C++, see
# https://cmake.org/cmake/help/latest/module/FindXercesC.html
FIND_PACKAGE(XercesC REQUIRED)
INCLUDE_DIRECTORIES(${XercesC_INCLUDE_DIRS})
# Uncomment the next two lines if you want to find where Xerces headers and DLLs are on your system
#message( "Xerces-C++ include directories: " ${XercesC_INCLUDE_DIRS} )
#message( "Xerces-C++ libraries: " ${XercesC_LIBRARIES} )
#===============================Find Xalan-C++================================
# Same comments apply here as for Xerces above
FIND_PACKAGE(XalanC REQUIRED)
INCLUDE_DIRECTORIES(${XalanC_INCLUDE_DIRS})
# Uncomment the next two lines if you want to find where Xalan headers and DLLs are on your system
message( "Xalan-C++ include directories: " ${XalanC_INCLUDE_DIRS} )
message( "Xalan-C++ libraries: " ${XalanC_LIBRARIES} )
#=========================Configure brewtarget.qrc.in==========================
SET( brewtarget_QRC "${CMAKE_CURRENT_SOURCE_DIR}/brewtarget.qrc" )
#============================Doxygen Custom Target=============================
FIND_PROGRAM( DOXYGEN_CMD doxygen )
IF( DOXYGEN_CMD )
SET( DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile" )
CONFIGURE_FILE( "${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in" ${DOXYFILE} )
ADD_CUSTOM_TARGET( source_doc
COMMAND ${DOXYGEN_CMD} ${DOXYFILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/doc"
)
ENDIF()
#=========================Changelog custom target==============================
FIND_PROGRAM( GZIP_CMD gzip )
IF( GZIP_CMD )
SET( CHANGELOG_UNCOMPRESSED "${CMAKE_CURRENT_SOURCE_DIR}/CHANGES.markdown" )
SET( CHANGELOG "${CMAKE_CURRENT_BINARY_DIR}/changelog.gz" )
ADD_CUSTOM_COMMAND(
OUTPUT ${CHANGELOG}
COMMAND ${GZIP_CMD} -9 -n -c ${CHANGELOG_UNCOMPRESSED} > ${CHANGELOG}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
MAIN_DEPENDENCY ${CHANGELOG_UNCOMPRESSED}
)
ADD_CUSTOM_TARGET(changelog ALL DEPENDS ${CHANGELOG})
ENDIF()
#========================Construct the directories=============================
# Debian standard directories.
IF( NOT EXEC_PREFIX )
SET( EXEC_PREFIX ${CMAKE_INSTALL_PREFIX} )
ENDIF()
SET( DATAROOTDIR "${EXEC_PREFIX}/share" )
SET( BINDIR "${EXEC_PREFIX}/bin" )
IF( NOT DOCDIR )
SET( DOCDIR "${DATAROOTDIR}/doc/${CMAKE_PROJECT_NAME}" )
ENDIF()
# Actual install directories.
IF( UNIX AND NOT APPLE )
SET( DATAPATH "${DATAROOTDIR}/${CMAKE_PROJECT_NAME}" )
SET( TARGETPATH ${BINDIR} )
SET( DOCPATH ${DOCDIR} )
ELSEIF( WIN32 )
# Works for regular "make install", but not CPack/NSIS installer.
#SET( CMAKE_INSTALL_PREFIX "C:/Program Files/brewtarget-${brewtarget_VERSION_STRING}" )
#SET( DATAPATH "brewtarget-${brewtarget_VERSION_STRING}" )
#SET( TARGETPATH "brewtarget-${brewtarget_VERSION_STRING}" )
#SET( DOCPATH "brewtarget-${brewtarget_VERSION_STRING}/doc" )
# For some damn reason, for the NSIS installer,
# the prefix needs to be empty. Also, seems that the .exe
# needs to be in bin/. Fucking piece of shit CPack...
# Can anybody shed some light on this situation?
#SET( CMAKE_INSTALL_PREFIX "" )
SET( CPACK_INSTALL_PREFIX "" )
SET( DATAPATH "data" )
SET( TARGETPATH "bin" )
SET( DOCPATH "doc" )
ELSEIF( APPLE )
SET( DATAPATH "${BT_BUNDLE_DIR}/Contents/Resources" )
SET( TARGETPATH "${BT_BUNDLE_DIR}/Contents/MacOS" )
SET( DOCPATH "${BT_BUNDLE_DIR}/Contents/Resources/en.lproj" )
ENDIF()
#==============================Setup the config.h==============================
# "#define CONFIGDATADIR ${CONFIGDATADIR}$" in config.in will be replaced
# by the below corresponding value in ${CONFIGDATADIR} below when
# CONFIGURE_FILE() is called.
IF( ${DATAPATH} MATCHES "^/" )
SET( CONFIGDATADIR "${DATAPATH}/" )
ELSE()
SET( CONFIGDATADIR "/${DATAPATH}/" )
ENDIF()
IF( ${DOCPATH} MATCHES "^/" )
SET( CONFIGDOCDIR "${DOCPATH}/" )
ELSE()
SET( CONFIGDOCDIR "/${DOCPATH}/" )
ENDIF()
# Tell cmake where the configure file is and where
# to put the output. All variables in config.in written as "${VAR}$
# will be replaced by VAR as determined by cmake in config.h.
# Outputs only in the build directory.
CONFIGURE_FILE( src/config.in src/config.h )
#================================Files=========================================
# List of documentation files to be installed.
SET( brewtarget_DOCS
${ROOTDIR}/README.markdown
${ROOTDIR}/COPYRIGHT
)
# List of data files to be installed.
SET( brewtarget_DATA
${DATADIR}/default_db.sqlite
${DATADIR}/DefaultData.xml
# Yes, I know this is 'documentation', but Debian policy suggests it should be
# with the data (see section 12.3 of the policy manual).
${ROOTDIR}/doc/manual-en.pdf
)
# Desktop files to install.
SET( brewtarget_DESKTOP
${ROOTDIR}/brewtarget.desktop
)
# Icon files to install.
SET( brewtarget_ICONS
${ROOTDIR}/images/brewtarget.svg
)
SET( TRANSLATIONS_FILES
${TRANSLATIONSDIR}/bt_ca.ts # Catalan
${TRANSLATIONSDIR}/bt_cs.ts # Czech
${TRANSLATIONSDIR}/bt_de.ts # German
${TRANSLATIONSDIR}/bt_en.ts # English
${TRANSLATIONSDIR}/bt_el.ts # Greek
${TRANSLATIONSDIR}/bt_es.ts # Spanish
${TRANSLATIONSDIR}/bt_et.ts # Estonian
${TRANSLATIONSDIR}/bt_eu.ts # Basque
${TRANSLATIONSDIR}/bt_fr.ts # French
${TRANSLATIONSDIR}/bt_gl.ts # Galician
${TRANSLATIONSDIR}/bt_nb.ts # Norwegian Bokmal
${TRANSLATIONSDIR}/bt_it.ts # Italian
${TRANSLATIONSDIR}/bt_lv.ts # Latvian
${TRANSLATIONSDIR}/bt_nl.ts # Dutch
${TRANSLATIONSDIR}/bt_pl.ts # Polish
${TRANSLATIONSDIR}/bt_pt.ts # Portuguese
${TRANSLATIONSDIR}/bt_hu.ts # Hungarian
${TRANSLATIONSDIR}/bt_ru.ts # Russian
${TRANSLATIONSDIR}/bt_sr.ts # Serbian
${TRANSLATIONSDIR}/bt_sv.ts # Swedish
${TRANSLATIONSDIR}/bt_tr.ts # Turkish
${TRANSLATIONSDIR}/bt_zh.ts # Chinese
)
SET( RCFILE ${WINDIR}/icon.rc )
SET( brewtarget_SOUNDS
${DATADIR}/sounds/45minLeft.wav
${DATADIR}/sounds/addFuckinHops.wav
${DATADIR}/sounds/aromaHops.wav
${DATADIR}/sounds/beep.wav
${DATADIR}/sounds/bitteringHops.wav
${DATADIR}/sounds/checkBoil.wav
${DATADIR}/sounds/checkFirstRunnings.wav
${DATADIR}/sounds/checkGravity.wav
${DATADIR}/sounds/checkHydrometer.wav
${DATADIR}/sounds/checkMashTemps.wav
${DATADIR}/sounds/checkTemp.wav
${DATADIR}/sounds/clarifyingAgent.wav
${DATADIR}/sounds/cleanup.wav
${DATADIR}/sounds/closeFuckinValves.wav
${DATADIR}/sounds/closeValves.wav
${DATADIR}/sounds/doughIn.wav
${DATADIR}/sounds/drinkAnotherHomebrew.wav
${DATADIR}/sounds/drinkHomebrew.wav
${DATADIR}/sounds/emptyMashTun.wav
${DATADIR}/sounds/extraPropane.wav
${DATADIR}/sounds/flameout.wav
${DATADIR}/sounds/flavorHops.wav
${DATADIR}/sounds/heatWater.wav
${DATADIR}/sounds/mashHops.wav
${DATADIR}/sounds/pitchYeast.wav
${DATADIR}/sounds/sanitize.wav
${DATADIR}/sounds/sparge.wav
${DATADIR}/sounds/startBurner.wav
${DATADIR}/sounds/startChill.wav
${DATADIR}/sounds/stirMash.wav
)
SET( brewtarget_INFO_PLIST "${ROOTDIR}/mac/Info.plist" )
SET( brewtarget_MAC_ICNS "${ROOTDIR}/mac/BrewtargetIcon.icns" )
#==========================Find dlls for Win32=================================
# Note that WIN32 is true "when the target system is Windows, including Win64" (see
# https://cmake.org/cmake/help/latest/variable/WIN32.html), so this is ALL versions of Windows, not just 32-bit.
#
# .:TBD:. MY 2020-12-29 What do we need to do for Xerces and Xalan here?
IF( WIN32 )
FIND_PACKAGE(Qt5MultimediaWidgets REQUIRED)
FIND_PACKAGE(Qt5OpenGL REQUIRED)
GET_TARGET_PROPERTY(QtCore_location Qt5::Core LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtGui_location Qt5::Gui LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtMultimedia_location Qt5::Multimedia LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtMultimediaWidgets_location Qt5::MultimediaWidgets LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtNetwork_location Qt5::Network LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtOpenGL_location Qt5::OpenGL LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtPrintSupport_location Qt5::PrintSupport LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtSql_location Qt5::Sql LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtSvg_location Qt5::Svg LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtWidgets_location Qt5::Widgets LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtXml_location Qt5::Xml LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtSqliteDriver_location Qt5::QSQLiteDriverPlugin LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtQgif_location Qt5::QGifPlugin LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtQico_location Qt5::QICOPlugin LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtQjpeg_location Qt5::QJpegPlugin LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtQsvg_location Qt5::QSvgPlugin LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtQtiff_location Qt5::QTiffPlugin LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtQWindows_location Qt5::QWindowsIntegrationPlugin LOCATION_${CMAKE_BUILD_TYPE})
GET_TARGET_PROPERTY(QtQsvgIcon_location Qt5::QSvgIconPlugin LOCATION_${CMAKE_BUILD_TYPE})
SET( Qt_DLLs
${QtCore_location}
${QtWidgets_location}
${QtNetwork_location}
${QtPrintSupport_location}
${QtSql_location}
${QtSvg_location}
${QtXml_location}
${QtWebKit_location}
${QtGui_location}
${QtWebKitWidgets_location}
${QtOpenGL_location}
)
SET( Qt_DLLs
${Qt_DLLs}
${QtMultimedia_location}
${QtMultimediaWidgets_location}
)
SET( SQL_Drivers_DLLs
${QtSqliteDriver_location}
)
SET( Image_Formats_DLLs
${QtQgif_location}
${QtQico_location}
${QtQjpeg_location}
${QtQmng_location}
${QtQsvg_location}
${QtQtiff_location}
)
SET( Icon_Engines_DLLs
${QtQsvgIcon_location}
)
SET( Platform_DLLs
${QtQWindows_location}
)
GET_TARGET_PROPERTY( _qmake_executable Qt5::qmake IMPORTED_LOCATION )
GET_FILENAME_COMPONENT( QT5_BIN_DIR "${_qmake_executable}" DIRECTORY )
FIND_PROGRAM( WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT5_BIN_DIR}" )
IF( EXISTS ${WINDEPLOYQT_EXECUTABLE} )
add_executable(Qt5::windeployqt IMPORTED)
set_target_properties(Qt5::windeployqt PROPERTIES
IMPORTED_LOCATION ${WINDEPLOYQT_EXECUTABLE}
)
ENDIF()
FILE( GLOB IcuDlls
"${QT5_BIN_DIR}/ic*.dll"
)
# Find extra MinGW-specific dlls.
IF( MINGW )
IF( NOT MINGW_BIN_DIR )
FIND_PATH(MINGW_BIN_DIR "mingw32-make.exe")
ENDIF()
IF( NOT EXISTS ${MINGW_BIN_DIR} )
MESSAGE( FATAL_ERROR "MinGW bin dir not found. Run cmake again with the option -DMINGW_BIN_DIR=c:/path/to/mingw/bin" )
ELSE()
get_filename_component( Mingw_Path ${CMAKE_CXX_COMPILER} PATH )
ENDIF()
ENDIF()
ENDIF()
include( InstallRequiredSystemLibraries )
#===============================Packaging======================================
# To make the packages, "make package". For source packages, "make package_source"
IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
SET(CPACK_SET_DESTDIR "on")
SET(CPACK_PACKAGING_INSTALL_PREFIX "/tmp")
SET(CPACK_SOURCE_GENERATOR "TBZ2;")
SET(CPACK_SOURCE_IGNORE_FILES
"/.svn/"
"~$"
"/CMakeFiles/"
"/_CPack_Packages/"
"^brewtarget.*deb$"
"^brewtarget.*rpm$"
"^brewtarget.*tar.*$"
"CPack.*"
"Makefile"
"cmake_install.*"
"\\\\.o$"
"/brewtarget.dir/"
"moc_.*"
"qrc_brewtarget.*"
"ui_.*h"
"install_manifest.*"
"config\\\\.h"
)
SET( CPACK_PACKAGE_VERSION ${brewtarget_VERSION_STRING} )
SET( CPACK_PACKAGE_VENDOR "Philip G. Lee" )
SET( CPACK_PACKAGE_CONTACT "Philip G. Lee <[email protected]>" )
SET( CPACK_PACKAGE_DESCRIPTION_SUMMARY "GUI beer brewing software" )
SET( CPACK_PACKAGE_DESCRIPTION
"Brewtarget is a calculator for brewing beer. It is a Qt-based program which
allows you to create recipes from a database of ingredients. It calculates all
the important parameters, helps you with mash temperatures, and just makes the
process of recipe formulation much easier." )
SET(CPACK_PACKAGE_VERSION_MAJOR ${brewtarget_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${brewtarget_VERSION_MINOR}) # to create a debian confirm file-version-string
SET(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${brewtarget_VERSION_STRING}_${CMAKE_SYSTEM_PROCESSOR}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${brewtarget_VERSION_STRING}_source")
SET(CPACK_PACKAGE_EXECUTABLES "${brewtarget_EXECUTABLE}" "Brewtarget" )
IF( ${DO_RELEASE_BUILD} )
SET(CPACK_STRIP_FILES ${brewtarget_EXECUTABLE})
ENDIF()
#===========================UNIX======================================
IF(UNIX AND NOT APPLE)
SET(CPACK_GENERATOR "DEB;RPM;TBZ2;")
#-----------------DEB----------------
SET( CPACK_DEBIAN_PACKAGE_MAINTAINER "Philip G. Lee <[email protected]>" )
# NOTE: Use the getdependencies script to get the dependencies!
SET( CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.6-6~), libc6 (>= 2.1.3), libgcc1 (>= 1:4.1.1), libphonon4 (>= 4:4.2.0), libqt4-dbus (>= 4:4.5.3), libqt4-network (>= 4:4.5.3), libqt4-svg (>= 4:4.5.3), libqtwebkit4 (>= 2.3.4.dfsg-9.1), libqt4-xml (>= 4:4.5.3), libqtcore4 (>= 4:4.6.1), libqtgui4 (>= 4:4.5.3), libstdc++6 (>= 4.1.1), phonon (>= 4:4.5.2)" )
SET( CPACK_DEBIAN_PACKAGE_SECTION "misc" )
SET( CPACK_DEBIAN_PACKAGE_VERSION "${brewtarget_VERSION_STRING}-1")
SET( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" )
SET(CPACK_DEBIAN_PACKAGE_NAME ${CMAKE_PROJECT_NAME}_${brewtarget_VERSION_STRING})
#-----------------RPM-----------------
SET(CPACK_RPM_PACKAGE_LICENSE "GPLv3")
SET(CPACK_RPM_PACKAGE_GROUP "Applications/Productivity")
SET(CPACK_RPM_PACKAGE_REQUIRES "qt >= 4.6.0, phonon >= 4.2.0") # NOTE: I'm just guessing here. Somebody needs to check.
SET(CPACK_RPM_SPEC_MORE_DEFINE "%define ignore \#")
SET(CPACK_RPM_USER_FILELIST "%ignore /usr" "%ignore /usr/local" "%ignore /usr/local/bin" "%ignore /usr/local/share" "%ignore /usr/local/share/applications")
#============================WINDOWS===============================
ELSEIF(WIN32)
# http://www.thegigsite.com/cmake-2.6.0/CMakeCPackOptions.cmake
SET( CPACK_GENERATOR "NSIS" )
SET( CPACK_RESOURCE_FILE_LICENSE "${ROOTDIR}/COPYING.GPLv3" )
SET( CPACK_NSIS_PACKAGE_NAME "Brewtarget-${brewtarget_VERSION_STRING}" )
SET( CPACK_NSIS_DISPLAY__NAME "Brewtarget-${brewtarget_VERSION_STRING}" )
SET( CPACK_PACKAGE_INSTALL_REGISTRY_KEY "Brewtarget-${brewtarget_VERSION_STRING}" )
SET( CPACK_PACKAGE_INSTALL_DIRECTORY "Brewtarget-${brewtarget_VERSION_STRING}" )
SET( CPACK_NSIS_MODIFY_PATH ON )
# Extra start menu items.
#SET( CPACK_NSIS_MENU_LINKS
# "bin/${brewtarget_EXECUTABLE}" "My Brewtarget"
# )
#============================APPLE=================================
#ELSEIF(APPLE)
# SET( CPACK_GENERATOR "Bundle" )
#
# SET( CPACK_BUNDLE_NAME "${CMAKE_PROJECT_NAME}_${brewtarget_VERSION_STRING}" )
# SET( CPACK_BUNDLE_ICON "../mac/BrewtargetIcon.icns" )
# SET( CPACK_BUNDLE_PLIST "../mac/Info.plist" )
# SET( CPACK_BUNDLE_STARTUP_COMMAND "${brewtarget_EXECUTABLE}")
#
ELSEIF(APPLE)
#SET( CPACK_GENERATOR "DragNDrop" )
#SET( CPACK_DMG_FORMAT "UDBZ" )
ENDIF()
INCLUDE(CPack)
ENDIF()
#================================Installs======================================
IF( NOT ${BUILD_DESIGNER_PLUGINS} )
# Install the data.
INSTALL( FILES ${brewtarget_DATA}
DESTINATION ${DATAPATH}
COMPONENT ${DATA_INSTALL_COMPONENT} )
# Install the documentation.
INSTALL( FILES ${brewtarget_DOCS}
DESTINATION ${DOCPATH}
COMPONENT ${DATA_INSTALL_COMPONENT} )
# Install sounds.
INSTALL( FILES ${brewtarget_SOUNDS}
DESTINATION "${DATAPATH}/sounds"
COMPONENT ${DATA_INSTALL_COMPONENT} )
#-----------Unix-----------
IF( UNIX AND NOT APPLE )
# Install the icons.
INSTALL( FILES ${brewtarget_ICONS}
DESTINATION "${DATAROOTDIR}/icons/hicolor/scalable/apps/"
COMPONENT ${DATA_INSTALL_COMPONENT} )
# Install the .desktop file.
INSTALL( FILES ${brewtarget_DESKTOP}
DESTINATION "${DATAROOTDIR}/applications"
COMPONENT ${DATA_INSTALL_COMPONENT} )
# Install changelog
INSTALL( FILES ${CHANGELOG}
DESTINATION ${DOCPATH}
COMPONENT ${DATA_INSTALL_COMPONENT} )
ENDIF()
IF( CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS )
INSTALL( PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION bin COMPONENT System )
ENDIF( CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS )
ENDIF()
# =====================Process other CMakeList.txt's===========================
IF( ${BUILD_DESIGNER_PLUGINS} )
MESSAGE( STATUS "Building Qt Designer plugins." )
ADD_SUBDIRECTORY(QtDesignerPlugins)
ELSE()
MESSAGE( STATUS "Building Brewtarget." )
ADD_SUBDIRECTORY(${SRCDIR})
ENDIF()