Skip to content

Commit

Permalink
Fix disabling Unicode support
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jul 4, 2024
1 parent 9d946a2 commit e50c8b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<$<COMPILE_LANGUAGE:CXX>:/utf-8>)
target_compile_options(fmt-header-only INTERFACE $<$<COMPILE_LANGUAGE:CXX>:/utf-8>)
else ()
target_compile_definitions(fmt PUBLIC FMT_UNICODE=0)
endif ()

target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1)
Expand Down
4 changes: 4 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit e50c8b6

Please sign in to comment.