# Usage

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

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

**Page:** 18

---

## [Presets - conditional config](https://discourse.cmake.org/t/presets-conditional-config/3864)

<div class="topic-metadata">

**Author:** [@rbailey](https://discourse.cmake.org/u/rbailey)\
**Replies:** 13\
**Last updated:** [June 18, 2024, 4:10pm UTC](https://discourse.cmake.org/t/presets-conditional-config/3864 "2024-06-18T16:10:57Z")

</div>

Is there a way for a single preset to apply different settings based on a condition? For example, I would like cmake --preset default to choose the appropriate vcpkg triplet for the current OS. "configurePresets": \[ …

---

## [using read -p from in script launched by execute\_process](https://discourse.cmake.org/t/using-read-p-from-in-script-launched-by-execute-process/7941)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 4\
**Last updated:** [December 16, 2024, 2:47pm UTC](https://discourse.cmake.org/t/using-read-p-from-in-script-launched-by-execute-process/7941 "2024-12-16T14:47:18Z")

</div>

Hi, related to: execute\_process buffers and doesn't print question when process is waiting on user input. My goal is to add a path to user PATH environment variable during installation process but I want to request his…

---

## [Build some executables for host and some for target system (cross compile)](https://discourse.cmake.org/t/build-some-executables-for-host-and-some-for-target-system-cross-compile/13204)

<div class="topic-metadata">

**Author:** [@Paradox84](https://discourse.cmake.org/u/Paradox84)\
**Replies:** 1\
**Last updated:** [December 15, 2024, 5:44am UTC](https://discourse.cmake.org/t/build-some-executables-for-host-and-some-for-target-system-cross-compile/13204 "2024-12-15T05:44:33Z")

</div>

When cross compiling, CMake tries to build everything for target system, but this doesn’t work for tools that used in build time. Consider this CMake file: project(CustomCommandExample) add\_executable(HelperExecutable h…

---

## [\[43882\]\[My CDash\] How to keep old builds?](https://discourse.cmake.org/t/43882-my-cdash-how-to-keep-old-builds/13194)

<div class="topic-metadata">

**Author:** [@Salomon](https://discourse.cmake.org/u/Salomon)\
**Replies:** 1\
**Last updated:** [December 13, 2024, 9:54pm UTC](https://discourse.cmake.org/t/43882-my-cdash-how-to-keep-old-builds/13194 "2024-12-13T21:54:01Z")

</div>

Hello, I recently migrated my client project to a private My CDash project. Yesterday, the oldest builds were in: https://my.cdash.org/index.php?project=\<Project\>&date=2024-11-27. So in “Edit Project”, I set: AutoRe…

---

## [How to find static version of package](https://discourse.cmake.org/t/how-to-find-static-version-of-package/13198)

<div class="topic-metadata">

**Author:** [@opoplawski](https://discourse.cmake.org/u/opoplawski)\
**Replies:** 0\
**Last updated:** [December 13, 2024, 9:03pm UTC](https://discourse.cmake.org/t/how-to-find-static-version-of-package/13198 "2024-12-13T21:03:48Z")

</div>

Fedora provides a static version of yaml-cpp with the config files installed to /usr/lib64/cmake/yaml-cpp-static. I’m trying to make use of this to build micromamba 2.0.5 but I can’t get it to prefer the static one. I …

---

## [find\_package fails for MPI in build directory with long absolute path (Linux)](https://discourse.cmake.org/t/find-package-fails-for-mpi-in-build-directory-with-long-absolute-path-linux/13192)

<div class="topic-metadata">

**Author:** [@KTRR](https://discourse.cmake.org/u/KTRR)\
**Replies:** 1\
**Last updated:** [December 13, 2024, 7:47pm UTC](https://discourse.cmake.org/t/find-package-fails-for-mpi-in-build-directory-with-long-absolute-path-linux/13192 "2024-12-13T19:47:39Z")

</div>

On a Linux system with a build directory path longer than ~256 characters\* find\_package(MPI REQUIRED) is failing because missing: MPI\_Fortran\_WORKS. Is there something I can do to fix or diagnose what might be going wron…

---

## [How to force FindPython to locate a specific version of Python without specifying every last artifact?](https://discourse.cmake.org/t/how-to-force-findpython-to-locate-a-specific-version-of-python-without-specifying-every-last-artifact/13165)

<div class="topic-metadata">

**Author:** [@PieterP](https://discourse.cmake.org/u/PieterP)\
**Replies:** 6\
**Last updated:** [December 13, 2024, 9:12am UTC](https://discourse.cmake.org/t/how-to-force-findpython-to-locate-a-specific-version-of-python-without-specifying-every-last-artifact/13165 "2024-12-13T09:12:22Z")

</div>

Background: the Python build backend py-build-cmake that I maintain needs to invoke CMake to build Python extension modules in user-provided CMake projects. The goal of the build backend is to build these extension modul…

---

## [function(set\_our\_header\_properties) not defined or something](https://discourse.cmake.org/t/function-set-our-header-properties-not-defined-or-something/13183)

<div class="topic-metadata">

**Author:** [@qweqqweq](https://discourse.cmake.org/u/qweqqweq)\
**Replies:** 6\
**Last updated:** [December 13, 2024, 8:12am UTC](https://discourse.cmake.org/t/function-set-our-header-properties-not-defined-or-something/13183 "2024-12-13T08:12:45Z")

</div>

when i make my project i’m getting a message something like, "set\_our+header\_properties) is not defined so i located the file it’s defined at and here’s what it says now after i tried putting in a message to indicate the…

---

## [Get information on interface library without sources via CMake File API](https://discourse.cmake.org/t/get-information-on-interface-library-without-sources-via-cmake-file-api/13189)

<div class="topic-metadata">

**Author:** [@itavero](https://discourse.cmake.org/u/itavero)\
**Replies:** 1\
**Last updated:** [December 12, 2024, 9:22pm UTC](https://discourse.cmake.org/t/get-information-on-interface-library-without-sources-via-cmake-file-api/13189 "2024-12-12T21:22:32Z")

</div>

I was using the CMake File API to simply have my code analysis tool “ask” what files to analyze for a given target. Unfortunately I noticed that if I have an interface library that only has include directories added, bu…

---

## [custom\_command with directory as first OUTPUT fail!](https://discourse.cmake.org/t/custom-command-with-directory-as-first-output-fail/13181)

<div class="topic-metadata">

**Author:** [@klaus.holst.jacobsen](https://discourse.cmake.org/u/klaus.holst.jacobsen)\
**Replies:** 3\
**Last updated:** [December 12, 2024, 9:20pm UTC](https://discourse.cmake.org/t/custom-command-with-directory-as-first-output-fail/13181 "2024-12-12T21:20:12Z")

</div>

OS: Linux Generator: Unix Makefiles CMake: 3.28.1 If have this custom command: add\_custom\_command( OUTPUT ${CMAKE\_CURRENT\_SOURCE\_DIR}/out ${CMAKE\_CURRENT\_SOURCE\_DIR}/out/out1.txt ${CMAKE\_CURRENT\_SOURCE…

---

## [How to cross compile from linux to all desktop OSes and architectures](https://discourse.cmake.org/t/how-to-cross-compile-from-linux-to-all-desktop-oses-and-architectures/13191)

<div class="topic-metadata">

**Author:** [@Paradox84](https://discourse.cmake.org/u/Paradox84)\
**Replies:** 0\
**Last updated:** [December 12, 2024, 8:46pm UTC](https://discourse.cmake.org/t/how-to-cross-compile-from-linux-to-all-desktop-oses-and-architectures/13191 "2024-12-12T20:46:21Z")

</div>

I’m trying to cross compile from github actions for all the desktop OSes and architectures. Github actions part is only relevant to always starting from a fresh install of ubuntu 24.04 Host is always ubuntu 24.04 x86\_64…

---

## [\--install . behaviour differs from --build . --target install](https://discourse.cmake.org/t/install-behaviour-differs-from-build-target-install/13167)

<div class="topic-metadata">

**Author:** [@matt-sm](https://discourse.cmake.org/u/matt-sm)\
**Replies:** 13\
**Last updated:** [December 12, 2024, 6:04am UTC](https://discourse.cmake.org/t/install-behaviour-differs-from-build-target-install/13167 "2024-12-12T06:04:29Z")

</div>

I configure a project via: cmake -S …/ -B . -DCMAKE\_BUILD\_TYPE=None -DCMAKE\_INSTALL\_PREFIX=/tmp/prefix -G ‘Unix Makefiles’ In CMakeLists,txt there is call to install(export): install(EXPORT ${PROJECT\_NAME}Targets NAM…

---

## [Kitware APT repo down?](https://discourse.cmake.org/t/kitware-apt-repo-down/13184)

<div class="topic-metadata">

**Author:** [@Ryanf55](https://discourse.cmake.org/u/Ryanf55)\
**Replies:** 2\
**Last updated:** [December 12, 2024, 4:57am UTC](https://discourse.cmake.org/t/kitware-apt-repo-down/13184 "2024-12-12T04:57:41Z")

</div>

Hello, I use the kitware apt repository: https://apt.kitware.com/ Just today, I noticed I can no longer run apt-get update. sudo apt-get update Get:1 https://download.docker.com/linux/ubuntu jammy InRelease \[48.8 kB\]…

---

## [Run tool automatically after generation phase](https://discourse.cmake.org/t/run-tool-automatically-after-generation-phase/13132)

<div class="topic-metadata">

**Author:** [@itavero](https://discourse.cmake.org/u/itavero)\
**Replies:** 4\
**Last updated:** [December 11, 2024, 6:05pm UTC](https://discourse.cmake.org/t/run-tool-automatically-after-generation-phase/13132 "2024-12-11T18:05:15Z")

</div>

We use CMake as our build automation tool (we develop for Cortex-M microcontrollers and a like). Currently we are working on setting up clangd to work properly in our IDE, but due to the cross-compilation we will likely…

---

## [Generator expression based on user presets](https://discourse.cmake.org/t/generator-expression-based-on-user-presets/13017)

<div class="topic-metadata">

**Author:** [@DavidRegan](https://discourse.cmake.org/u/DavidRegan)\
**Replies:** 4\
**Last updated:** [December 9, 2024, 9:26pm UTC](https://discourse.cmake.org/t/generator-expression-based-on-user-presets/13017 "2024-12-09T21:26:22Z")

</div>

I wish to control target\_compile\_definitions based on user presets so that local mods may be tested. (Want\_Config\_Dump) In my user preset I’ve added "configurePresets": \[ { "name": "config-base-local", "hidden": …

---

## [Building fraunhofer ecm on aarch64 in termux when i386 amd64 sse flags are in source and lib](https://discourse.cmake.org/t/building-fraunhofer-ecm-on-aarch64-in-termux-when-i386-amd64-sse-flags-are-in-source-and-lib/13163)

<div class="topic-metadata">

**Author:** [@Eaton\_Otemiel](https://discourse.cmake.org/u/Eaton_Otemiel)\
**Replies:** 0\
**Last updated:** [December 9, 2024, 8:02pm UTC](https://discourse.cmake.org/t/building-fraunhofer-ecm-on-aarch64-in-termux-when-i386-amd64-sse-flags-are-in-source-and-lib/13163 "2024-12-09T20:02:21Z")

</div>

Removing msse4 1 and 2 references with vim is not working. Is there a gcc option to override and use aarch64 gcc14; or, will I need to remove every i386 amd64 compiler reference with vim?

---

## [ExternalProject\_Add command succeed on 3.30.6 and fails on 3.31.1](https://discourse.cmake.org/t/externalproject-add-command-succeed-on-3-30-6-and-fails-on-3-31-1/13146)

<div class="topic-metadata">

**Author:** [@jonbc](https://discourse.cmake.org/u/jonbc)\
**Replies:** 2\
**Last updated:** [December 9, 2024, 5:41pm UTC](https://discourse.cmake.org/t/externalproject-add-command-succeed-on-3-30-6-and-fails-on-3-31-1/13146 "2024-12-09T17:41:51Z")

</div>

I’ve downloaded: v3.30.6 for linux-x86-64 from the v3.30.6 github release v3.31.1 for linux-x86-64 from the v3.31.1 github release I clean the build tree then build with cmake and the command succeeds on 3.30.6 but fa…

---

## [How to use custom Clang build with VS generator](https://discourse.cmake.org/t/how-to-use-custom-clang-build-with-vs-generator/13158)

<div class="topic-metadata">

**Author:** [@Angew](https://discourse.cmake.org/u/Angew)\
**Replies:** 0\
**Last updated:** [December 9, 2024, 10:49am UTC](https://discourse.cmake.org/t/how-to-use-custom-clang-build-with-vs-generator/13158 "2024-12-09T10:49:07Z")

</div>

Is there a way to fully use a custom installation of Clang with the VS generator (2022 in my case) in CMake? I have a custom build & installation of Clang. Based on MS information on using custom Clang in VS, I was able…

---

## [How to specify a toolset when using the Ninja generator in cmake-gui](https://discourse.cmake.org/t/how-to-specify-a-toolset-when-using-the-ninja-generator-in-cmake-gui/13151)

<div class="topic-metadata">

**Author:** [@Franksong28](https://discourse.cmake.org/u/Franksong28)\
**Replies:** 1\
**Last updated:** [December 8, 2024, 10:35pm UTC](https://discourse.cmake.org/t/how-to-specify-a-toolset-when-using-the-ninja-generator-in-cmake-gui/13151 "2024-12-08T22:35:35Z")

</div>

When using cmake-gui to generate a project with the generator set to Ninja Multi-Config and the compiler set to Visual Studio 15 2017, how do you specify the toolset as v141\_xp?

---

## [Why doesn't target\_compile\_options() print console warnings like set(CMAKE\_LANG\_FLAGS...)?](https://discourse.cmake.org/t/why-doesnt-target-compile-options-print-console-warnings-like-set-cmake-lang-flags/11371)

<div class="topic-metadata">

**Author:** [@RudyFisher7](https://discourse.cmake.org/u/RudyFisher7)\
**Replies:** 3\
**Last updated:** [December 5, 2024, 8:10pm UTC](https://discourse.cmake.org/t/why-doesnt-target-compile-options-print-console-warnings-like-set-cmake-lang-flags/11371 "2024-12-05T20:10:36Z")

</div>

The title says it all really. I’ve built a handful of c++ project with CMake now. set(CMAKE\_CXX\_FLAGS…) needs to be used in order to get the compiler warnings to print during compilation. target\_compile\_options() never p…

---

## [make install Mac arm64](https://discourse.cmake.org/t/make-install-mac-arm64/13128)

<div class="topic-metadata">

**Author:** [@lindsayad](https://discourse.cmake.org/u/lindsayad)\
**Replies:** 0\
**Last updated:** [December 5, 2024, 4:44am UTC](https://discourse.cmake.org/t/make-install-mac-arm64/13128 "2024-12-05T04:44:49Z")

</div>

What is current best practice for avoiding warnings about invalidation of code signatures due to install\_name\_tool modification of binaries when copying from build to install? I’ve found advice to add custom post build c…

---

## [WIX installer GUID clashes](https://discourse.cmake.org/t/wix-installer-guid-clashes/13118)

<div class="topic-metadata">

**Author:** [@mgerhardy](https://discourse.cmake.org/u/mgerhardy)\
**Replies:** 0\
**Last updated:** [December 4, 2024, 8:12am UTC](https://discourse.cmake.org/t/wix-installer-guid-clashes/13118 "2024-12-04T08:12:29Z")

</div>

Hello, I have a problem with wix errors regarding duplicated guids for files I add to a component. I have two components here voxedit voxconvert They both inherit files from a module they depend on (the lua scripts t…

---

## [CMAKE\_PREFIX\_PATH with clang-cl didn't find package](https://discourse.cmake.org/t/cmake-prefix-path-with-clang-cl-didnt-find-package/13109)

<div class="topic-metadata">

**Author:** [@gaz0](https://discourse.cmake.org/u/gaz0)\
**Replies:** 4\
**Last updated:** [December 3, 2024, 8:33pm UTC](https://discourse.cmake.org/t/cmake-prefix-path-with-clang-cl-didnt-find-package/13109 "2024-12-03T20:33:41Z")

</div>

I had a small MSVC x64 project using the template library inja, just to check that I could work with it in a larger project. It used find\_package to locate where cget installed the inja package. To do that I set CMAKE\_PR…

---

## ['No rule to make target' when compiling a Linux kernel module](https://discourse.cmake.org/t/no-rule-to-make-target-when-compiling-a-linux-kernel-module/13106)

<div class="topic-metadata">

**Author:** [@CloseHandle](https://discourse.cmake.org/u/CloseHandle)\
**Replies:** 0\
**Last updated:** [December 2, 2024, 11:26am UTC](https://discourse.cmake.org/t/no-rule-to-make-target-when-compiling-a-linux-kernel-module/13106 "2024-12-02T11:26:43Z")

</div>

Hello, I failed to compile a Linux kernel module using CMake, for example, “Hello World” projects in the following repositories: Christoph Acham / cmake-kernel-module · GitLab GitHub - enginning/cmake-kernel-module: c…

---

## [Prevent FetchContent\_MakeAvailable to execute CMakeLists.txt](https://discourse.cmake.org/t/prevent-fetchcontent-makeavailable-to-execute-cmakelists-txt/12704)

<div class="topic-metadata">

**Author:** [@fry](https://discourse.cmake.org/u/fry)\
**Replies:** 15\
**Last updated:** [December 2, 2024, 1:25pm UTC](https://discourse.cmake.org/t/prevent-fetchcontent-makeavailable-to-execute-cmakelists-txt/12704 "2024-12-02T13:25:23Z")

</div>

After seeing the deprecation warnings for FetchContent\_Populate I replaced it with FetchContent\_MakeAvailable but now my project is failing. I use to do this (in a nutshell) # ... FetchContent\_Declare(re-logging ...) F…

---

## [Advice on C++20 modules (Boost)](https://discourse.cmake.org/t/advice-on-c-20-modules-boost/10641)

<div class="topic-metadata">

**Author:** [@anarthal](https://discourse.cmake.org/u/anarthal)\
**Replies:** 13\
**Last updated:** [December 2, 2024, 8:42am UTC](https://discourse.cmake.org/t/advice-on-c-20-modules-boost/10641 "2024-12-02T08:42:59Z")

</div>

Hi all, I’m a Boost author exploring the possibilities offered by C++20 modules for our codebase. My objective is enabling my users to import my libraries, as per import boost.xyz. I’ve done some research (C++20 modules…

---

## [How to clear link libs added by LINK\_LIBRARIES()](https://discourse.cmake.org/t/how-to-clear-link-libs-added-by-link-libraries/13098)

<div class="topic-metadata">

**Author:** [@tntljc](https://discourse.cmake.org/u/tntljc)\
**Replies:** 0\
**Last updated:** [November 30, 2024, 1:12pm UTC](https://discourse.cmake.org/t/how-to-clear-link-libs-added-by-link-libraries/13098 "2024-11-30T13:12:22Z")

</div>

Basically my code look like this: LINK\_LIBRARIES(Foo) add\_library(StaticLib lib.cpp) add\_executable(Exe) target\_link\_library(StaticLib) set\_target\_properties(Exe PROPERTIES LINK\_LIBRARIES "") # ^^^^^ I called get\_t…

---

## ['MT\_StaticRelease' doesn't match value 'MD\_DynamicRelease'](https://discourse.cmake.org/t/mt-staticrelease-doesnt-match-value-md-dynamicrelease/5428)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 4\
**Last updated:** [November 29, 2024, 11:05pm UTC](https://discourse.cmake.org/t/mt-staticrelease-doesnt-match-value-md-dynamicrelease/5428 "2024-11-29T23:05:18Z")

</div>

I see the document RuntimeLibrary part and then I don’t know what can I do. https://docs.microsoft.com/en-us/previous-versions/jj889284(v=vs.140)?redirectedfrom=MSDN libcpmt.lib(StlCompareStringA.obj) : error LNK2038: …

---

## [Can I use different generator in same project?](https://discourse.cmake.org/t/can-i-use-different-generator-in-same-project/11766)

<div class="topic-metadata">

**Author:** [@fox](https://discourse.cmake.org/u/fox)\
**Replies:** 4\
**Last updated:** [November 29, 2024, 12:22pm UTC](https://discourse.cmake.org/t/can-i-use-different-generator-in-same-project/11766 "2024-11-29T12:22:33Z")

</div>

I want compile a project, use VS 2022. And it contain a library, I want use VS 2017 ,toolset v141 compile it, Can I do this in CMAKE?

---

## [Cmake not seeing project or cmake\_minimum\_required](https://discourse.cmake.org/t/cmake-not-seeing-project-or-cmake-minimum-required/13091)

<div class="topic-metadata">

**Author:** [@algebravic](https://discourse.cmake.org/u/algebravic)\
**Replies:** 1\
**Last updated:** [November 28, 2024, 9:18pm UTC](https://discourse.cmake.org/t/cmake-not-seeing-project-or-cmake-minimum-required/13091 "2024-11-28T21:18:38Z")

</div>

I’m trying to install a package called libsnark on a mac (OS 15.1.1, M3). I’m using cmake 3.31 available from homebrew. Its CMakeLists.txt file starts with cmake\_minimum\_required(VERSION 2.8) project (libsnark) Never…

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

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