From 91db2917367b121b2f22f3abbf6e736543651e5d Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sat, 1 Jun 2024 15:51:54 -0400 Subject: [PATCH] build: optionally static link boost --- cmake/compile_definitions/common.cmake | 4 ++++ cmake/compile_definitions/linux.cmake | 1 - cmake/dependencies/common.cmake | 9 +++++++++ cmake/dependencies/unix.cmake | 2 -- cmake/dependencies/windows.cmake | 4 +--- cmake/prep/options.cmake | 2 ++ docker/fedora-39.dockerfile | 1 + docker/fedora-40.dockerfile | 1 + docs/source/building/linux.rst | 1 + packaging/linux/flatpak/dev.lizardbyte.sunshine.yml | 2 +- 10 files changed, 20 insertions(+), 7 deletions(-) diff --git a/cmake/compile_definitions/common.cmake b/cmake/compile_definitions/common.cmake index 90a71802cde..381f0445ec4 100644 --- a/cmake/compile_definitions/common.cmake +++ b/cmake/compile_definitions/common.cmake @@ -129,6 +129,10 @@ include_directories( ${PLATFORM_INCLUDE_DIRS} ) +if(BOOST_USE_DYNAMIC) + list(APPEND PLATFORM_LIBRARIES Boost::dynamic_linking) +endif() + list(APPEND SUNSHINE_EXTERNAL_LIBRARIES ${MINIUPNP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} diff --git a/cmake/compile_definitions/linux.cmake b/cmake/compile_definitions/linux.cmake index b323eb82e84..fd04f0b951c 100644 --- a/cmake/compile_definitions/linux.cmake +++ b/cmake/compile_definitions/linux.cmake @@ -246,7 +246,6 @@ list(APPEND PLATFORM_TARGET_FILES "${CMAKE_SOURCE_DIR}/third-party/glad/include/glad/egl.h") list(APPEND PLATFORM_LIBRARIES - Boost::dynamic_linking dl pulse pulse-simple) diff --git a/cmake/dependencies/common.cmake b/cmake/dependencies/common.cmake index d10a769ca9c..30aef56ad2f 100644 --- a/cmake/dependencies/common.cmake +++ b/cmake/dependencies/common.cmake @@ -15,6 +15,15 @@ find_package(PkgConfig REQUIRED) find_package(Threads REQUIRED) pkg_check_modules(CURL REQUIRED libcurl) +if(NOT BOOST_USE_DYNAMIC) + set(Boost_USE_STATIC_LIBS ON) # cmake-lint: disable=C0103 + + # workaround to prevent link errors against icudata, icui18n + # TODO: only needed for Boost <= 1.74 ? + set(Boost_NO_BOOST_CMAKE ON) # cmake-lint: disable=C0103 +endif() +find_package(Boost 1.74.0 COMPONENTS locale log filesystem program_options REQUIRED) + # miniupnp pkg_check_modules(MINIUPNP miniupnpc REQUIRED) include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIRS}) diff --git a/cmake/dependencies/unix.cmake b/cmake/dependencies/unix.cmake index 5b13bf60403..1f5ffd3adc8 100644 --- a/cmake/dependencies/unix.cmake +++ b/cmake/dependencies/unix.cmake @@ -1,4 +1,2 @@ # unix specific dependencies # put anything here that applies to both linux and macos - -find_package(Boost COMPONENTS locale log filesystem program_options REQUIRED) diff --git a/cmake/dependencies/windows.cmake b/cmake/dependencies/windows.cmake index a7ecce3963d..b5ce18e209a 100644 --- a/cmake/dependencies/windows.cmake +++ b/cmake/dependencies/windows.cmake @@ -1,7 +1,5 @@ # windows specific dependencies -set(Boost_USE_STATIC_LIBS ON) # cmake-lint: disable=C0103 -find_package(Boost 1.71.0 COMPONENTS locale log filesystem program_options REQUIRED) - # nlohmann_json +# TODO: should we use boost json instead? pkg_check_modules(NLOHMANN_JSON nlohmann_json REQUIRED IMPORTED_TARGET) diff --git a/cmake/prep/options.cmake b/cmake/prep/options.cmake index 1555036eeb0..2066910e72d 100644 --- a/cmake/prep/options.cmake +++ b/cmake/prep/options.cmake @@ -15,6 +15,8 @@ option(SUNSHINE_REQUIRE_TRAY "Require system tray icon. Fail the build if tray r option(SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS "Use system installation of wayland-protocols rather than the submodule." OFF) +option(BOOST_USE_DYNAMIC "Use dynamic boost libraries." OFF) + option(CUDA_INHERIT_COMPILE_OPTIONS "When building CUDA code, inherit compile options from the the main project. You may want to disable this if your IDE throws errors about unknown flags after running cmake." ON) diff --git a/docker/fedora-39.dockerfile b/docker/fedora-39.dockerfile index 262b40fc7ac..84808a4a024 100644 --- a/docker/fedora-39.dockerfile +++ b/docker/fedora-39.dockerfile @@ -31,6 +31,7 @@ dnf -y update dnf -y group install "Development Tools" dnf -y install \ boost-devel-1.81.0* \ + boost-static-1.81.0* \ cmake-3.27.* \ doxygen \ gcc-13.2.* \ diff --git a/docker/fedora-40.dockerfile b/docker/fedora-40.dockerfile index 94a8a9fa733..c32a5b71abb 100644 --- a/docker/fedora-40.dockerfile +++ b/docker/fedora-40.dockerfile @@ -31,6 +31,7 @@ dnf -y update dnf -y group install "Development Tools" dnf -y install \ boost-devel-1.83.0* \ + boost-static-1.83.0* \ cmake-3.28.* \ doxygen \ gcc-14.1.* \ diff --git a/docs/source/building/linux.rst b/docs/source/building/linux.rst index d0d0af6ed9c..a90815ef2d9 100644 --- a/docs/source/building/linux.rst +++ b/docs/source/building/linux.rst @@ -56,6 +56,7 @@ Install Requirements sudo dnf group install "Development Tools" && \ sudo dnf install \ boost-devel \ + boost-static \ cmake \ gcc \ gcc-c++ \ diff --git a/packaging/linux/flatpak/dev.lizardbyte.sunshine.yml b/packaging/linux/flatpak/dev.lizardbyte.sunshine.yml index cba627807c3..41bd314efe2 100644 --- a/packaging/linux/flatpak/dev.lizardbyte.sunshine.yml +++ b/packaging/linux/flatpak/dev.lizardbyte.sunshine.yml @@ -42,7 +42,7 @@ modules: build-commands: - cd tools/build && bison -y -d -o src/engine/jamgram.cpp src/engine/jamgram.y - ./bootstrap.sh --prefix=$FLATPAK_DEST --with-libraries=locale,log,program_options,system,thread - - ./b2 install variant=release link=shared runtime-link=shared cxxflags="$CXXFLAGS" linkflags="$LDFLAGS" + - ./b2 install variant=release link=static,shared runtime-link=shared cxxflags="$CXXFLAGS" linkflags="$LDFLAGS" -j $FLATPAK_BUILDER_N_JOBS sources: - type: archive