Skip to content

Commit

Permalink
build: optionally static link boost
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Jun 1, 2024
1 parent 9afb1ae commit 91db291
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 7 deletions.
4 changes: 4 additions & 0 deletions cmake/compile_definitions/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
1 change: 0 additions & 1 deletion cmake/compile_definitions/linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions cmake/dependencies/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 0 additions & 2 deletions cmake/dependencies/unix.cmake
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 1 addition & 3 deletions cmake/dependencies/windows.cmake
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions cmake/prep/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docker/fedora-39.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.* \
Expand Down
1 change: 1 addition & 0 deletions docker/fedora-40.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.* \
Expand Down
1 change: 1 addition & 0 deletions docs/source/building/linux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Install Requirements
sudo dnf group install "Development Tools" && \
sudo dnf install \
boost-devel \
boost-static \
cmake \
gcc \
gcc-c++ \
Expand Down
2 changes: 1 addition & 1 deletion packaging/linux/flatpak/dev.lizardbyte.sunshine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 91db291

Please sign in to comment.