Skip to content

Commit

Permalink
build: nlohmann for all targets (copied from #2032)
Browse files Browse the repository at this point in the history
Mostly copied code from #2032 to try a PoC for the API I want to use
  • Loading branch information
Hazer committed May 2, 2024
1 parent 696776b commit 2516960
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 7 deletions.
1 change: 0 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,6 @@ jobs:
mingw-w64-x86_64-curl
mingw-w64-x86_64-graphviz
mingw-w64-x86_64-miniupnpc
mingw-w64-x86_64-nlohmann-json
mingw-w64-x86_64-nodejs
mingw-w64-x86_64-nsis
mingw-w64-x86_64-onevpl
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@
path = third-party/wlr-protocols
url = https://gitlab.freedesktop.org/wlroots/wlr-protocols
branch = master
[submodule "third-party/nlohmann_json"]
path = third-party/nlohmann_json
url = https://github.com/nlohmann/json
2 changes: 2 additions & 0 deletions cmake/compile_definitions/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ set(SUNSHINE_TARGET_FILES
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/RtspParser.c"
"${CMAKE_SOURCE_DIR}/third-party/moonlight-common-c/src/Video.h"
"${CMAKE_SOURCE_DIR}/third-party/tray/tray.h"
"${CMAKE_SOURCE_DIR}/src/display_device/dd.h"
"${CMAKE_SOURCE_DIR}/src/upnp.cpp"
"${CMAKE_SOURCE_DIR}/src/upnp.h"
"${CMAKE_SOURCE_DIR}/src/cbs.cpp"
Expand Down Expand Up @@ -138,4 +139,5 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
${Boost_LIBRARIES}
${OPENSSL_LIBRARIES}
${CURL_LIBRARIES}
${JSON_LIBRARIES}
${PLATFORM_LIBRARIES})
1 change: 1 addition & 0 deletions cmake/compile_definitions/macos.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ set(PLATFORM_TARGET_FILES
"${CMAKE_SOURCE_DIR}/src/platform/macos/av_video.h"
"${CMAKE_SOURCE_DIR}/src/platform/macos/av_video.m"
"${CMAKE_SOURCE_DIR}/src/platform/macos/display.mm"
"${CMAKE_SOURCE_DIR}/src/platform/macos/display_options.mm"
"${CMAKE_SOURCE_DIR}/src/platform/macos/input.cpp"
"${CMAKE_SOURCE_DIR}/src/platform/macos/microphone.mm"
"${CMAKE_SOURCE_DIR}/src/platform/macos/misc.mm"
Expand Down
1 change: 0 additions & 1 deletion cmake/compile_definitions/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ list(PREPEND PLATFORM_LIBRARIES
avrt
iphlpapi
shlwapi
PkgConfig::NLOHMANN_JSON
${CURL_STATIC_LIBRARIES})

if(SUNSHINE_ENABLE_TRAY)
Expand Down
9 changes: 9 additions & 0 deletions cmake/dependencies/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ pkg_check_modules(CURL REQUIRED libcurl)
pkg_check_modules(MINIUPNP miniupnpc REQUIRED)
include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIRS})

# nlohmann_json
if(SUNSHINE_SYSTEM_NLOHMANN_JSON)
pkg_check_modules(NLOHMANN_JSON nlohmann_json>=3.9.0 REQUIRED IMPORTED_TARGET)
set(JSON_LIBRARIES PkgConfig::NLOHMANN_JSON)
else()
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/nlohmann_json")
set(JSON_LIBRARIES nlohmann_json::nlohmann_json)
endif()

# ffmpeg pre-compiled binaries
if(WIN32)
if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")
Expand Down
5 changes: 1 addition & 4 deletions cmake/dependencies/windows.cmake
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)
find_package(Boost 1.71.0 COMPONENTS locale log filesystem program_options REQUIRED)
1 change: 1 addition & 0 deletions cmake/prep/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ option(SUNSHINE_CONFIGURE_ONLY "Configure special files only, then exit." OFF)
option(SUNSHINE_ENABLE_TRAY "Enable system tray icon. This option will be ignored on macOS." ON)
option(SUNSHINE_REQUIRE_TRAY "Require system tray icon. Fail the build if tray requirements are not met." ON)

option(SUNSHINE_SYSTEM_NLOHMANN_JSON "Use system installation of nlohmann_json rather than the submodule." OFF)
option(SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS "Use system installation of wayland-protocols rather than the submodule." OFF)

option(CUDA_INHERIT_COMPILE_OPTIONS
Expand Down
1 change: 0 additions & 1 deletion docs/source/building/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Install dependencies:
mingw-w64-x86_64-curl \
mingw-w64-x86_64-graphviz \
mingw-w64-x86_64-miniupnpc \
mingw-w64-x86_64-nlohmann-json \
mingw-w64-x86_64-nodejs \
mingw-w64-x86_64-onevpl \
mingw-w64-x86_64-openssl \
Expand Down
7 changes: 7 additions & 0 deletions docs/source/source_code/source_code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ Source

src/*

.. toctree::
:caption: src/display_device
:maxdepth: 1
:glob:

src/display_device/*

.. toctree::
:caption: src/platform
:maxdepth: 1
Expand Down
2 changes: 2 additions & 0 deletions src/confighttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <Simple-Web-Server/server_https.hpp>
#include <boost/asio/ssl/context_base.hpp>

#include <nlohmann/json.hpp>

#include "config.h"
#include "confighttp.h"
#include "crypto.h"
Expand Down
22 changes: 22 additions & 0 deletions src/display_device/dd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @file src/display_device/dd.h
* @brief todo this file may not exist in the future,
* todo and we only import <libdisplaydevice/display_device.h> instead, avoiding duplication
*/

#pragma once

#include <bitset>
#include <chrono>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>

// lib includes
#include <nlohmann/json.hpp>

namespace dd {
namespace options {
}
}
1 change: 1 addition & 0 deletions third-party/nlohmann_json
Submodule nlohmann_json added at 8c391e

0 comments on commit 2516960

Please sign in to comment.