# Usage

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

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

**Page:** 66

---

## [How to get output name that will be generated by a Target?](https://discourse.cmake.org/t/how-to-get-output-name-that-will-be-generated-by-a-target/5159)

<div class="topic-metadata">

**Author:** [@fabiop](https://discourse.cmake.org/u/fabiop)\
**Replies:** 4\
**Last updated:** [March 4, 2022, 8:41pm UTC](https://discourse.cmake.org/t/how-to-get-output-name-that-will-be-generated-by-a-target/5159 "2022-03-04T20:41:17Z")

</div>

I want to get the path on disk of the artefact that will be produced by a target. I am using get\_target\_property() with OUTPUT\_NAME property but this does not work. Reading the documentation it seems that this is a prope…

---

## [bison-like tools run in both Debug & Release (in Visual Studio) ?](https://discourse.cmake.org/t/bison-like-tools-run-in-both-debug-release-in-visual-studio/5152)

<div class="topic-metadata">

**Author:** [@johan556](https://discourse.cmake.org/u/johan556)\
**Replies:** 3\
**Last updated:** [March 4, 2022, 8:39pm UTC](https://discourse.cmake.org/t/bison-like-tools-run-in-both-debug-release-in-visual-studio/5152 "2022-03-04T20:39:54Z")

</div>

We have an in-house code generator similar to Bison (generating both h- and cpp-files). We describe it with an add\_custom\_command() call. The generation of the h/cpp-files is independent of Debug/Release, so I had assume…

---

## [How to create MD5 file within add\_custom\_target](https://discourse.cmake.org/t/how-to-create-md5-file-within-add-custom-target/5156)

<div class="topic-metadata">

**Author:** [@fabiop](https://discourse.cmake.org/u/fabiop)\
**Replies:** 5\
**Last updated:** [March 4, 2022, 8:38pm UTC](https://discourse.cmake.org/t/how-to-create-md5-file-within-add-custom-target/5156 "2022-03-04T20:38:27Z")

</div>

I would like to create a file containing the MD5 computed over another file, within the implementation of a custom target (so, not using file(MD5…)). Once I have done cmake -E md5sum filename, how to store the result in…

---

## [cmake is trying to set permissions on /usr/include](https://discourse.cmake.org/t/cmake-is-trying-to-set-permissions-on-usr-include/5158)

<div class="topic-metadata">

**Author:** [@johnburrell](https://discourse.cmake.org/u/johnburrell)\
**Replies:** 1\
**Last updated:** [March 4, 2022, 11:58am UTC](https://discourse.cmake.org/t/cmake-is-trying-to-set-permissions-on-usr-include/5158 "2022-03-04T11:58:34Z")

</div>

I’m trying to install frei0r-plugins which uses cmake for installation. I get this error when doing make install: Install the project… – Install configuration: “Release” – Up-to-date: /usr/./include CMake Error at c…

---

## [How to override compiler optimisation level?](https://discourse.cmake.org/t/how-to-override-compiler-optimisation-level/5153)

<div class="topic-metadata">

**Author:** [@DavidA](https://discourse.cmake.org/u/DavidA)\
**Replies:** 5\
**Last updated:** [March 4, 2022, 12:17am UTC](https://discourse.cmake.org/t/how-to-override-compiler-optimisation-level/5153 "2022-03-04T00:17:59Z")

</div>

What is the modern CMake way of overriding (replacing) the C++ optimisation level (for all targets) ? For Release builds using armclang I want to replace -O3 with -Ofast.

---

## [Programmatically select cxx\_std\_\<yy\> meta features](https://discourse.cmake.org/t/programmatically-select-cxx-std-yy-meta-features/5143)

<div class="topic-metadata">

**Author:** [@h-vetinari](https://discourse.cmake.org/u/h-vetinari)\
**Replies:** 2\
**Last updated:** [March 3, 2022, 10:15pm UTC](https://discourse.cmake.org/t/programmatically-select-cxx-std-yy-meta-features/5143 "2022-03-03T22:15:52Z")

</div>

Hey all I’m working on packaging abseil-cpp for conda-forge; abseil already uses target\_compile\_features, but sets it only to cxx\_std\_11, which is to my understanding not correct if abseil itself is compiled with a newe…

---

## [How to distinguish WIndows Architecture](https://discourse.cmake.org/t/how-to-distinguish-windows-architecture/5104)

<div class="topic-metadata">

**Author:** [@fabiop](https://discourse.cmake.org/u/fabiop)\
**Replies:** 5\
**Last updated:** [March 2, 2022, 3:20pm UTC](https://discourse.cmake.org/t/how-to-distinguish-windows-architecture/5104 "2022-03-02T15:20:02Z")

</div>

Hi all, Is there any CMake variable for distinguish, on Windows, if we are building for 32 bits Architecture or 64 bits Architecture? Thanks in advance for any help

---

## [Usage of Windows\_TemporaryKey.pfx](https://discourse.cmake.org/t/usage-of-windows-temporarykey-pfx/5146)

<div class="topic-metadata">

**Author:** [@Veena\_Lakshmana\_Swam](https://discourse.cmake.org/u/Veena_Lakshmana_Swam)\
**Replies:** 1\
**Last updated:** [March 2, 2022, 12:16pm UTC](https://discourse.cmake.org/t/usage-of-windows-temporarykey-pfx/5146 "2022-03-02T12:16:03Z")

</div>

Hello everyone, Hope you are doing well. I have a query on one of the files that are a part of CMake download. I did not find documentation on this: When I download the sources, I get the file share/cmake-3.15/Templat…

---

## [How to run unit tests on a C project (like an Operating System) that redefines built-in functions?](https://discourse.cmake.org/t/how-to-run-unit-tests-on-a-c-project-like-an-operating-system-that-redefines-built-in-functions/5145)

<div class="topic-metadata">

**Author:** [@p4t](https://discourse.cmake.org/u/p4t)\
**Replies:** 0\
**Last updated:** [March 2, 2022, 5:41am UTC](https://discourse.cmake.org/t/how-to-run-unit-tests-on-a-c-project-like-an-operating-system-that-redefines-built-in-functions/5145 "2022-03-02T05:41:26Z")

</div>

I’m learning about Operating Systems by using the OS161 teaching kernel that was developed by Harvard and used by several online courses and MOOCs like the one I’m taking. I’m keen to do some of the exercises for OS161;…

---

## [How to Simplify build time commands](https://discourse.cmake.org/t/how-to-simplify-build-time-commands/5135)

<div class="topic-metadata">

**Author:** [@fabiop](https://discourse.cmake.org/u/fabiop)\
**Replies:** 2\
**Last updated:** [March 1, 2022, 3:43pm UTC](https://discourse.cmake.org/t/how-to-simplify-build-time-commands/5135 "2022-03-01T15:43:16Z")

</div>

Hi everyone, i’m writing a target for building and uploading at build time a custom target, and i have written a monster like this: add\_custom\_target(targetUploader # Install target in installDir within its bin…

---

## [macOS: cmake detect system processor incorrectly on Apple Silicon?](https://discourse.cmake.org/t/macos-cmake-detect-system-processor-incorrectly-on-apple-silicon/5129)

<div class="topic-metadata">

**Author:** [@Cham\_Su](https://discourse.cmake.org/u/Cham_Su)\
**Replies:** 5\
**Last updated:** [March 1, 2022, 2:12pm UTC](https://discourse.cmake.org/t/macos-cmake-detect-system-processor-incorrectly-on-apple-silicon/5129 "2022-03-01T14:12:29Z")

</div>

When I use cmake(3.22 or 3.23), the CMAKE\_SYSTEM\_PROCESSOR equal “x86\_64” with Mac 1M silicon, while the expected value is “arm64”. I don’t know whether there are bugs or my environments errors.

---

## [preset: include from other files](https://discourse.cmake.org/t/preset-include-from-other-files/4392)

<div class="topic-metadata">

**Author:** [@gerhardol](https://discourse.cmake.org/u/gerhardol)\
**Replies:** 2\
**Last updated:** [February 28, 2022, 3:48pm UTC](https://discourse.cmake.org/t/preset-include-from-other-files/4392 "2022-02-28T15:48:09Z")

</div>

A few suggestions for the nice preset feature preset include other files There is currently only possible to have presets read from two files in the root directory: CMakePresets.json and CMakeUserPresets.json It is n…

---

## [How to prevent cmake from getting source if the package is already installed.](https://discourse.cmake.org/t/how-to-prevent-cmake-from-getting-source-if-the-package-is-already-installed/5114)

<div class="topic-metadata">

**Author:** [@MatN](https://discourse.cmake.org/u/MatN)\
**Replies:** 6\
**Last updated:** [February 28, 2022, 3:37pm UTC](https://discourse.cmake.org/t/how-to-prevent-cmake-from-getting-source-if-the-package-is-already-installed/5114 "2022-02-28T15:37:07Z")

</div>

System x86\_64, Fedora\_35. I am trying to build LinuxDeploy locally. This consistently fails in CImg . This is header-only source, which is installed via the package manager (package CImg-devel on Fedora). Two problems: …

---

## [Empty DMG File](https://discourse.cmake.org/t/empty-dmg-file/5130)

<div class="topic-metadata">

**Author:** [@mrmsdbdl](https://discourse.cmake.org/u/mrmsdbdl)\
**Replies:** 1\
**Last updated:** [February 28, 2022, 3:28pm UTC](https://discourse.cmake.org/t/empty-dmg-file/5130 "2022-02-28T15:28:10Z")

</div>

I’m trying to create a DMG file using the CPack DragNDrop generator, however, for some reason, the final DMG that CMake creates does not include my .app file. I think this is because I’m not actually creating a Bundle us…

---

## [Conditional (target/dependency based) fetchcontent?](https://discourse.cmake.org/t/conditional-target-dependency-based-fetchcontent/5124)

<div class="topic-metadata">

**Author:** [@kfsone](https://discourse.cmake.org/u/kfsone)\
**Replies:** 1\
**Last updated:** [February 27, 2022, 8:41pm UTC](https://discourse.cmake.org/t/conditional-target-dependency-based-fetchcontent/5124 "2022-02-27T20:41:29Z")

</div>

In the following pseduo-scenario, I’d like fetch content to only fetch/do anything when the dependent target is being built. Include(FetchContent) Add\_Library( MyLib ... ) FetchContent\_Declare( fmt ... ) FetchC…

---

## [Boost/CMake Deeper understanding (Boost\_Use\_XYZ) flags](https://discourse.cmake.org/t/boost-cmake-deeper-understanding-boost-use-xyz-flags/5125)

<div class="topic-metadata">

**Author:** [@leeruns](https://discourse.cmake.org/u/leeruns)\
**Replies:** 0\
**Last updated:** [February 27, 2022, 4:42pm UTC](https://discourse.cmake.org/t/boost-cmake-deeper-understanding-boost-use-xyz-flags/5125 "2022-02-27T16:42:30Z")

</div>

Let me start by saying I spent a while on this and have done my share of digging, but really know that to truly improve we all have to admit what we don’t know. Well, i got through a bug and cannot actually explain why …

---

## [Install IMPORTED\_RUNTIME\_ARTIFACTS does nothing](https://discourse.cmake.org/t/install-imported-runtime-artifacts-does-nothing/5123)

<div class="topic-metadata">

**Author:** [@marstaik](https://discourse.cmake.org/u/marstaik)\
**Replies:** 3\
**Last updated:** [February 26, 2022, 9:23pm UTC](https://discourse.cmake.org/t/install-imported-runtime-artifacts-does-nothing/5123 "2022-02-26T21:23:25Z")

</div>

Hi, I’ve been trying to find a simple way to copy an imported libs runtime artifacts into an installation directory. In my project, I have a final executable that is built, as well as a static/shared libraries (plural) t…

---

## [Property PROCESSOR\_AFFINITY has no effect](https://discourse.cmake.org/t/property-processor-affinity-has-no-effect/5106)

<div class="topic-metadata">

**Author:** [@sporksmith](https://discourse.cmake.org/u/sporksmith)\
**Replies:** 4\
**Last updated:** [February 25, 2022, 2:18pm UTC](https://discourse.cmake.org/t/property-processor-affinity-has-no-effect/5106 "2022-02-25T14:18:19Z")

</div>

I’m running a large test suite for a project that gets a significant performance benefit from CPU pinning. Currently we disable this feature in our test suite, since otherwise parallel tests would try to pin to the same…

---

## [CTEST\_CUSTOM\_POST\_TEST runs when doing "ctest -N"](https://discourse.cmake.org/t/ctest-custom-post-test-runs-when-doing-ctest-n/5066)

<div class="topic-metadata">

**Author:** [@janhieber](https://discourse.cmake.org/u/janhieber)\
**Replies:** 4\
**Last updated:** [February 25, 2022, 12:30pm UTC](https://discourse.cmake.org/t/ctest-custom-post-test-runs-when-doing-ctest-n/5066 "2022-02-25T12:30:59Z")

</div>

I use CTEST\_CUSTOM\_POST\_TEST in CTestCustom.cmake to do postprocessing of tests. My problem is that these commands are even executed when I do ctest -N to list available tests. Is this intended? Is there a ways to prev…

---

## [cmake --job](https://discourse.cmake.org/t/cmake-job/5081)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 6\
**Last updated:** [February 24, 2022, 3:28pm UTC](https://discourse.cmake.org/t/cmake-job/5081 "2022-02-24T15:28:40Z")

</div>

cmake --help I cant find --job information. Here is the command and I want to speed up the build and install. How can I add some parameter for the command to speed up? cmake -B build/ -D CMAKE\_BUILD\_TYPE=Release cmak…

---

## [ninja and cmake --install](https://discourse.cmake.org/t/ninja-and-cmake-install/5108)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 1\
**Last updated:** [February 24, 2022, 3:27pm UTC](https://discourse.cmake.org/t/ninja-and-cmake-install/5108 "2022-02-24T15:27:35Z")

</div>

cmake -B build/ -D CMAKE\_BUILD\_TYPE=Release cmake --build build/ --config Release -j12 cmake --install build/ --config Release --prefix C:/release/ -j12 and cmake -B build/ -D CMAKE\_BUILD\_TYPE=Release ninja install . -…

---

## [cmake: how to use libtorch in my project](https://discourse.cmake.org/t/cmake-how-to-use-libtorch-in-my-project/5092)

<div class="topic-metadata">

**Author:** [@zhang-qiang-github](https://discourse.cmake.org/u/zhang-qiang-github)\
**Replies:** 1\
**Last updated:** [February 23, 2022, 3:35pm UTC](https://discourse.cmake.org/t/cmake-how-to-use-libtorch-in-my-project/5092 "2022-02-23T15:35:21Z")

</div>

I want to use libtorch in my project. The libtorch release the debug/release version: Download here (Release version): https://download.pytorch.org/libtorch/cu102/libtorch-win-shared-with-deps-1.10.2%2Bcu102.zip Downlo…

---

## [Visual Studio: The Fortran compiler is not able to compile a simple test program.](https://discourse.cmake.org/t/visual-studio-the-fortran-compiler-is-not-able-to-compile-a-simple-test-program/5091)

<div class="topic-metadata">

**Author:** [@FFFFFG-IGG](https://discourse.cmake.org/u/FFFFFG-IGG)\
**Replies:** 1\
**Last updated:** [February 23, 2022, 3:33pm UTC](https://discourse.cmake.org/t/visual-studio-the-fortran-compiler-is-not-able-to-compile-a-simple-test-program/5091 "2022-02-23T15:33:59Z")

</div>

I‘m a visual studio user under win11. Now I’d like compile the source code downloaded from github and further generate the vs 2022 project with Cmake 3.23.0-rc1(gui). But I met some mistakes and could not find the way ou…

---

## [How to Upload/Download files at build time](https://discourse.cmake.org/t/how-to-upload-download-files-at-build-time/5086)

<div class="topic-metadata">

**Author:** [@fabiop](https://discourse.cmake.org/u/fabiop)\
**Replies:** 7\
**Last updated:** [February 22, 2022, 4:26pm UTC](https://discourse.cmake.org/t/how-to-upload-download-files-at-build-time/5086 "2022-02-22T16:26:11Z")

</div>

I have to download/upload some files at build time, not a configure time. So, i am using a custom target, but how to specify a command for downloading/uploading data at build time (at configure time i would use file() co…

---

## [Cross compiling to ARM, CMAKE can't find libraries](https://discourse.cmake.org/t/cross-compiling-to-arm-cmake-cant-find-libraries/5080)

<div class="topic-metadata">

**Author:** [@nwetter](https://discourse.cmake.org/u/nwetter)\
**Replies:** 5\
**Last updated:** [February 22, 2022, 11:54am UTC](https://discourse.cmake.org/t/cross-compiling-to-arm-cmake-cant-find-libraries/5080 "2022-02-22T11:54:45Z")

</div>

I’m trying to get our existing project to cross compile because it takes so long to compile on the target. I’ve looked through many articles and tutorials and it looks simple, but it just won’t work. I know the libraries…

---

## [\`include\_guard\` useful in files that only define functions?](https://discourse.cmake.org/t/include-guard-useful-in-files-that-only-define-functions/5057)

<div class="topic-metadata">

**Author:** [@dbahadir](https://discourse.cmake.org/u/dbahadir)\
**Replies:** 5\
**Last updated:** [February 22, 2022, 11:39am UTC](https://discourse.cmake.org/t/include-guard-useful-in-files-that-only-define-functions/5057 "2022-02-22T11:39:47Z")

</div>

I quite often have CMake files that only define several CMake functions (and nothing in the surrounding file scope) and I include these in order to be able to call such functions. I was wondering if an include\_guard has…

---

## [Why does /MP turn to /MP1](https://discourse.cmake.org/t/why-does-mp-turn-to-mp1/5072)

<div class="topic-metadata">

**Author:** [@imrichardcole](https://discourse.cmake.org/u/imrichardcole)\
**Replies:** 1\
**Last updated:** [February 21, 2022, 8:05pm UTC](https://discourse.cmake.org/t/why-does-mp-turn-to-mp1/5072 "2022-02-21T20:05:02Z")

</div>

I’m using CMake with Visual Studio (i.e MSBuild). I have the /MP setting across the board, but running on various machines with 8, 16, 32 physical cores, I’m seeing /MP1 being set when cl.exe is called. Why is my desire…

---

## [building standalone app bundle with SSL certs](https://discourse.cmake.org/t/building-standalone-app-bundle-with-ssl-certs/5078)

<div class="topic-metadata">

**Author:** [@ipatch](https://discourse.cmake.org/u/ipatch)\
**Replies:** 0\
**Last updated:** [February 21, 2022, 6:14pm UTC](https://discourse.cmake.org/t/building-standalone-app-bundle-with-ssl-certs/5078 "2022-02-21T18:14:34Z")

</div>

hello, :wave: i’m one of the current tap maintainers for the homebrew-freecad tap. i’ve run into an issue building freecad into a self contained apple .app bundle. the issue pertains to SSL. Freecad itself is compromise…

---

## [cmake -B parameter](https://discourse.cmake.org/t/cmake-b-parameter/5012)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 12\
**Last updated:** [February 21, 2022, 6:48am UTC](https://discourse.cmake.org/t/cmake-b-parameter/5012 "2022-02-21T06:48:53Z")

</div>

If I have a project sample ../sample/ ├── build ├── CMakeLists.txt ├── main.cpp └── release Is the two command the same thing? cd sample\\build cmake -S ..\\ cd sample cmake -S .\\ -B build ref: cmake --install

---

## [\[Visual Studio\] Setting arbitary configuration properties in project file](https://discourse.cmake.org/t/visual-studio-setting-arbitary-configuration-properties-in-project-file/5049)

<div class="topic-metadata">

**Author:** [@ian.gralinski.inv](https://discourse.cmake.org/u/ian.gralinski.inv)\
**Replies:** 2\
**Last updated:** [February 21, 2022, 12:02am UTC](https://discourse.cmake.org/t/visual-studio-setting-arbitary-configuration-properties-in-project-file/5049 "2022-02-21T00:02:59Z")

</div>

Is there a way to set arbitrary configuration properties in a Visual Studio project file from CMake? As a concrete example I would like the following to appear in the generated project file: \<PropertyGroup Condition="'…

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

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