Skip to content

Commit

Permalink
#2216: Add CMake option to enable using external fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Apr 30, 2024
1 parent 21c6d6b commit 1a166e0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
7 changes: 7 additions & 0 deletions cmake/configure_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ define_option(vt_build_tests "tests" "Build VT tests" ON empty_feature)
define_option(vt_build_tools "tools" "Build VT tools" ON empty_feature)
define_option(vt_build_examples "examples" "Build VT examples" ON empty_feature)

option(vt_external_fmt "Build VT with external fmt" OFF)
if(${vt_external_fmt})
message(STATUS "Building vt with external fmt library")
else()
message(STATUS "Building vt with included fmt library")
endif()

list(POP_BACK CMAKE_MESSAGE_INDENT)

##########################################################################################################
19 changes: 15 additions & 4 deletions cmake/load_bundled_libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,21 @@ endif()
# CLI11 always included in the build
add_subdirectory(${PROJECT_LIB_DIR}/CLI)

# fmt always included in the build
set(FMT_LIBRARY fmt)
add_subdirectory(${PROJECT_LIB_DIR}/fmt)
set_darma_compiler_flags(${FMT_LIBRARY})
# use included fmt or external one
if(${vt_external_fmt})
# user should provide 'fmt_DIR' to CMake (unless fmt is installed in system libs)
if(${fmt_DIR})
message(STATUS "vt_external_fmt = ON. Using fmt located at ${fmt_DIR}")
else()
message(STATUS "vt_external_fmt = ON but ${fmt_DIR} is not provided.")
endif()
find_package(fmt REQUIRED)
else()
set(FMT_LIBRARY fmt)
add_subdirectory(${PROJECT_LIB_DIR}/fmt)
set_darma_compiler_flags(${FMT_LIBRARY})
endif()


# EngFormat-Cpp always included in the build
set(ENG_FORMAT_LIBRARY EngFormat-Cpp)
Expand Down

0 comments on commit 1a166e0

Please sign in to comment.