# Usage

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

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

**Page:** 26

---

## [How to modify the makefile post build: gstrip item to adapt to the Cmake project](https://discourse.cmake.org/t/how-to-modify-the-makefile-post-build-gstrip-item-to-adapt-to-the-cmake-project/10278)

<div class="topic-metadata">

**Author:** [@Bruce\_Ye](https://discourse.cmake.org/u/Bruce_Ye)\
**Replies:** 9\
**Last updated:** [May 22, 2024, 8:07am UTC](https://discourse.cmake.org/t/how-to-modify-the-makefile-post-build-gstrip-item-to-adapt-to-the-cmake-project/10278 "2024-05-22T08:07:52Z")

</div>

I am trying to build my project using Cmake to replace the work of the IDE（S32DS for GHS）. How to modify IDE makefile scripts to adapt to C make syntax? post-build: -gstrip -r=.debug\_frame S32K344\_DEMO\_20.elf -@echo …

---

## [What is the difference between cmake\_policy specifying only min or specifying min and max at the same time?](https://discourse.cmake.org/t/what-is-the-difference-between-cmake-policy-specifying-only-min-or-specifying-min-and-max-at-the-same-time/10864)

<div class="topic-metadata">

**Author:** [@hq354974212](https://discourse.cmake.org/u/hq354974212)\
**Replies:** 2\
**Last updated:** [May 20, 2024, 5:18am UTC](https://discourse.cmake.org/t/what-is-the-difference-between-cmake-policy-specifying-only-min-or-specifying-min-and-max-at-the-same-time/10864 "2024-05-20T05:18:52Z")

</div>

I tried the following two ways of writing: cmake\_policy(VERSION 3.24) cmake\_policy(VERSION 3.20…3.24) the other test code is: cmake\_policy(GET CMP0139 v) message("CMP0143=${v} ") #CMake 3.22 （…

---

## [Suppress "System is unknown to cmake" warning](https://discourse.cmake.org/t/suppress-system-is-unknown-to-cmake-warning/10656)

<div class="topic-metadata">

**Author:** [@erinnl](https://discourse.cmake.org/u/erinnl)\
**Replies:** 3\
**Last updated:** [May 18, 2024, 12:53pm UTC](https://discourse.cmake.org/t/suppress-system-is-unknown-to-cmake-warning/10656 "2024-05-18T12:53:30Z")

</div>

I wrote a toolchain file for a proprietary platform covered by NDAs. I was looking for a way to suppress the following warning that I can embed in the toolchain file itself. This warning is for project developers. Use…

---

## [Coverage tool for cmake](https://discourse.cmake.org/t/coverage-tool-for-cmake/10643)

<div class="topic-metadata">

**Author:** [@pkiran](https://discourse.cmake.org/u/pkiran)\
**Replies:** 6\
**Last updated:** [May 17, 2024, 1:47pm UTC](https://discourse.cmake.org/t/coverage-tool-for-cmake/10643 "2024-05-17T13:47:43Z")

</div>

Hello, We have a lot of lines of code in cmake, maintained by multiple teams. I was wondering if there is some kind of a coverage tool for cmake itself, which helps to identify dead code. Thanks

---

## [What is the use of target\_link\_libraries( ... PUBLIC ... )?](https://discourse.cmake.org/t/what-is-the-use-of-target-link-libraries-public/10839)

<div class="topic-metadata">

**Author:** [@dabrahams](https://discourse.cmake.org/u/dabrahams)\
**Replies:** 7\
**Last updated:** [May 15, 2024, 1:28pm UTC](https://discourse.cmake.org/t/what-is-the-use-of-target-link-libraries-public/10839 "2024-05-15T13:28:45Z")

</div>

If I’m reading the documentation correctly, the difference between the target\_link\_libraries signature without PUBLIC|PRIVATE|INTERFACE and the one with PUBLIC is that the former propagates the link dependency transitive…

---

## [CDash: Remove old builds](https://discourse.cmake.org/t/cdash-remove-old-builds/8617)

<div class="topic-metadata">

**Author:** [@codeling](https://discourse.cmake.org/u/codeling)\
**Replies:** 3\
**Last updated:** [May 16, 2024, 10:25am UTC](https://discourse.cmake.org/t/cdash-remove-old-builds/8617 "2024-05-16T10:25:36Z")

</div>

I just recently upgraded to CDash 3.1 and had a bit of a hard time figuring out how old builds are now removed; Long story short, there seem to be two ways: in .env, add AUTOREMOVE\_BUILDS=true, then old builds should b…

---

## [CMake's cross-compilation variables for the toolchain generator project](https://discourse.cmake.org/t/cmakes-cross-compilation-variables-for-the-toolchain-generator-project/10861)

<div class="topic-metadata">

**Author:** [@Kentzo](https://discourse.cmake.org/u/Kentzo)\
**Replies:** 0\
**Last updated:** [May 15, 2024, 3:11pm UTC](https://discourse.cmake.org/t/cmakes-cross-compilation-variables-for-the-toolchain-generator-project/10861 "2024-05-15T15:11:20Z")

</div>

My CMake project generates the toolchain (tooling, libraries etc, including the toolchain file), for the downstream CMake projects. Some of my dependencies are CMake projects, others use 3rd party systems. At this momen…

---

## [Ninja generator not detecting changes to custom command dependencies](https://discourse.cmake.org/t/ninja-generator-not-detecting-changes-to-custom-command-dependencies/10849)

<div class="topic-metadata">

**Author:** [@martingalvan-volue](https://discourse.cmake.org/u/martingalvan-volue)\
**Replies:** 2\
**Last updated:** [May 14, 2024, 2:25pm UTC](https://discourse.cmake.org/t/ninja-generator-not-detecting-changes-to-custom-command-dependencies/10849 "2024-05-14T14:25:26Z")

</div>

Hi, I’m using CMake 3.29.0-rc3 on Windows 11, with the Ninja generator. I have a project with a custom command which generates a header file called gen.h, depending on an input.txt. The CMakeLists.txt looks like this: …

---

## [Dependencies when using custom commands](https://discourse.cmake.org/t/dependencies-when-using-custom-commands/10780)

<div class="topic-metadata">

**Author:** [@martingalvan-volue](https://discourse.cmake.org/u/martingalvan-volue)\
**Replies:** 8\
**Last updated:** [May 14, 2024, 1:47pm UTC](https://discourse.cmake.org/t/dependencies-when-using-custom-commands/10780 "2024-05-14T13:47:10Z")

</div>

According to https://cmake.org/cmake/help/latest/command/add\_custom\_command.html#example-generating-files-for-multiple-targets the recommended practice when multiple targets depend on a file generated through a custom co…

---

## [CMake + Catch2 on iOS](https://discourse.cmake.org/t/cmake-catch2-on-ios/10829)

<div class="topic-metadata">

**Author:** [@jasonaylward](https://discourse.cmake.org/u/jasonaylward)\
**Replies:** 6\
**Last updated:** [May 13, 2024, 1:45pm UTC](https://discourse.cmake.org/t/cmake-catch2-on-ios/10829 "2024-05-13T13:45:46Z")

</div>

Hi. I’m working on a cross-platform project that uses CMake to build and Catch2 (and its CMake integration) for tests. I have it almost working but there’s a Postbuild Script that is generated in Xcode that fails. The…

---

## [simple cmake file failed when generate ninja build script](https://discourse.cmake.org/t/simple-cmake-file-failed-when-generate-ninja-build-script/10825)

<div class="topic-metadata">

**Author:** [@yushang](https://discourse.cmake.org/u/yushang)\
**Replies:** 3\
**Last updated:** [May 12, 2024, 3:58am UTC](https://discourse.cmake.org/t/simple-cmake-file-failed-when-generate-ninja-build-script/10825 "2024-05-12T03:58:06Z")

</div>

Hi guys, I’m trying to setup a simple CMake project without using the MSVC tools cmake\_minimum\_required(VERSION 3.13) project(myproj C) add\_executable(test test.c) in build directory cmake .. -G Ninja failed with -…

---

## [CMake .desktop file on Ubuntu](https://discourse.cmake.org/t/cmake-desktop-file-on-ubuntu/10611)

<div class="topic-metadata">

**Author:** [@tomhh](https://discourse.cmake.org/u/tomhh)\
**Replies:** 2\
**Last updated:** [May 10, 2024, 2:07pm UTC](https://discourse.cmake.org/t/cmake-desktop-file-on-ubuntu/10611 "2024-05-10T14:07:46Z")

</div>

This is probably a really simple thing to do, but on Linux (Ubuntu), if I download a CMake binary distribution from https://cmake.org/download/, is there a quick simple step to run to get the .desktop file installed and …

---

## [How to set the FOLDER property for all Targets in a given subdirectory](https://discourse.cmake.org/t/how-to-set-the-folder-property-for-all-targets-in-a-given-subdirectory/3384)

<div class="topic-metadata">

**Author:** [@RichTea](https://discourse.cmake.org/u/RichTea)\
**Replies:** 3\
**Last updated:** [May 10, 2024, 2:06pm UTC](https://discourse.cmake.org/t/how-to-set-the-folder-property-for-all-targets-in-a-given-subdirectory/3384 "2024-05-10T14:06:12Z")

</div>

We have an uber-project that brings in several sub-projects via add\_subdirectory(). Several of these creates a large number of static library Targets which they then assemble into the dynamic libraries and executables t…

---

## [Copying all linked shared objects with cpack](https://discourse.cmake.org/t/copying-all-linked-shared-objects-with-cpack/10831)

<div class="topic-metadata">

**Author:** [@akshaybabloo](https://discourse.cmake.org/u/akshaybabloo)\
**Replies:** 1\
**Last updated:** [May 10, 2024, 4:48am UTC](https://discourse.cmake.org/t/copying-all-linked-shared-objects-with-cpack/10831 "2024-05-10T04:48:11Z")

</div>

I am using Qt framework and I am trying to build a deb and tar.gz file using cpack. Everything seems to be working fine but the copied shard objects have full version numbers instead of just the major version. For exampl…

---

## [How do cmake policy warnings work?](https://discourse.cmake.org/t/how-do-cmake-policy-warnings-work/10555)

<div class="topic-metadata">

**Author:** [@JRR](https://discourse.cmake.org/u/JRR)\
**Replies:** 2\
**Last updated:** [May 9, 2024, 10:32pm UTC](https://discourse.cmake.org/t/how-do-cmake-policy-warnings-work/10555 "2024-05-09T22:32:42Z")

</div>

I’m looking for clarification on how cmake policy warnings work. In particular the policy warnings for CMP0112. We have code that triggers the warning for CMP0112. We validated our usage is fine and use cmake\_policy(SE…

---

## [How to describe runtime library dependency](https://discourse.cmake.org/t/how-to-describe-runtime-library-dependency/10727)

<div class="topic-metadata">

**Author:** [@AndreasSchacherbauer](https://discourse.cmake.org/u/AndreasSchacherbauer)\
**Replies:** 1\
**Last updated:** [May 9, 2024, 10:09pm UTC](https://discourse.cmake.org/t/how-to-describe-runtime-library-dependency/10727 "2024-05-09T22:09:25Z")

</div>

Hi! In order to use ASAN for our tests, we need to preload a library that defines a no op for dl\_close. My question is now, how do I describe the dependency to this library in CMake best? We have a CMake function that …

---

## [What do the switches "--verbose" and "--extra-verbose" do for ctest?](https://discourse.cmake.org/t/what-do-the-switches-verbose-and-extra-verbose-do-for-ctest/10644)

<div class="topic-metadata">

**Author:** [@solemnPonie0](https://discourse.cmake.org/u/solemnPonie0)\
**Replies:** 1\
**Last updated:** [May 9, 2024, 10:05pm UTC](https://discourse.cmake.org/t/what-do-the-switches-verbose-and-extra-verbose-do-for-ctest/10644 "2024-05-09T22:05:26Z")

</div>

So, I am running ctest as a script, with -S. It seems that with no switches, all my message(STATUS “something”) reports are lost, whereas with --verbose, they are mixed with test output. Is there a way to make ctest pr…

---

## [Trouble with tutorial step 9: cpack using wrong generator](https://discourse.cmake.org/t/trouble-with-tutorial-step-9-cpack-using-wrong-generator/10502)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 4\
**Last updated:** [May 9, 2024, 6:16pm UTC](https://discourse.cmake.org/t/trouble-with-tutorial-step-9-cpack-using-wrong-generator/10502 "2024-05-09T18:16:51Z")

</div>

Hi, Going through tutorial step9, cpack is giving: CPack Error: Cannot find NSIS compiler makensis: likely it is not installed, or not in your PATH CPack Error: Could not read NSIS registry value. This is usually cause…

---

## [CMake error at CMakeLists.txt](https://discourse.cmake.org/t/cmake-error-at-cmakelists-txt/10817)

<div class="topic-metadata">

**Author:** [@MarlonB](https://discourse.cmake.org/u/MarlonB)\
**Replies:** 1\
**Last updated:** [May 7, 2024, 10:18pm UTC](https://discourse.cmake.org/t/cmake-error-at-cmakelists-txt/10817 "2024-05-07T22:18:12Z")

</div>

I’m trying to compile a lib (Anjay LwM2M) that I got from github, but the following message is displayed at the terminal: C:\\Projetos\\Anjay\\Anjay\>cmake . – Building for: NMake Makefiles CMake Error at CMakeLists.txt:1…

---

## [ctest 3.29.2 crash on Windows with oversubscription](https://discourse.cmake.org/t/ctest-3-29-2-crash-on-windows-with-oversubscription/10763)

<div class="topic-metadata">

**Author:** [@FROMAGMA](https://discourse.cmake.org/u/FROMAGMA)\
**Replies:** 3\
**Last updated:** [May 7, 2024, 1:57pm UTC](https://discourse.cmake.org/t/ctest-3-29-2-crash-on-windows-with-oversubscription/10763 "2024-05-07T13:57:24Z")

</div>

Hi, Maybe this is the wrong place to report the following issue: We found a heap corruption in ctest 3.29.2 while executing: ctest --preset windows-debug --parallel 50 on a 2x18core Intel Windows 10 Enterprise machin…

---

## [No CMAKE\_CSharp\_COMPILER could be found](https://discourse.cmake.org/t/no-cmake-csharp-compiler-could-be-found/10808)

<div class="topic-metadata">

**Author:** [@ian.gralinski.inv](https://discourse.cmake.org/u/ian.gralinski.inv)\
**Replies:** 1\
**Last updated:** [May 7, 2024, 12:51am UTC](https://discourse.cmake.org/t/no-cmake-csharp-compiler-could-be-found/10808 "2024-05-07T00:51:07Z")

</div>

I am trying to create a Visual Studio 2022 solution that contains C# projects, but I’m seeing the failure No CMAKE\_CSharp\_COMPILER could be found. Running the configure step with --trace-redirect I can see that the C# c…

---

## [Error using FetchContent with URL](https://discourse.cmake.org/t/error-using-fetchcontent-with-url/10788)

<div class="topic-metadata">

**Author:** [@Dylan\_Reedy](https://discourse.cmake.org/u/Dylan_Reedy)\
**Replies:** 4\
**Last updated:** [May 7, 2024, 12:39am UTC](https://discourse.cmake.org/t/error-using-fetchcontent-with-url/10788 "2024-05-07T00:39:21Z")

</div>

Hello, I’m trying to download a binary dependency and put it in the same location as my source build (this is due to some legacy nonsense involving environment variables). I do the following: FetchContent\_Declare(MyDe…

---

## [Pass Ctrl+C signal from ctest to test programs.](https://discourse.cmake.org/t/pass-ctrl-c-signal-from-ctest-to-test-programs/10794)

<div class="topic-metadata">

**Author:** [@mokoko](https://discourse.cmake.org/u/mokoko)\
**Replies:** 2\
**Last updated:** [May 4, 2024, 10:10am UTC](https://discourse.cmake.org/t/pass-ctrl-c-signal-from-ctest-to-test-programs/10794 "2024-05-04T10:10:12Z")

</div>

My situation is exactly like https://cmake.org/pipermail/cmake/2014-August/058437.html. I want to run some clean up when signals like SIGTERM are received. When I run the test manually and press Ctrl+C, the signal is h…

---

## [Preset: setting build directory based on compiler](https://discourse.cmake.org/t/preset-setting-build-directory-based-on-compiler/10796)

<div class="topic-metadata">

**Author:** [@Barry\_Revzin](https://discourse.cmake.org/u/Barry_Revzin)\
**Replies:** 1\
**Last updated:** [May 3, 2024, 10:53pm UTC](https://discourse.cmake.org/t/preset-setting-build-directory-based-on-compiler/10796 "2024-05-03T22:53:17Z")

</div>

I’m working on a library that I will compile with lots of different compilers, build modes, etc. I can add, as a preset: "binaryDir": "build/debug", or even "binaryDir": "build/${presetName}", But I don’t see a macr…

---

## [\-std=c++11 not being used/set properly with GCC 4.8.5](https://discourse.cmake.org/t/std-c-11-not-being-used-set-properly-with-gcc-4-8-5/10767)

<div class="topic-metadata">

**Author:** [@bp7878](https://discourse.cmake.org/u/bp7878)\
**Replies:** 0\
**Last updated:** [April 30, 2024, 6:11pm UTC](https://discourse.cmake.org/t/std-c-11-not-being-used-set-properly-with-gcc-4-8-5/10767 "2024-04-30T18:11:14Z")

</div>

I’m working on an older project under RHEL 7 with GCC 4.8.5. I have cmake3 3.17.5 installed. I’m building a shared library that is complaining about a for loop error: error: ‘for’ loop initial declarations are only a…

---

## [Add custom config in subdir](https://discourse.cmake.org/t/add-custom-config-in-subdir/10761)

<div class="topic-metadata">

**Author:** [@garyo](https://discourse.cmake.org/u/garyo)\
**Replies:** 1\
**Last updated:** [April 30, 2024, 6:04am UTC](https://discourse.cmake.org/t/add-custom-config-in-subdir/10761 "2024-04-30T06:04:24Z")

</div>

I have a set of subdirs with example programs that cmake builds. To keep things simple, the subdirs don’t have their own CMake files, just the sources; they all follow a common template. So the top-level CMake file looks…

---

## [Wrong apple platform or variant when linking xcframework in 3.28+](https://discourse.cmake.org/t/wrong-apple-platform-or-variant-when-linking-xcframework-in-3-28/10342)

<div class="topic-metadata">

**Author:** [@mjz48](https://discourse.cmake.org/u/mjz48)\
**Replies:** 3\
**Last updated:** [April 29, 2024, 11:19pm UTC](https://discourse.cmake.org/t/wrong-apple-platform-or-variant-when-linking-xcframework-in-3-28/10342 "2024-04-29T23:19:00Z")

</div>

Hi, I’m trying to use the new xcframework support for find\_library and target\_link\_libraries for apple. I’m trying to build for both ios and ios-simulator, but I’m running into this xcode error with my generated project: …

---

## [How to know the scope of variables](https://discourse.cmake.org/t/how-to-know-the-scope-of-variables/10683)

<div class="topic-metadata">

**Author:** [@dabrahams](https://discourse.cmake.org/u/dabrahams)\
**Replies:** 3\
**Last updated:** [April 29, 2024, 8:49pm UTC](https://discourse.cmake.org/t/how-to-know-the-scope-of-variables/10683 "2024-04-29T20:49:54Z")

</div>

When I see a variable like CMAKE\_ARCHIVE\_OUTPUT\_DIRECTORY being set I always wonder whether it affects just the current project or directory, or whether it is truly global, and I’m not sure how to tell other than by runn…

---

## [CPack: - Run preinstall target...](https://discourse.cmake.org/t/cpack-run-preinstall-target/10187)

<div class="topic-metadata">

**Author:** [@Nocaster60](https://discourse.cmake.org/u/Nocaster60)\
**Replies:** 18\
**Last updated:** [April 28, 2024, 12:49pm UTC](https://discourse.cmake.org/t/cpack-run-preinstall-target/10187 "2024-04-28T12:49:42Z")

</div>

I have a project that takes about 15 mins to build on Windows using the Intel fortran compiler. I have added the required files to create an Inno setup installer. Using the NMake Makefiles generator, building and running…

---

## [Toolchains and presets](https://discourse.cmake.org/t/toolchains-and-presets/10742)

<div class="topic-metadata">

**Author:** [@Kentzo](https://discourse.cmake.org/u/Kentzo)\
**Replies:** 2\
**Last updated:** [April 28, 2024, 5:31am UTC](https://discourse.cmake.org/t/toolchains-and-presets/10742 "2024-04-28T05:31:15Z")

</div>

Is there a way to access variables specified in the toolchain file passed via the --toolchain or -DCMAKE\_TOOLCHAIN\_FILE from a preset?

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

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