build: Make MSVC builds more deterministic to aid caching. (#7213)

This commit is contained in:
Steveice10 2023-11-28 14:15:36 -08:00 committed by GitHub
parent 6ec079ede8
commit 0842ee6d7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,6 +51,10 @@ if (MSVC)
/Zc:throwingNew /Zc:throwingNew
/GT /GT
# Some flags for more deterministic builds, to aid caching.
/experimental:deterministic
/d1trimfile:"${CMAKE_SOURCE_DIR}"
# External headers diagnostics # External headers diagnostics
/experimental:external # Enables the external headers options. This option isn't required in Visual Studio 2019 version 16.10 and later /experimental:external # Enables the external headers options. This option isn't required in Visual Studio 2019 version 16.10 and later
/external:anglebrackets # Treats all headers included by #include <header>, where the header file is enclosed in angle brackets (< >), as external headers /external:anglebrackets # Treats all headers included by #include <header>, where the header file is enclosed in angle brackets (< >), as external headers
@ -87,7 +91,8 @@ if (MSVC)
# Since MSVC's debugging information is not very deterministic, so we have to disable it # Since MSVC's debugging information is not very deterministic, so we have to disable it
# when using ccache or other caching tools # when using ccache or other caching tools
if (CITRA_USE_CCACHE OR CITRA_USE_PRECOMPILED_HEADERS) if (CMAKE_C_COMPILER_LAUNCHER STREQUAL "ccache" OR CMAKE_CXX_COMPILER_LAUNCHER STREQUAL "ccache"
OR CITRA_USE_PRECOMPILED_HEADERS)
# Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21 # Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21
add_compile_options(/Z7) add_compile_options(/Z7)
else() else()
@ -98,7 +103,7 @@ if (MSVC)
add_compile_options("$<$<CONFIG:Release>:/GS->") add_compile_options("$<$<CONFIG:Release>:/GS->")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG /MANIFEST:NO" CACHE STRING "" FORCE) set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG /MANIFEST:NO" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE) set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF /PDBALTPATH:%_PDB%" CACHE STRING "" FORCE)
else() else()
add_compile_options( add_compile_options(
-Wall -Wall