111 lines
3.9 KiB
Diff
111 lines
3.9 KiB
Diff
From 54a58e479f4d63e62e9118637cd92a2013a4fb95 Mon Sep 17 00:00:00 2001
|
|
From: Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
|
|
Date: Thu, 15 Aug 2019 16:07:01 +0200
|
|
Subject: [PATCH 1/2] cmake: Add option to build with system jsoncpp.
|
|
|
|
This patch adds the CMake build option `USE_SYSTEM_JSONCPP`,
|
|
which instead of using the internal `jsoncpp.cpp` links against
|
|
the system installed jsoncpp library.
|
|
|
|
This results in a `libopenvr_api.so` that is only 115K instead of 301K
|
|
on my system.
|
|
|
|
Distributions like Debian will prefer this behaviour, since it will give
|
|
them the possibility to maintain version and security issues for jsoncpp
|
|
in one place.
|
|
|
|
This behaviour can be enabled by
|
|
|
|
```
|
|
cmake -DUSE_SYSTEM_JSONCPP=True .
|
|
```
|
|
|
|
When the flag is not set, the build will behave like it did before.
|
|
|
|
I tested this patch using the system wide jsoncpp successfully
|
|
with xrdesktop.
|
|
---
|
|
CMakeLists.txt | 1 +
|
|
src/CMakeLists.txt | 12 +++++++++++-
|
|
2 files changed, 12 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index 8956cdad..1150c53d 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -28,6 +28,7 @@ option(BUILD_UNIVERSAL "Builds the shared or framework as a universal (fat, 32-
|
|
option(BUILD_OSX_I386 "Builds the shared or framework as a 32-bit binary, even on a 64-bit platform" OFF)
|
|
option(USE_LIBCXX "Uses libc++ instead of libstdc++" ON)
|
|
option(USE_CUSTOM_LIBCXX "Uses a custom libc++" OFF)
|
|
+option(USE_SYSTEM_JSONCPP "Uses the system installed jsoncpp." OFF)
|
|
|
|
add_definitions( -DVR_API_PUBLIC )
|
|
|
|
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
|
index b83710af..a7b64db9 100644
|
|
--- a/src/CMakeLists.txt
|
|
+++ b/src/CMakeLists.txt
|
|
@@ -34,8 +34,14 @@ endif()
|
|
# Set the source group and files.
|
|
set(CORE_FILES
|
|
openvr_api_public.cpp
|
|
- jsoncpp.cpp
|
|
)
|
|
+
|
|
+if(NOT USE_SYSTEM_JSONCPP)
|
|
+ set(JSON_CPP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/jsoncpp)
|
|
+ include_directories(${JSON_CPP_DIR})
|
|
+ list(APPEND CORE_FILES ${JSON_CPP_DIR}/jsoncpp.cpp)
|
|
+endif()
|
|
+
|
|
set(VRCORE_FILES
|
|
vrcore/dirtools_public.cpp
|
|
vrcore/envvartools_public.cpp
|
|
@@ -100,6 +106,10 @@ if(USE_CUSTOM_LIBCXX)
|
|
set(EXTRA_LIBS ${EXTRA_LIBS} c++ c++abi)
|
|
endif()
|
|
|
|
+if(USE_SYSTEM_JSONCPP)
|
|
+ list(APPEND EXTRA_LIBS jsoncpp)
|
|
+endif()
|
|
+
|
|
target_link_libraries(${LIBNAME} ${EXTRA_LIBS} ${CMAKE_DL_LIBS})
|
|
target_include_directories(${LIBNAME} PUBLIC ${OPENVR_HEADER_DIR})
|
|
|
|
|
|
From a7a6995d1d6f9ee1a17a3741661156f9706c40ce Mon Sep 17 00:00:00 2001
|
|
From: Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
|
|
Date: Thu, 15 Aug 2019 15:05:34 +0200
|
|
Subject: [PATCH 2/2] thirdparty: Move jsoncpp to thridparty directory.
|
|
|
|
Even though the previous patch in this patch set enabled the build with
|
|
a system wide jsoncpp and worked for me, it still left the internal
|
|
jsoncpp includes in the include path, since the includes were placed
|
|
in `CMAKE_CURRENT_SOURCE_DIR`. This could cause problems on other systems
|
|
when trying to build with a system wide jsoncpp.
|
|
|
|
In order to remove the internal json.h from the include path,
|
|
I moved all jsoncpp files into a thridparty directory amd include
|
|
it in the case of `USE_SYSTEM_JSONCPP` not being set.
|
|
---
|
|
{src => thirdparty/jsoncpp}/json/json-forwards.h | 0
|
|
{src => thirdparty/jsoncpp}/json/json.h | 0
|
|
{src => thirdparty/jsoncpp}/jsoncpp.cpp | 0
|
|
3 files changed, 0 insertions(+), 0 deletions(-)
|
|
rename {src => thirdparty/jsoncpp}/json/json-forwards.h (100%)
|
|
rename {src => thirdparty/jsoncpp}/json/json.h (100%)
|
|
rename {src => thirdparty/jsoncpp}/jsoncpp.cpp (100%)
|
|
|
|
diff --git a/src/json/json-forwards.h b/thirdparty/jsoncpp/json/json-forwards.h
|
|
similarity index 100%
|
|
rename from src/json/json-forwards.h
|
|
rename to thirdparty/jsoncpp/json/json-forwards.h
|
|
diff --git a/src/json/json.h b/thirdparty/jsoncpp/json/json.h
|
|
similarity index 100%
|
|
rename from src/json/json.h
|
|
rename to thirdparty/jsoncpp/json/json.h
|
|
diff --git a/src/jsoncpp.cpp b/thirdparty/jsoncpp/jsoncpp.cpp
|
|
similarity index 100%
|
|
rename from src/jsoncpp.cpp
|
|
rename to thirdparty/jsoncpp/jsoncpp.cpp
|