From 62c2ed5cf6b4a58310af2e1ab88b5d7bd21b8d35 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Tue, 3 Mar 2026 17:40:03 +0800 Subject: [PATCH] chore: sync VS release optimization flags into CMake build --- CMakeLists.txt | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f9496ee..72cfb7b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,15 @@ endif() set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +function(configure_msvc_target target) + target_compile_options(${target} PRIVATE + $<$:/W3> + $<$:/MP> + $<$:/EHsc> + $<$,$>:/GL /O2 /Ob3 /Oi /GT /GF> + ) +endfunction() + include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/WorldSources.cmake") include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/ClientSources.cmake") @@ -31,11 +40,7 @@ target_compile_definitions(MinecraftWorld PRIVATE $<$>:_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_LIB;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64> ) if(MSVC) - target_compile_options(MinecraftWorld PRIVATE - $<$:/W3> - $<$:/MP> - $<$:/EHsc> - ) + configure_msvc_target(MinecraftWorld) endif() add_executable(MinecraftClient WIN32 ${MINECRAFT_CLIENT_SOURCES}) @@ -50,10 +55,9 @@ target_compile_definitions(MinecraftClient PRIVATE $<$>:_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64> ) if(MSVC) - target_compile_options(MinecraftClient PRIVATE - $<$:/W3> - $<$:/MP> - $<$:/EHsc> + configure_msvc_target(MinecraftClient) + target_link_options(MinecraftClient PRIVATE + $<$:/LTCG /INCREMENTAL:NO> ) endif()