# Usage

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

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

**Page:** 25

---

## [Correctly exporting configuration: second part](https://discourse.cmake.org/t/correctly-exporting-configuration-second-part/11053)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 2\
**Last updated:** [June 19, 2024, 7:33pm UTC](https://discourse.cmake.org/t/correctly-exporting-configuration-second-part/11053 "2024-06-19T19:33:49Z")

</div>

This is a follow up of Correctly exporting configuration. In first question, I focused on the installation part. In this part I’d like advices on the creation and installation of the export configuration files. So far…

---

## [different compilation flags for C and CXX files](https://discourse.cmake.org/t/different-compilation-flags-for-c-and-cxx-files/11033)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 3\
**Last updated:** [June 18, 2024, 2:54pm UTC](https://discourse.cmake.org/t/different-compilation-flags-for-c-and-cxx-files/11033 "2024-06-18T14:54:34Z")

</div>

Hi, I’m passing warning options like this: target\_compile\_options(${TARGET\_NAME} PRIVATE/PUBLIC ${MY\_WARNING\_FLAGS}) Yet, among my flags, I’ve got a C++ only warning (-Wold-style-cast): set(MY\_WARNING\_FLAGS -Wall -We…

---

## [Linking to library created as INTERFACE propagate all the compile option and create error](https://discourse.cmake.org/t/linking-to-library-created-as-interface-propagate-all-the-compile-option-and-create-error/10946)

<div class="topic-metadata">

**Author:** [@AntoineN](https://discourse.cmake.org/u/AntoineN)\
**Replies:** 8\
**Last updated:** [June 18, 2024, 10:19am UTC](https://discourse.cmake.org/t/linking-to-library-created-as-interface-propagate-all-the-compile-option-and-create-error/10946 "2024-06-18T10:19:29Z")

</div>

Hello, I’m working on a project using a lib create as an INTERFACE (stm32cubemx lib, generate by STM32CubeMX, so I cannot change it :frowning: ) I have a lib, libPWM that have to link to the stm32cubemx lib. In my lib,…

---

## [Should I use find\_package for INTERFACE\_LINK\_LIBRARIES LINK\_ONLY target?](https://discourse.cmake.org/t/should-i-use-find-package-for-interface-link-libraries-link-only-target/10985)

<div class="topic-metadata">

**Author:** [@Felix\_Xu](https://discourse.cmake.org/u/Felix_Xu)\
**Replies:** 1\
**Last updated:** [June 13, 2024, 12:23pm UTC](https://discourse.cmake.org/t/should-i-use-find-package-for-interface-link-libraries-link-only-target/10985 "2024-06-13T12:23:27Z")

</div>

Hi, I’m working on a shared dll library project called resource\_retriever, it has exported cmake like this: set\_target\_properties(resource\_retriever::resource\_retriever PROPERTIES INTERFACE\_INCLUDE\_DIRECTORIES "${\_IM…

---

## [configure\_package\_config\_file throws error of unknown keyword ${PROJECT\_NAME}-config.cmake](https://discourse.cmake.org/t/configure-package-config-file-throws-error-of-unknown-keyword-project-name-config-cmake/10998)

<div class="topic-metadata">

**Author:** [@maichmueller](https://discourse.cmake.org/u/maichmueller)\
**Replies:** 2\
**Last updated:** [June 13, 2024, 8:50am UTC](https://discourse.cmake.org/t/configure-package-config-file-throws-error-of-unknown-keyword-project-name-config-cmake/10998 "2024-06-13T08:50:51Z")

</div>

Hi all, I am trying to pull in the Arcade-Learning-Environment project via CPM in my project via CPMAddPackage( NAME ale GIT\_TAG v0.9.0 # Configuration options passed to the dependency (option…

---

## [configure\_file vs configure\_package\_config\_file](https://discourse.cmake.org/t/configure-file-vs-configure-package-config-file/10993)

<div class="topic-metadata">

**Author:** [@tomhh](https://discourse.cmake.org/u/tomhh)\
**Replies:** 2\
**Last updated:** [June 13, 2024, 7:27am UTC](https://discourse.cmake.org/t/configure-file-vs-configure-package-config-file/10993 "2024-06-13T07:27:37Z")

</div>

Hi there, Very quick question, I just wanted to check is it always preferred to use configure\_package\_config\_file as opposed to configure\_file when doing anything with package config files (this is for the main package …

---

## [make: \*\*\* \[Makefile:108: install\] Error 1](https://discourse.cmake.org/t/make-makefile-install-error-1/10982)

<div class="topic-metadata">

**Author:** [@moajouz](https://discourse.cmake.org/u/moajouz)\
**Replies:** 10\
**Last updated:** [June 12, 2024, 11:06am UTC](https://discourse.cmake.org/t/make-makefile-install-error-1/10982 "2024-06-12T11:06:31Z")

</div>

I have been getting this error for a while and a lot of discussions where they had this error, they got a directory in the brackets . I got this error after trying “sudo make install” this is the full log except for wa…

---

## [Functional safety](https://discourse.cmake.org/t/functional-safety/10853)

<div class="topic-metadata">

**Author:** [@DanieleNardi](https://discourse.cmake.org/u/DanieleNardi)\
**Replies:** 1\
**Last updated:** [June 11, 2024, 7:04pm UTC](https://discourse.cmake.org/t/functional-safety/10853 "2024-06-11T19:04:15Z")

</div>

Hello, is it possible to use Cmake for embedded systems with functional safety requirements? In particular, does anyone ever made a qualification tool process of Cmake for IEC 61508 or ISO 26262 projects?

---

## [Dynamic Generation of source files at configure/build time](https://discourse.cmake.org/t/dynamic-generation-of-source-files-at-configure-build-time/10749)

<div class="topic-metadata">

**Author:** [@biddisco](https://discourse.cmake.org/u/biddisco)\
**Replies:** 5\
**Last updated:** [June 11, 2024, 5:01pm UTC](https://discourse.cmake.org/t/dynamic-generation-of-source-files-at-configure-build-time/10749 "2024-06-11T17:01:25Z")

</div>

Hi all, We have several hundred files which must pass through several stages of preprocessing, and the output of all of that is eventually a source list that can then be used to build a target. The preprocessing of the…

---

## [ctest presets and --build-and-test](https://discourse.cmake.org/t/ctest-presets-and-build-and-test/7514)

<div class="topic-metadata">

**Author:** [@kisielk](https://discourse.cmake.org/u/kisielk)\
**Replies:** 3\
**Last updated:** [June 11, 2024, 4:59pm UTC](https://discourse.cmake.org/t/ctest-presets-and-build-and-test/7514 "2024-06-11T16:59:56Z")

</div>

I’m trying to use the --build-and-test option with ctest in conjunction with presets. I’m using Ninja Multi-Config as my generator. My test presets include both the configurePreset and configuration fields yet when I try…

---

## [Using CPM to add Eigen and OpenXLSX libraries](https://discourse.cmake.org/t/using-cpm-to-add-eigen-and-openxlsx-libraries/10881)

<div class="topic-metadata">

**Author:** [@Shepard](https://discourse.cmake.org/u/Shepard)\
**Replies:** 4\
**Last updated:** [June 11, 2024, 4:58pm UTC](https://discourse.cmake.org/t/using-cpm-to-add-eigen-and-openxlsx-libraries/10881 "2024-06-11T16:58:24Z")

</div>

Hi, I have a cmake + C++ project where I need both Eigen and OpenXLSX libraries. According to the readme, the OpenXLSX should build on both windows and linux platforms. My attempt I am using CPM, so my main root/CMake…

---

## [Example code for Metal shaders?](https://discourse.cmake.org/t/example-code-for-metal-shaders/6404)

<div class="topic-metadata">

**Author:** [@RobN](https://discourse.cmake.org/u/RobN)\
**Replies:** 3\
**Last updated:** [June 11, 2024, 3:27pm UTC](https://discourse.cmake.org/t/example-code-for-metal-shaders/6404 "2024-06-11T15:27:21Z")

</div>

I’m trying to move an Xcode project to CLion and CMake. I’ve got the C/C++ part working, but my build is doing nothing with the Metal shader files. I found this: metal - Building metallib with CMake - Stack Overflow I …

---

## [Directory creation by ninja when using BYPRODUCTS of add\_custom\_command](https://discourse.cmake.org/t/directory-creation-by-ninja-when-using-byproducts-of-add-custom-command/10859)

<div class="topic-metadata">

**Author:** [@Chardrazle](https://discourse.cmake.org/u/Chardrazle)\
**Replies:** 1\
**Last updated:** [June 10, 2024, 8:08pm UTC](https://discourse.cmake.org/t/directory-creation-by-ninja-when-using-byproducts-of-add-custom-command/10859 "2024-06-10T20:08:13Z")

</div>

Further to issue 25808, I experimented a little more with the pattern…bear with :slight\_smile: @brad.king on cursory reading, the comment you made here is what was being performed in the example cmake configuration as g…

---

## [Seeing cmake install failure with STATIC libraries](https://discourse.cmake.org/t/seeing-cmake-install-failure-with-static-libraries/10879)

<div class="topic-metadata">

**Author:** [@ramana](https://discourse.cmake.org/u/ramana)\
**Replies:** 2\
**Last updated:** [June 10, 2024, 1:37pm UTC](https://discourse.cmake.org/t/seeing-cmake-install-failure-with-static-libraries/10879 "2024-06-10T13:37:25Z")

</div>

Trying to run install command and seeing the following issue: Install the project… – Install configuration: “Release” – Installing: /usr/lib/libcares.a CMake Error at cmake\_install.cmake:46 (file): file INSTALL cann…

---

## [C++20 modules: manually specifying module providers](https://discourse.cmake.org/t/c-20-modules-manually-specifying-module-providers/10948)

<div class="topic-metadata">

**Author:** [@osiris](https://discourse.cmake.org/u/osiris)\
**Replies:** 4\
**Last updated:** [June 8, 2024, 7:15pm UTC](https://discourse.cmake.org/t/c-20-modules-manually-specifying-module-providers/10948 "2024-06-08T19:15:00Z")

</div>

Hi, is there a way to manually specify what modules are provided by given library? I.e. I precompile header modules in add\_custom\_command via: “g++ -fmodule-header -x c++system-header cassert” Then wrap it into a sta…

---

## [Problem with ExternalProject\_Add](https://discourse.cmake.org/t/problem-with-externalproject-add/10951)

<div class="topic-metadata">

**Author:** [@Jean-Michel\_Caricand](https://discourse.cmake.org/u/Jean-Michel_Caricand)\
**Replies:** 4\
**Last updated:** [June 8, 2024, 4:26am UTC](https://discourse.cmake.org/t/problem-with-externalproject-add/10951 "2024-06-08T04:26:24Z")

</div>

Hello, I have a little problem with ExternalProject\_Add when I try to use find command. ExternalProject\_Add(libopc GIT\_REPOSITORY https://github.com/freuter/libopc.git UPDATE\_DISCONNECTED True CONFIGURE\_COM…

---

## [Setting C++ standard on INTERFACE libraries](https://discourse.cmake.org/t/setting-c-standard-on-interface-libraries/10933)

<div class="topic-metadata">

**Author:** [@Zingam](https://discourse.cmake.org/u/Zingam)\
**Replies:** 5\
**Last updated:** [June 8, 2024, 2:11am UTC](https://discourse.cmake.org/t/setting-c-standard-on-interface-libraries/10933 "2024-06-08T02:11:48Z")

</div>

I try to understand why setting the C++ standard properties on an interface library doesn’t work. I can’t find this documented or properly explained anywhere. CMake doesn’t seem to issue any warnings or errors. add\_libr…

---

## [Manually setting \`CMAKE\_MAKE\_PROGRAM\` before calling \`project()\`](https://discourse.cmake.org/t/manually-setting-cmake-make-program-before-calling-project/10967)

<div class="topic-metadata">

**Author:** [@Fabrice\_de\_Gans](https://discourse.cmake.org/u/Fabrice_de_Gans)\
**Replies:** 3\
**Last updated:** [June 7, 2024, 10:35pm UTC](https://discourse.cmake.org/t/manually-setting-cmake-make-program-before-calling-project/10967 "2024-06-07T22:35:01Z")

</div>

Assuming the generator is Ninja and there is no system-wide installation of ninja (i.e. not in PATH), consider the following code: # Doing work to download/install a pinned ninja version in here. set(CMAKE\_MAKE\_PROGRAM …

---

## [CMake fails on external drive](https://discourse.cmake.org/t/cmake-fails-on-external-drive/10961)

<div class="topic-metadata">

**Author:** [@jishengxie-TF](https://discourse.cmake.org/u/jishengxie-TF)\
**Replies:** 2\
**Last updated:** [June 7, 2024, 4:08am UTC](https://discourse.cmake.org/t/cmake-fails-on-external-drive/10961 "2024-06-07T04:08:24Z")

</div>

I am trying to run CMake to generate VS2017 solutions from source folder(with pre-defined CMakeList files). It works fine if the output folder is on C drive(I only have one drive in this Windows 11). If I change the outp…

---

## [symlinks are not getting created properly with cmake 3.28](https://discourse.cmake.org/t/symlinks-are-not-getting-created-properly-with-cmake-3-28/10970)

<div class="topic-metadata">

**Author:** [@ramana](https://discourse.cmake.org/u/ramana)\
**Replies:** 0\
**Last updated:** [June 7, 2024, 3:39am UTC](https://discourse.cmake.org/t/symlinks-are-not-getting-created-properly-with-cmake-3-28/10970 "2024-06-07T03:39:52Z")

</div>

We are trying to create a deb package for different sources after running cmake; make ; and checkinstall and with 3.28 only the symlinks are not getting created. Where as with cmake 3.16 and 3.20, the symlinks are gettin…

---

## [Behavior of target\_link\_libraries when target is a static lib](https://discourse.cmake.org/t/behavior-of-target-link-libraries-when-target-is-a-static-lib/10898)

<div class="topic-metadata">

**Author:** [@martingalvan-volue](https://discourse.cmake.org/u/martingalvan-volue)\
**Replies:** 5\
**Last updated:** [June 3, 2024, 4:28pm UTC](https://discourse.cmake.org/t/behavior-of-target-link-libraries-when-target-is-a-static-lib/10898 "2024-06-03T16:28:22Z")

</div>

Hi, I’m using CMake 3.29.0-rc3 with the Ninja generator on Windows with MSVC. I have the following CMakeLists.txt: cmake\_minimum\_required(VERSION 3.29.0 FATAL\_ERROR) project(test C) add\_library(my\_lib STATIC my\_lib.c)…

---

## [Can I point CMake to use the (older) libc of a different rootfs?](https://discourse.cmake.org/t/can-i-point-cmake-to-use-the-older-libc-of-a-different-rootfs/10925)

<div class="topic-metadata">

**Author:** [@bertulli](https://discourse.cmake.org/u/bertulli)\
**Replies:** 1\
**Last updated:** [June 3, 2024, 7:48am UTC](https://discourse.cmake.org/t/can-i-point-cmake-to-use-the-older-libc-of-a-different-rootfs/10925 "2024-06-03T07:48:05Z")

</div>

Hi all! I’m trying to set up CMake to cross compile an application targeted to an old (2017) Linux system (functioning, but slow). I managed to write a toolchain file and I can compile it, but of course the libc picked i…

---

## [MSVS gtest\_discover\_tests environment](https://discourse.cmake.org/t/msvs-gtest-discover-tests-environment/9225)

<div class="topic-metadata">

**Author:** [@ivanschou](https://discourse.cmake.org/u/ivanschou)\
**Replies:** 6\
**Last updated:** [June 2, 2024, 11:56am UTC](https://discourse.cmake.org/t/msvs-gtest-discover-tests-environment/9225 "2024-06-02T11:56:15Z")

</div>

I have a project that uses a third-party library and I’ve written unit tests and added them to my test suite via gtest\_discover\_tests, but in order to successfully build the test target in VS I need to add the path to th…

---

## [How to debug "Detecting C compiler ABI info" hanging (Cygwin on GitHub Actions)](https://discourse.cmake.org/t/how-to-debug-detecting-c-compiler-abi-info-hanging-cygwin-on-github-actions/4580)

<div class="topic-metadata">

**Author:** [@claremacrae](https://discourse.cmake.org/u/claremacrae)\
**Replies:** 9\
**Last updated:** [June 2, 2024, 7:43am UTC](https://discourse.cmake.org/t/how-to-debug-detecting-c-compiler-abi-info-hanging-cygwin-on-github-actions/4580 "2024-06-02T07:43:54Z")

</div>

My cmake builds on GitHub Actions with Cygwin have recently started timing out at 6 hours, when they used to take 10 minutes or so. I’ve been looking at it, and the difference in output is: last working build: 2021-10…

---

## [How to run extra install code, after ninja install installs all its configurations in a multi-config setup](https://discourse.cmake.org/t/how-to-run-extra-install-code-after-ninja-install-installs-all-its-configurations-in-a-multi-config-setup/10902)

<div class="topic-metadata">

**Author:** [@alcroito](https://discourse.cmake.org/u/alcroito)\
**Replies:** 3\
**Last updated:** [May 28, 2024, 1:45pm UTC](https://discourse.cmake.org/t/how-to-run-extra-install-code-after-ninja-install-installs-all-its-configurations-in-a-multi-config-setup/10902 "2024-05-28T13:45:02Z")

</div>

Given the following project: cmake\_minimum\_required(VERSION 3.18) set(CMAKE\_CROSS\_CONFIGS "all" CACHE STRING "" FORCE) set(CMAKE\_DEFAULT\_CONFIGS "all" CACHE STRING "" FORCE) set(CMAKE\_INSTALL\_PREFIX "${CMAKE\_CURRENT\_BI…

---

## [What is the correct or best way to build/install 3rdParty code with multiple configuraions?](https://discourse.cmake.org/t/what-is-the-correct-or-best-way-to-build-install-3rdparty-code-with-multiple-configuraions/10897)

<div class="topic-metadata">

**Author:** [@JRR](https://discourse.cmake.org/u/JRR)\
**Replies:** 4\
**Last updated:** [May 27, 2024, 11:07am UTC](https://discourse.cmake.org/t/what-is-the-correct-or-best-way-to-build-install-3rdparty-code-with-multiple-configuraions/10897 "2024-05-27T11:07:07Z")

</div>

My company uses 3rdParty libraries with Windows and Linux compiles. We will compile these 3rdParty libraries once and deploy them to a common location on a file share. Using the glorious magic of find\_package() develope…

---

## [cmake does not find libraries when compiling for Android](https://discourse.cmake.org/t/cmake-does-not-find-libraries-when-compiling-for-android/5098)

<div class="topic-metadata">

**Author:** [@emmenlau](https://discourse.cmake.org/u/emmenlau)\
**Replies:** 5\
**Last updated:** [May 26, 2024, 10:44am UTC](https://discourse.cmake.org/t/cmake-does-not-find-libraries-when-compiling-for-android/5098 "2024-05-26T10:44:52Z")

</div>

I’ve just today discovered that its surprisingly simple to compile c++ projects with cmake for Android. I use Ubuntu Linux as a host, with the latest NDK. The build worked smoothly for a whole number of standard librarie…

---

## [CMakePresets.json Error Messages - How can I decipher what the actual issue is.](https://discourse.cmake.org/t/cmakepresets-json-error-messages-how-can-i-decipher-what-the-actual-issue-is/10888)

<div class="topic-metadata">

**Author:** [@imikejackson](https://discourse.cmake.org/u/imikejackson)\
**Replies:** 4\
**Last updated:** [May 24, 2024, 9:01pm UTC](https://discourse.cmake.org/t/cmakepresets-json-error-messages-how-can-i-decipher-what-the-actual-issue-is/10888 "2024-05-24T21:01:58Z")

</div>

I tend to get this a lot: CMake Error: Could not read presets from /Users/mjackson/EMsoft-Dev/EMsoft: Invalid "configurePreset" field I literally copied and pasted the contents from another project, and that project wo…

---

## [\[GNU/Linux\] \[Debian 12\] CMake fails to find OpenGL when MESA has been built without GLX support](https://discourse.cmake.org/t/gnu-linux-debian-12-cmake-fails-to-find-opengl-when-mesa-has-been-built-without-glx-support/10901)

<div class="topic-metadata">

**Author:** [@vanfanel](https://discourse.cmake.org/u/vanfanel)\
**Replies:** 1\
**Last updated:** [May 24, 2024, 2:49pm UTC](https://discourse.cmake.org/t/gnu-linux-debian-12-cmake-fails-to-find-opengl-when-mesa-has-been-built-without-glx-support/10901 "2024-05-24T14:49:36Z")

</div>

Hello there! CMake (version included in Debian 12 and also latest stable cmake version 3.29.3) fails to find OpenGL when doing find\_package(OpenGL REQUIRED) if MESA is built without GLX support: This is the error I get…

---

## [CTEST\_CUSTOM\_COVERAGE\_EXCLUDE is not work](https://discourse.cmake.org/t/ctest-custom-coverage-exclude-is-not-work/10884)

<div class="topic-metadata">

**Author:** [@vhext](https://discourse.cmake.org/u/vhext)\
**Replies:** 1\
**Last updated:** [May 23, 2024, 8:43am UTC](https://discourse.cmake.org/t/ctest-custom-coverage-exclude-is-not-work/10884 "2024-05-23T08:43:37Z")

</div>

Hi everyone, I’m new to cmake, now I can run ctest -T Coverage to get my code coverage, then I want to exclude ./test/\*.c, so I execute -fprofile-exclude-files= . /test/\* and added list(APPEND CTEST\_CUSTOM\_COVERAGE\_EXCLU…

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

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