From ef2d067e02dfb754c22933c76b81de02ea9ec5a3 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 15 May 2023 05:42:28 -0700 Subject: [PATCH] Use /INCREMENTAL:NO for Debug (#86170) * Use /INCREMENTAL:NO for Debug when using Visual Studio generator --------- Co-authored-by: Juan Hoyos <19413848+hoyosjs@users.noreply.github.com> Co-authored-by: Aaron Robinson Co-authored-by: Jasper --- eng/native/configurecompiler.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 0282e29..fbe60f7 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -85,6 +85,15 @@ if (MSVC) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /sourcelink:${CLR_SOURCELINK_FILE_PATH}") endif(EXISTS ${CLR_SOURCELINK_FILE_PATH}) + if (CMAKE_GENERATOR MATCHES "^Visual Studio.*$") + # Debug build specific flags + # The Ninja generator doesn't appear to have the default `/INCREMENTAL:ON` that + # the Visual Studio generator has. Therefore we will override the default for Visual Studio only. + add_linker_flag(/INCREMENTAL:NO DEBUG) + add_linker_flag(/OPT:REF DEBUG) + add_linker_flag(/OPT:NOICF DEBUG) + endif (CMAKE_GENERATOR MATCHES "^Visual Studio.*$") + # Checked build specific flags add_linker_flag(/INCREMENTAL:NO CHECKED) # prevent "warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:REF' specification" add_linker_flag(/OPT:REF CHECKED) -- 2.7.4