From 4c79ee82ac0ad995414529350bc952a400109d1a Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 31 Dec 2025 17:30:02 +1000 Subject: [PATCH] CMake: Adjust fmt build macros Set on the library, not globally. --- CMakeLists.txt | 3 --- dep/CMakeLists.txt | 8 +++++++- dep/fmt/fmt.vcxproj | 6 +++--- src/common/common.props | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0dbfaf27..862a521fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,9 +116,6 @@ if(BUILD_TESTS) enable_testing() endif() -# Prevent fmt from being built with exceptions, or being thrown at call sites. -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFMT_EXCEPTIONS=0") - # Recursively include the source tree. add_subdirectory(dep) add_subdirectory(src) diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt index 633267c66..dc7372747 100644 --- a/dep/CMakeLists.txt +++ b/dep/CMakeLists.txt @@ -1,9 +1,15 @@ set(_saved_CMAKE_MESSAGE_LOG_LEVEL ${CMAKE_MESSAGE_LOG_LEVEL}) set(CMAKE_MESSAGE_LOG_LEVEL NOTICE) -set(FMT_INSTALL OFF CACHE BOOL "") add_subdirectory(fmt EXCLUDE_FROM_ALL) disable_compiler_warnings_for_target(fmt) +# Prevent fmt from being built with exceptions, or being thrown at call sites. +target_compile_definitions(fmt PUBLIC + "FMT_EXCEPTIONS=0" + "FMT_USE_RTTI=0" + "FMT_CPP_LIB_FILESYSTEM=0" +) + add_subdirectory(minizip EXCLUDE_FROM_ALL) disable_compiler_warnings_for_target(minizip) add_subdirectory(lzma EXCLUDE_FROM_ALL) diff --git a/dep/fmt/fmt.vcxproj b/dep/fmt/fmt.vcxproj index 4a0156e9b..bcd0fa536 100644 --- a/dep/fmt/fmt.vcxproj +++ b/dep/fmt/fmt.vcxproj @@ -28,9 +28,9 @@ TurnOffAllWarnings - $(SolutionDir)dep\fmt\include;$(ProjectDir)include;%(AdditionalIncludeDirectories) - FMT_EXCEPTIONS=0;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories);$(ProjectDir)include + %(PreprocessorDefinitions);FMT_EXCEPTIONS=0;FMT_USE_RTTI=0;FMT_CPP_LIB_FILESYSTEM=0 - \ No newline at end of file + diff --git a/src/common/common.props b/src/common/common.props index ea9990faa..7b7eddb33 100644 --- a/src/common/common.props +++ b/src/common/common.props @@ -3,7 +3,7 @@ $(SolutionDir)src;%(AdditionalIncludeDirectories);$(SolutionDir)dep\fast_float\include;$(SolutionDir)dep\fmt\include - %(PreprocessorDefinitions);FMT_EXCEPTIONS=0 + %(PreprocessorDefinitions);FMT_EXCEPTIONS=0;FMT_USE_RTTI=0;FMT_CPP_LIB_FILESYSTEM=0