forked from eBookProjects/uChmViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·108 lines (93 loc) · 3.99 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
# uChmViewer build script with cmake
#
# Common option:
# USE_KF5 - if defined, build with KDE Framework 5.
# USE_STATIC_CHMLIB - if defined, static linkage to the chm library is used.
# USE_WEBENGINE - if defined, WebEngine is used, otherwise WebKit is used.
# USE_GETTEXT - if defined, then GNU Gettext will be used for translation.
# The default is ON.
# USE_DBUS - if defined, build with D-Bus integration.
# The default is ON for Linux.
# USE_MAC_APP - if defined, build with derived QApplication.
# The default is ON for macOs.
#
# System-specific option:
# USE_DEPLOY_RUNTIME - if defined, the runtime dependencies will be copied to the
# folder with the executable. This option is applicable for
# Windows and macOS.
# USE_MACOS_BUNDLE - if defined, configure installation for macOS as a bundle.
# The default is ON.
################################################
cmake_minimum_required(VERSION 3.13)
# Project info
project(uchmviewer HOMEPAGE_URL "https://github.com/u-235/uchmviewer")
include(cmake/get-version.cmake)
set(CMAKE_PROJECT_VERSION ${PROJECT_VERSION})
include(cmake/use-in.cmake)
option(USE_KF5 "Use KDE Framework 5" OFF)
option(USE_WEBENGINE "Use Qt WebEngine" OFF)
option(USE_STATIC_CHMLIB "Use static link with chm library" OFF)
option(USE_DEPLOY_RUNTIME "Copy runtime dependencies for deployment" OFF)
option(USE_GETTEXT "Use GNU Gettext for translation" ON)
option(USE_MACOS_BUNDLE "Install as macOS bundle" ON)
use_in(USE_DBUS "Use D-Bus integration" "Linux")
use_in(USE_MAC_APP "Use derived QApplication" "Darvin")
# Init cmake
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Interface library to collect additional dependencies.
add_library(extra INTERFACE)
# Necessary packages
# libzip
find_package(libzip REQUIRED)
# Prepare to find Qt modules.
set(APP_QT_VERSION 5.0)
set(APP_QT_MODULES Core Network PrintSupport Widgets Xml)
# Modules for WebKit or WebEngine.
if (${USE_WEBENGINE})
set(APP_QT_VERSION 5.9)
list(APPEND APP_QT_MODULES WebEngineWidgets)
target_link_libraries(extra INTERFACE Qt::WebEngineWidgets)
target_compile_definitions(extra INTERFACE USE_WEBENGINE)
else ()
list(APPEND APP_QT_MODULES WebKit WebKitWidgets)
target_link_libraries(extra INTERFACE Qt::WebKit Qt::WebKitWidgets)
endif ()
# What version of Qt are we working with?
find_package(QT ${APP_QT_VERSION} NAMES Qt5 Qt6 REQUIRED)
set(QT Qt${QT_VERSION_MAJOR})
# Since Qt 6 QTextCodec moved in the Qt 5 Core Compat module.
if (${QT_VERSION_MAJOR} GREATER_EQUAL 6)
list(APPEND APP_QT_MODULES Core5Compat)
target_link_libraries(extra INTERFACE ${QT}::Core5Compat)
endif ()
if (${USE_DBUS})
list(APPEND APP_QT_MODULES DBus)
target_link_libraries(extra INTERFACE Qt::DBus)
target_compile_definitions(extra INTERFACE USE_DBUS)
endif ()
if (${USE_MAC_APP})
target_compile_definitions(extra INTERFACE USE_MAC_APP)
endif ()
# Now we know all the required Qt modules.
find_package(${QT} REQUIRED ${APP_QT_MODULES})
if (${USE_KF5})
# Needed by find_package(KF5) below.
find_package(ECM REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
find_package(KF5 REQUIRED KDELibs4Support)
target_link_libraries(extra INTERFACE KF5::KDELibs4Support)
target_compile_definitions(extra INTERFACE USE_KDE)
endif ()
include(cmake/qt-aliases.cmake)
include(cmake/install-helper.cmake)
add_compile_options(
$<$<CXX_COMPILER_ID:MSVC>:/W3>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wextra>)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_CXX_STANDARD 11)
# Run in those subdirectories
add_subdirectory(lib)
add_subdirectory(src)
add_subdirectory(po)
add_subdirectory(packages)