# Usage

**URL:** https://discourse.cmake.org/c/usage/12.md?page=23

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

**Page:** 24

---

## [FetchContent\_Declare with CMAKE\_ARGS does not work](https://discourse.cmake.org/t/fetchcontent-declare-with-cmake-args-does-not-work/11227)

<div class="topic-metadata">

**Author:** [@buildtool](https://discourse.cmake.org/u/buildtool)\
**Replies:** 7\
**Last updated:** [July 13, 2024, 6:30am UTC](https://discourse.cmake.org/t/fetchcontent-declare-with-cmake-args-does-not-work/11227 "2024-07-13T06:30:10Z")

</div>

Consider this example. FetchContent\_Declare( glfw GIT\_REPOSITORY https://github.com/glfw/glfw.git GIT\_TAG "master" SOURCE\_DIR "${CMAKE\_CURRENT\_SOURCE\_DIR}/glfw-src" GIT\_SHALLOW TRUE…

---

## [launching powershell script from cmake](https://discourse.cmake.org/t/launching-powershell-script-from-cmake/7844)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 6\
**Last updated:** [July 12, 2024, 6:06am UTC](https://discourse.cmake.org/t/launching-powershell-script-from-cmake/7844 "2024-07-12T06:06:15Z")

</div>

Hi, This question is linked with #7833. I designed a powershell script that can take a path from CLI and add it to user path. I can run the script from a powershell or a cmd terminal but not from CMake. I tried: exec…

---

## [Handling of imported shared libraries' runtime files for relocatable builds/packages on Windows and Linux when properties contain generator expressions](https://discourse.cmake.org/t/handling-of-imported-shared-libraries-runtime-files-for-relocatable-builds-packages-on-windows-and-linux-when-properties-contain-generator-expressions/11108)

<div class="topic-metadata">

**Author:** [@Gulasch](https://discourse.cmake.org/u/Gulasch)\
**Replies:** 1\
**Last updated:** [July 11, 2024, 10:45am UTC](https://discourse.cmake.org/t/handling-of-imported-shared-libraries-runtime-files-for-relocatable-builds-packages-on-windows-and-linux-when-properties-contain-generator-expressions/11108 "2024-07-11T10:45:15Z")

</div>

TL;DR: How is the generator expression $\<TARGET\_RUNTIME\_DLLS:..\> able to (recursively?) iterate over all linked targets at generation time and can I replicate the behaviour for Linux’ shared objects somehow? Project ba…

---

## [FindOpenMP fails with CMake 3.30 with WIndows VisualStudio 2019](https://discourse.cmake.org/t/findopenmp-fails-with-cmake-3-30-with-windows-visualstudio-2019/11210)

<div class="topic-metadata">

**Author:** [@bldrvnlw](https://discourse.cmake.org/u/bldrvnlw)\
**Replies:** 1\
**Last updated:** [July 10, 2024, 10:02pm UTC](https://discourse.cmake.org/t/findopenmp-fails-with-cmake-3-30-with-windows-visualstudio-2019/11210 "2024-07-10T22:02:18Z")

</div>

We have a CMakeLists.txt used on several platforms (Linux, Macos and Windows) that includes find\_package(OpenMP REQUIRED) This worked on all platforms with CMake \< 3.3.0 but fails on Windows with 3.30 CMake Error at …

---

## [What is the advantage of using $\<BUILD\_INTERFACE\>?](https://discourse.cmake.org/t/what-is-the-advantage-of-using-build-interface/11206)

<div class="topic-metadata">

**Author:** [@cmonkey](https://discourse.cmake.org/u/cmonkey)\
**Replies:** 2\
**Last updated:** [July 10, 2024, 9:55pm UTC](https://discourse.cmake.org/t/what-is-the-advantage-of-using-build-interface/11206 "2024-07-10T21:55:28Z")

</div>

I couldn’t make sense of this line in the Getting started tutorial: target\_compile\_options(tutorial\_compiler\_flags INTERFACE "$\<${gcc\_like\_cxx}:$\<BUILD\_INTERFACE:-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused\>\>" "$\<${ms…

---

## [What's happened to the Cmake GUI?](https://discourse.cmake.org/t/whats-happened-to-the-cmake-gui/11204)

<div class="topic-metadata">

**Author:** [@Nocaster60](https://discourse.cmake.org/u/Nocaster60)\
**Replies:** 1\
**Last updated:** [July 10, 2024, 3:31pm UTC](https://discourse.cmake.org/t/whats-happened-to-the-cmake-gui/11204 "2024-07-10T15:31:57Z")

</div>

Installing 3.30 in WIndows 10 the CMake GUI text is massive. How do I get it back to what it was? I tried QT\_FONT\_DPI but fixing the fonts in CMake messes them up in other applications including, believe it or not, runni…

---

## [Attempting to write a CMake function that does testing with an interactive prompt.](https://discourse.cmake.org/t/attempting-to-write-a-cmake-function-that-does-testing-with-an-interactive-prompt/11190)

<div class="topic-metadata">

**Author:** [@jymchng](https://discourse.cmake.org/u/jymchng)\
**Replies:** 7\
**Last updated:** [July 9, 2024, 3:47pm UTC](https://discourse.cmake.org/t/attempting-to-write-a-cmake-function-that-does-testing-with-an-interactive-prompt/11190 "2024-07-09T15:47:03Z")

</div>

\# https://stackoverflow.com/a/54675911/19504610 FUNCTION(command\_line\_test test\_executable input\_arguments expected\_output expected\_error) EXECUTE\_PROCESS( COMMAND "echo \\"${input\_argumen…

---

## [Question about simple multi target project setup and code sharing](https://discourse.cmake.org/t/question-about-simple-multi-target-project-setup-and-code-sharing/11178)

<div class="topic-metadata">

**Author:** [@miniman](https://discourse.cmake.org/u/miniman)\
**Replies:** 1\
**Last updated:** [July 8, 2024, 8:53pm UTC](https://discourse.cmake.org/t/question-about-simple-multi-target-project-setup-and-code-sharing/11178 "2024-07-08T20:53:59Z")

</div>

Hi I’m quite new to setting up my own CMake projects and I have an issue I have not been able to solve yet despite searching around some. Maybe you can help me or point me in the right direction? I have a C project wit…

---

## [How to force target\_link\_libraries to link only dependency, no additional include directories?](https://discourse.cmake.org/t/how-to-force-target-link-libraries-to-link-only-dependency-no-additional-include-directories/11186)

<div class="topic-metadata">

**Author:** [@davemilter](https://discourse.cmake.org/u/davemilter)\
**Replies:** 1\
**Last updated:** [July 8, 2024, 8:11pm UTC](https://discourse.cmake.org/t/how-to-force-target-link-libraries-to-link-only-dependency-no-additional-include-directories/11186 "2024-07-08T20:11:16Z")

</div>

Here minimal example: cmake\_minimum\_required(VERSION 3.17 FATAL\_ERROR) project(foo) add\_library(lib1 OBJECT lib1/lib1.cpp lib1/lib1.hpp) target\_include\_directories(lib1 PUBLIC lib1) add\_library(lib2 OBJECT lib2/lib2.…

---

## [target\_link\_libraries appears to link libraries twice](https://discourse.cmake.org/t/target-link-libraries-appears-to-link-libraries-twice/11164)

<div class="topic-metadata">

**Author:** [@DavidA](https://discourse.cmake.org/u/DavidA)\
**Replies:** 2\
**Last updated:** [July 8, 2024, 7:19pm UTC](https://discourse.cmake.org/t/target-link-libraries-appears-to-link-libraries-twice/11164 "2024-07-08T19:19:25Z")

</div>

Hi, I have a CMakeLists.txt file that builds a static library using gcc 12. We need to link in many Intel DPDK libraries, which we do as follows: target\_link\_libraries(${\_kernel\_lib\_name} -Wl,--as-needed -Wl,--…

---

## [How to skip conversion of /permissive into \<ConformanceMode\>](https://discourse.cmake.org/t/how-to-skip-conversion-of-permissive-into-conformancemode/11193)

<div class="topic-metadata">

**Author:** [@Nekto](https://discourse.cmake.org/u/Nekto)\
**Replies:** 1\
**Last updated:** [July 8, 2024, 3:54pm UTC](https://discourse.cmake.org/t/how-to-skip-conversion-of-permissive-into-conformancemode/11193 "2024-07-08T15:54:52Z")

</div>

Hi, C++20 in MSVC enables standard conformance. I would like to disable it for now. CMake properly converts /permissive flag into false in .vcxproj. And MSBuild adds /permissive flag to compilation. The problem is that …

---

## [How to make Cmake build only the test binaries without making the other executables?](https://discourse.cmake.org/t/how-to-make-cmake-build-only-the-test-binaries-without-making-the-other-executables/11181)

<div class="topic-metadata">

**Author:** [@jymchng](https://discourse.cmake.org/u/jymchng)\
**Replies:** 2\
**Last updated:** [July 8, 2024, 8:13am UTC](https://discourse.cmake.org/t/how-to-make-cmake-build-only-the-test-binaries-without-making-the-other-executables/11181 "2024-07-08T08:13:21Z")

</div>

Hi, I am about 3 days old to Cmake, lol. I have read the relevant chapters in Professional Cmake book but have not found the answer to my question. Here is my CMakeList.txt cmake\_minimum\_required(VERSION 3.21) include…

---

## [Target INSTALL not restoring nuget package?](https://discourse.cmake.org/t/target-install-not-restoring-nuget-package/11183)

<div class="topic-metadata">

**Author:** [@Holt59](https://discourse.cmake.org/u/Holt59)\
**Replies:** 2\
**Last updated:** [July 8, 2024, 6:46am UTC](https://discourse.cmake.org/t/target-install-not-restoring-nuget-package/11183 "2024-07-08T06:46:53Z")

</div>

I have a C# project that uses VS\_PACKAGE\_REFERENCES, so I need to set CMAKE\_VS\_NUGET\_PACKAGE\_RESTORE to build it (https://gitlab.kitware.com/cmake/cmake/-/issues/20646). When building using cmake --build build --target …

---

## [CMAKE\_CXX\_CLANG\_TIDY error : unknown argument: '-external:IC:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.22621.0\\ucrt'](https://discourse.cmake.org/t/cmake-cxx-clang-tidy-error-unknown-argument-external-program-files-x86-windows-kits-10-include-10-0-22621-0-ucrt/11169)

<div class="topic-metadata">

**Author:** [@mickae1](https://discourse.cmake.org/u/mickae1)\
**Replies:** 2\
**Last updated:** [July 5, 2024, 3:02pm UTC](https://discourse.cmake.org/t/cmake-cxx-clang-tidy-error-unknown-argument-external-program-files-x86-windows-kits-10-include-10-0-22621-0-ucrt/11169 "2024-07-05T15:02:26Z")

</div>

I’m using CMake with visual studio 2022, When I try to use CMAKE\_CXX\_CLANG\_TIDY , it doesn’t work, because visual studio 2022 use: -external:I How Can I fix it ?

---

## [Using SYSTEM for targets, but still check for changes](https://discourse.cmake.org/t/using-system-for-targets-but-still-check-for-changes/11172)

<div class="topic-metadata">

**Author:** [@martijntje](https://discourse.cmake.org/u/martijntje)\
**Replies:** 13\
**Last updated:** [July 5, 2024, 3:01pm UTC](https://discourse.cmake.org/t/using-system-for-targets-but-still-check-for-changes/11172 "2024-07-05T15:01:40Z")

</div>

I’m running into the following issue: We have targets that set their include paths with the SYSTEM property. We need to include them this way, because they contain code that would trigger warnings otherwise, and we have …

---

## [FILE(DOWNLOAD....) How to get more informative error messages](https://discourse.cmake.org/t/file-download-how-to-get-more-informative-error-messages/11118)

<div class="topic-metadata">

**Author:** [@imikejackson](https://discourse.cmake.org/u/imikejackson)\
**Replies:** 4\
**Last updated:** [July 1, 2024, 10:07pm UTC](https://discourse.cmake.org/t/file-download-how-to-get-more-informative-error-messages/11118 "2024-07-01T22:07:37Z")

</div>

As part of our project we generate a CMake file with these contents: # ----------------------------------------------------------------------- cmake\_policy(SET CMP0012 NEW) cmake\_policy(SET CMP0054 NEW) # -------------…

---

## [ccmake variable name column width](https://discourse.cmake.org/t/ccmake-variable-name-column-width/11143)

<div class="topic-metadata">

**Author:** [@hebasto](https://discourse.cmake.org/u/hebasto)\
**Replies:** 1\
**Last updated:** [July 1, 2024, 1:31pm UTC](https://discourse.cmake.org/t/ccmake-variable-name-column-width/11143 "2024-07-01T13:31:14Z")

</div>

Is there a way to increase the variable name column width for the ccmake tool?

---

## [How to choose Visual Studio Preview Generator](https://discourse.cmake.org/t/how-to-choose-visual-studio-preview-generator/11135)

<div class="topic-metadata">

**Author:** [@KStocky](https://discourse.cmake.org/u/KStocky)\
**Replies:** 1\
**Last updated:** [June 30, 2024, 8:56pm UTC](https://discourse.cmake.org/t/how-to-choose-visual-studio-preview-generator/11135 "2024-06-30T20:56:06Z")

</div>

Hi! I have just had an interesting issue where I deleted my build folder to recreate everything and CMake has now decided to use my VS 2022 installation as my generator instead of my VS 2022 Preview installation. This l…

---

## [cmake error while building ourCraft](https://discourse.cmake.org/t/cmake-error-while-building-ourcraft/11132)

<div class="topic-metadata">

**Author:** [@Philipbox](https://discourse.cmake.org/u/Philipbox)\
**Replies:** 1\
**Last updated:** [June 29, 2024, 10:41pm UTC](https://discourse.cmake.org/t/cmake-error-while-building-ourcraft/11132 "2024-06-29T22:41:23Z")

</div>

\[ 64%\] Building CXX object CMakeFiles/ourCraft.dir/src/gameLayer/chunkSystem.cpp.o In file included from /run/media/philip//Downloads/ourCraft-master/thirdparty/gl2d/include/gl2d/gl2d.h:60, from /run/media/philip//Down…

---

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

---

## [\[Issue\] CMake error invoke sh](https://discourse.cmake.org/t/issue-cmake-error-invoke-sh/11119)

<div class="topic-metadata">

**Author:** [@TritiumXs](https://discourse.cmake.org/u/TritiumXs)\
**Replies:** 1\
**Last updated:** [June 27, 2024, 10:14pm UTC](https://discourse.cmake.org/t/issue-cmake-error-invoke-sh/11119 "2024-06-27T22:14:33Z")

</div>

When I am using PowerShell and VS Code, CMake incorrectly invoked the sh in MSYS, and the sh in msys2 incorrectly handled Windows-style paths, which resulted in my clang not being called correctly. How should I handle th…

---

## [CMake always rebuilds the whole project even though I haven't made any changes when I use a specific compiler. How to diagnose?](https://discourse.cmake.org/t/cmake-always-rebuilds-the-whole-project-even-though-i-havent-made-any-changes-when-i-use-a-specific-compiler-how-to-diagnose/11064)

<div class="topic-metadata">

**Author:** [@nahso](https://discourse.cmake.org/u/nahso)\
**Replies:** 11\
**Last updated:** [June 26, 2024, 1:45pm UTC](https://discourse.cmake.org/t/cmake-always-rebuilds-the-whole-project-even-though-i-havent-made-any-changes-when-i-use-a-specific-compiler-how-to-diagnose/11064 "2024-06-26T13:45:46Z")

</div>

CMake always rebuilds the whole project even though I haven’t made any changes when I use the mpiFCCpx. It is a clang-based compiler in supercomputer Fugaku. But gcc does not have this issue. And this issue only occurs …

---

## [find\_package OPTIONAL\_COMPONENT](https://discourse.cmake.org/t/find-package-optional-component/7856)

<div class="topic-metadata">

**Author:** [@codeling](https://discourse.cmake.org/u/codeling)\
**Replies:** 4\
**Last updated:** [June 25, 2024, 7:07am UTC](https://discourse.cmake.org/t/find-package-optional-component/7856 "2024-06-25T07:07:09Z")

</div>

find\_package(Qt${QT\_VERSION\_MAJOR} REQUIRED Concurrent Gui OpenGL Svg Widgets Xml OPTIONAL\_COMPONENTS Charts HttpServer WebSockets) I’m trying to find the Qt package, with some required and some optional components. Th…

---

## [Cmake asks me to make a post here, unknown platform Platform/MINGW64\_NT-10.0-19045](https://discourse.cmake.org/t/cmake-asks-me-to-make-a-post-here-unknown-platform-platform-mingw64-nt-10-0-19045/11096)

<div class="topic-metadata">

**Author:** [@dzdg6mm\_dzdg6mm](https://discourse.cmake.org/u/dzdg6mm_dzdg6mm)\
**Replies:** 0\
**Last updated:** [June 24, 2024, 11:04pm UTC](https://discourse.cmake.org/t/cmake-asks-me-to-make-a-post-here-unknown-platform-platform-mingw64-nt-10-0-19045/11096 "2024-06-24T23:04:52Z")

</div>

Cmake wants me to make a post here. System is unknown to cmake, create: Platform/MINGW64\_NT-10.0-19045 to use this system, please post your config file on discourse.cmake.org so it can be added to cmake -- Check size of…

---

## [Stop clean from removing custom file?](https://discourse.cmake.org/t/stop-clean-from-removing-custom-file/11087)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 1\
**Last updated:** [June 24, 2024, 8:10pm UTC](https://discourse.cmake.org/t/stop-clean-from-removing-custom-file/11087 "2024-06-24T20:10:11Z")

</div>

Hi, we have a custom command/target that EDITS a file. The file is in git and may be changed by the build. The developer can then modify and commit it. The problem is, since that file is marked as GENERATED, the file is…

---

## [Included CMake files not part of Visual Studio projects ?](https://discourse.cmake.org/t/included-cmake-files-not-part-of-visual-studio-projects/7437)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 2\
**Last updated:** [June 23, 2024, 2:14pm UTC](https://discourse.cmake.org/t/included-cmake-files-not-part-of-visual-studio-projects/7437 "2024-06-23T14:14:33Z")

</div>

Hi, using cmake 3.24 and Visual Studio (not Code) I can’t find the cmake files which are used in the project in the “Solution Explorer” widget. I see the CMakeLists.txt, but I cannot find the other cmake files, which h…

---

## [Installing CMake on Ubuntu](https://discourse.cmake.org/t/installing-cmake-on-ubuntu/10528)

<div class="topic-metadata">

**Author:** [@monamimani](https://discourse.cmake.org/u/monamimani)\
**Replies:** 4\
**Last updated:** [June 21, 2024, 9:01pm UTC](https://discourse.cmake.org/t/installing-cmake-on-ubuntu/10528 "2024-06-21T21:01:34Z")

</div>

Is the instruction here “https://apt.kitware.com/” are still supported and updated? And if yes is there a reason why the shell script states that only Focal and Jammy are supported and block Mantic and Noble,…? I also …

---

## [Different target dependencies in cmake --graphviz and file-api output](https://discourse.cmake.org/t/different-target-dependencies-in-cmake-graphviz-and-file-api-output/11058)

<div class="topic-metadata">

**Author:** [@kvnruss](https://discourse.cmake.org/u/kvnruss)\
**Replies:** 2\
**Last updated:** [June 20, 2024, 5:08pm UTC](https://discourse.cmake.org/t/different-target-dependencies-in-cmake-graphviz-and-file-api-output/11058 "2024-06-20T17:08:04Z")

</div>

Hi, I want to read cmake target dependencies and other details like type/path via the cmake file-api for a SBOM (software bill of materials) tool I’m working on. For this use-case I’m only interested in the direct depe…

---

## [FindPython does not find Development directory](https://discourse.cmake.org/t/findpython-does-not-find-development-directory/11066)

<div class="topic-metadata">

**Author:** [@AmauryW](https://discourse.cmake.org/u/AmauryW)\
**Replies:** 4\
**Last updated:** [June 20, 2024, 2:39pm UTC](https://discourse.cmake.org/t/findpython-does-not-find-development-directory/11066 "2024-06-20T14:39:13Z")

</div>

Hello, I have some CMake code that tries to find Python with the following lines \_set\_default( arg\_VERSION 3.9 ) find\_package( Python ${arg\_VERSION} COMPONENTS Interpreter Development) However, it fails to fi…

---

## [Uncaught exception when trying to generate a project using Ninja Multi-Config](https://discourse.cmake.org/t/uncaught-exception-when-trying-to-generate-a-project-using-ninja-multi-config/11051)

<div class="topic-metadata">

**Author:** [@oqqet](https://discourse.cmake.org/u/oqqet)\
**Replies:** 1\
**Last updated:** [June 19, 2024, 10:24pm UTC](https://discourse.cmake.org/t/uncaught-exception-when-trying-to-generate-a-project-using-ninja-multi-config/11051 "2024-06-19T22:24:42Z")

</div>

Ninja Multi-Config crashes with uncaught exception when trying to add a subfolder where its CMakeLists.txt defines different configuration types than the main project CMakeLists.txt does. The issue is reproducible with …

[Previous page](https://discourse.cmake.org/c/usage/12.md?page=22)

[Next page](https://discourse.cmake.org/c/usage/12.md?page=24)
