# \#gen:vs

**URL:** https://discourse.cmake.org/tag/gen-vs/9.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\>…

---

## [Comment line for custom target has added leading 1\>](https://discourse.cmake.org/t/comment-line-for-custom-target-has-added-leading-1/15764)

<div class="topic-metadata">

**Author:** [@Wallby](https://discourse.cmake.org/u/Wallby)\
**Replies:** 3\
**Last updated:** [July 31, 2026, 11:25am UTC](https://discourse.cmake.org/t/comment-line-for-custom-target-has-added-leading-1/15764 "2026-07-31T11:25:49Z")

</div>

For example: set(name example) add\_executable(${name} ${...}) set(customName customTarget) add\_custom\_target(${customName} COMMENT "#${customName}" COMMAND ${CMAKE\_COMMAND} -E echo $\<TARGET\_FILE…

---

## [Custom command/target results in MSB8065 warnings in Visual Studio 2022 & 2026](https://discourse.cmake.org/t/custom-command-target-results-in-msb8065-warnings-in-visual-studio-2022-2026/15757)

<div class="topic-metadata">

**Author:** [@MarkCallow](https://discourse.cmake.org/u/MarkCallow)\
**Replies:** 2\
**Last updated:** [July 23, 2026, 2:27pm UTC](https://discourse.cmake.org/t/custom-command-target-results-in-msb8065-warnings-in-visual-studio-2022-2026/15757 "2026-07-23T14:27:29Z")

</div>

I am aware of Custom command results in MSB8065 warnings in Visual Studio 2019. That is a different issue. In that case the custom command OUTPUT is not a real file. In this case it is a real file, actually a directory. …

---

## [For posterity: another of these CMake "hacks" — No CMAKE\_C\_COMPILER could be found.](https://discourse.cmake.org/t/for-posterity-another-of-these-cmake-hacks-no-cmake-c-compiler-could-be-found/15721)

<div class="topic-metadata">

**Author:** [@exoosh](https://discourse.cmake.org/u/exoosh)\
**Replies:** 9\
**Last updated:** [June 23, 2026, 3:15pm UTC](https://discourse.cmake.org/t/for-posterity-another-of-these-cmake-hacks-no-cmake-c-compiler-could-be-found/15721 "2026-06-23T15:15:57Z")

</div>

So, CMake seems incapable of passing through /pdbaltpath:%\_PDB% when given in a CMakeLists.txt (first learning). It somehow ends up as %%%%\_PDB%%%% which then will evaluate — assuming a foobar.exe — to %%%foobar.pdb%%% i…

---

## [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…

---

## [Visual Studio Generator EXCLUDE\_FROM\_ALL behavior](https://discourse.cmake.org/t/visual-studio-generator-exclude-from-all-behavior/15620)

<div class="topic-metadata">

**Author:** [@dbs4261](https://discourse.cmake.org/u/dbs4261)\
**Replies:** 0\
**Last updated:** [April 23, 2026, 5:07pm UTC](https://discourse.cmake.org/t/visual-studio-generator-exclude-from-all-behavior/15620 "2026-04-23T17:07:32Z")

</div>

I am running into an issue with the VIsual Studio 17 2022 generator and I am not sure if this is the intended behavior. I have a project configured with CMake that uses FetchContent to fetch it’s dependencies. In my CLio…

---

## [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…

---

## [Problem with CMake when compiling a project with Clang and CUDA support](https://discourse.cmake.org/t/problem-with-cmake-when-compiling-a-project-with-clang-and-cuda-support/11723)

<div class="topic-metadata">

**Author:** [@AAUDI](https://discourse.cmake.org/u/AAUDI)\
**Replies:** 1\
**Last updated:** [March 12, 2026, 5:01pm UTC](https://discourse.cmake.org/t/problem-with-cmake-when-compiling-a-project-with-clang-and-cuda-support/11723 "2026-03-12T17:01:23Z")

</div>

Hello, I’m trying to build an open-source project called VORTEX on Windows using CLANG as the compiler. However, when I run the CMake command, it seems that the NVCC (CUDA) compiler is not being detected. Could you plea…

---

## ["Cannot find source file" when library is linked to a particular executable](https://discourse.cmake.org/t/cannot-find-source-file-when-library-is-linked-to-a-particular-executable/15527)

<div class="topic-metadata">

**Author:** [@codeling](https://discourse.cmake.org/u/codeling)\
**Replies:** 3\
**Last updated:** [February 24, 2026, 9:32pm UTC](https://discourse.cmake.org/t/cannot-find-source-file-when-library-is-linked-to-a-particular-executable/15527 "2026-02-24T21:32:31Z")

</div>

I am in the process of migrating an existing project to CMake. In it, I have several libraries and executables; When I add one of the library targets (let’s say library lib) to the main executable (let’s call it exe), a…

---

## [Using ccache with Visual Studio generator and ClangCL toolset](https://discourse.cmake.org/t/using-ccache-with-visual-studio-generator-and-clangcl-toolset/15497)

<div class="topic-metadata">

**Author:** [@retif](https://discourse.cmake.org/u/retif)\
**Replies:** 2\
**Last updated:** [February 16, 2026, 11:06am UTC](https://discourse.cmake.org/t/using-ccache-with-visual-studio-generator-and-clangcl-toolset/15497 "2026-02-16T11:06:25Z")

</div>

I am looking at enabling ccache in my projects, and I got it working on/with almost all the platforms/generators that I need. The “Professional CMake” book was a great help with that (big thanks to @craig.scott, as usual)…

---

## [cmake 4.2.2 not able to detect VS2026 outside 'developer command prompt'?](https://discourse.cmake.org/t/cmake-4-2-2-not-able-to-detect-vs2026-outside-developer-command-prompt/15478)

<div class="topic-metadata">

**Author:** [@Andre\_Weissflog](https://discourse.cmake.org/u/Andre_Weissflog)\
**Replies:** 1\
**Last updated:** [February 1, 2026, 11:56am UTC](https://discourse.cmake.org/t/cmake-4-2-2-not-able-to-detect-vs2026-outside-developer-command-prompt/15478 "2026-02-01T11:56:26Z")

</div>

Good day. When setting up a new Win11 dev machine with VS2026 Community Edition I’m running into trouble that cmake doesn’t seem to be able to detect Visual Studio (specifically VS2026) unless it’s running inside the ‘Vi…

---

## [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…

---

## [C# SDK style projects Any CPU](https://discourse.cmake.org/t/c-sdk-style-projects-any-cpu/5913)

<div class="topic-metadata">

**Author:** [@mattsnowboard](https://discourse.cmake.org/u/mattsnowboard)\
**Replies:** 6\
**Last updated:** [October 21, 2025, 10:08pm UTC](https://discourse.cmake.org/t/c-sdk-style-projects-any-cpu/5913 "2025-10-21T22:08:22Z")

</div>

I can now generate SDK style projects for my C# projects in my c++/C# program. This has enabled me to use .NET6, which is nice. But my one problem is that the sln file generated for Visual Studio forces all of the proje…

---

## [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…

---

## [What is the proper configuration-dependent location for files created by add\_custom\_target or add\_custom\_command?](https://discourse.cmake.org/t/what-is-the-proper-configuration-dependent-location-for-files-created-by-add-custom-target-or-add-custom-command/15198)

<div class="topic-metadata">

**Author:** [@AytonDew](https://discourse.cmake.org/u/AytonDew)\
**Replies:** 0\
**Last updated:** [September 25, 2025, 7:02pm UTC](https://discourse.cmake.org/t/what-is-the-proper-configuration-dependent-location-for-files-created-by-add-custom-target-or-add-custom-command/15198 "2025-09-25T19:02:31Z")

</div>

Hello, I have been struggling with intermediate directories and where to place temporary files during the build when running custom commands. Is there a configuration-dependent location that a custom command can create …

---

## [does POST\_BUILD work with add\_custom\_target and Visual Studio?](https://discourse.cmake.org/t/does-post-build-work-with-add-custom-target-and-visual-studio/5290)

<div class="topic-metadata">

**Author:** [@dockd](https://discourse.cmake.org/u/dockd)\
**Replies:** 8\
**Last updated:** [August 17, 2025, 11:54pm UTC](https://discourse.cmake.org/t/does-post-build-work-with-add-custom-target-and-visual-studio/5290 "2025-08-17T23:54:58Z")

</div>

I build a static library and then want to add two more static libs to it after it is built. The documentation for add\_custom\_command/“BUILD EVENTS” says The command becomes part of the target and will only execute whe…

---

## [Can the VS 2019 generator be used if only VS2022 is installed?](https://discourse.cmake.org/t/can-the-vs-2019-generator-be-used-if-only-vs2022-is-installed/6972)

<div class="topic-metadata">

**Author:** [@Garrick](https://discourse.cmake.org/u/Garrick)\
**Replies:** 6\
**Last updated:** [July 30, 2025, 3:28pm UTC](https://discourse.cmake.org/t/can-the-vs-2019-generator-be-used-if-only-vs2022-is-installed/6972 "2025-07-30T15:28:26Z")

</div>

If Visual Studio 2022 is installed, including the older Toolset V142, and NO VS2019 is installed, can the ‘Visual Studio 16 2019 Generator’ be used, to create a solution targeting the old toolset? Our large application …

---

## [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…

---

## [MSBUILD : error MSB1009: no target all?](https://discourse.cmake.org/t/msbuild-error-msb1009-no-target-all/12892)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 4\
**Last updated:** [July 22, 2025, 5:13am UTC](https://discourse.cmake.org/t/msbuild-error-msb1009-no-target-all/12892 "2025-07-22T05:13:52Z")

</div>

C:\\Users\\KLEIN\_CL\\Workspace\\cpp\\execution26\>cmake --workflow --preset debug Executing workflow step 1 of 3: configure preset "debug" Preset CMake variables: CMAKE\_CXX\_EXTENSIONS:BOOL="FALSE" CMAKE\_CXX\_FLAGS="/W3 /E…

---

## [CCache with Visual Studio Generator causing files to be compiled always](https://discourse.cmake.org/t/ccache-with-visual-studio-generator-causing-files-to-be-compiled-always/11342)

<div class="topic-metadata">

**Author:** [@siddmohsin](https://discourse.cmake.org/u/siddmohsin)\
**Replies:** 1\
**Last updated:** [July 19, 2025, 1:55pm UTC](https://discourse.cmake.org/t/ccache-with-visual-studio-generator-causing-files-to-be-compiled-always/11342 "2025-07-19T13:55:11Z")

</div>

Hello All, I picked up compiler caching subject again for C++ on windows using Visual Studio Generator. I was reading ProfessionalCMake\_18th\_Edition.pdf and this book has complete section compiler cache wehere in compil…

---

## [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…

---

## [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…

---

## [Why are DLL builds bottlenecked by Linker calls?](https://discourse.cmake.org/t/why-are-dll-builds-bottlenecked-by-linker-calls/13973)

<div class="topic-metadata">

**Author:** [@zachdanz](https://discourse.cmake.org/u/zachdanz)\
**Replies:** 2\
**Last updated:** [April 28, 2025, 11:03pm UTC](https://discourse.cmake.org/t/why-are-dll-builds-bottlenecked-by-linker-calls/13973 "2025-04-28T23:03:24Z")

</div>

Hey Cmake Community! We build our project statically as well as dynamically, and we have noticed that when building with DLLs, the build is severely bottlenecked compared to its static lib OPTIMIZE\_DEPENDENCIES — CMake …

---

## [How to control the MSVC CRT with cmake?](https://discourse.cmake.org/t/how-to-control-the-msvc-crt-with-cmake/13195)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 1\
**Last updated:** [April 25, 2025, 11:28am UTC](https://discourse.cmake.org/t/how-to-control-the-msvc-crt-with-cmake/13195 "2025-04-25T11:28:34Z")

</div>

I I need to use MSVC v140 toolchain and QT v8.8.7 with an old version of OpenSSL. Both does’t support to mix debug and release builds out of the box. Warning LNK2038: defaultlib '\*library\* ' conflicts with use of other…

---

## [Old visual studio generators in recent cmake](https://discourse.cmake.org/t/old-visual-studio-generators-in-recent-cmake/13934)

<div class="topic-metadata">

**Author:** [@GiovaBx](https://discourse.cmake.org/u/GiovaBx)\
**Replies:** 7\
**Last updated:** [April 25, 2025, 10:34am UTC](https://discourse.cmake.org/t/old-visual-studio-generators-in-recent-cmake/13934 "2025-04-25T10:34:01Z")

</div>

Hi, I use cmake with conan to generate prebuild version of libraries for different Visual Studio version and architecture. We mostly use Visual Studio 2022 and 2019, but we still need to support new library version (bu…

---

## [Add CMakeLists.txt that only uses add\_subdirectory() to Visual Studio solution](https://discourse.cmake.org/t/add-cmakelists-txt-that-only-uses-add-subdirectory-to-visual-studio-solution/13903)

<div class="topic-metadata">

**Author:** [@Andreas](https://discourse.cmake.org/u/Andreas)\
**Replies:** 0\
**Last updated:** [April 9, 2025, 9:30am UTC](https://discourse.cmake.org/t/add-cmakelists-txt-that-only-uses-add-subdirectory-to-visual-studio-solution/13903 "2025-04-09T09:30:15Z")

</div>

We have the following structure /libs/CMakeLists.txt /libs/lib1/CMakeLists.txt /libs/lib1/src/... /libs/lib2/CMakeLists.txt /libs/lib2/src/... In /libs/CMakeLists.txt we only include other CMakeLists.txt files: add\_su…

---

## [CMP0143 seemingly not working, how to debug?](https://discourse.cmake.org/t/cmp0143-seemingly-not-working-how-to-debug/13828)

<div class="topic-metadata">

**Author:** [@aursulis](https://discourse.cmake.org/u/aursulis)\
**Replies:** 3\
**Last updated:** [March 27, 2025, 10:37pm UTC](https://discourse.cmake.org/t/cmp0143-seemingly-not-working-how-to-debug/13828 "2025-03-27T22:37:42Z")

</div>

Hi there, a colleague of mine was upgrading our CMake version from 3.24.2 to 3.31.6 (along with all the policy changes) and we stumbled upon some strange behaviour with the USE\_FOLDERS property which should now default t…

---

## [Using a compiler cache on Windows with MSVC?](https://discourse.cmake.org/t/using-a-compiler-cache-on-windows-with-msvc/13694)

<div class="topic-metadata">

**Author:** [@exoosh](https://discourse.cmake.org/u/exoosh)\
**Replies:** 2\
**Last updated:** [March 7, 2025, 2:24pm UTC](https://discourse.cmake.org/t/using-a-compiler-cache-on-windows-with-msvc/13694 "2025-03-07T14:24:07Z")

</div>

Hi, the documentation of \<LANG\>\_COMPILER\_LAUNCHER suggests — although not in very explicit terms — that only Unix Makefiles and Ninja are supported for this property: Specify a semicolon-separated list containing a co…

---

## [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…

[Next page](https://discourse.cmake.org/tag/gen-vs/9.md?match_all_tags=true&page=1&tags%5B%5D=gen%3Avs)
