Files
json/tests/fmt_formatter/project/CMakeLists.txt
T
Niels Lohmann 8d7e0046f4 Add std::format and fmt support (#5224)
*  add std::format and fmt support

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* ♻️ reorganize PR

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 💚 fix build

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 💚 fix build

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* 💚 fix build

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-07-02 15:59:36 +02:00

37 lines
1.2 KiB
CMake

cmake_minimum_required(VERSION 3.14)
project(FmtFormatterTest CXX)
include(FetchContent)
get_filename_component(GIT_REPOSITORY_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../.. ABSOLUTE)
FetchContent_Declare(json GIT_REPOSITORY ${GIT_REPOSITORY_DIRECTORY} GIT_TAG HEAD)
set(FMT_TEST OFF CACHE BOOL "" FORCE)
set(FMT_DOC OFF CACHE BOOL "" FORCE)
set(FMT_INSTALL OFF CACHE BOOL "" FORCE)
FetchContent_Declare(fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 12.2.0
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(json fmt)
if(MSVC)
add_compile_options(/EHsc)
endif()
add_executable(fmt_formatter_test main.cpp)
target_link_libraries(fmt_formatter_test PRIVATE nlohmann_json::nlohmann_json fmt::fmt)
target_compile_features(fmt_formatter_test PRIVATE cxx_std_17)
# Fail the build itself (and therefore the ctest "build" step that drives it) if the
# recipe's runtime assertions don't hold -- there is no separate "run" step, since the
# executable's location varies by platform/generator, but CMake resolves a target name
# passed to a custom command's COMMAND for us.
add_custom_command(TARGET fmt_formatter_test POST_BUILD
COMMAND fmt_formatter_test
COMMENT "Running fmt::formatter<nlohmann::json> recipe test"
)