-
Notifications
You must be signed in to change notification settings - Fork 117
/
CMakeLists.txt
195 lines (167 loc) · 5.9 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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
cmake_minimum_required(VERSION 3.20)
# The source file GENERATED property is visible from all directory scopes when set.
cmake_policy(SET CMP0118 NEW)
option(BUILD_TESTS "Whether or not to build test targets" ON)
message("Configuring for ${CMAKE_GENERATOR}")
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT (IS_MULTI_CONFIG OR DEFINED CMAKE_BUILD_TYPE))
## Ensure the build type is set for single-config generators.
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "default build type" FORCE)
message("Setting build type ${CMAKE_BUILD_TYPE}")
endif()
if(WIN32 AND DEFINED ENV{CONDA_PREFIX})
include(scripts/windows/conda-toolchain.cmake)
endif()
file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/version.txt" APP_VERSION)
message(APP_VERSION=${APP_VERSION})
project("Mozilla VPN" VERSION ${APP_VERSION} LANGUAGES C CXX
DESCRIPTION "Mozilla VPN"
HOMEPAGE_URL "https://vpn.mozilla.org"
)
# Enable testing
include(CTest)
add_custom_target(build_tests)
set_target_properties(build_tests PROPERTIES
EXCLUDE_FROM_ALL TRUE
FOLDER "Tests"
)
# Include Global Helper functions
include(scripts/cmake/utilities.cmake)
include(scripts/cmake/clang_tidy.cmake)
## Some workarounds for platform build quirks
if(WIN32)
## CMake v3.20 has problems with race conditions in dependency generation.
## See: https://gitlab.kitware.com/cmake/cmake/-/issues/22014
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_EQUAL 3.20)
cmake_policy(SET CMP0116 OLD)
endif()
## CMake also has trouble finding OpenSSL libraries on Windows, and may
## need some help.
if(EXISTS "C:/MozillaVPNBuild/SSL" AND NOT DEFINED OPENSSL_ROOT_DIR)
set(OPENSSL_ROOT_DIR "C:/MozillaVPNBuild/SSL")
find_package(OpenSSL REQUIRED)
endif()
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/unsigned"
CACHE PATH "default install path" FORCE)
endif()
## Generate a cargo/config.toml file to pass the Conda toolchain into rust too.
if(DEFINED ENV{CONDA_PREFIX})
configure_file(scripts/windows/cargo-config.toml.in ${CMAKE_BINARY_DIR}/cargo_home/config.toml)
endif()
endif()
if(APPLE)
enable_language(OBJC)
enable_language(OBJCXX)
if(IOS)
enable_language(Swift)
endif()
## Setup some defaults for code signing.
if(NOT BUILD_OSX_APP_IDENTIFIER)
set(BUILD_OSX_APP_IDENTIFIER org.mozilla.macos.FirefoxVPN CACHE STRING "OSX Application identifier")
endif()
if(NOT BUILD_IOS_APP_IDENTIFIER)
set(BUILD_IOS_APP_IDENTIFIER org.mozilla.ios.FirefoxVPN CACHE STRING "iOS Application identifier")
endif()
if(NOT BUILD_IOS_GROUP_IDENTIFIER)
set(BUILD_IOS_GROUP_IDENTIFIER group.org.mozilla.ios.Guardian CACHE STRING "iOS Group identifier")
endif()
if(NOT BUILD_VPN_DEVELOPMENT_TEAM)
set(BUILD_VPN_DEVELOPMENT_TEAM 43AQ936H96 CACHE STRING "Mozilla VPN Development Team")
endif()
set(CMAKE_XCODE_GENERATE_SCHEME FALSE)
set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${BUILD_VPN_DEVELOPMENT_TEAM})
set(CMAKE_XCODE_ATTRIBUTE_GROUP_ID_IOS ${BUILD_IOS_GROUP_IDENTIFIER})
if(IOS)
set(CMAKE_OSX_DEPLOYMENT_TARGET 14.0)
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0)
endif()
endif()
if(ANDROID)
# Don't move, this provides OpenSSL on android.
include(src/cmake/android_openssl.cmake)
endif()
if(NOT DEFINED BUILD_ID)
string(TIMESTAMP BUILD_ID "${PROJECT_VERSION_MAJOR}.%Y%m%d%H%M")
message("Generated BUILD_ID: ${BUILD_ID}")
endif()
## Toolchain Setup
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_program(PYTHON_EXECUTABLE NAMES python3 python)
if(MSVC)
include(src/cmake/msvc.cmake)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang$")
include(src/cmake/clang.cmake)
endif()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER "Autogen")
set_property(GLOBAL PROPERTY AUTOMOC_TARGETS_FOLDER "Autogen")
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "Autogen")
find_package(Qt6 COMPONENTS
Core
Gui
Network
Qml
Quick
QuickTest
Test
WebSockets
Widgets
Xml
Svg
)
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten" AND
NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android")
find_package(Qt6 COMPONENTS
NetworkAuth
)
endif()
if(QT_KNOWN_POLICY_QTP0001)
qt_policy(SET QTP0001 NEW)
endif()
message("Using Qt version ${Qt6_VERSION}")
add_definitions(-DQT_DEPRECATED_WARNINGS)
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050F00)
# Glean -- this must be added before src/
add_subdirectory(qtglean)
# VPN Client build targets
add_subdirectory(src)
add_subdirectory(lottie)
add_subdirectory(nebula)
add_subdirectory(src/translations)
add_subdirectory(addons)
if(NOT CMAKE_CROSSCOMPILING)
# Extra rustlang libraries
add_subdirectory(extension)
if(BUILD_TESTS)
# Unit Tests
add_subdirectory(tests/nativemessaging EXCLUDE_FROM_ALL)
add_subdirectory(tests/unit EXCLUDE_FROM_ALL)
add_subdirectory(tests/qml EXCLUDE_FROM_ALL)
add_subdirectory(tests/unit_tests EXCLUDE_FROM_ALL)
# E2E Tests
add_subdirectory(tests/auth_tests EXCLUDE_FROM_ALL)
endif()
endif()
# Extra platform targets
if(WIN32)
add_subdirectory(windows/installer)
add_subdirectory(windows/split-tunnel)
add_subdirectory(windows/wireguard_nt)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_subdirectory(macos/loginitem)
add_subdirectory(macos/pkg)
elseif(IOS)
add_subdirectory(ios/networkextension)
if(BUILD_ADJUST_SDK_TOKEN)
add_subdirectory(ios/adjust)
endif()
endif()