# \#comp:msvc

**URL:** https://discourse.cmake.org/tag/comp-msvc/6.md

[Latest](https://discourse.cmake.org/latest.md) · [Categories](https://discourse.cmake.org/categories.md) · [Tags](https://discourse.cmake.org/tags.md)

---

## [Recommended way to enable PDB for Release configuration](https://discourse.cmake.org/t/recommended-way-to-enable-pdb-for-release-configuration/15808)

<div class="topic-metadata">

**Author:** [@dgrabiec](https://discourse.cmake.org/u/dgrabiec)\
**Replies:** 7\
**Last updated:** [August 28, 2026, 1:13pm UTC](https://discourse.cmake.org/t/recommended-way-to-enable-pdb-for-release-configuration/15808 "2026-08-28T13:13:51Z")

</div>

I’m wondering what the canonical way to enable generation of PDB files for a Release build is? Naively I’ve just added this to my toolchain file for the MSVC generators: add\_compile\_options("$\<$\`\<\`CONFIG:Release\`\>\`:/Zi\>…

---

## [CMake 4.2.3 picks wrong MSVC?](https://discourse.cmake.org/t/cmake-4-2-3-picks-wrong-msvc/15572)

<div class="topic-metadata">

**Author:** [@exoosh](https://discourse.cmake.org/u/exoosh)\
**Replies:** 7\
**Last updated:** [May 20, 2026, 1:48pm UTC](https://discourse.cmake.org/t/cmake-4-2-3-picks-wrong-msvc/15572 "2026-05-20T13:48:17Z")

</div>

Hi, so today I tried to build a project where we used to rely on the fact that CMake uses the ambient environment to figure out the compiler to use. Alas, despite being started in the VS2022 Developer Powershell, it en…

---

## [/F MSVC stack size not working with CMake](https://discourse.cmake.org/t/f-msvc-stack-size-not-working-with-cmake/15641)

<div class="topic-metadata">

**Author:** [@AliADev](https://discourse.cmake.org/u/AliADev)\
**Replies:** 0\
**Last updated:** [May 5, 2026, 5:34pm UTC](https://discourse.cmake.org/t/f-msvc-stack-size-not-working-with-cmake/15641 "2026-05-05T17:34:23Z")

</div>

This program stack overflows by default on windows, because it allocates more than 1MB on the stack on debug builds. So I pass /F to MSVC and it works. However, when I do it in CMake, it does not seem to work and keep ge…

---

## [Find\_package - MSVC - Standard Architecture not defined.](https://discourse.cmake.org/t/find-package-msvc-standard-architecture-not-defined/15581)

<div class="topic-metadata">

**Author:** [@Kphillisjr](https://discourse.cmake.org/u/Kphillisjr)\
**Replies:** 1\
**Last updated:** [March 30, 2026, 8:09pm UTC](https://discourse.cmake.org/t/find-package-msvc-standard-architecture-not-defined/15581 "2026-03-30T20:09:39Z")

</div>

I am working with a few packages and noticed that the CMAKE find\_package is fundamentally broken with MSVC. From what I can tell the following variables are not defined: CMAKE\_LIBRARY\_ARCHITECTURE CMAKE\_C\_LIBRARY\_ARCHI…

---

## [FIND\_PACKAGE working at main level, failing on dependencies](https://discourse.cmake.org/t/find-package-working-at-main-level-failing-on-dependencies/15414)

<div class="topic-metadata">

**Author:** [@Joymaker](https://discourse.cmake.org/u/Joymaker)\
**Replies:** 4\
**Last updated:** [January 3, 2026, 7:08am UTC](https://discourse.cmake.org/t/find-package-working-at-main-level-failing-on-dependencies/15414 "2026-01-03T07:08:16Z")

</div>

I’m bringing my CMake world under the Visual Studio umbrella. Lots of things are working, including the finding of packages that I explicitly invoke (whew!). But now I’m having strange problems with FIND\_PACKAGE operatin…

---

## [Unexpected VS2022 build flag changes with CMake 4.1](https://discourse.cmake.org/t/unexpected-vs2022-build-flag-changes-with-cmake-4-1/15324)

<div class="topic-metadata">

**Author:** [@kwaegel](https://discourse.cmake.org/u/kwaegel)\
**Replies:** 6\
**Last updated:** [December 8, 2025, 4:02pm UTC](https://discourse.cmake.org/t/unexpected-vs2022-build-flag-changes-with-cmake-4-1/15324 "2025-12-08T16:02:55Z")

</div>

I recently tried upgrading CMake and got an unexpected build failure with Visual Studio 2022 suddenly returning LNK1189 (\>65k symbols) for a large private project. After a bunch of testing different versions, it looks li…

---

## [VS: Build Arm64X PE binary? (Windows 11 on Arm)](https://discourse.cmake.org/t/vs-build-arm64x-pe-binary-windows-11-on-arm/14447)

<div class="topic-metadata">

**Author:** [@kenjiuno](https://discourse.cmake.org/u/kenjiuno)\
**Replies:** 4\
**Last updated:** [October 10, 2025, 2:48pm UTC](https://discourse.cmake.org/t/vs-build-arm64x-pe-binary-windows-11-on-arm/14447 "2025-10-10T14:48:40Z")

</div>

Is there a plan to support the build of Arm64X PE binaries with the Visual Studio 17 2022 generator? For example, the ODBC driver is better with an Arm64X PE binary. MariaDB Connector/ODBC is a CMake-enabled project. T…

---

## [No executable in Visual Studio despite the CMake compiling](https://discourse.cmake.org/t/no-executable-in-visual-studio-despite-the-cmake-compiling/14895)

<div class="topic-metadata">

**Author:** [@FabianDim](https://discourse.cmake.org/u/FabianDim)\
**Replies:** 6\
**Last updated:** [August 6, 2025, 6:53pm UTC](https://discourse.cmake.org/t/no-executable-in-visual-studio-despite-the-cmake-compiling/14895 "2025-08-06T18:53:08Z")

</div>

full repo: https\[delete me\]://github.com/FabianDim/InvokeInvoiceSystem I have attempted to refactor my code to have two cmake files, I put it in the CMakeList.txt as a subdir. The CMake build generates in VS and display…

---

## [Can't get NEW CMP0147 (BuildInParallel) to work](https://discourse.cmake.org/t/cant-get-new-cmp0147-buildinparallel-to-work/11478)

<div class="topic-metadata">

**Author:** [@JanK](https://discourse.cmake.org/u/JanK)\
**Replies:** 3\
**Last updated:** [July 29, 2025, 6:48pm UTC](https://discourse.cmake.org/t/cant-get-new-cmp0147-buildinparallel-to-work/11478 "2025-07-29T18:48:50Z")

</div>

I’m generating projects for Visual Studio 2022. I upgraded my CMake.exe to version 3.30.2. Then I bumped my cmake\_minimum\_required to 3.30. I also added cmake\_policy(SET CMP0147 NEW) a couple of times into my top-leve…

---

## [How to make a source file compile before any others within a target](https://discourse.cmake.org/t/how-to-make-a-source-file-compile-before-any-others-within-a-target/14231)

<div class="topic-metadata">

**Author:** [@huangqinjin](https://discourse.cmake.org/u/huangqinjin)\
**Replies:** 2\
**Last updated:** [June 29, 2025, 2:34pm UTC](https://discourse.cmake.org/t/how-to-make-a-source-file-compile-before-any-others-within-a-target/14231 "2025-06-29T14:34:55Z")

</div>

I have a target hello with two source files a.cpp and b.cpp. And both contain the #import directive: #import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no\_namespace rename("EOF", "EndOfFile") which will g…

---

## [Unexpected behavior when regenerating a project with Ninja Multi-Config and MSVC](https://discourse.cmake.org/t/unexpected-behavior-when-regenerating-a-project-with-ninja-multi-config-and-msvc/14099)

<div class="topic-metadata">

**Author:** [@aeart](https://discourse.cmake.org/u/aeart)\
**Replies:** 1\
**Last updated:** [June 19, 2025, 1:37am UTC](https://discourse.cmake.org/t/unexpected-behavior-when-regenerating-a-project-with-ninja-multi-config-and-msvc/14099 "2025-06-19T01:37:59Z")

</div>

I have encountered an unusual behavior when regenerating a project using Ninja Multi-Config as the generator and Microsoft Visual C++ (MSVC) as the compiler. Here is a minimal example project consisting of three files: …

---

## [Support for disabling \<Midl\> on vcxproj generation](https://discourse.cmake.org/t/support-for-disabling-midl-on-vcxproj-generation/14252)

<div class="topic-metadata">

**Author:** [@FrayxRulez](https://discourse.cmake.org/u/FrayxRulez)\
**Replies:** 0\
**Last updated:** [June 17, 2025, 3:01pm UTC](https://discourse.cmake.org/t/support-for-disabling-midl-on-vcxproj-generation/14252 "2025-06-17T15:01:09Z")

</div>

Hello, We’re migrating some project in our pipeline from C++/CX to C++/WinRT. Everything is going quite smoothly, apart from the fact that CMake automatically adds tags whenever a \*.idl file is detected and it appears…

---

## [Method to build unit tests with separate toolchain](https://discourse.cmake.org/t/method-to-build-unit-tests-with-separate-toolchain/14097)

<div class="topic-metadata">

**Author:** [@DerekCresswell](https://discourse.cmake.org/u/DerekCresswell)\
**Replies:** 2\
**Last updated:** [May 15, 2025, 3:16pm UTC](https://discourse.cmake.org/t/method-to-build-unit-tests-with-separate-toolchain/14097 "2025-05-15T15:16:48Z")

</div>

Here’s a brief outline of my situation: I’m working on a large Windows Kernel Mode Driver Our unit tests need to run in user mode Our toolchain is setup to support user and kernel mode But we cannot unify the building …

---

## [PCH unable to get precompiled headers working](https://discourse.cmake.org/t/pch-unable-to-get-precompiled-headers-working/14075)

<div class="topic-metadata">

**Author:** [@tksuoran](https://discourse.cmake.org/u/tksuoran)\
**Replies:** 0\
**Last updated:** [May 10, 2025, 1:17pm UTC](https://discourse.cmake.org/t/pch-unable-to-get-precompiled-headers-working/14075 "2025-05-10T13:17:11Z")

</div>

I am trying to use precompiled headers. One library target (erhe\_pch ) is used for creating PCH to be shared with other targets, with REUSE\_FROM. When I build erhe\_pch target in VS, the pch file (cmake\_pch.pch ) is cre…

---

## [Integrating CSharp unit tests with add\_test](https://discourse.cmake.org/t/integrating-csharp-unit-tests-with-add-test/10288)

<div class="topic-metadata">

**Author:** [@Nino\_Stanusic](https://discourse.cmake.org/u/Nino_Stanusic)\
**Replies:** 1\
**Last updated:** [March 3, 2025, 4:04pm UTC](https://discourse.cmake.org/t/integrating-csharp-unit-tests-with-add-test/10288 "2025-03-03T16:04:58Z")

</div>

Hello everytone, The goal: I want to achieve csharp unit testing alongside C++ tests in cmake. we have a C++ project that uses the UseSWIG module to generate our C# bindings. And we would like to test them. The curre…

---

## [ExternalWarningLevel automatically set](https://discourse.cmake.org/t/externalwarninglevel-automatically-set/13477)

<div class="topic-metadata">

**Author:** [@nick](https://discourse.cmake.org/u/nick)\
**Replies:** 1\
**Last updated:** [January 27, 2025, 9:58am UTC](https://discourse.cmake.org/t/externalwarninglevel-automatically-set/13477 "2025-01-27T09:58:57Z")

</div>

I was investigating why external warnings were turned off in our generated projects. I found out that imported libraries, i.e. add\_library(library\_name INTERFACE IMPORTED), automatically sets the SYSTEM property, which i…

---

## [Cannot set toolset when configuring with the Visual Studio 2022 generator.](https://discourse.cmake.org/t/cannot-set-toolset-when-configuring-with-the-visual-studio-2022-generator/10160)

<div class="topic-metadata">

**Author:** [@teo-tsirpanis](https://discourse.cmake.org/u/teo-tsirpanis)\
**Replies:** 15\
**Last updated:** [January 15, 2025, 1:45pm UTC](https://discourse.cmake.org/t/cannot-set-toolset-when-configuring-with-the-visual-studio-2022-generator/10160 "2025-01-15T13:45:52Z")

</div>

I have installed on my machine Visual Studio 2022 17.9 with the MSVC toolsets 14.36, 14.38 and 14.39. I created with Visual Studio a new “CMake project” and after configuring it with cmake -S . -B build -G "Visual Studio…

---

## [Inject "/EHa" MSVC option via CXXFLAGS for Visual Studio generator - not possible?](https://discourse.cmake.org/t/inject-eha-msvc-option-via-cxxflags-for-visual-studio-generator-not-possible/13014)

<div class="topic-metadata">

**Author:** [@YN\_Slb](https://discourse.cmake.org/u/YN_Slb)\
**Replies:** 0\
**Last updated:** [November 21, 2024, 3:01pm UTC](https://discourse.cmake.org/t/inject-eha-msvc-option-via-cxxflags-for-visual-studio-generator-not-possible/13014 "2024-11-21T15:01:17Z")

</div>

Per Microsoft documentation (/EH (Exception handling model) | Microsoft Learn), /EHa overrides both /EHs and /EHc arguments But, when these options are not provided by CMake to compiler directly - because of using Vi…

---

## [\[BUG\] CMake uses extra hidden flags](https://discourse.cmake.org/t/bug-cmake-uses-extra-hidden-flags/12983)

<div class="topic-metadata">

**Author:** [@Paradox84](https://discourse.cmake.org/u/Paradox84)\
**Replies:** 6\
**Last updated:** [November 18, 2024, 2:18pm UTC](https://discourse.cmake.org/t/bug-cmake-uses-extra-hidden-flags/12983 "2024-11-18T14:18:55Z")

</div>

In Debug configuration CMake uses \\Zi flag, but when you try to create a custom configuration which is just a clone of Debug, that config won’t have \\Zi flag In my opinion this is a bug and CMake only should use flags w…

---

## [matlab\_add\_mex configures conflicting warning options for MSVC](https://discourse.cmake.org/t/matlab-add-mex-configures-conflicting-warning-options-for-msvc/12727)

<div class="topic-metadata">

**Author:** [@mpitka](https://discourse.cmake.org/u/mpitka)\
**Replies:** 0\
**Last updated:** [October 9, 2024, 6:03am UTC](https://discourse.cmake.org/t/matlab-add-mex-configures-conflicting-warning-options-for-msvc/12727 "2024-10-09T06:03:14Z")

</div>

Hi, CMake silences compiler warnings for MEX\_VERSION\_FILE (c\_mexapi\_version.c or cpp\_mexapi\_version.cpp) for a list of compilers with a -w switch. When building with the MSVC compiler, this creates a compiler warning abo…

---

## [Visual Studio Multi-config solution](https://discourse.cmake.org/t/visual-studio-multi-config-solution/11633)

<div class="topic-metadata">

**Author:** [@Joerg](https://discourse.cmake.org/u/Joerg)\
**Replies:** 1\
**Last updated:** [September 17, 2024, 8:10am UTC](https://discourse.cmake.org/t/visual-studio-multi-config-solution/11633 "2024-09-17T08:10:29Z")

</div>

Hello, we are currently investigating switching from MPC (GitHub - DOCGroup/MPC: MPC (The Makefile, Project, and Workspace Creator)) to CMake. As a test, I am trying to convert a slightly larger C++ project to CMake. No…

---

## [Specifying Toolset with Ninja Generator in Visual Studio vs Vanilla CMake](https://discourse.cmake.org/t/specifying-toolset-with-ninja-generator-in-visual-studio-vs-vanilla-cmake/11238)

<div class="topic-metadata">

**Author:** [@KStocky](https://discourse.cmake.org/u/KStocky)\
**Replies:** 2\
**Last updated:** [July 25, 2024, 9:19pm UTC](https://discourse.cmake.org/t/specifying-toolset-with-ninja-generator-in-visual-studio-vs-vanilla-cmake/11238 "2024-07-25T21:19:09Z")

</div>

Hi all! Given the following CMakeLists.txt cmake\_minimum\_required(VERSION 3.26) project(MyProj LANGUAGES CXX) add\_executable(MyProj src.cpp) and CMakePresets.json { "version": 6, "configurePresets": \[ {…

---

## ["note" messages from MSVC are filtered out from cmake output](https://discourse.cmake.org/t/note-messages-from-msvc-are-filtered-out-from-cmake-output/10892)

<div class="topic-metadata">

**Author:** [@jeanga](https://discourse.cmake.org/u/jeanga)\
**Replies:** 2\
**Last updated:** [July 19, 2024, 2:10pm UTC](https://discourse.cmake.org/t/note-messages-from-msvc-are-filtered-out-from-cmake-output/10892 "2024-07-19T14:10:13Z")

</div>

recently (VS 2022 17.10&17.11), MSVC has been using “note” messages to detail the context of an error message: Blockquote C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.39.33519\\include\\memo…

---

## [How do I use VS\_GLOBAL\_SECTION\_POST\_ExtensibilityGlobals](https://discourse.cmake.org/t/how-do-i-use-vs-global-section-post-extensibilityglobals/11121)

<div class="topic-metadata">

**Author:** [@chad\_s](https://discourse.cmake.org/u/chad_s)\
**Replies:** 2\
**Last updated:** [June 28, 2024, 2:25pm UTC](https://discourse.cmake.org/t/how-do-i-use-vs-global-section-post-extensibilityglobals/11121 "2024-06-28T14:25:59Z")

</div>

I’m having trouble finding or creating any working examples of using VS\_GLOBAL\_SECTION\_POST\_ExtensibilityGlobals to add a property to a solution (for a plugin). It seems that GlobalSection(ExtensibilityGlobals) is being …

---

## [Installing dll dependencies using RUNTIME\_DEPENDENCY\_SET and $\<TARGET\_RUNTIME\_DLL\_DIRS:${target}\> bug?](https://discourse.cmake.org/t/installing-dll-dependencies-using-runtime-dependency-set-and-target-runtime-dll-dirs-target-bug/10959)

<div class="topic-metadata">

**Author:** [@octopus42](https://discourse.cmake.org/u/octopus42)\
**Replies:** 4\
**Last updated:** [June 25, 2024, 11:10am UTC](https://discourse.cmake.org/t/installing-dll-dependencies-using-runtime-dependency-set-and-target-runtime-dll-dirs-target-bug/10959 "2024-06-25T11:10:11Z")

</div>

I think I found an issue with how the cmake\_install.cmake is generated or I’m using it wrong. Using the latest, 3.29.4, and attempting to create an install routine to bundle runtime dlls, for a product; dlls are for thi…

---

## [netcoreapp3.1 project with CMake](https://discourse.cmake.org/t/netcoreapp3-1-project-with-cmake/2917)

<div class="topic-metadata">

**Author:** [@pifopi](https://discourse.cmake.org/u/pifopi)\
**Replies:** 2\
**Last updated:** [June 18, 2024, 5:17pm UTC](https://discourse.cmake.org/t/netcoreapp3-1-project-with-cmake/2917 "2024-06-18T17:17:27Z")

</div>

Hello everyone ! I’m creating this post today because I’m wondering how to generate a netcoreapp3.1 project with CMake. I have seen some examples online (for net framework 4.7.2) mentionning this set(CMAKE\_DOTNET\_TARG…

---

## [Ninja: Unneeded build target dependency when using add\_custom\_command to generate a cpp file](https://discourse.cmake.org/t/ninja-unneeded-build-target-dependency-when-using-add-custom-command-to-generate-a-cpp-file/10903)

<div class="topic-metadata">

**Author:** [@psoftware](https://discourse.cmake.org/u/psoftware)\
**Replies:** 9\
**Last updated:** [June 10, 2024, 4:55pm UTC](https://discourse.cmake.org/t/ninja-unneeded-build-target-dependency-when-using-add-custom-command-to-generate-a-cpp-file/10903 "2024-06-10T16:55:04Z")

</div>

Hi there! I am struggling in removing a compile dependency in my project that makes use of add\_custom\_command. Consider this simple snippet: cmake\_minimum\_required(VERSION 3.12) project(test-cmake-customcommand-depend…

---

## [How to disable system directory search for file(GET\_RUNTIME\_DEPENDENCIES](https://discourse.cmake.org/t/how-to-disable-system-directory-search-for-file-get-runtime-dependencies/2014)

<div class="topic-metadata">

**Author:** [@Warmyone](https://discourse.cmake.org/u/Warmyone)\
**Replies:** 3\
**Last updated:** [May 31, 2024, 10:18am UTC](https://discourse.cmake.org/t/how-to-disable-system-directory-search-for-file-get-runtime-dependencies/2014 "2024-05-31T10:18:20Z")

</div>

We are building an executable with the visual studio compiler. When deploying we want to include the msvc redist dll’s as customers might not have installed them. Furthermore, we do not want to use those located in sys…

---

## [CMAKE\_GENERATOR\_TOOLSET's toolset and version keys gives unexpected results with vs2022/vs2019?](https://discourse.cmake.org/t/cmake-generator-toolsets-toolset-and-version-keys-gives-unexpected-results-with-vs2022-vs2019/10800)

<div class="topic-metadata">

**Author:** [@StewMcC](https://discourse.cmake.org/u/StewMcC)\
**Replies:** 2\
**Last updated:** [May 4, 2024, 7:03pm UTC](https://discourse.cmake.org/t/cmake-generator-toolsets-toolset-and-version-keys-gives-unexpected-results-with-vs2022-vs2019/10800 "2024-05-04T19:03:19Z")

</div>

CMake Version: 3.27.8 no policy overrides VS/MSVC installs: VS2019/14.29.30133, VS2022/14.34.31933 I am trying to customize a windows toolchain file to specify the toolset requirements for visual studio when using a Vi…

---

## [CMAKE\_IPO\_ISSUE msvc (/LTCG:incremental)](https://discourse.cmake.org/t/cmake-ipo-issue-msvc-ltcg-incremental/826)

<div class="topic-metadata">

**Author:** [@anon45792294](https://discourse.cmake.org/u/anon45792294)\
**Replies:** 5\
**Last updated:** [April 26, 2024, 2:17pm UTC](https://discourse.cmake.org/t/cmake-ipo-issue-msvc-ltcg-incremental/826 "2024-04-26T14:17:16Z")

</div>

I’ve create a public github to demonstrate this issue. set(CMAKE\_INTERPROCEDURAL\_OPTIMIZATION ON) The code above turns on LTO but not in an always desirable fashion. It sets /LTCG to be INCREMENTAL. Which isn’t what…

[Next page](https://discourse.cmake.org/tag/comp-msvc/6.md?match_all_tags=true&page=1&tags%5B%5D=comp%3Amsvc)
