Skip to content

Commit dddffbd

Browse files
JacobDomagalacwschilly
authored andcommitted
#2216: Add CMake option to enable using external fmt
1 parent 7dec869 commit dddffbd

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
@@ -151,6 +151,13 @@ define_option(vt_build_tests "tests" "Build VT tests" ON empty_feature)
151151
define_option(vt_build_tools "tools" "Build VT tools" ON empty_feature)
152152
define_option(vt_build_examples "examples" "Build VT examples" ON empty_feature)
153153

154+
option(vt_external_fmt "Build VT with external fmt" OFF)
155+
if(${vt_external_fmt})
156+
message(STATUS "Building vt with external fmt library")
157+
else()
158+
message(STATUS "Building vt with included fmt library")
159+
endif()
160+
154161
list(POP_BACK CMAKE_MESSAGE_INDENT)
155162

156163
##########################################################################################################

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)