-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: optionally static link boost (#2628)
- Loading branch information
1 parent
5f6fe33
commit ebc41ac
Showing
30 changed files
with
194 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# | ||
# Loads the boost library giving the priority to the system package first, with a fallback to FetchContent. | ||
# | ||
include_guard(GLOBAL) | ||
|
||
set(BOOST_VERSION 1.85) | ||
set(BOOST_COMPONENTS | ||
filesystem | ||
locale | ||
log | ||
program_options | ||
system) # system is not used by Sunshine, but by Simple-Web-Server, added here for convenience | ||
|
||
if(BOOST_USE_STATIC) | ||
set(Boost_USE_STATIC_LIBS ON) # cmake-lint: disable=C0103 | ||
endif() | ||
|
||
find_package(Boost ${BOOST_VERSION} COMPONENTS ${BOOST_COMPONENTS}) | ||
if(NOT Boost_FOUND) | ||
message(STATUS "Boost v${BOOST_VERSION}.x package not found in the system. Falling back to FetchContent.") | ||
include(FetchContent) | ||
|
||
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24: | ||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") | ||
cmake_policy(SET CMP0135 NEW) | ||
endif() | ||
|
||
# more components required for compiling boost targets | ||
list(APPEND BOOST_COMPONENTS | ||
asio | ||
crc | ||
format | ||
process | ||
property_tree) | ||
|
||
set(BOOST_ENABLE_CMAKE ON) | ||
|
||
# Limit boost to the required libraries only | ||
set(BOOST_INCLUDE_LIBRARIES | ||
${BOOST_COMPONENTS}) | ||
set(BOOST_URL | ||
"https://github.com/boostorg/boost/releases/download/boost-1.85.0/boost-1.85.0-cmake.tar.xz") | ||
set(BOOST_HASH | ||
"MD5=BADEA970931766604D4D5F8F4090B176") | ||
|
||
if(CMAKE_VERSION VERSION_LESS "3.24.0") | ||
FetchContent_Declare( | ||
Boost | ||
URL ${BOOST_URL} | ||
URL_HASH ${BOOST_HASH} | ||
) | ||
elseif(APPLE AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.25.0") | ||
# add SYSTEM to FetchContent_Declare, this fails on debian bookworm | ||
FetchContent_Declare( | ||
Boost | ||
URL ${BOOST_URL} | ||
URL_HASH ${BOOST_HASH} | ||
SYSTEM # requires CMake 3.25+ | ||
OVERRIDE_FIND_PACKAGE # requires CMake 3.24+, but we have a macro to handle it for other versions | ||
) | ||
elseif(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") | ||
FetchContent_Declare( | ||
Boost | ||
URL ${BOOST_URL} | ||
URL_HASH ${BOOST_HASH} | ||
OVERRIDE_FIND_PACKAGE # requires CMake 3.24+, but we have a macro to handle it for other versions | ||
) | ||
endif() | ||
|
||
FetchContent_MakeAvailable(Boost) | ||
set(FETCH_CONTENT_BOOST_USED TRUE) | ||
|
||
set(Boost_FOUND TRUE) # cmake-lint: disable=C0103 | ||
set(Boost_INCLUDE_DIRS # cmake-lint: disable=C0103 | ||
"$<BUILD_INTERFACE:${Boost_SOURCE_DIR}/libs/headers/include>;$<INSTALL_INTERFACE:include/boost-1_85>") | ||
|
||
if(WIN32) | ||
# Windows build is failing to create .h file in this directory | ||
file(MAKE_DIRECTORY ${Boost_BINARY_DIR}/libs/log/src/windows) | ||
endif() | ||
|
||
set(Boost_LIBRARIES "") # cmake-lint: disable=C0103 | ||
foreach(component ${BOOST_COMPONENTS}) | ||
list(APPEND Boost_LIBRARIES "Boost::${component}") | ||
endforeach() | ||
endif() | ||
|
||
message(STATUS "Boost include dirs: ${Boost_INCLUDE_DIRS}") | ||
message(STATUS "Boost libraries: ${Boost_LIBRARIES}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# | ||
# Loads the libevdev library giving the priority to the system package first, with a fallback to ExternalProject | ||
# | ||
include_guard(GLOBAL) | ||
|
||
set(LIBEVDEV_VERSION libevdev-1.13.2) | ||
|
||
pkg_check_modules(PC_EVDEV libevdev) | ||
if(PC_EVDEV_FOUND) | ||
find_path(EVDEV_INCLUDE_DIR libevdev/libevdev.h | ||
HINTS ${PC_EVDEV_INCLUDE_DIRS} ${PC_EVDEV_INCLUDEDIR}) | ||
find_library(EVDEV_LIBRARY | ||
NAMES evdev libevdev) | ||
else() | ||
include(ExternalProject) | ||
|
||
ExternalProject_Add(libevdev | ||
URL http://www.freedesktop.org/software/libevdev/${LIBEVDEV_VERSION}.tar.xz | ||
PREFIX ${LIBEVDEV_VERSION} | ||
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> | ||
BUILD_COMMAND "make" | ||
INSTALL_COMMAND "" | ||
) | ||
|
||
ExternalProject_Get_Property(libevdev SOURCE_DIR) | ||
message(STATUS "libevdev source dir: ${SOURCE_DIR}") | ||
set(EVDEV_INCLUDE_DIR "${SOURCE_DIR}") | ||
|
||
ExternalProject_Get_Property(libevdev BINARY_DIR) | ||
message(STATUS "libevdev binary dir: ${BINARY_DIR}") | ||
set(EVDEV_LIBRARY "${BINARY_DIR}/libevdev/.libs/libevdev.a") | ||
|
||
# compile libevdev before sunshine | ||
set(SUNSHINE_TARGET_DEPENDENCIES ${SUNSHINE_TARGET_DEPENDENCIES} libevdev) | ||
|
||
set(EXTERNAL_PROJECT_LIBEVDEV_USED TRUE) | ||
endif() | ||
|
||
if(EVDEV_INCLUDE_DIR AND EVDEV_LIBRARY) | ||
include_directories(SYSTEM ${EVDEV_INCLUDE_DIR}) | ||
list(APPEND PLATFORM_LIBRARIES ${EVDEV_LIBRARY}) | ||
else() | ||
message(FATAL_ERROR "Couldn't find or fetch libevdev") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
# 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 | ||
pkg_check_modules(NLOHMANN_JSON nlohmann_json REQUIRED IMPORTED_TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.