-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
757 lines (655 loc) · 27.6 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
749
750
751
752
753
754
755
756
757
#
# Copyright 2017, 2018, 2019, 2024 Gary R. Van Sickle ([email protected]).
#
# This file is part of AwesomeMediaLibraryManager.
#
# AwesomeMediaLibraryManager 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.
#
# AwesomeMediaLibraryManager 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 AwesomeMediaLibraryManager. If not, see <http://www.gnu.org/licenses/>.
#
# @file ./CMakeLists.txt
# References:
# Too many to list. Some of the critical ones:
# https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1 ("Effective Modern CMake")
# https://github.com/euler0/mini-cmake-qt (QtCommon et al, Public Domain, https://github.com/euler0/mini-cmake-qt/blob/master/LICENSE)
# https://cmake.org/cmake/help/v3.0/manual/cmake-qt.7.html
# Installer refs:
# https://github.com/skypjack/qt_cpackifw
# https://cmake.org/cmake/help/v3.9/module/CPackIFW.html
# https://github.com/kracejic/cleanCppProject/blob/master/CMakeLists.txt
# @note For QtIFW installer:
# - On Linux, CPACK_IFW_ROOT (cmake var) or QTIFWDIR (env var) should point to something like ~/Qt/QtIFW-3.0.1
# cmake setup.
cmake_minimum_required(VERSION 3.27 FATAL_ERROR)
cmake_policy(SET CMP0053 NEW) # Use new var ref/esc seq eval
cmake_policy(SET CMP0010 NEW) # Silence warning on CMP0010.
message(STATUS "CMake-time ENV PATH: $ENV{PATH}")
message(STATUS "CMake-time ENV CMAKE_PREFIX_PATH: $ENV{CMAKE_PREFIX_PATH}")
message(STATUS "CMake-time ENV CMAKE_MODULE_PATH: $ENV{CMAKE_MODULE_PATH}")
include(cmake/GetVersionInfo.cmake)
# Prevent an in-root-of-src-tree build and any accidental build-induced changes to source files.
# Per @link https://stackoverflow.com/questions/1208681/with-cmake-how-would-you-disable-in-source-builds, these have to
# be prior to project().
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message("ERROR: ${CMAKE_SOURCE_DIR} == ${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "Prevented in-root-of-tree build. Please create a build directory outside of the source code root directory and call cmake from there. Thank you.")
endif()
if(FALSE)
### Set up the <LANG>_COMPILER_LAUNCHERs.
### @note "This property is initialized by the value of
### the CMAKE_<LANG>_COMPILER_LAUNCHER variable if it is set when a target is created."
# Use ccache if it's available.
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
# if(TRUE) # csbuild - the static analysis one.
# set_property(GLOBAL PROPERTY CMAKE_CXX_COMPILER_LAUNCHER "csbuild;--print-current;-c")
# endif()
endif()
# Basic information about project
# Note that here is where CMake determines compilers and loads any toolchain.cmake file.
# (per https://cgold.readthedocs.io/en/latest/tutorials/project.html)
project(AwesomeMediaLibraryManager
VERSION ${GVI_VERSION_TAG_QUAD}
DESCRIPTION "The Awesome Media Library Manager"
LANGUAGES C CXX)
# Additional project info.
set(PROJECT_AUTHOR "Gary R. Van Sickle")
set(PROJECT_AUTHOR_EMAIL "[email protected]")
set(FULL_COPYRIGHT_STRING "Copyright (c) 2017, 2018, 2019, 2024 ${PROJECT_AUTHOR} <${PROJECT_AUTHOR_EMAIL}>")
# Early include of some basic cmake stuff.
include(CMakePrintHelpers)
### Set the required language standards.
# C11
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
# C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Min versions of Qt5, KF5, KF5/ECM.
set(QT_MIN_VERSION "5.12.1")
set(KF5_MIN_VERSION "5.57.0") ### @win temp: Only have 5.52.0
set(ECM_MIN_VERSION "6.0.0") #"5.57.0")
###
### IDE helper setup
###
source_group(TREE ${CMAKE_SOURCE_DIR})
set(AUTOGEN_SOURCE_GROUP autogen)
set(AUTOMOC_SOURCE_GROUP automoc)
set(AUTORCC_SOURCE_GROUP autorcc)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
###
### ECM Setup ====================================================================================================
###
# KDE extra-cmake-modules, see https://api.kde.org/ecm/
# @note find_package() MODULE vs. NO_MODULE (==CONFIG mode):
# "Config mode provides an elaborate interface and search procedure. Much of the interface is provided for completeness
# and for use internally by find-modules loaded by Module mode. Most user code should simply call:
# find_package(<package> [major[.minor]] [EXACT] [REQUIRED|QUIET])"
### @todo NO WIN:
find_package(PkgConfig REQUIRED) # @note I see PkgConfig just before ECM in a few KDE scripts.
find_package(ECM ${ECM_MIN_VERSION} REQUIRED NO_MODULE)
# Add dirs where we keep support *.cmake's, ucm, cotire, ECM, etc.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake
#${CMAKE_SOURCE_DIR}/cmake/cotire/CMake
${CMAKE_SOURCE_DIR}/cmake/ucm/cmake
${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}
${CMAKE_SOURCE_DIR}/src/third_party/continuable/cmake)
###
### ECM Macros
### Note: The order here follows that of KDevelop and Calligra's top-level CMakeLists.txt's. Some macros used there are omitted here.
###
# ECM KDE macros
# @note Order matters for these next two include()s. Per the docs, InstallDirs needs to come before CMakeSettings.
# @link https://api.kde.org/ecm/kde-module/KDECMakeSettings.html#runtime-paths
include(KDEInstallDirs) ##< Replaces/uses GNUInstallDirs.
#set(APPLE_FORCE_X11 ON) # This applies to KDECMakeSettings.
set(ENABLE_CLAZY ON) # This applies to KDECMakeSettings.
include(KDECMakeSettings NO_POLICY_SCOPE)
# CMake macros.
include(FeatureSummary)
# ECM macros.
include(ECMOptionalAddSubdirectory)
include(ECMInstallIcons)
include(ECMAddAppIcon)
include(ECMAddTests)
include(ECMMarkAsTest)
include(ECMQtDeclareLoggingCategory)
# Sanitizers.
# @note KF5:
# The sanitizers are not enabled by default. Instead, you must set ECM_ENABLE_SANITIZERS (either in your
# CMakeLists.txt or on the command line) to a semicolon-separated list of sanitizers you wish to enable.
# The options are:
# address memory thread leak undefined
# The sanitizers "address", "memory" and "thread" are mutually exclusive. You cannot enable two of them in the same build.
# "leak" requires the "address" sanitizer.
### @note KDECompileFlags includes include(ECMEnableSanitizers).
#set(ECM_ENABLE_SANITIZERS "leak;address")
include(ECMEnableSanitizers)
# KDE macros.
# @see https://api.kde.org/ecm/manual/ecm-kde-modules.7.html
# @note Don't set the to true:
# "If KDE_INSTALL_DIRS_NO_DEPRECATED is set to TRUE, only those variables defined by the GNUInstallDirs module
# (shipped with CMake) are defined."
# That is what happens, but I'm not clear on why this var would control that; are all the KDE Install Dirs deprecated?
#set(KDE_INSTALL_DIRS_NO_DEPRECATED TRUE)
# KDECompilerSettings
# Enables more warnings. Transitively includes include(ECMEnableSanitizers).
# @note This disables exceptions. We'll turn them back on with kde_enable_exceptions() below.
# @warning This also sets the compiler stds way too low (C89(!!))
# @see https://api.kde.org/ecm/kde-module/KDECompilerSettings.html
#include(KDECompilerSettings NO_POLICY_SCOPE)
#kde_enable_exceptions()
# And undo even more of what KDECompilerSettings did to/for us.
###string(REPLACE "-Werror=undef" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# string(REGEX REPLACE "-O[^;]*" "-Og" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
# string(REGEX REPLACE "-g[^;]*" "-ggdb3" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
# string(REGEX REPLACE "-O[^;]*" "-Og" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
# string(REGEX REPLACE "-g[^;]*" "-ggdb3" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
#list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS_DEBUG)
###
### END ECM Setup ====================================================================================================
###
# Set some extra debug flags early.
# This is stupid, but I can't for the life of me figure out a better way to set the compiler options in
# cmake and/or Qt Creator.
# https://github.com/onqtam/ucm#ucm_add_flags
include(ucm)
# Target-focused compile settings.
add_library(cxx_settings INTERFACE)
target_compile_features(cxx_settings INTERFACE cxx_std_17)
add_library(cxx_definitions_qt INTERFACE)
target_compile_definitions(cxx_definitions_qt INTERFACE)
add_library(cxx_compile_options INTERFACE)
target_compile_options(cxx_compile_options INTERFACE)
if(UNIX)
target_compile_options(cxx_compile_options
INTERFACE
-Og -ggdb3 -fno-omit-frame-pointer -fmessage-length=0 -pthread -Werror=return-type)
ucm_add_flags(-Og -ggdb3 -fno-omit-frame-pointer -fmessage-length=0 -pthread -Werror=return-type)
# Flags for GNU libstdc++
### @todo Detect that we're actually using GNU libstdc++
# "compiles user code using the debug mode. When defined, _GLIBCXX_ASSERTIONS is defined automatically"
### @note This crashes when linked with non-debug libstdc++. Can't pass containers between them.
#ucm_add_flags(CXX -D_GLIBCXX_DEBUG=1)
endif(UNIX)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message(STATUS "C++ Compiler is GCC")
ucm_add_flags(-fvar-tracking -fvar-tracking-assignments -gpubnames -ggnu-pubnames)
# Max debug flags
target_compile_options(cxx_compile_options
INTERFACE
-gvariable-location-views
-gas-loc-support -gstatement-frontiers -ginline-points -femit-struct-debug-detailed=any
)
#ucm_add_flags(-gvariable-location-views)
ucm_add_flags(-grecord-gcc-switches)
ucm_add_flags(-fno-eliminate-unused-debug-types -fno-inline)
ucm_add_flags(-Wmaybe-uninitialized -Werror=maybe-uninitialized -fdiagnostics-show-template-tree -fdiagnostics-show-option)
ucm_add_flags(-fuse-ld=gold) # Let's try the gold linker.
# GCC 9.x suggestions.
add_library(cxx_suggestions INTERFACE)
target_compile_options(cxx_suggestions INTERFACE
-Wsuggest-attribute=const)
target_link_libraries(cxx_settings INTERFACE cxx_suggestions)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message(STATUS "C++ Compiler is Clang")
target_compile_options(cxx_compile_options
INTERFACE
-fforce-emit-vtables
)
ucm_add_flags(-Wthread-safety -fdebug-macro -fdiagnostics-show-template-tree -mno-omit-leaf-frame-pointer)
#ucm_add_flags(-fdelayed-template-parsing -frelaxed-template-template-args)
endif()
if(WIN32)
#ucm_add_flags(/showIncludes)
### NOTE: Make sure CMAKE_PREFIX_PATH has the path to the directory, so cmake can find win_flex and win_bison.
### On Windows they're in a couple places, e.g.:
# C:\Qt\5.12.0\Src\gnuwin32\bin\bison.exe
# C:\CraftRoot\build\dev-utils\flexbison\work\win_bison.exe
# C:\CraftRoot\build\dev-utils\flexbison\image-Debug-2.5.14\dev-utils\bin\win_bison.exe
# We also need png2ico on Windows, which is here:
# C:\CraftRoot\dev-utils\bin\png2ico.exe
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};C:/CraftRoot/dev-utils/bin;C:/Qt/5.12.0/Src/gnuwin32/bin)
endif(WIN32)
target_link_libraries(cxx_settings INTERFACE cxx_compile_options)
message(STATUS "C compiler supported features = ${CMAKE_C_COMPILE_FEATURES}")
message(STATUS "C++ compiler supported features = ${CMAKE_CXX_COMPILE_FEATURES}")
message(STATUS "C++ CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}")
message(STATUS "C++ CMAKE_CXX_FLAGS_DEBUG = ${CMAKE_CXX_FLAGS_DEBUG}")
###
# Include some basic cmake functions.
include(CheckCXXCompilerFlag)
include(PrintTargetProperties)
include(helperfunctions)
# Include some basic Qt5-related cmake functions
include(QtCommon)
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE) # Without this, Release builds won't include the MSVC C runtime.
include(InstallRequiredSystemLibraries)
# For DownloadProject, which we use for GoogleTest and Boost.
set(UPDATE_DISCONNECTED_IF_AVAILABLE "UPDATE_DISCONNECTED FALSE")
#include(ExternalProject)
include(DownloadProject)
# Right now we need all the verbosity we can get.
set(CMAKE_VERBOSE_MAKEFILE YES)
# "CMake automatically analyzes the global inter-target dependency graph at the beginning of native build system generation.
# This property causes it to display details of its analysis to stderr."
# set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1)
set(CPACK_IFW_VERBOSE YES)
#set(CMAKE_DEBUG_TARGET_PROPERTIES
# INCLUDE_DIRECTORIES
# COMPILE_DEFINITIONS
# POSITION_INDEPENDENT_CODE
# CONTAINER_SIZE_REQUIRED
# LIB_VERSION
# )
message("******************************************************************")
message("* ${PROJECT_NAME} version ${PROJECT_VERSION}-${GVI_VERSION_COMMITS}-g${GVI_VERSION_HASH}${GVI_VERSION_DIRTY_POSTFIX} (${CMAKE_BUILD_TYPE})")
message("* ${FULL_COPYRIGHT_STRING}")
message("******************************************************************")
message("* Using CMake version ${CMAKE_VERSION}")
message("* CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
message("*")
message("* From top level:")
message("* Source directory: ${PROJECT_SOURCE_DIR} (${AwesomeMediaLibraryManager_SOURCE_DIR})")
message("* Top level of build tree: ${CMAKE_BINARY_DIR}")
message("* Build directory: ${PROJECT_BINARY_DIR} (${AwesomeMediaLibraryManager_BINARY_DIR})")
message("* Version: ${PROJECT_VERSION}")
message("* Version (alt): ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}")
message("* Discovered tools:")
message("* CMAKE_MAKE_PROGRAM: ${CMAKE_MAKE_PROGRAM}")
message("* GIT_EXECUTABLE: ${GIT_EXECUTABLE}")
# Per @link https://stackoverflow.com/a/24470998
message("* Generated with config types: ${CMAKE_CONFIGURATION_TYPES}")
print_compilers_and_params()
# FBO at least visual studio
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Export compile commands.
# FBO Eclipse, clang-tidy, iwyu, etc.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# The. Simplest. Things.
# Set default install location to "install" folder in build dir.
# we do not want to install to /usr by default.
# "CMake sets this variable to a TRUE value when the CMAKE_INSTALL_PREFIX has just been initialized to its default value,
# typically on the first run of CMake within a new build tree. This can be used by project code to change the default
# without overriding a user-provided value"
### @todo This is still broken: prefix.sh gets generated (first time after a wipe?) with /usr/bin paths.
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(NEW_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install")
message(STATUS "Changing CMAKE_INSTALL_PREFIX from ${CMAKE_INSTALL_PREFIX} to ${NEW_INSTALL_PREFIX}")
set (CMAKE_INSTALL_PREFIX "${NEW_INSTALL_PREFIX}" CACHE
PATH "Install path prefix, prepended onto install directories." FORCE )
message(STATUS "Set CMAKE_INSTALL_PREFIX to ${CMAKE_INSTALL_PREFIX}")
else()
message(WARNING "CMAKE_INSTALL_PREFIX set to default ${CMAKE_INSTALL_PREFIX}")
endif()
print_varlist(CMAKE_INSTALL_PREFIX KDE_INSTALL_ICONDIR)
# Compiler flag support checks.
set(EXTRA_CXX_COMPILE_FLAGS "")
check_cxx_compiler_flag("-Wuninitialized" CXX_W_UNINIT)
if(CXX_W_UNINIT)
message(STATUS "Compile flag supported: ${CXX_W_UNINIT}")
list(APPEND EXTRA_CXX_COMPILE_FLAGS "-Wuninitialized")
endif()
if(WIN32)
# Make sure we're supporting Unicode on Windows.
### @todo With KDECompileFlags we don't need this.
add_definitions(-DUNICODE -D_UNICODE)
endif()
# Find includes in corresponding build directories.
set(CMAKE_INCLUDE_CURRENT_DIR ON)
###
### The Qt5 packages we require.
### @note CONFIG|MODULE: "If no module is found the command falls back to Config mode, described below.
### This fall back is disabled if the MODULE option is given."
###
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
Gui
Widgets
Multimedia
XmlPatterns
Concurrent
Test # For Q...ModelTester.
)
set(QT5_LINK_LIB_TARGETS Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Multimedia Qt5::XmlPatterns Qt5::Concurrent Qt5::Test)
# Unix-only
if(UNIX)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
X11Extras)
list(APPEND QT5_LINK_LIB_TARGETS Qt5::X11Extras)
endif(UNIX)
# Windows only
if(WIN32)
list(APPEND QT5_LINK_LIB_TARGETS Qt5::WinMain)
endif(WIN32)
print_qtinfo()
###
### KDE KF5 libs.
###
# Krita has ~this warning: "don't reorder these, this is the order they depend on each other."
set(KF5_LINK_LIB_TARGETS "")
### @note "Config" is both a find_package() keyword as well as the KF5Config components KF5::ConfigCore and KF5::ConfigGui.
### We'll require KF5Config separately to avoid any ambiguity.
find_package(KF5Config ${KF5_MIN_VERSION} REQUIRED)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Archive ### @todo TRYING THIS IN CASE IconThemes needs it to work properly, otherwise REMOVE
WidgetsAddons
CoreAddons ## USE_KF5_COREADDONS, git clone git://anongit.kde.org/kcoreaddons.git
GuiAddons
ConfigWidgets ## Not in Krita from this until WindowSystem.
KIO ## USE_KDE_KIO, git clone git://anongit.kde.org/kio.git
ItemModels
ItemViews
XmlGui
IconThemes
WindowSystem
)
set(HAVE_KF501 ${KF5_FOUND})
list(APPEND KF5_LINK_LIB_TARGETS KF5::CoreAddons KF5::ConfigCore KF5::ConfigGui)
list(APPEND KF5_LINK_LIB_TARGETS KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets KF5::KIONTLM)
list(APPEND KF5_LINK_LIB_TARGETS KF5::WidgetsAddons KF5::XmlGui KF5::GuiAddons KF5::IconThemes KF5::ItemModels KF5::ItemViews)
list(APPEND KF5_LINK_LIB_TARGETS KF5::WindowSystem)
###### EXPERIMENT
# SQLite3
find_package(SQLite3
REQUIRED)
#find_package(BreezeIcons REQUIRED) # Doesn't exist yet.
### @todo Need to find a better way than hardcoding the path to the rcc file here.
set(WITH_BUNDLED_BREEZE_ICONS true)
if(WIN32)
set(BREEZEICONS_DIR
# Craft has a couple of breeze-icons.rcc's, plus an icontheme.rcc in CraftRoot/bin/data/.
C:/CraftRoot/bin/data/icons/breeze
)
else()
set(BREEZEICONS_DIR
/usr/share/icons/breeze
~/.icons/breeze
)
endif()
if(WITH_BUNDLED_BREEZE_ICONS)
### @todo SOMETHING IS WRONG HERE, FIX THIS
set(AMLM_INSTALL_BUNDLED_ICON_THEME_DIR "${KDE_INSTALL_FULL_DATAROOTDIR}/gvansickle/AwesomeMediaLibraryManager")
find_file(BREEZEICONS_PATH breeze-icons.rcc
HINTS
${BREEZEICONS_DIR}
PATH_SUFFIXES
breeze
DOC
"Full path to the breeze-icons.rcc file"
)
if (NOT EXISTS ${BREEZEICONS_PATH})
message(FATAL_ERROR "Cannot find breeze-icons.rcc")
else()
message(STATUS "Found source default icon theme: ${BREEZEICONS_PATH}")
message(STATUS "Default icon theme will be installed in: ${AMLM_INSTALL_BUNDLED_ICON_THEME_DIR}")
# Install it as our default icon theme.
install(FILES ${BREEZEICONS_PATH}
DESTINATION ${AMLM_INSTALL_BUNDLED_ICON_THEME_DIR}
RENAME "icontheme.rcc"
COMPONENT coreapp)
endif()
endif()
#list(APPEND KF5_LINK_LIB_TARGETS Breeze)
print_varlist(BREEZEICONS_PATH)
###
### GTK Libs.
### See https://wiki.gnome.org/Projects/gtkmm/UsingCMake, https://cmake.org/cmake/help/v3.10/module/FindPkgConfig.html
###
set(GTK_LINK_LIB_TARGETS "")
if(UNIX)
# pkg_check_modules(GTKMM REQUIRED IMPORTED_TARGET gtkmm-3.0)
# list(APPEND GTK_LINK_LIB_TARGETS PkgConfig::GTKMM)
# set(HAVE_GTKMM01 ${GTKMM_FOUND})
endif(UNIX)
###
### X11 and XCB libs.
###
if(UNIX)
find_package(X11 REQUIRED)
list(APPEND GTK_LINK_LIB_TARGETS ${X11_X11_LIB})
find_package(X11_XCB REQUIRED)
list(APPEND GTK_LINK_LIB_TARGETS ${X11_XCB_LIBRARIES})
cmake_print_variables(X11_XCB_FOUND)
find_package(XCB REQUIRED COMPONENTS
XCB
)
list(APPEND GTK_LINK_LIB_TARGETS ${XCB_TARGETS})
print_varlist(XCB_TARGETS GTK_LINK_LIB_TARGETS)
endif(UNIX)
#
# And Boost. Sorry.
# @link https://cmake.org/cmake/help/v3.14/module/FindBoost.html?highlight=boost#findboost
if(FALSE)
### CallableTraits only in 1.66+.
set(Boost_USE_MULTITHREADED ON)
find_package(Boost REQUIRED 1.66.0
COMPONENTS CallableTraits
)
else()
if(FALSE)
download_project(PROJ boost_callable_traits
GIT_REPOSITORY https://github.com/boostorg/callable_traits.git
GIT_TAG master
${UPDATE_DISCONNECTED_IF_AVAILABLE}
)
add_subdirectory(${boost_callable_traits_SOURCE_DIR} ${boost_callable_traits_BINARY_DIR} EXCLUDE_FROM_ALL)
print_varlist(boost_callable_traits_SOURCE_DIR boost_callable_traits_BINARY_DIR)
endif()
endif()
# Boost
if(TRUE)
# See @link https://cmake.org/cmake/help/latest/module/FindBoost.html
#set(BOOST_THREAD_VERSION 5) # Latest in 1.69 as of this writing, defaults to "2".
#set(BOOST_THREAD_PROVIDES_FUTURE ON)
#set(BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION ON)
#set(BOOST_THREAD_FUTURE_USES_OPTIONAL ON)
add_compile_definitions(BOOST_THREAD_VERSION=5
BOOST_THREAD_PROVIDES_FUTURE=1
BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION=1
BOOST_THREAD_FUTURE_USES_OPTIONAL=1
)
set(Boost_USE_STATIC_LIBS ON) # Only find static libs.
#set(Boost_USE_STATIC_RUNTIME ON) # Want static runtime.
set(Boost_USE_MULTITHREADED ON) # Need multithreaded.
#set(Boost_USE_DEBUG_LIBS ON)
#set(Boost_USE_RELEASE_LIBS OFF)
set(BOOST_ALL_DYN_LINK OFF)
#set(Boost_USE_DEBUG_RUNTIME ON)
set(Boost_DEBUG ON) # enable debug output from FindBoost.
set(Boost_DETAILED_FAILURE_MSG ON) # add detailed information to the failure message
# # even when the REQUIRED option is not given to the find_package call.
find_package(Boost 1.69.0 REQUIRED
COMPONENTS
date_time
thread
system
)
if(Boost_FOUND)
add_library(amlm_boost_settings_target INTERFACE)
target_link_libraries(amlm_boost_settings_target INTERFACE ${Boost_LIBRARIES})
target_compile_definitions(amlm_boost_settings_target
INTERFACE
BOOST_THREAD_VERSION=5)
add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
endif()
endif() # BOOST
# Qt logging categories.
# @link https://api.kde.org/ecm/module/ECMQtDeclareLoggingCategory.html
ecm_qt_declare_logging_category(QT5_LOGGING_CATEGORY_SOURCE_FILES
HEADER logging_cat_ExtFuture.h
IDENTIFIER EXTFUTURE
CATEGORY_NAME amlm.concurrency.extfuture
DEFAULT_SEVERITY Debug ### <Debug|Info|Warning|Critical|Fatal>
)
ecm_qt_declare_logging_category(QT5_LOGGING_CATEGORY_SOURCE_FILES
HEADER logging_cat_ExtAsync.h
IDENTIFIER EXTASYNC
CATEGORY_NAME amlm.concurrency.extasync
DEFAULT_SEVERITY Debug ### <Debug|Info|Warning|Critical|Fatal>
)
# Qt-specific compiler definitions.
target_compile_definitions(cxx_definitions_qt
INTERFACE
-DQT_DEPRECATED_WARNINGS
-DQT_SHAREDPOINTER_TRACK_POINTERS=1
-DQT_NO_KEYWORDS
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
#-DQT_NO_URL_CAST_FROM_STRING
#-DQT_NO_CAST_FROM_ASCII
#-DQT_NO_CAST_TO_ASCII
#-DQT_NO_CAST_FROM_BYTEARRAY
-DQT_STRICT_ITERATORS
-DQT_USE_QSTRINGBUILDER
-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT
)
# Set PROJECT_VERSION_PATCH and PROJECT_VERSION_TWEAK to 0 if not present, needed by add_project_meta
fix_project_version()
# Set additional project information FBO QtCommon.cmake/add_project_meta().
# Resource directory FBO QtCommon/add_project_meta().
set(RESOURCE_FOLDER resources)
# The basename of the application's icon.
set(ICON_NAME "AMLMAppIcon")
# For the "CompanyName" field in the rc file.
set(RC_COMPANYNAME "${PROJECT_AUTHOR}")
set(RC_LEGALCOPYRIGHT "${FULL_COPYRIGHT_STRING}")
# Reverse of app.setOrganizationDomain()?
set(IDENTIFIER "io.github.gvansickle")
### Generate configured headers.
# @note The version info file is generated in the "resources" dir/target.
# Generate the amlm-configure.h file.
configure_file(${PROJECT_SOURCE_DIR}/src/config.h.in
${PROJECT_BINARY_DIR}/src/config.h
ESCAPE_QUOTES)
# Create a graphviz dep graph.
# add_custom_target(graphviz ALL
# ${CMAKE_COMMAND} .. "--graphviz=graphviz.dot" .
# WORKING_DIRECTORY .)
###
### Add the project subdirs.
###
#set(amlm_APP_ICONS "re-set this in resources_subdir")
add_subdirectory(resources EXCLUDE_FROM_ALL)
message(AUTHOR_WARNING "amlm_APP_ICONS: ${amlm_APP_ICONS}")
add_subdirectory(src)
###
### Testing
###
enable_testing()
### @todo IS THIS STILL TRUE???: Google Test creates a target named "tests" as well.
add_subdirectory(tests)
#include(resources/CMakeLists.txt)
#print_varlist(amlm_ICONS amlm_SRCS)
#ecm_add_app_icon(amlm_SRCS ICONS ${amlm_ICONS})
# This function sets up the variable META_FILES_TO_INCLUDE to the extra files
# needed for a windows build (essentially just the configured .rc file).
add_project_meta(META_FILES_TO_INCLUDE)
###
### Install
###
# In subdirs.
###
### Packaging
###
if(false) # This has to be broken now.
# From within the build directory, just run the following commands to create the package:
# $ cmake ..
# $ make package
# Custom target for coordinating the packaging.
add_custom_target(packaging
ALL
DEPENDS ${PROJECT_NAME} icons_oxygen ${AppIcon_rcc}
COMMENT "Packaging ${PROJECT_NAME}...")
if(WIN32)
# Add custom commands and install targets for Qt windeploy.
include(package/PackageWindows.cmake)
endif()
# Relocate this?
set(CPACK_GENERATOR NSIS)
# Generic.
# https://cmake.org/cmake/help/v3.10/module/CPack.html
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION ${GVI_GIT_DESCRIBE_OUTPUT}-${CMAKE_BUILD_TYPE})
# Doesn't look like we need to set these separately.
#set(CPACK_PACKAGE_VERSION_MAJOR ???)
#set(CPACK_PACKAGE_VERSION_MINOR ???)
#set(CPACK_PACKAGE_VERSION_PATCH ???)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME} - ${PROJECT_DESCRIPTION}")
set(CPACK_PACKAGE_CONTACT "${PROJECT_AUTHOR} <${PROJECT_AUTHOR_EMAIL}>")
set(CPACK_PACKAGE_VENDOR "${COMPANY}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}")
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE)
set(CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME};${PROJECT_NAME}")
# Packaging: NSIS
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_NSIS_EXECUTABLES_DIRECTORY .)
set(CPACK_NSIS_PACKAGE_ARCHITECTURE "64")
set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
set(CPACK_NSIS_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
# Add a "Finished, Run the app?" page to the installer.
set(CPACK_NSIS_MUI_FINISHPAGE_RUN ${PROJECT_NAME})
set(CPACK_NSIS_MENU_LINKS "https://github.com/gvansickle/AwesomeMediaLibraryManager" "AwesomeMediaLibraryManager at GitHub")
include(CPack)
if(WIN32)
include(CpackNSIS)
endif()
include(CPackIFW REQUIRED)
# Add components to be packaged by CPack.
cpack_add_component(
coreapp
DISPLAY_NAME "${PROJECT_NAME} application"
DESCRIPTION "Install ${PROJECT_NAME} application files"
REQUIRED)
#include(CPackHelper)
#### Show package configuration files
#add_custom_target(package_files
# SOURCES package/qtifw/create_start_menu_shortcuts.qs
# COMMENT "Dummy target to show package configuration files in Qt Creator interface")
endif()### END INSTALLER STUFF
# Generate a dependency graph.
# @see CMakeGraphVizOptions.cmake
if(FALSE)
add_custom_target(graphviz ALL
COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_BINARY_DIR}/graphviz"
COMMAND "${CMAKE_COMMAND}" "--graphviz=graphviz/amlm.dot" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
endif()
###
### Print summary.
###
message(STATUS "======================== START CMAKE SUMMARY ====================================")
message(STATUS "Variables:")
print_varlist(
PROJECT_NAME
CMAKE_BINARY_DIR
PROJECT_BINARY_DIR
CMAKE_LIBRARY_PATH
CMAKE_PREFIX_PATH
CMAKE_CXX_COMPILER
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_EXPORT_COMPILE_COMMANDS
CMAKE_INSTALL_PREFIX
KDE_INSTALL_BINDIR
KDE_INSTALL_DATADIR
KDE_INSTALL_ICONDIR
META_FILES_TO_INCLUDE
KDE_INSTALL_TARGETS_DEFAULT_ARGS)
#message_cpack_summary()
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
message(STATUS "======================== END CMAKE SUMMARY ====================================")