include(CheckIPOSupported) check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR) function(EnableFastReleaseMode TargetName) message("> Enabling optimization for: ${TargetName}") if(MSVC) target_compile_options(${TargetName} PRIVATE $<$: /O2 # speed /Ob2 # inline aggressively /Oi # intrinsics /GL # whole program opt /Gy # function-level linking /Gw # global data in COMDAT /GF # string pooling /Zc:inline # remove unreferenced inline /fp:fast # fast math (graphics friendly) /DNDEBUG /arch:AVX2 # Advanced Vector Extensions 2 /GS- # Disable Buffer Security Check (faster) /Qspectre- # Disable Spectre mitigations (faster) > ) if(TARGET ${TargetName}) target_link_options(${TargetName} PRIVATE $<$: /LTCG # link-time code generation /OPT:REF # remove unreferenced /OPT:ICF # fold identical COMDATs > ) endif() endif() if(IPO_SUPPORTED) set_property(TARGET ${TargetName} PROPERTY INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE) else() message(WARNING "Interprocedural optimization not supported: ${ipo_error}") endif() endfunction()