Skip to content

Commit d6fff83

Browse files
authored
Allow to use rapidjson from the system (#1859)
Signed-off-by: Julius Künzel <[email protected]>
1 parent 6f2c378 commit d6fff83

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ option(OTIO_INSTALL_COMMANDLINE_TOOLS "Install the OTIO command line tools" ON)
3434
option(OTIO_INSTALL_CONTRIB "Install the opentimelineio_contrib Python package" ON)
3535
set(OTIO_IMATH_LIBS "" CACHE STRING "Imath library overrides to use instead of src/deps or find_package")
3636
option(OTIO_FIND_IMATH "Find Imath using find_package, ignored if OTIO_IMATH_LIBS is set" OFF)
37+
option(OTIO_FIND_RAPIDJSON "Find RapidJSON using find_package" OFF)
3738
set(OTIO_PYTHON_INSTALL_DIR "" CACHE STRING "Python installation dir (such as the site-packages dir)")
3839

3940
# Build options
@@ -240,6 +241,17 @@ if(USE_DEPS_IMATH)
240241
include_directories("${PROJECT_SOURCE_DIR}/src/deps/Imath/src")
241242
endif()
242243

244+
#----- RapidJSON
245+
246+
if(OTIO_FIND_RAPIDJSON)
247+
find_package(RapidJSON CONFIG REQUIRED)
248+
if (RapidJSON_FOUND)
249+
message(STATUS "Found RapidJSON at ${RapidJSON_CONFIG}")
250+
endif()
251+
else()
252+
message(STATUS "Using src/deps/rapidjson by default")
253+
endif()
254+
243255
# set up the internally hosted dependencies
244256
add_subdirectory(src/deps)
245257

src/deps/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
#----- Other dependencies
55

66
# detect if the submodules haven't been updated
7-
set(DEPS_SUBMODULES pybind11 rapidjson)
7+
set(DEPS_SUBMODULES pybind11)
8+
9+
if(NOT OTIO_FIND_RAPIDJSON)
10+
set(DEPS_SUBMODULES ${DEPS_SUBMODULES} rapidjson)
11+
endif()
12+
813
foreach(submodule IN LISTS DEPS_SUBMODULES)
914
file(GLOB SUBMOD_CONTENTS ${submodule})
1015
list(LENGTH SUBMOD_CONTENTS SUBMOD_CONTENT_LEN)

src/opentimelineio/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,15 @@ add_library(opentimelineio ${OTIO_SHARED_OR_STATIC_LIB}
7878
add_library(OTIO::opentimelineio ALIAS opentimelineio)
7979

8080
target_include_directories(opentimelineio
81-
PRIVATE "${PROJECT_SOURCE_DIR}/src"
82-
"${PROJECT_SOURCE_DIR}/src/deps"
83-
"${PROJECT_SOURCE_DIR}/src/deps/rapidjson/include")
81+
PRIVATE "${PROJECT_SOURCE_DIR}/src")
82+
83+
if(OTIO_FIND_RAPIDJSON)
84+
target_include_directories(opentimelineio
85+
PRIVATE "${RapidJSON_INCLUDE_DIRS}")
86+
else()
87+
target_include_directories(opentimelineio
88+
PRIVATE "${PROJECT_SOURCE_DIR}/src/deps/rapidjson/include")
89+
endif()
8490

8591

8692
target_link_libraries(opentimelineio

0 commit comments

Comments
 (0)