diff --git a/CMakeLists.txt b/CMakeLists.txt index 310ab61d..6ce37de2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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) @@ -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 # ---------------------------------------------------------------------------------------