aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflow <flowlnlnln@gmail.com>2022-12-17 05:53:17 -0800
committerGitHub <noreply@github.com>2022-12-17 05:53:17 -0800
commit40f16b6d62993c3c74f79f40e89ac26699919fb2 (patch)
treeecc906cc3eb890d488997185e5931f8783398ecb
parentee67b5f1ad1a273b44e15ef0bf37f9b5c202f9a0 (diff)
parenta61daa40dcc93c7ab24bdf9bd1ff08d01576ae34 (diff)
downloadPrismLauncher-40f16b6d62993c3c74f79f40e89ac26699919fb2.tar.gz
PrismLauncher-40f16b6d62993c3c74f79f40e89ac26699919fb2.tar.bz2
PrismLauncher-40f16b6d62993c3c74f79f40e89ac26699919fb2.zip
Merge pull request #631 from getchoo/better-msvc-flags
-rw-r--r--CMakeLists.txt17
1 files changed, 13 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 75360f86..de9b6fe1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,19 +28,28 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
include(GenerateExportHeader)
if(MSVC)
- # Use /W4 as /Wall includes unnesserey warnings such as added padding to structs
- # /permissive- specify standards-conforming compiler behavior, also enabled by Qt6, default on with std:c++20
# /GS Adds buffer security checks, default on but incuded anyway to mirror gcc's fstack-protector flag
- set(CMAKE_CXX_FLAGS "/W4 /permissive- /GS ${CMAKE_CXX_FLAGS}")
+ # /permissive- specify standards-conforming compiler behavior, also enabled by Qt6, default on with std:c++20
+ # Use /W4 as /Wall includes unnesserey warnings such as added padding to structs
+ set(CMAKE_CXX_FLAGS "/GS /permissive- /W4 ${CMAKE_CXX_FLAGS}")
# LINK accepts /SUBSYSTEM whics sets if we are a WINDOWS (gui) or a CONSOLE programs
# This implicitly selects an entrypoint specific to the subsystem selected
# qtmain/QtEntryPointLib provides the correct entrypoint (wWinMain) for gui programs
# Additinaly LINK autodetects we use a GUI so we can omit /SUBSYSTEM
# This allows tests to still use have console without using seperate linker flags
+ # /LTCG allows for linking wholy optimizated programs
# /MANIFEST:NO disables generating a manifest file, we instead provide our own
# /STACK sets the stack reserve size, ATL's pack list needs 3-4 MiB as of November 2022, provide 8 MiB
- set(CMAKE_EXE_LINKER_FLAGS "/MANIFEST:NO /STACK:8388608 ${CMAKE_EXE_LINKER_FLAGS}")
+ set(CMAKE_EXE_LINKER_FLAGS "/LTCG /MANIFEST:NO /STACK:8388608 ${CMAKE_EXE_LINKER_FLAGS}")
+
+ # /GL enables whole program optimizations
+ # /Gw helps reduce binary size
+ # /Gy allows the compiler to package individual functions
+ # /guard:cf enables control flow guard
+ foreach(lang C CXX)
+ set("CMAKE_${lang}_FLAGS_RELEASE" "/GL /Gw /Gy /guard:cf")
+ endforeach()
# See https://github.com/ccache/ccache/issues/1040
# Note, CMake 3.25 replaces this with CMAKE_MSVC_DEBUG_INFORMATION_FORMAT