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
|
|
|
|
|
|
|
|
# Root-level CMake build file.
|
|
|
|
|
|
|
|
# Minimum CMake version. This must be in the root level CMakeLists.txt.
|
2024-02-14 21:59:18 +00:00
|
|
|
cmake_minimum_required(VERSION 3.24)
|
2023-12-01 17:32:19 +00:00
|
|
|
|
|
|
|
# These policy settings should be included before the project definition.
|
|
|
|
include("packager/policies.cmake")
|
|
|
|
|
|
|
|
# Project name. May not contain spaces. Versioning is managed elsewhere.
|
|
|
|
project(shaka-packager VERSION "")
|
|
|
|
|
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
|
|
|
# Whether to build a shared libpackager library. By default, don't.
|
2023-12-01 17:32:19 +00:00
|
|
|
option(BUILD_SHARED_LIBS "Build libpackager as a shared library" OFF)
|
|
|
|
|
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
|
|
|
# Whether to attempt a static linking of the command line front-end.
|
|
|
|
# Only supported on Linux and with musl. This will also cause us to link
|
|
|
|
# against mimalloc to replace the standard allocator in musl, which is slow.
|
|
|
|
option(FULLY_STATIC "Attempt fully static linking of all CLI apps" OFF)
|
|
|
|
|
2023-12-01 17:32:19 +00:00
|
|
|
# Enable CMake's test infrastructure.
|
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
option(SKIP_INTEGRATION_TESTS "Skip the packager integration tests" ON)
|
|
|
|
|
|
|
|
# Subdirectories with their own CMakeLists.txt
|
|
|
|
add_subdirectory(packager)
|
|
|
|
add_subdirectory(link-test)
|