Skip to content

Commit

Permalink
Add rapidjson as a thirdparty library
Browse files Browse the repository at this point in the history
  • Loading branch information
flexferrum committed Oct 17, 2019
1 parent 12a72da commit a697c77
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 14 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ target_include_directories(${LIB_TARGET_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE ${RapidJSON_INCLUDE_DIR})
)

if(JINJA2CPP_STRICT_WARNINGS)
if(NOT MSVC)
Expand Down Expand Up @@ -195,7 +195,6 @@ if (JINJA2CPP_BUILD_TESTS)
CollectSources(TestSources TestHeaders ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/test)
add_executable(jinja2cpp_tests ${TestSources} ${TestHeaders})
target_link_libraries(jinja2cpp_tests gtest gtest_main nlohmann_json ${LIB_TARGET_NAME} ${EXTRA_TEST_LIBS} ${JINJA2CPP_PRIVATE_LIBS})
target_include_directories(jinja2cpp_tests PRIVATE ${RapidJSON_INCLUDE_DIR})

set_target_properties(jinja2cpp_tests PROPERTIES
CXX_STANDARD ${JINJA2CPP_CXX_STANDARD}
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if(JINJA2CPP_BUILD_TESTS)
endif()

if (NOT DEFINED JINJA2_PRIVATE_LIBS_INT)
set(JINJA2CPP_PRIVATE_LIBS ${JINJA2CPP_PRIVATE_LIBS} boost_variant boost_filesystem boost_algorithm fmt)
set(JINJA2CPP_PRIVATE_LIBS ${JINJA2CPP_PRIVATE_LIBS} boost_variant boost_filesystem boost_algorithm fmt RapidJson)
else ()
set (JINJA2CPP_PRIVATE_LIBS ${JINJA2_PRIVATE_LIBS_INT})
endif ()
Expand Down
28 changes: 19 additions & 9 deletions thirdparty/internal_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,24 @@ set (FMT_INSTALL ON CACHE BOOL "" FORCE)
add_subdirectory(thirdparty/fmtlib EXCLUDE_FROM_ALL)
add_library(fmt ALIAS fmt-header-only)

update_submodule(json/rapid)
set (RAPIDJSON_BUILD_DOC OFF CACHE BOOL "" FORCE)
set (RAPIDJSON_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set (RAPIDJSON_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set (RAPIDJSON_BUILD_THIRDPARTY_GTEST OFF CACHE BOOL "" FORCE)
set (RAPIDJSON_ENABLE_INSTRUMENTATION_OPT OFF CACHE BOOL "" FORCE)
add_subdirectory(thirdparty/json/rapid EXCLUDE_FROM_ALL)
find_package(RapidJSON)
add_library(RapidJson INTERFACE)
set_target_properties(RapidJson PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${RapidJSON_INCLUDE_DIR})

if (JINJA2CPP_BUILD_TESTS)
update_submodule(json/nlohmann)
set (JSON_BuildTests OFF CACHE BOOL "" FORCE)
set (JSON_Install OFF CACHE BOOL "" FORCE)
set (JSON_MultipleHeaders ON CACHE BOOL "" FORCE)
add_subdirectory(thirdparty/json/nlohmann EXCLUDE_FROM_ALL)

update_submodule(json/rapid)
set (RAPIDJSON_BUILD_DOC OFF CACHE BOOL "" FORCE)
set (RAPIDJSON_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set (RAPIDJSON_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set (RAPIDJSON_BUILD_THIRDPARTY_GTEST OFF CACHE BOOL "" FORCE)
set (RAPIDJSON_ENABLE_INSTRUMENTATION_OPT OFF CACHE BOOL "" FORCE)
add_subdirectory(thirdparty/json/rapid EXCLUDE_FROM_ALL)
find_package(RapidJSON)
endif()

install (FILES
Expand All @@ -41,3 +44,10 @@ install (FILES
thirdparty/nonstd/optional-lite/include/nonstd/optional.hpp
thirdparty/nonstd/string-view-lite/include/nonstd/string_view.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nonstd)

install (TARGETS RapidJson
EXPORT InstallTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
)
3 changes: 2 additions & 1 deletion thirdparty/thirdparty-conan-build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ find_package(optional-lite)
find_package(string-view-lite)
find_package(boost)
find_package(fmt)
find_package(rapidjson)

set(JINJA2_PRIVATE_LIBS_INT boost::boost fmt::fmt)
set(JINJA2_PRIVATE_LIBS_INT boost::boost fmt::fmt rapidjson::rapidjson)
set (JINJA2_PUBLIC_LIBS_INT expected-lite::expected-lite variant-lite::variant-lite optional-lite::optional-lite string-view-lite::string-view-lite)
14 changes: 13 additions & 1 deletion thirdparty/thirdparty-external.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ macro (FindHeaderOnlyLib HDR_PATH TARGET_NAME)
endmacro ()

macro (find_hdr_package PKG_NAME HDR_PATH)
find_package(${PKG_NAME})
find_package(${PKG_NAME} QUIET)
if(NOT ${PKG_NAME}_FOUND)
FindHeaderOnlyLib(${HDR_PATH} ${PKG_NAME})
endif ()
Expand All @@ -40,6 +40,11 @@ find_hdr_package(optional-lite nonstd/optional.hpp)
find_hdr_package(string-view-lite nonstd/string_view.hpp)
find_hdr_package(fmt-header-only fmt/format.h)

find_package(RapidJSON)
add_library(RapidJson INTERFACE)
set_target_properties(RapidJson PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${RapidJSON_INCLUDE_DIR})

if (TARGET fmt-header-only)
target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1)
add_library(fmt ALIAS fmt-header-only)
Expand All @@ -60,4 +65,11 @@ install(TARGETS fmt-header-only
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
)

install(TARGETS RapidJson
EXPORT InstallTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
)

include (./thirdparty/external_boost_deps.cmake)

0 comments on commit a697c77

Please sign in to comment.