2023-12-01 17:32:19 +00:00
|
|
|
# Copyright 2022 Google LLC. All rights reserved.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file or at
|
|
|
|
# https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
|
|
|
# Packager CMake build file for third-party libraries.
|
|
|
|
|
|
|
|
# Tell third-party libraries generally not to build their own tests.
|
|
|
|
set(BUILD_TESTING OFF)
|
|
|
|
|
|
|
|
# Tell third-party libraries generally not to build shared library targets.
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
|
|
|
|
|
|
# Tell CMake that we intend to override some libraries' options with set().
|
|
|
|
# By setting this default instead of using cmake_policy(SET CMP0077 NEW), we
|
|
|
|
# ensure that the defaults are reset when a library calls
|
|
|
|
# cmake_minimum_required.
|
|
|
|
# See https://gitlab.kitware.com/cmake/cmake/-/issues/20312
|
|
|
|
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
# Use warning level 3 in third-party code, as opposed to level 4 used in our
|
|
|
|
# own code.
|
|
|
|
add_compile_options(/W3)
|
2024-02-10 03:10:08 +00:00
|
|
|
|
|
|
|
# Do not treat warnings as errors in third-party code.
|
|
|
|
add_compile_options(/WX-)
|
|
|
|
else()
|
|
|
|
# Do not treat warnings as errors in third-party code.
|
|
|
|
# Surprisingly, both of these are required to satisfy various platforms and
|
|
|
|
# compilers at once.
|
|
|
|
add_compile_options(-Wno-error -Wno-error=all)
|
2024-02-27 03:57:13 +00:00
|
|
|
# Hide warnings in third-party code. The noise isn't helpful, and this line
|
|
|
|
# can be commented out if we ever want to see/audit third-party warnings.
|
|
|
|
add_compile_options(-w)
|
2023-12-01 17:32:19 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# These all use EXCLUDE_FROM_ALL so that only the referenced targets get built.
|
|
|
|
add_subdirectory(abseil-cpp EXCLUDE_FROM_ALL)
|
|
|
|
add_subdirectory(c-ares EXCLUDE_FROM_ALL)
|
|
|
|
add_subdirectory(curl EXCLUDE_FROM_ALL)
|
|
|
|
add_subdirectory(googletest EXCLUDE_FROM_ALL)
|
|
|
|
add_subdirectory(json EXCLUDE_FROM_ALL)
|
|
|
|
add_subdirectory(libpng EXCLUDE_FROM_ALL)
|
|
|
|
add_subdirectory(libwebm EXCLUDE_FROM_ALL)
|
|
|
|
add_subdirectory(libxml2 EXCLUDE_FROM_ALL)
|
|
|
|
add_subdirectory(mbedtls EXCLUDE_FROM_ALL)
|
feat: Portable, fully-static release executables on Linux (#1351)
This adds the option FULLY_STATIC to create fully-static executables.
To create portable, fully-static release executables on Linux, we need
to use musl instead of glibc. Static executables from glibc are not
portable.
The popular musl-gcc wrapper does not support C++, so instead we use a
full musl cross-compiler toolchain in the build workflow.
To build FULLY_STATIC, the user must point to the appropriate
cross-compiler, as we do in the workflow. On systems where musl is the
native libc (such as Alpine Linux), this is not necessary.
I have also read that musl's allocator is not very fast in
multi-threaded applications. So when FULLY_STATIC is enabled, we will
also enable mimalloc, a replacement allocator that is very fast.
I tested a very basic packaging command to compare speeds of dynamic
glibc, static musl, and static musl+mimalloc:
dynamic glibc:
runs: 2.527, 2.798, 2.703, 2.756, 2.959
avg = 2.749, std dev = 0.156s
static musl:
runs: 2.813, 2.920, 3.129, 3.003, 2.738
avg = 2.921s, std dev = 0.154s
static musl+mimalloc:
runs: 2.291, 2.034, 2.415, 2.303, 2.265
avg = 2.262s, std dev = 0.140s
The mimalloc build is 82% faster than musl default allocator, 77% faster
than glibc, and has more consistent runtime characteristics (lower
standard deviation).
2024-02-27 18:47:04 +00:00
|
|
|
add_subdirectory(mimalloc EXCLUDE_FROM_ALL)
|
2023-12-01 17:32:19 +00:00
|
|
|
add_subdirectory(mongoose EXCLUDE_FROM_ALL)
|
|
|
|
add_subdirectory(protobuf EXCLUDE_FROM_ALL)
|
|
|
|
add_subdirectory(zlib EXCLUDE_FROM_ALL)
|