From e50c8b6bd870eb743b2cf13850d5aafcf7d1bad8 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 4 Jul 2024 07:27:22 -0700 Subject: [PATCH] Fix disabling Unicode support --- CMakeLists.txt | 6 +++++- test/CMakeLists.txt | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a1f86bc..e3b35110 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -355,10 +355,14 @@ endif () add_library(fmt-header-only INTERFACE) add_library(fmt::fmt-header-only ALIAS fmt-header-only) -if (MSVC AND FMT_UNICODE) +if (NOT MSVC) + # Unicode is always supported on compilers other than MSVC. +elseif (FMT_UNICODE) # Unicode support requires compiling with /utf-8. target_compile_options(fmt PUBLIC $<$:/utf-8>) target_compile_options(fmt-header-only INTERFACE $<$:/utf-8>) +else () + target_compile_definitions(fmt PUBLIC FMT_UNICODE=0) endif () target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6f7214a8..fac82392 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -45,6 +45,10 @@ function(add_fmt_test name) add_fmt_executable(${name} ${sources}) target_link_libraries(${name} ${libs}) + if (ADD_FMT_TEST_HEADER_ONLY AND NOT FMT_UNICODE) + target_compile_definitions(${name} PUBLIC FMT_UNICODE=0) + endif () + # Define if certain C++ features can be used. if (FMT_PEDANTIC) target_compile_options(${name} PRIVATE ${PEDANTIC_COMPILE_FLAGS})