# Usage

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

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

**Page:** 38

---

## [target\_include\_directories error](https://discourse.cmake.org/t/target-include-directories-error/9164)

<div class="topic-metadata">

**Author:** [@tanmayd26](https://discourse.cmake.org/u/tanmayd26)\
**Replies:** 10\
**Last updated:** [October 12, 2023, 6:49pm UTC](https://discourse.cmake.org/t/target-include-directories-error/9164 "2023-10-12T18:49:54Z")

</div>

This is snippet in my CMakeLists.txt. I have set the architecture but I still get error when I am making my packages.if(CUDA\_FOUND) enable\_language(CUDA) include(FindCUDA) set(CUDA\_PROPAGATE\_HOST\_FLAGS OFF) set(…

---

## [How to android development using cmake](https://discourse.cmake.org/t/how-to-android-development-using-cmake/8904)

<div class="topic-metadata">

**Author:** [@siddmohsin](https://discourse.cmake.org/u/siddmohsin)\
**Replies:** 1\
**Last updated:** [October 12, 2023, 12:44pm UTC](https://discourse.cmake.org/t/how-to-android-development-using-cmake/8904 "2023-10-12T12:44:34Z")

</div>

Hello All, We are using Visual Studio {rpfessional with CMake for our cross-platform builds. Currently, we are using “Visual Studio 17 2022” for Windows builds, “Ninja Multi-Config” for Linux/Android, and “Xcode” for ma…

---

## [Using a function to add items to a list](https://discourse.cmake.org/t/using-a-function-to-add-items-to-a-list/9178)

<div class="topic-metadata">

**Author:** [@EosPengwern](https://discourse.cmake.org/u/EosPengwern)\
**Replies:** 4\
**Last updated:** [October 11, 2023, 10:48pm UTC](https://discourse.cmake.org/t/using-a-function-to-add-items-to-a-list/9178 "2023-10-11T22:48:33Z")

</div>

I’m trying to write a CMake function that takes a list as an argument, and that adds items to the list, and then returns so that the caller can use the modified list. It sounds simple but I can’t get it to work. Here’s …

---

## [ctest "-I" does not behave as advertised in "Mastering CMake » Testing With CMake and CTest » Testing Using CTest"](https://discourse.cmake.org/t/ctest-i-does-not-behave-as-advertised-in-mastering-cmake-testing-with-cmake-and-ctest-testing-using-ctest/8682)

<div class="topic-metadata">

**Author:** [@davidp](https://discourse.cmake.org/u/davidp)\
**Replies:** 3\
**Last updated:** [October 11, 2023, 9:35pm UTC](https://discourse.cmake.org/t/ctest-i-does-not-behave-as-advertised-in-mastering-cmake-testing-with-cmake-and-ctest-testing-using-ctest/8682 "2023-10-11T21:35:54Z")

</div>

This post is provided as an informative one rather than a plea for help. I’ve successfully built my project using CMake; however, the CTest command line does behave as advertised when using the -I option (reference: Mas…

---

## [forcing find\_package to search only for the exact same build type than the calling target](https://discourse.cmake.org/t/forcing-find-package-to-search-only-for-the-exact-same-build-type-than-the-calling-target/9177)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 1\
**Last updated:** [October 11, 2023, 4:15pm UTC](https://discourse.cmake.org/t/forcing-find-package-to-search-only-for-the-exact-same-build-type-than-the-calling-target/9177 "2023-10-11T16:15:24Z")

</div>

Hi, I build targets with different possible build types: Debug (with my own flags) Release (with my own flags) Custom, with a given name I observed the following behavior, which, as far as I understand, is the default…

---

## [Question: wrong syntax with add\_custom\_command but cmake runs without errors?](https://discourse.cmake.org/t/question-wrong-syntax-with-add-custom-command-but-cmake-runs-without-errors/9174)

<div class="topic-metadata">

**Author:** [@berthin](https://discourse.cmake.org/u/berthin)\
**Replies:** 2\
**Last updated:** [October 11, 2023, 4:05pm UTC](https://discourse.cmake.org/t/question-wrong-syntax-with-add-custom-command-but-cmake-runs-without-errors/9174 "2023-10-11T16:05:37Z")

</div>

Hi, According to the documentation, the syntax for add\_custom\_command is: add\_custom\_command(OUTPUT output1 \[output2 ...\] COMMAND command1 \[ARGS\] \[args1...\] \[COMMAND command2 \[ARGS…

---

## [I am migrating my system from windows to Linux, and now want cmakefile.txt to be generated automatically for my source code, can I use the tool for the same](https://discourse.cmake.org/t/i-am-migrating-my-system-from-windows-to-linux-and-now-want-cmakefile-txt-to-be-generated-automatically-for-my-source-code-can-i-use-the-tool-for-the-same/9160)

<div class="topic-metadata">

**Author:** [@AYUSH\_KUMAR](https://discourse.cmake.org/u/AYUSH_KUMAR)\
**Replies:** 5\
**Last updated:** [October 10, 2023, 9:56pm UTC](https://discourse.cmake.org/t/i-am-migrating-my-system-from-windows-to-linux-and-now-want-cmakefile-txt-to-be-generated-automatically-for-my-source-code-can-i-use-the-tool-for-the-same/9160 "2023-10-10T21:56:23Z")

</div>

I am migrating my project from windows to Linux and want cmakefile .text to be generated automatically can I use cmake in any way. For the existing projects

---

## [DOCKER:CMAKE ERROR](https://discourse.cmake.org/t/docker-cmake-error/9163)

<div class="topic-metadata">

**Author:** [@tanmayd26](https://discourse.cmake.org/u/tanmayd26)\
**Replies:** 2\
**Last updated:** [October 10, 2023, 5:38pm UTC](https://discourse.cmake.org/t/docker-cmake-error/9163 "2023-10-10T17:38:47Z")

</div>

CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCUDACompiler.cmake:46 (message): The CUDA compiler “/usr/local/cuda-12.2/bin/nvcc” is not able to compile a simple test program. It fails with the following outp…

---

## [cuda architecture error](https://discourse.cmake.org/t/cuda-architecture-error/9166)

<div class="topic-metadata">

**Author:** [@tanmayd26](https://discourse.cmake.org/u/tanmayd26)\
**Replies:** 1\
**Last updated:** [October 10, 2023, 5:09pm UTC](https://discourse.cmake.org/t/cuda-architecture-error/9166 "2023-10-10T17:09:10Z")

</div>

This is snippet in my CMakeLists.txt. I have set the architecture but I still get error when I am making my packages.if(CUDA\_FOUND) enable\_language(CUDA) include(FindCUDA) set(CUDA\_PROPAGATE\_HOST\_FLAGS OFF) set(…

---

## [Usage of target\_sources() does not work](https://discourse.cmake.org/t/usage-of-target-sources-does-not-work/9157)

<div class="topic-metadata">

**Author:** [@ChristophR](https://discourse.cmake.org/u/ChristophR)\
**Replies:** 4\
**Last updated:** [October 10, 2023, 3:57pm UTC](https://discourse.cmake.org/t/usage-of-target-sources-does-not-work/9157 "2023-10-10T15:57:51Z")

</div>

Hello all, I am new to cmake and therefore sorry in advance if I missed the solution to my problem in this forum. Like many people, I have a project consisting of sub-directories with C files. I read that add\_subdirect…

---

## [CPack RPM : special situation for boost.mpi library](https://discourse.cmake.org/t/cpack-rpm-special-situation-for-boost-mpi-library/8874)

<div class="topic-metadata">

**Author:** [@MM77](https://discourse.cmake.org/u/MM77)\
**Replies:** 6\
**Last updated:** [October 10, 2023, 2:21pm UTC](https://discourse.cmake.org/t/cpack-rpm-special-situation-for-boost-mpi-library/8874 "2023-10-10T14:21:21Z")

</div>

This may not precisely a cpack question, but I thought to start asking here. I generate a binary .rpm file. That rpm requires (by checking rpm -q --requries) libboost\_mpi.so.1.78.0()(64bit) however, the Fedora inst…

---

## [FetchContent name clash overwrites my function](https://discourse.cmake.org/t/fetchcontent-name-clash-overwrites-my-function/9156)

<div class="topic-metadata">

**Author:** [@Barry\_Revzin](https://discourse.cmake.org/u/Barry_Revzin)\
**Replies:** 7\
**Last updated:** [October 9, 2023, 8:51pm UTC](https://discourse.cmake.org/t/fetchcontent-name-clash-overwrites-my-function/9156 "2023-10-09T20:51:59Z")

</div>

I am upgrading my version of {fmt} from 9.1 to 10.1.1. My repo has a Findfmt.cmake which starts off like: FetchContent\_Declare( fmt GIT\_REPOSITORY ... GIT\_TAG 9.1.0 OVERRIDE\_FIND\_PACKAGE ) And everythi…

---

## [Is it possible to build 32 bit and 64 bit projects in single root project](https://discourse.cmake.org/t/is-it-possible-to-build-32-bit-and-64-bit-projects-in-single-root-project/9134)

<div class="topic-metadata">

**Author:** [@Ram](https://discourse.cmake.org/u/Ram)\
**Replies:** 5\
**Last updated:** [October 4, 2023, 6:45am UTC](https://discourse.cmake.org/t/is-it-possible-to-build-32-bit-and-64-bit-projects-in-single-root-project/9134 "2023-10-04T06:45:50Z")

</div>

I have projectMain which is root cmake , which add project32bit and project64bit Problem is i am unable to change target build architecture of project64bit to 64 If i use -T target option that chaging entire project no…

---

## [How do I find the dll/so files used when linking an executable?](https://discourse.cmake.org/t/how-do-i-find-the-dll-so-files-used-when-linking-an-executable/9059)

<div class="topic-metadata">

**Author:** [@JRR](https://discourse.cmake.org/u/JRR)\
**Replies:** 5\
**Last updated:** [October 3, 2023, 5:34pm UTC](https://discourse.cmake.org/t/how-do-i-find-the-dll-so-files-used-when-linking-an-executable/9059 "2023-10-03T17:34:13Z")

</div>

Setup: Repository A creates a shared library that we have a relocatable packages for. Repository B creates a shared library that we have a relocatable package for. Moreover, Repo-B uses Repo-A, therefore Repo-A appears…

---

## [How to ignore 3rd-party sources from static analysis](https://discourse.cmake.org/t/how-to-ignore-3rd-party-sources-from-static-analysis/8596)

<div class="topic-metadata">

**Author:** [@decomplect](https://discourse.cmake.org/u/decomplect)\
**Replies:** 5\
**Last updated:** [October 3, 2023, 12:08pm UTC](https://discourse.cmake.org/t/how-to-ignore-3rd-party-sources-from-static-analysis/8596 "2023-10-03T12:08:01Z")

</div>

I’ve been using project options as a way to get some solid defaults for my projects without too much trouble. One problem I’ve been running into though is the CMAKE\_$LANG\_CPPCHECK defaults and how they apply to 3rd part…

---

## [proper way to define a dedicated target to build (and run) tests.](https://discourse.cmake.org/t/proper-way-to-define-a-dedicated-target-to-build-and-run-tests/9129)

<div class="topic-metadata">

**Author:** [@Stefan\_Seefeld](https://discourse.cmake.org/u/Stefan_Seefeld)\
**Replies:** 4\
**Last updated:** [October 3, 2023, 10:55am UTC](https://discourse.cmake.org/t/proper-way-to-define-a-dedicated-target-to-build-and-run-tests/9129 "2023-10-03T10:55:05Z")

</div>

I’m working on a fairly large project with many sub-components (libraries, executables, associated tests). Right now, the ALL target includes everything, so a typical workflow involves config, build, and test stages, rou…

---

## [FrameworkReference required for c++/cli project on .Net Core](https://discourse.cmake.org/t/frameworkreference-required-for-c-cli-project-on-net-core/8212)

<div class="topic-metadata">

**Author:** [@Yann\_Cudennec](https://discourse.cmake.org/u/Yann_Cudennec)\
**Replies:** 2\
**Last updated:** [October 2, 2023, 7:07pm UTC](https://discourse.cmake.org/t/frameworkreference-required-for-c-cli-project-on-net-core/8212 "2023-10-02T19:07:09Z")

</div>

In order to build a c++/cli project on dot net core I must have a vcxproj that includes \<ItemGroup\> \<FrameworkReference Include=“Microsoft.WindowsDesktop.App” /\> \</ItemGroup\> My build system is using CMake and I can’…

---

## [FetchContent\_MakeAvailable resets patches](https://discourse.cmake.org/t/fetchcontent-makeavailable-resets-patches/9127)

<div class="topic-metadata">

**Author:** [@BoyanH](https://discourse.cmake.org/u/BoyanH)\
**Replies:** 1\
**Last updated:** [October 2, 2023, 4:34pm UTC](https://discourse.cmake.org/t/fetchcontent-makeavailable-resets-patches/9127 "2023-10-02T16:34:19Z")

</div>

A dependency I use via FetchContent is itself pulling further dependencies via FetchContent, similarly to the snippet below. It seems that CMake is cloning the repo, then applying both patches and finally perfoming an u…

---

## [CMake Silent Install with Options Help](https://discourse.cmake.org/t/cmake-silent-install-with-options-help/1475)

<div class="topic-metadata">

**Author:** [@Fleischmann\_US\_Josep](https://discourse.cmake.org/u/Fleischmann_US_Josep)\
**Replies:** 3\
**Last updated:** [October 2, 2023, 2:10pm UTC](https://discourse.cmake.org/t/cmake-silent-install-with-options-help/1475 "2023-10-02T14:10:14Z")

</div>

Hi, I am trying to find the right command line to enter for silently installing CMake 3.15.5 while also having it autoselect the radio button “Add CMake to the system PATH for all users”. Everything I’ve tried so far re…

---

## [AppleClang 15 new linker general issues](https://discourse.cmake.org/t/appleclang-15-new-linker-general-issues/9106)

<div class="topic-metadata">

**Author:** [@scivision](https://discourse.cmake.org/u/scivision)\
**Replies:** 1\
**Last updated:** [September 30, 2023, 3:23pm UTC](https://discourse.cmake.org/t/appleclang-15-new-linker-general-issues/9106 "2023-09-30T15:23:25Z")

</div>

This is not a CMake issue, but people may open issues in projects using CMake as the new linker in AppleClang 15 is causing ld link warnings and errors. This may occur for try\_compile, check\_source\_compiles and similar a…

---

## [CMake fails with: "The C compiler '../cl.exe' is not able to compile a simple test program"](https://discourse.cmake.org/t/cmake-fails-with-the-c-compiler-cl-exe-is-not-able-to-compile-a-simple-test-program/9073)

<div class="topic-metadata">

**Author:** [@AngelDev06](https://discourse.cmake.org/u/AngelDev06)\
**Replies:** 20\
**Last updated:** [September 30, 2023, 3:22pm UTC](https://discourse.cmake.org/t/cmake-fails-with-the-c-compiler-cl-exe-is-not-able-to-compile-a-simple-test-program/9073 "2023-09-30T15:22:19Z")

</div>

I tried using cmake & ninja to build a simple project of mine and while it wasn’t an issue before when I was doing it with visual studio, I am now unable to do it with either the IDE or the command line because it fails …

---

## [How should one glob all files that end with .c, .h, or .S in a folder?](https://discourse.cmake.org/t/how-should-one-glob-all-files-that-end-with-c-h-or-s-in-a-folder/9099)

<div class="topic-metadata">

**Author:** [@f-zl](https://discourse.cmake.org/u/f-zl)\
**Replies:** 2\
**Last updated:** [September 27, 2023, 9:36pm UTC](https://discourse.cmake.org/t/how-should-one-glob-all-files-that-end-with-c-h-or-s-in-a-folder/9099 "2023-09-27T21:36:18Z")

</div>

I want to create a list of all .c, .h, .S files in a folder. file(GLOB SRCS \*.\[chS\]) fails to match .S files. file(GLOB SRCS \*.\[chs\]) does match all those files (on Windows) but it doesn’t look correct because .S files…

---

## [cmake shows -static-libstdc++ file missing when it existed on the LINUX system.](https://discourse.cmake.org/t/cmake-shows-static-libstdc-file-missing-when-it-existed-on-the-linux-system/9028)

<div class="topic-metadata">

**Author:** [@indianscorpion](https://discourse.cmake.org/u/indianscorpion)\
**Replies:** 18\
**Last updated:** [September 27, 2023, 5:30pm UTC](https://discourse.cmake.org/t/cmake-shows-static-libstdc-file-missing-when-it-existed-on-the-linux-system/9028 "2023-09-27T17:30:00Z")

</div>

Below code failed to run, why? How to fix? – Performing Test STATIC\_SYSTEM\_LIBS – Performing Test STATIC\_SYSTEM\_LIBS - Failed set(CMAKE\_SHARED\_LINKER\_FLAGS "${CMAKE\_SHARED\_LINKER\_FLAGS} -static-libgcc -static-libstd…

---

## [Overriding CPack variables](https://discourse.cmake.org/t/overriding-cpack-variables/9083)

<div class="topic-metadata">

**Author:** [@MathiasMagnus](https://discourse.cmake.org/u/MathiasMagnus)\
**Replies:** 6\
**Last updated:** [September 27, 2023, 3:07pm UTC](https://discourse.cmake.org/t/overriding-cpack-variables/9083 "2023-09-27T15:07:07Z")

</div>

I’m having trouble with CPack, specifically its behavior of -D variables on the CLI not overriding those found in CPackSourceConfig.cmake. The documentation says: Set a CPack variable. This will override any value set …

---

## [in CMakePresets.json, allow trailing commas](https://discourse.cmake.org/t/in-cmakepresets-json-allow-trailing-commas/9077)

<div class="topic-metadata">

**Author:** [@burtonrodman](https://discourse.cmake.org/u/burtonrodman)\
**Replies:** 9\
**Last updated:** [September 27, 2023, 12:38pm UTC](https://discourse.cmake.org/t/in-cmakepresets-json-allow-trailing-commas/9077 "2023-09-27T12:38:44Z")

</div>

in CMakePresets.json, comments are currently allowed. Please relax the parser to allow trailing commas. cmake --list-presets CMake Error: Could not read presets from /workspaces/nf-interpreter: JSON parse error

---

## [BUG: in CMakePresets.json, when a file can't be found, the offending file name is not reported.](https://discourse.cmake.org/t/bug-in-cmakepresets-json-when-a-file-cant-be-found-the-offending-file-name-is-not-reported/9076)

<div class="topic-metadata">

**Author:** [@burtonrodman](https://discourse.cmake.org/u/burtonrodman)\
**Replies:** 2\
**Last updated:** [September 27, 2023, 2:00am UTC](https://discourse.cmake.org/t/bug-in-cmakepresets-json-when-a-file-cant-be-found-the-offending-file-name-is-not-reported/9076 "2023-09-27T02:00:16Z")

</div>

in CMakePresets.json, if one adds an include that references a file that can’t be found, the error message is simple “File not found”. Please list the name of the missing file. cmake --list-presets CMake Error: Could …

---

## [Porting project for ESP32](https://discourse.cmake.org/t/porting-project-for-esp32/9088)

<div class="topic-metadata">

**Author:** [@Vidar\_Freyr\_Gudmunds](https://discourse.cmake.org/u/Vidar_Freyr_Gudmunds)\
**Replies:** 1\
**Last updated:** [September 26, 2023, 6:25pm UTC](https://discourse.cmake.org/t/porting-project-for-esp32/9088 "2023-09-26T18:25:47Z")

</div>

Hey fellow software people. I want to port this here framework for DASH7 protocol for LoRa for use with the ESP32 platform. They even have a section about porting: https://sub-iot.github.io/Sub-IoT-Stack/docs/porting/ …

---

## [Migrating CMakeSettings.json over to CMakePresets.json and integrating with Linux workflow](https://discourse.cmake.org/t/migrating-cmakesettings-json-over-to-cmakepresets-json-and-integrating-with-linux-workflow/9092)

<div class="topic-metadata">

**Author:** [@TryerGit](https://discourse.cmake.org/u/TryerGit)\
**Replies:** 0\
**Last updated:** [September 26, 2023, 2:10am UTC](https://discourse.cmake.org/t/migrating-cmakesettings-json-over-to-cmakepresets-json-and-integrating-with-linux-workflow/9092 "2023-09-26T02:10:11Z")

</div>

Hello, According to official Visual Studio docs (see here), they recommend not using CMakeSettings.json but use CMakePresets.json.going forward. Visual Studio IDE (VSIDE) continues to support CMakeSettings.json as of no…

---

## [Generator Expression using Custom Configuration Name](https://discourse.cmake.org/t/generator-expression-using-custom-configuration-name/9042)

<div class="topic-metadata">

**Author:** [@pcd3897](https://discourse.cmake.org/u/pcd3897)\
**Replies:** 6\
**Last updated:** [September 25, 2023, 1:52pm UTC](https://discourse.cmake.org/t/generator-expression-using-custom-configuration-name/9042 "2023-09-25T13:52:48Z")

</div>

I am working with the Visual Studio Generator. I created custom configuration types using -DCMAKE\_CONFIGURATION\_TYPES="Custom-1;Custom-2" when calling CMAKE. My CMAKELISTS.txt uses the config type like this: set(Var1 $\<$…

---

## [How to add additional directories to RSYNC used in Visual Studio 2019 Remote Linux Development using CMAKE](https://discourse.cmake.org/t/how-to-add-additional-directories-to-rsync-used-in-visual-studio-2019-remote-linux-development-using-cmake/9001)

<div class="topic-metadata">

**Author:** [@pcd3897](https://discourse.cmake.org/u/pcd3897)\
**Replies:** 4\
**Last updated:** [September 24, 2023, 1:05pm UTC](https://discourse.cmake.org/t/how-to-add-additional-directories-to-rsync-used-in-visual-studio-2019-remote-linux-development-using-cmake/9001 "2023-09-24T13:05:47Z")

</div>

I have a folder structure as shown below. When I refer to project I mean in the CMAKE sense. Root folder: --Project A Root: ----CMakelists.txt ----CMakeSettings.json ----Target (executable) Root: ------src --Project B R…

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

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