Skip to content

Commit 777f130

Browse files
committed
#2216: Add CMake option to enable using external fmt
1 parent a72520e commit 777f130

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

cmake/configure_options.cmake

+7
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,13 @@ else()
214214
set(vt_feature_cmake_ci_build "0")
215215
endif()
216216

217+
option(vt_external_fmt "Build VT with external fmt" OFF)
218+
if(${vt_external_fmt})
219+
message(STATUS "Building vt with external fmt library")
220+
else()
221+
message(STATUS "Building vt with included fmt library")
222+
endif()
223+
217224
list(POP_BACK CMAKE_MESSAGE_INDENT)
218225

219226
message(STATUS "CI_BUILD = ${vt_feature_cmake_ci_build}")

cmake/load_bundled_libraries.cmake

+15-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,21 @@ endif()
2020
# CLI11 always included in the build
2121
add_subdirectory(${PROJECT_LIB_DIR}/CLI)
2222

23-
# fmt always included in the build
24-
set(FMT_LIBRARY fmt)
25-
add_subdirectory(${PROJECT_LIB_DIR}/fmt)
26-
set_darma_compiler_flags(${FMT_LIBRARY})
23+
# use included fmt or external one
24+
if(${vt_external_fmt})
25+
# user should provide 'fmt_DIR' to CMake (unless fmt is installed in system libs)
26+
if(${fmt_DIR})
27+
message(STATUS "vt_external_fmt = ON. Using fmt located at ${fmt_DIR}")
28+
else()
29+
message(STATUS "vt_external_fmt = ON but ${fmt_DIR} is not provided.")
30+
endif()
31+
find_package(fmt REQUIRED)
32+
else()
33+
set(FMT_LIBRARY fmt)
34+
add_subdirectory(${PROJECT_LIB_DIR}/fmt)
35+
set_darma_compiler_flags(${FMT_LIBRARY})
36+
endif()
37+
2738

2839
# EngFormat-Cpp always included in the build
2940
set(ENG_FORMAT_LIBRARY EngFormat-Cpp)

0 commit comments

Comments
 (0)