# Is there a way to disable incremental linking for Visual Studio 2022

**URL:** https://discourse.cmake.org/t/is-there-a-way-to-disable-incremental-linking-for-visual-studio-2022/4817
**Category:** Usage
**Tags:** comp:msvc, gen:vs, os:windows
**Created:** [January 12, 2022, 7:16am UTC](https://discourse.cmake.org/t/is-there-a-way-to-disable-incremental-linking-for-visual-studio-2022/4817 "2022-01-12T07:16:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tksuoran](https://discourse.cmake.org/user_avatar/discourse.cmake.org/tksuoran/32/2093_2.png) [@tksuoran](https://discourse.cmake.org/u/tksuoran)
#### Post date: [January 12, 2022, 7:16am UTC](https://discourse.cmake.org/t/is-there-a-way-to-disable-incremental-linking-for-visual-studio-2022/4817/1 "2022-01-12T07:16:05Z")

</div>

CMake 3.21.3, Windows 10, Visual Studio 2022

I am trying to create executable that I can examine with SizeBench. For that, I need full debug info, and no incremental linking. I’ve tried disabling incremental linking by passing these to my configure script (bat):

```auto
cmake ^
    -G "Visual Studio 17 2022" ^
    -A x64 ^
    -Thost=x64 ^
    -B build ^
    -S . ^
    -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ^
    -DCMAKE_EXE_LINKER_FLAGS_DEBUG="/debug /incremental:no" ^
    -DCMAKE_EXE_LINKER_FLAGS_MINSIZEREL="/debug /incremental:no" ^
    -DCMAKE_EXE_LINKER_FLAGS_RELEASE="/debug /incremental:no" ^
    -DCMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO="/debug /incremental:no" ^
    -DCMAKE_STATIC_LINKER_FLAGS_DEBUG="/debug /incremental:no" ^
    -DCMAKE_STATIC_LINKER_FLAGS_MINSIZEREL="/debug /incremental:no" ^
    -DCMAKE_STATIC_LINKER_FLAGS_RELEASE="/debug /incremental:no" ^
    -DCMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO="/debug /incremental:no" ^
    -DCMAKE_SHARED_LINKER_FLAGS_DEBUG="/debug /incremental:no" ^
    -DCMAKE_SHARED_LINKER_FLAGS_MINSIZEREL="/debug /incremental:no" ^
    -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="/debug /incremental:no" ^
    -DCMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO="/debug /incremental:no" ^
    -DCMAKE_MODULE_LINKER_FLAGS_DEBUG="/debug /incremental:no" ^
    -DCMAKE_MODULE_LINKER_FLAGS_MINSIZEREL="/debug /incremental:no" ^
    -DCMAKE_MODULE_LINKER_FLAGS_RELEASE="/debug /incremental:no" ^
    -DCMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO="/debug /incremental:no"

```

However, the generated solution has in my executable project `/INCREMENTAL` enabled. Looking inside `.vcxproj` I can find things like

```auto
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</LinkIncremental>

```

Can I somehow really disable incremental linking with CMake?

---

<div class="post-metadata">

### Author: ![petwu](https://discourse.cmake.org/user_avatar/discourse.cmake.org/petwu/32/1399_2.png) [@petwu](https://discourse.cmake.org/u/petwu)
#### Post date: [January 12, 2022, 4:20pm UTC](https://discourse.cmake.org/t/is-there-a-way-to-disable-incremental-linking-for-visual-studio-2022/4817/2 "2022-01-12T16:20:00Z")

</div>

For me it worked with all uppercase flags `/DEBUG /INCREMENTAL:NO`.

My careful guess why this happens: I think CMake uses flags tables like [v143\_Link.json](https://github.com/Kitware/CMake/blob/v3.22.1/Templates/MSBuild/FlagTables/v143_Link.json#L563) to parse command line flags and map them to the corresponding MSBuild options and this is probably done in a case-sensitive way. If you provide the flag in lowercase, this parsing/mapping fails and then the fallback value for `LinkIncremental` is `true`, see [here](https://github.com/Kitware/CMake/blob/v3.22.1/Source/cmVisualStudio10TargetGenerator.cxx#L2778).

If you think lowercase flags should be recognized as well, maybe you could open a new issue.

---

<div class="post-metadata">

### Author: ![Marek\_R](https://discourse.cmake.org/user_avatar/discourse.cmake.org/marek_r/32/2024_2.png) [@Marek\_R](https://discourse.cmake.org/u/Marek_R)
#### Post date: [August 19, 2022, 12:10pm UTC](https://discourse.cmake.org/t/is-there-a-way-to-disable-incremental-linking-for-visual-studio-2022/4817/3 "2022-08-19T12:10:59Z")

</div>

Main problem are entries: `-DCMAKE_STATIC_LINKER_FLAGS_*`.  
Static libraries do not have incremental linking, so linker files an error for this switch for static libraries (it should warn this function is not available for this kind of target).
