forked from Mudlet/Mudlet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
245 lines (212 loc) · 9.83 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
############################################################################
# Copyright (C) 2014 by Ahmed Charles - [email protected] #
# Copyright (C) 2015-2018, 2020, 2022 by Stephen Lyons #
# - [email protected] #
# #
# This program 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 2 of the License, or #
# (at your option) any later version. #
# #
# This program 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, write to the #
# Free Software Foundation, Inc., #
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
############################################################################
# #
# NOTICE: FreeBSD, OpenBSD and GNU/Hurd are not officially supported #
# platforms as such; the work on getting them working has been done by #
# myself, and other developers, unless they have explicitly said so, #
# are not able to address issues relating specifically to these #
# Operating Systems. Nevertheless users of these operating systems are #
# equally welcome to contribute to the development of Mudlet - bugfixes #
# and enhancements are welcome from all! #
# Stephen Lyons, February 2018, updated March 2021 & October 2022 #
# #
############################################################################
# Should be called before PROJECT.
cmake_minimum_required(VERSION 3.3)
if(APPLE)
# needed for fetching Sparkle
cmake_minimum_required(VERSION 3.18)
# minimum supported version by Apple
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "")
endif()
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/vcpkg/scripts/buildsystems/vcpkg.cmake)
# In cases where VCPkg is NOT being used we need to skip this
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/vcpkg/scripts/buildsystems/vcpkg.cmake
CACHE STRING "Vcpkg toolchain file")
message(STATUS "Using Vcpkg toolchain file: ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/vcpkg/scripts/buildsystems/vcpkg.cmake .")
else()
message(STATUS "Vcpkg toolchain file ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/vcpkg/scripts/buildsystems/vcpkg.cmake NOT found, proceeding without it.")
endif()
project(mudlet)
if(CMAKE_CONFIGURATION_TYPES)
add_custom_target(
check COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process
--output-on-failure --build-config "$<CONFIGURATION>")
else()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
--force-new-ctest-process --output-on-failure)
endif()
enable_testing()
if(POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
endif()
if(POLICY CMP0057)
cmake_policy(SET CMP0057 NEW)
endif()
if(WIN32)
set(APP_TARGET mudlet.exe)
elseif(APPLE)
set(APP_TARGET Mudlet)
else()
set(APP_TARGET mudlet)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(Git REQUIRED)
# Get Git SHA1 hash
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_SHA1
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# APP_BUILD should only be empty/null in official "release" builds, developers
# may like to set the MUDLET_VERSION_BUILD environment variable to their user
# and branch names to make it easier to tell different builds apart!
#
# Changing this pair of values affects: ctelnet.cpp, main.cpp, mudlet.cpp
# dlgAboutDialog.cpp and TLuaInterpreter.cpp. It will not necessarily cause
# those files to be automatically rebuilt so you may need to 'touch' those files
# if the variables are changed and you are not doing a full, clean, rebuild! Use
# APP_VERSION, APP_BUILD and APP_TARGET defines in the source code if needed.
# IMPORTANT: To insure consistency please ensure the SAME of the first two
# values are also assigned to the "VERSION" and "BUILD" variables in the native
# qmake project file, which is NOW called: ./src/mudlet.pro
set(APP_VERSION 4.17.2)
if(DEFINED ENV{MUDLET_VERSION_BUILD} AND NOT $ENV{MUDLET_VERSION_BUILD}
STREQUAL "")
file(WRITE ${CMAKE_SOURCE_DIR}/src/app-build.txt "$ENV{MUDLET_VERSION_BUILD}")
set(APP_BUILD $ENV{MUDLET_VERSION_BUILD})
else()
file(WRITE ${CMAKE_SOURCE_DIR}/src/app-build.txt "-dev")
set(APP_BUILD "-dev")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
include(IncludeOptionalModule)
include_optional_module(ENVIRONMENT_VARIABLE WITH_UPDATER
OPTION_VARIABLE USE_UPDATER
READABLE_NAME "updater"
SUPPORTED_SYSTEMS "Linux"
"Windows"
"Darwin")
include_optional_module(ENVIRONMENT_VARIABLE WITH_FONTS
OPTION_VARIABLE USE_FONTS
READABLE_NAME "fonts")
include_optional_module(ENVIRONMENT_VARIABLE WITH_3DMAPPER
OPTION_VARIABLE USE_3DMAPPER
READABLE_NAME "3D mapper")
include_optional_module(ENVIRONMENT_VARIABLE WITH_VARIABLE_SPLASH_SCREEN
OPTION_VARIABLE USE_VARIABLE_SPLASH_SCREEN
READABLE_NAME "build-type splash screen")
include_optional_module(ENVIRONMENT_VARIABLE WITH_OWN_QTKEYCHAIN
OPTION_VARIABLE USE_OWN_QTKEYCHAIN
READABLE_NAME "own QtKeychain library")
include_optional_module(ENVIRONMENT_VARIABLE WITH_MAIN_BUILD_SYSTEM
OPTION_VARIABLE USE_MAIN_BUILD_SYSTEM
READABLE_NAME "original CI (setup-windows-sdk.ps1) windows build system"
SUPPORTED_SYSTEMS "Windows")
include_optional_module(ENVIRONMENT_VARIABLE WITH_QT6
OPTION_VARIABLE USE_QT6
READABLE_NAME "build with Qt6 (if installed)")
if(USE_QT6)
find_package(
Qt6 6.2.0
QUIET)
if(NOT Qt6_FOUND)
message(STATUS "Qt6 >= 6.2.0 was not found. Building with Qt5.")
endif()
endif()
# Set Qt version for src, test, translations and communi
set(WITH_QT6 ${Qt6_FOUND} CACHE BOOL "Whether to build with Qt6 or Qt5.")
# Set Qt version for edbee-lib and dblsqd
if(WITH_QT6)
option(BUILD_WITH_QT5 "" OFF)
else()
option(BUILD_WITH_QT5 "" ON)
endif()
# Set Qt version for qtkeychain
option(BUILD_WITH_QT6 "" ${WITH_QT6})
include(InitGitSubmodule)
git_submodule_init(
CHECK_FILE "3rdparty/edbee-lib/CMakeLists.txt" SUBMODULE_PATH
"3rdparty/edbee-lib" READABLE_NAME "edbee-lib editor widget")
if(USE_OWN_QTKEYCHAIN)
git_submodule_init(
CHECK_FILE "3rdparty/qtkeychain/CMakeLists.txt"
SUBMODULE_PATH "3rdparty/qtkeychain"
READABLE_NAME "QtKeychain")
add_subdirectory(3rdparty/qtkeychain)
endif()
git_submodule_init(
CHECK_FILE "3rdparty/lcf/lcf-scm-1.rockspec" SUBMODULE_PATH "3rdparty/lcf"
READABLE_NAME "lua code formatter source code")
# PLACEMARKER: sample benchmarking code
# include(FetchContent)
# FetchContent_Declare(
# nanobench
# GIT_REPOSITORY https://github.com/martinus/nanobench.git
# GIT_TAG v4.3.11
# GIT_SHALLOW TRUE)
# FetchContent_MakeAvailable(nanobench)
if(USE_UPDATER)
git_submodule_init(CHECK_FILE "3rdparty/dblsqd/CMakeLists.txt" SUBMODULE_PATH
"3rdparty/dblsqd" READABLE_NAME "DBLSQD updater")
endif()
if(APPLE)
if(USE_UPDATER)
git_submodule_init(
CHECK_FILE "3rdparty/sparkle-glue/CMakeLists.txt" SUBMODULE_PATH
"3rdparty/sparkle-glue" READABLE_NAME "Sparkle glue for updater")
if(NOT EXISTS "${CMAKE_HOME_DIRECTORY}/3rdparty/cocoapods/Pods/Sparkle")
message(
STATUS "Sparkle is missing, fetching it..."
)
file(DOWNLOAD "https://github.com/sparkle-project/Sparkle/releases/download/1.25.0/Sparkle-1.25.0.tar.xz" "${CMAKE_HOME_DIRECTORY}/3rdparty/cocoapods/Pods/Sparkle-1.25.0.tar.xz"
TIMEOUT 60 # seconds
TLS_VERIFY ON
)
file(ARCHIVE_EXTRACT INPUT "${CMAKE_HOME_DIRECTORY}/3rdparty/cocoapods/Pods/Sparkle-1.25.0.tar.xz"
DESTINATION "${CMAKE_HOME_DIRECTORY}/3rdparty/cocoapods/Pods/Sparkle")
file(REMOVE "${CMAKE_HOME_DIRECTORY}/3rdparty/cocoapods/Pods/Sparkle-1.25.0.tar.xz")
endif()
endif()
endif()
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)
add_subdirectory(3rdparty/edbee-lib/edbee-lib)
add_subdirectory(3rdparty/communi)
add_subdirectory(translations/translated)
add_subdirectory(src)
add_subdirectory(test)
if(USE_UPDATER)
add_subdirectory(3rdparty/dblsqd)
if(APPLE)
add_subdirectory(3rdparty/sparkle-glue)
endif()
endif()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE -O3)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG -O0)