Skip to content

Commit

Permalink
Use system rapidjson, fall back to bundled.
Browse files Browse the repository at this point in the history
Currently the `rapidjson` headers are hard-coded into
`davix_gcloud_utils.cpp` in a way that makes it difficult to use
external/system provided rapidjson headers rather than the bundled ones.

This commit uses `find_package` to look for an external instance of
rapidjson, falling back to the bundled version in `src/libs/rapidjson`
if that search fails. In either case, it sets up the variable
`RAPIDJSON_INCLUDE_DIRS` pointing to the location of the headers and
adds this to the list of `DAVIX_INTERNAL_INCLUDES` to allow the location
to be included during compilation (via `-I${RAPIDJSON_INCLUDE_DIRS}`).
Finally, it modifies the `#include` in `davix_gcloud_utils.cpp` to
support a generic location.
  • Loading branch information
badshah400 authored and mpatrascoiu committed Jun 21, 2024
1 parent 3960564 commit 9c27f48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ set(NE_HAVE_SSL 1)

add_subdirectory(deps)

find_package(RapidJSON QUIET)
if(${RapidJSON_FOUND})
set(RAPIDJSON_INCLUDE_DIRS ${RapidJSON_INCLUDE_DIRS})
else()
message(STATUS "Using bundled RapidJSON")
set(RAPIDJSON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/libs)
endif()

#libuuid
if(NOT APPLE)
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ set(DAVIX_SOURCES
set(DAVIX_INTERNAL_INCLUDES
${OPENSSL_INCLUDE_DIR}
${LIBXML2_INCLUDE_DIR}
${RAPIDJSON_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/deps
${PROJECT_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/davix_gcloud_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <libs/alibxx/crypto/hmacsha.hpp>
#include <libs/alibxx/crypto/base64.hpp>
#include <fstream>
#include <libs/rapidjson/document.h>
#include <rapidjson/document.h>
#include <sstream>

#define SSTR(message) static_cast<std::ostringstream&>(std::ostringstream().flush() << message).str()
Expand Down

0 comments on commit 9c27f48

Please sign in to comment.