Skip to content

Commit

Permalink
#1469: cmake: add brotli and json library to bundled build
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Jun 12, 2021
1 parent 6b2416a commit 416a20a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmake/link_vt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function(link_target_with_vt)
LINK_DL
LINK_ZOLTAN
LINK_FORT
LINK_JSON
LINK_BROTLI
)
set(
multiValueArg
Expand All @@ -49,6 +51,18 @@ function(link_target_with_vt)
message(STATUS "link_target_with_vt: default link=${ARG_DEFAULT_LINK_SET}")
endif()

if (NOT DEFINED ARG_LINK_JSON AND ${ARG_DEFAULT_LINK_SET} OR ARG_LINK_JSON)
target_link_libraries(
${ARG_TARGET} PRIVATE ${ARG_BUILD_TYPE} ${JSON_LIBRARY}
)
endif()

if (NOT DEFINED ARG_LINK_BROTLI AND ${ARG_DEFAULT_LINK_SET} OR ARG_LINK_BROTLI)
target_link_libraries(
${ARG_TARGET} PRIVATE ${ARG_BUILD_TYPE} ${BROTLI_LIBRARY}
)
endif()

if (NOT DEFINED ARG_LINK_FORT AND ${ARG_DEFAULT_LINK_SET} OR ARG_LINK_FORT)
if (vt_libfort_enabled)
target_link_libraries(
Expand Down
13 changes: 13 additions & 0 deletions cmake/load_bundled_libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ add_subdirectory(${PROJECT_LIB_DIR}/CLI)
set(FMT_LIBRARY fmt)
add_subdirectory(${PROJECT_LIB_DIR}/fmt)

# json library always included in the build
set(JSON_BuildTests OFF)
set(JSON_MultipleHeaders ON)
set(JSON_LIBRARY nlohmann_json)
add_subdirectory(${PROJECT_LIB_DIR}/json)

# brotli library always included in the build
set(BROTLI_DISABLE_TESTS ON)
# we need to disable bundled mode so it will install properly
set(BROTLI_BUNDLED_MODE OFF)
set(BROTLI_LIBRARY brotlicommon brotlienc brotlidec)
add_subdirectory(${PROJECT_LIB_DIR}/brotli)

# Optionally include mimalloc (alternative memory allocator)
if (vt_mimalloc_enabled)
add_subdirectory(${PROJECT_LIB_DIR}/mimalloc)
Expand Down
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ install(
set(FMT_LIBRARY_EXPORT ${FMT_LIBRARY})
install(TARGETS ${FMT_LIBRARY} EXPORT ${VIRTUAL_TRANSPORT_LIBRARY})

install(TARGETS ${JSON_LIBRARY} EXPORT ${VIRTUAL_TRANSPORT_LIBRARY})
install(TARGETS ${BROTLI_LIBRARY} EXPORT ${VIRTUAL_TRANSPORT_LIBRARY})

if (vt_mimalloc_enabled)
set(MIMALLOC_LIBRARY_EXPORT ${MIMALLOC_LIBRARY})
endif()
Expand Down Expand Up @@ -338,6 +341,8 @@ export(
${FMT_LIBRARY_EXPORT}
${CHEKPOINT_EXPORT}
${DETECTOR_EXPORT}
${JSON_LIBRARY}
${BROTLI_LIBRARY}
FILE "vtTargets.cmake"
NAMESPACE vt::runtime::
)

0 comments on commit 416a20a

Please sign in to comment.