-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
use_system_libs.patch
112 lines (107 loc) · 3.32 KB
/
use_system_libs.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2368dfc2..a377bc57 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,12 @@ cmake_minimum_required(VERSION 3.0.2)
set(EXTERNAL_DIR "${CMAKE_SOURCE_DIR}/external")
+option(USE_SYSTEM_LIBS "Prefer to use system libraries" OFF)
+
+if(USE_SYSTEM_LIBS)
+ set(DISABLE_VCPKG ON)
+endif()
+
if(DISABLE_VCPKG)
else()
# Enable vcpkg
@@ -100,6 +106,68 @@ find_package(Protobuf REQUIRED)
find_package(ZLIB REQUIRED)
find_package(Unwind)
+if(USE_SYSTEM_LIBS)
+ find_package(cxxopts 3.0.0)
+ if(cxxopts_FOUND)
+ message(STATUS "Found cxxopts (${cxxopts_VERSION})")
+ list(INSERT CORE_LIBRARIES 0 cxxopts::cxxopts)
+ else()
+ message(STATUS "No suitable system cxxopts found, using bundled library")
+ include_directories(${EXTERNAL_DIR}/cxxopts/include)
+ endif()
+
+ find_package(msgpack 4.1.1)
+ if(msgpack_FOUND)
+ message(STATUS "Found msgpack (${msgpack_VERSION})")
+ list(INSERT CORE_LIBRARIES 0 msgpackc-cxx::msgpackc-cxx)
+ else()
+ message(STATUS "No suitable system msgpack found, using bundled library")
+ include_directories(${EXTERNAL_DIR}/msgpack-c/include)
+ endif()
+
+ find_package(nlohmann_json 3.10.0)
+ if(nlohmann_json_FOUND)
+ list(INSERT CORE_LIBRARIES 0 nlohmann_json::nlohmann_json)
+ else()
+ message(STATUS "No suitable system json-c++ found, using bundled library")
+ include_directories(${EXTERNAL_DIR}/json/include)
+ endif()
+
+ find_package(simpleini 4.18)
+ if(simpleini_FOUND)
+ list(INSERT CORE_LIBRARIES 0 simpleini::simpleini)
+ else()
+ message(STATUS "No suitable system simpleini found, using bundled library")
+ include_directories(${EXTERNAL_DIR}/simpleini)
+ endif()
+
+ if(BUILD_TESTING)
+ find_package(Catch2 2.13.7)
+ if(Catch2_FOUND)
+ message(STATUS "Found catch2 (${Catch2_VERSION})")
+ list(INSERT CORE_LIBRARIES 0 Catch2::Catch2)
+ else()
+ message(STATUS "No suitable system catch2 found, using bundled library")
+ include_directories(${EXTERNAL_DIR}/Catch2/single_include)
+ endif()
+ endif()
+
+ find_package(httplib 0.8.0)
+ if(httplib_FOUND)
+ list(INSERT CORE_LIBRARIES 0 httplib::httplib)
+ else()
+ message(STATUS "No suitable system httplib found, using bundled library")
+ include_directories(${EXTERNAL_DIR}/cpp-httplib)
+ endif()
+else()
+ include_directories(${EXTERNAL_DIR}/cxxopts/include
+ ${EXTERNAL_DIR}/msgpack-c/include
+ ${EXTERNAL_DIR}/json/include
+ ${EXTERNAL_DIR}/simpleini
+ ${EXTERNAL_DIR}/Catch2/single_include
+ ${EXTERNAL_DIR}/cpp-httplib)
+endif()
+
# Optional packages
find_package(UTempter)
if(LINUX)
@@ -321,14 +389,8 @@ include_directories(
${EXTERNAL_DIR}/easyloggingpp/src
${EXTERNAL_DIR}/ThreadPool
${EXTERNAL_DIR}/PlatformFolders
- ${EXTERNAL_DIR}/Catch2/single_include
- ${EXTERNAL_DIR}/cxxopts/include
- ${EXTERNAL_DIR}/msgpack-c/include
- ${EXTERNAL_DIR}/json/single_include/nlohmann
${EXTERNAL_DIR}/sole
${EXTERNAL_DIR}/base64
- ${EXTERNAL_DIR}/simpleini
- ${EXTERNAL_DIR}/cpp-httplib
src/base
src/terminal
src/terminal/forwarding
diff --git a/src/base/JsonLib.hpp b/src/base/JsonLib.hpp
index a0de911b..d206bd99 100644
--- a/src/base/JsonLib.hpp
+++ b/src/base/JsonLib.hpp
@@ -1,5 +1,5 @@
#pragma once
-#include "json.hpp"
+#include "nlohmann/json.hpp"
using json = nlohmann::json;