Skip to content

Commit

Permalink
CMake option to Enable/disable msvc /utf-8 flag (on by default)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabime committed Nov 8, 2024
1 parent 63f0875 commit d343d41
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ elseif(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

# under msvc make sure __cplusplus, parallel build and utf-8 enabled
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus /MP /utf-8")
endif()

set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down Expand Up @@ -113,6 +109,8 @@ if(WIN32)
option(SPDLOG_WCHAR_SUPPORT "Support wchar api" OFF)
option(SPDLOG_WCHAR_FILENAMES "Support wchar filenames" OFF)
option(SPDLOG_WCHAR_CONSOLE "Support wchar output to console" OFF)
# the "/utf-8" compiler flag required by fmt 11.x under msvc
option(SPDLOG_MSVC_UTF8 "Enable/disable msvc /utf-8 flag required by fmt lib" ON)
else()
set(SPDLOG_WCHAR_SUPPORT OFF CACHE BOOL "non supported option" FORCE)
set(SPDLOG_WCHAR_FILENAMES OFF CACHE BOOL "non supported option" FORCE)
Expand Down Expand Up @@ -270,6 +268,15 @@ foreach(
endif()
endforeach()

if(MSVC)
target_compile_options(spdlog PRIVATE "/Zc:__cplusplus")
target_compile_options(spdlog_header_only INTERFACE "/Zc:__cplusplus")
if(SPDLOG_MSVC_UTF8)
target_compile_options(spdlog PUBLIC "/utf-8")
target_compile_options(spdlog_header_only INTERFACE "/utf-8")
endif()
endif()

# ---------------------------------------------------------------------------------------
# If exceptions are disabled, disable them in the bundled fmt as well
# ---------------------------------------------------------------------------------------
Expand Down

0 comments on commit d343d41

Please sign in to comment.