# Usage

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

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

**Page:** 2

---

## [newbie question about cmake escape character](https://discourse.cmake.org/t/newbie-question-about-cmake-escape-character/15722)

<div class="topic-metadata">

**Author:** [@yushang](https://discourse.cmake.org/u/yushang)\
**Replies:** 0\
**Last updated:** [June 20, 2026, 2:36am UTC](https://discourse.cmake.org/t/newbie-question-about-cmake-escape-character/15722 "2026-06-20T02:36:21Z")

</div>

Hi guys, by this syntax https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#escape-sequences $ is not a valid escape character, but \\${} works. What I’v missed?

---

## [Help with Cmake version problem stopping IC design software install](https://discourse.cmake.org/t/help-with-cmake-version-problem-stopping-ic-design-software-install/15716)

<div class="topic-metadata">

**Author:** [@Fasttrain77](https://discourse.cmake.org/u/Fasttrain77)\
**Replies:** 1\
**Last updated:** [June 17, 2026, 7:09pm UTC](https://discourse.cmake.org/t/help-with-cmake-version-problem-stopping-ic-design-software-install/15716 "2026-06-17T19:09:38Z")

</div>

Hi: Please forward this to the correct area if this isn’t the right team. I am a student working on an online integrated circuit design course. I am using ubuntu linux 26. I am trying to install tools so I can do the co…

---

## [find\_package: can't find "jansson" library](https://discourse.cmake.org/t/find-package-cant-find-jansson-library/15711)

<div class="topic-metadata">

**Author:** [@bam](https://discourse.cmake.org/u/bam)\
**Replies:** 1\
**Last updated:** [June 17, 2026, 9:23am UTC](https://discourse.cmake.org/t/find-package-cant-find-jansson-library/15711 "2026-06-17T09:23:41Z")

</div>

Hi, cmake can’t find “jansson” library: \[cmake\] CMake Error at CMakeLists.txt:187 (find\_package): \[cmake\] Could not find a package configuration file provided by "jansson" with any \[cmake\] of the following names: \[c…

---

## [ninja: build stopped: subcommand failed.](https://discourse.cmake.org/t/ninja-build-stopped-subcommand-failed/15713)

<div class="topic-metadata">

**Author:** [@perdrix](https://discourse.cmake.org/u/perdrix)\
**Replies:** 2\
**Last updated:** [June 16, 2026, 9:53am UTC](https://discourse.cmake.org/t/ninja-build-stopped-subcommand-failed/15713 "2026-06-16T09:53:04Z")

</div>

I’m running a CMake build and got part way through and was then presented with the cryptic message in the subject line: ninja: build stopped: subcommand failed. The file ninja.log in my build directory doesn’t give m…

---

## [Unexpected/incomplete \`install\` of CSharp library/executable/NuGet](https://discourse.cmake.org/t/unexpected-incomplete-install-of-csharp-library-executable-nuget/15708)

<div class="topic-metadata">

**Author:** [@kevinyee](https://discourse.cmake.org/u/kevinyee)\
**Replies:** 0\
**Last updated:** [June 11, 2026, 4:38am UTC](https://discourse.cmake.org/t/unexpected-incomplete-install-of-csharp-library-executable-nuget/15708 "2026-06-11T04:38:56Z")

</div>

In the example below, I would expect the everything (MyExecutable.exe, CommandLine.dll, MyLibrary.dll and Newtonsoft.Json.dll) to be installed to bin (i.e. CMAKE\_INSTALL\_BINDIR). I observe the following (output pasted be…

---

## [The C compiler "/usr/bin/cc" is not able to compile a simple test program.](https://discourse.cmake.org/t/the-c-compiler-usr-bin-cc-is-not-able-to-compile-a-simple-test-program/6258)

<div class="topic-metadata">

**Author:** [@Doug\_Rattmann](https://discourse.cmake.org/u/Doug_Rattmann)\
**Replies:** 8\
**Last updated:** [June 10, 2026, 6:18am UTC](https://discourse.cmake.org/t/the-c-compiler-usr-bin-cc-is-not-able-to-compile-a-simple-test-program/6258 "2026-06-10T06:18:23Z")

</div>

Hi I was triying to install asepire by source i followed this tutorial: How to Compile Aseprite on Ubuntu Linux - YouTube on Linux Mint 19.3 its my first time trying to install something from source and using Cmake so Ia…

---

## [How to include subdirectory with a different generator?](https://discourse.cmake.org/t/how-to-include-subdirectory-with-a-different-generator/15594)

<div class="topic-metadata">

**Author:** [@Shane](https://discourse.cmake.org/u/Shane)\
**Replies:** 10\
**Last updated:** [June 5, 2026, 9:10am UTC](https://discourse.cmake.org/t/how-to-include-subdirectory-with-a-different-generator/15594 "2026-06-05T09:10:42Z")

</div>

Hello, I have two working CMakeList.txt files - \<project root\>CMakeList.txt #\[\[ # build with shared prebuilt SDL3 library (DLL) cmake -B build -G "Ninja Multi-Config" cmake --build build build\\Debug\\hello.exe cm…

---

## [presets: Omitting \`generator\` does not default to regular generator discovery procedure](https://discourse.cmake.org/t/presets-omitting-generator-does-not-default-to-regular-generator-discovery-procedure/7910)

<div class="topic-metadata">

**Author:** [@dabe](https://discourse.cmake.org/u/dabe)\
**Replies:** 2\
**Last updated:** [June 1, 2026, 12:38am UTC](https://discourse.cmake.org/t/presets-omitting-generator-does-not-default-to-regular-generator-discovery-procedure/7910 "2026-06-01T00:38:44Z")

</div>

I have a project that I’d like to use different generators for depending on the OS that is compiling it (specifically, Unix Makefiles for Linux and Visual Studio/Ninja for Windows). I’d like to just let the automatic ge…

---

## [cmake --install build/ --parallel autodetect impossible](https://discourse.cmake.org/t/cmake-install-build-parallel-autodetect-impossible/15687)

<div class="topic-metadata">

**Author:** [@Andrei\_Cherniaev](https://discourse.cmake.org/u/Andrei_Cherniaev)\
**Replies:** 0\
**Last updated:** [May 31, 2026, 5:08pm UTC](https://discourse.cmake.org/t/cmake-install-build-parallel-autodetect-impossible/15687 "2026-05-31T17:08:42Z")

</div>

As you know from doc, cmake --install can be given the --parallel \<jobs\> option to specify a maximum number of jobs. Why cmake can’t autodetect max number of jobs? I am sad surprised because cmake can detect the max num…

---

## [How to trigger recompilation on change of emcc --pre-js source files?](https://discourse.cmake.org/t/how-to-trigger-recompilation-on-change-of-emcc-pre-js-source-files/15669)

<div class="topic-metadata">

**Author:** [@Shane](https://discourse.cmake.org/u/Shane)\
**Replies:** 2\
**Last updated:** [May 28, 2026, 7:06am UTC](https://discourse.cmake.org/t/how-to-trigger-recompilation-on-change-of-emcc-pre-js-source-files/15669 "2026-05-28T07:06:38Z")

</div>

Hello, I have a working CMakeLists.txt which uses the emscripten compiler frontend (emcc). The core source files are written in C++ and when they are changed, cmake --build triggers recompilation as expected. emcc also …

---

## [Setting a known commit ID in the CTest Update Step for source tarballs](https://discourse.cmake.org/t/setting-a-known-commit-id-in-the-ctest-update-step-for-source-tarballs/15664)

<div class="topic-metadata">

**Author:** [@hebasto](https://discourse.cmake.org/u/hebasto)\
**Replies:** 0\
**Last updated:** [May 26, 2026, 2:49pm UTC](https://discourse.cmake.org/t/setting-a-known-commit-id-in-the-ctest-update-step-for-source-tarballs/15664 "2026-05-26T14:49:07Z")

</div>

Hi, One of the pipelines in our CI downloads a source tarball of the master branch (generated via git archive) and extracts the top commit hash from it. Because it’s a tarball, there is no actual .git directory present. …

---

## [Generate Build Database is Empty](https://discourse.cmake.org/t/generate-build-database-is-empty/15654)

<div class="topic-metadata">

**Author:** [@mwasplund](https://discourse.cmake.org/u/mwasplund)\
**Replies:** 8\
**Last updated:** [May 26, 2026, 1:50pm UTC](https://discourse.cmake.org/t/generate-build-database-is-empty/15654 "2026-05-26T13:50:31Z")

</div>

I am attempting to experiment with the experimental CMAKE\_EXPORT\_BUILD\_DATABASE flag. I think I got it up and running to the point where the cmake\_build\_database target is generating a build\_database.json. However the se…

---

## [Cannot bootstrap CMake 4.3.2 with nvc++ compiler](https://discourse.cmake.org/t/cannot-bootstrap-cmake-4-3-2-with-nvc-compiler/15663)

<div class="topic-metadata">

**Author:** [@MicPellegrino](https://discourse.cmake.org/u/MicPellegrino)\
**Replies:** 0\
**Last updated:** [May 26, 2026, 11:47am UTC](https://discourse.cmake.org/t/cannot-bootstrap-cmake-4-3-2-with-nvc-compiler/15663 "2026-05-26T11:47:39Z")

</div>

Hi, I am trying to build CMake 4.3.2 (NB not build with CMake) on my local university cluster. Since there’s no CUDA module (sigh) but plenty of NVHPC compiler modules (wrapping CUDA), I am trying to build CMake using n…

---

## [Why does cmake not have a \`--run option\` , or does it?](https://discourse.cmake.org/t/why-does-cmake-not-have-a-run-option-or-does-it/15661)

<div class="topic-metadata">

**Author:** [@a4z](https://discourse.cmake.org/u/a4z)\
**Replies:** 2\
**Last updated:** [May 23, 2026, 10:21am UTC](https://discourse.cmake.org/t/why-does-cmake-not-have-a-run-option-or-does-it/15661 "2026-05-23T10:21:58Z")

</div>

Can we have something like this, please cmake --run --preset brewgcc –target hello to run the add\_executable with the name hello or do we have that already?

---

## [CMake 4.2.3 picks wrong MSVC?](https://discourse.cmake.org/t/cmake-4-2-3-picks-wrong-msvc/15572)

<div class="topic-metadata">

**Author:** [@exoosh](https://discourse.cmake.org/u/exoosh)\
**Replies:** 7\
**Last updated:** [May 20, 2026, 1:48pm UTC](https://discourse.cmake.org/t/cmake-4-2-3-picks-wrong-msvc/15572 "2026-05-20T13:48:17Z")

</div>

Hi, so today I tried to build a project where we used to rely on the fact that CMake uses the ambient environment to figure out the compiler to use. Alas, despite being started in the VS2022 Developer Powershell, it en…

---

## [Generator expression $\<INSTALL\_PREFIX\> doesn't work with env variable DESTDIR](https://discourse.cmake.org/t/generator-expression-install-prefix-doesnt-work-with-env-variable-destdir/15645)

<div class="topic-metadata">

**Author:** [@jst\_mbs](https://discourse.cmake.org/u/jst_mbs)\
**Replies:** 5\
**Last updated:** [May 12, 2026, 2:51pm UTC](https://discourse.cmake.org/t/generator-expression-install-prefix-doesnt-work-with-env-variable-destdir/15645 "2026-05-12T14:51:21Z")

</div>

Using the generator expression $\<INSTALL\_PREFIX\> in install(CODE ) should work with CMake 3.27 and later. But the generator expression doesn’t work with the enviroment variable DESTDIR. I don’t know if this is the intend…

---

## [generate .o files from compiler instead of .obj files](https://discourse.cmake.org/t/generate-o-files-from-compiler-instead-of-obj-files/2690)

<div class="topic-metadata">

**Author:** [@deepan](https://discourse.cmake.org/u/deepan)\
**Replies:** 14\
**Last updated:** [May 6, 2026, 3:45am UTC](https://discourse.cmake.org/t/generate-o-files-from-compiler-instead-of-obj-files/2690 "2026-05-06T03:45:09Z")

</div>

I am working in an embedded project. target : ppc compiler : windriver Host environment : windows 10 build generator : cmake, MinGW makefiles during compilation i see .c.obj getting generated. I want .o instead of .…

---

## [Cache invalidation doesn't affect compile\_commands.json?](https://discourse.cmake.org/t/cache-invalidation-doesnt-affect-compile-commands-json/15642)

<div class="topic-metadata">

**Author:** [@tali](https://discourse.cmake.org/u/tali)\
**Replies:** 2\
**Last updated:** [May 5, 2026, 10:10pm UTC](https://discourse.cmake.org/t/cache-invalidation-doesnt-affect-compile-commands-json/15642 "2026-05-05T22:10:10Z")

</div>

Hello all - If a build directory is generated with -DCMAKE\_EXPORT\_COMPILE\_COMMANDS=1, and then the CMake command is run again identically but with a (different) value for --DCMAKE\_CXX\_COMPILER or -DCMAKE\_C\_COMPILER, the c…

---

## [/F MSVC stack size not working with CMake](https://discourse.cmake.org/t/f-msvc-stack-size-not-working-with-cmake/15641)

<div class="topic-metadata">

**Author:** [@AliADev](https://discourse.cmake.org/u/AliADev)\
**Replies:** 0\
**Last updated:** [May 5, 2026, 5:34pm UTC](https://discourse.cmake.org/t/f-msvc-stack-size-not-working-with-cmake/15641 "2026-05-05T17:34:23Z")

</div>

This program stack overflows by default on windows, because it allocates more than 1MB on the stack on debug builds. So I pass /F to MSVC and it works. However, when I do it in CMake, it does not seem to work and keep ge…

---

## [Print generated command by add\_custom\_command](https://discourse.cmake.org/t/print-generated-command-by-add-custom-command/15638)

<div class="topic-metadata">

**Author:** [@matdubuisson](https://discourse.cmake.org/u/matdubuisson)\
**Replies:** 1\
**Last updated:** [May 4, 2026, 10:35am UTC](https://discourse.cmake.org/t/print-generated-command-by-add-custom-command/15638 "2026-05-04T10:35:32Z")

</div>

Hello, I have a simple question, is it possible to ask cmake to print all generated commands our I have to do it manually py setting the COMMENT option of add\_custom\_command or adding a log ? Thank you in advance, Bes…

---

## [CMake C++17 "does not name a type" however class is included](https://discourse.cmake.org/t/cmake-c-17-does-not-name-a-type-however-class-is-included/15637)

<div class="topic-metadata">

**Author:** [@matdubuisson](https://discourse.cmake.org/u/matdubuisson)\
**Replies:** 2\
**Last updated:** [May 3, 2026, 8:18am UTC](https://discourse.cmake.org/t/cmake-c-17-does-not-name-a-type-however-class-is-included/15637 "2026-05-03T08:18:27Z")

</div>

Hello everyone, I have upgraded a project from cmake 2.8 to cmake 4.0 and llvm 3.9.0 to 22.1.0 so of course I got compilation issues. For example in the project there is a class not found error for vm.hh file and the cl…

---

## [Update CMake/CLang/LLVM versions of a big project Mozart2 system](https://discourse.cmake.org/t/update-cmake-clang-llvm-versions-of-a-big-project-mozart2-system/15622)

<div class="topic-metadata">

**Author:** [@matdubuisson](https://discourse.cmake.org/u/matdubuisson)\
**Replies:** 1\
**Last updated:** [May 2, 2026, 6:42pm UTC](https://discourse.cmake.org/t/update-cmake-clang-llvm-versions-of-a-big-project-mozart2-system/15622 "2026-05-02T18:42:46Z")

</div>

Hello everyone, I’m improving a programing language GitHub - mozart/mozart2: Mozart Programming System v2 · GitHub for my master thesis. The thing is it does a while no one made a real change so the build tools versions…

---

## ["CMAKE\_INSTALL\_RPATH $ORIGIN" expands to empty](https://discourse.cmake.org/t/cmake-install-rpath-origin-expands-to-empty/13876)

<div class="topic-metadata">

**Author:** [@Taw\_Moto](https://discourse.cmake.org/u/Taw_Moto)\
**Replies:** 9\
**Last updated:** [April 30, 2026, 2:23pm UTC](https://discourse.cmake.org/t/cmake-install-rpath-origin-expands-to-empty/13876 "2026-04-30T14:23:56Z")

</div>

Hi, I have an utils.cmake file which is used by all my projects and some of the lines were set(CMAKE\_SHARED\_LINKER\_FLAGS “${CMAKE\_SHARED\_LINKER\_FLAGS} -Wl,-rpath,‘$ORIGIN’”) set(CMAKE\_EXE\_LINKER\_FLAGS “${CMAKE\_EXE\_LIN…

---

## [CMAKE\_COMMAND variable resolves to a different executable](https://discourse.cmake.org/t/cmake-command-variable-resolves-to-a-different-executable/15633)

<div class="topic-metadata">

**Author:** [@nshustov](https://discourse.cmake.org/u/nshustov)\
**Replies:** 2\
**Last updated:** [April 27, 2026, 10:35pm UTC](https://discourse.cmake.org/t/cmake-command-variable-resolves-to-a-different-executable/15633 "2026-04-27T22:35:55Z")

</div>

Hi, I have a question about CMAKE\_COMMAND variable. We have multiple cmake executables in the same /my/bin directory, different in the name: /my/bin/cmake, /my/bin/cmake-3.30.3, /my/bin/cmake-4.1 and so on. When I la…

---

## [CDash dashboard occasionally missing subproject results](https://discourse.cmake.org/t/cdash-dashboard-occasionally-missing-subproject-results/15621)

<div class="topic-metadata">

**Author:** [@yus](https://discourse.cmake.org/u/yus)\
**Replies:** 2\
**Last updated:** [April 27, 2026, 4:22pm UTC](https://discourse.cmake.org/t/cdash-dashboard-occasionally-missing-subproject-results/15621 "2026-04-27T16:22:55Z")

</div>

Hi, I have a project with nightly tests across multiple subprojects, all uploading results to a CDash dashboard. Occasionally, one or two subprojects are missing from the dashboard after a nightly run. The issue seems …

---

## [Static Library VS Object Library Cache generation time](https://discourse.cmake.org/t/static-library-vs-object-library-cache-generation-time/15631)

<div class="topic-metadata">

**Author:** [@siddmohsin](https://discourse.cmake.org/u/siddmohsin)\
**Replies:** 0\
**Last updated:** [April 27, 2026, 4:33am UTC](https://discourse.cmake.org/t/static-library-vs-object-library-cache-generation-time/15631 "2026-04-27T04:33:55Z")

</div>

In my current project, we are creating C++ static libraries and these static libraries are getting linked to my executables. Now we looking directionally to create Object Libraries and consume them in linkage. When we ch…

---

## [FindLibXml2 adds unexpected include flag breaking build](https://discourse.cmake.org/t/findlibxml2-adds-unexpected-include-flag-breaking-build/15609)

<div class="topic-metadata">

**Author:** [@jcurl](https://discourse.cmake.org/u/jcurl)\
**Replies:** 2\
**Last updated:** [April 22, 2026, 5:54pm UTC](https://discourse.cmake.org/t/findlibxml2-adds-unexpected-include-flag-breaking-build/15609 "2026-04-22T17:54:48Z")

</div>

I’m finding the LibXml2 package and would appreciate insights in what I’m doing wrong. CMake 3.22 on Ubuntu 22.04.5. The CMakeLists.txt file contains the snippet: find\_package(LibXml2) if (LibXml2\_FOUND) #target\_incl…

---

## [\[graphviz\] How to generate dependency graph for larger monorepo projects when file names are too long?](https://discourse.cmake.org/t/graphviz-how-to-generate-dependency-graph-for-larger-monorepo-projects-when-file-names-are-too-long/15455)

<div class="topic-metadata">

**Author:** [@kratsg](https://discourse.cmake.org/u/kratsg)\
**Replies:** 5\
**Last updated:** [April 22, 2026, 1:13am UTC](https://discourse.cmake.org/t/graphviz-how-to-generate-dependency-graph-for-larger-monorepo-projects-when-file-names-are-too-long/15455 "2026-04-22T01:13:41Z")

</div>

We have a rather large CMake project for which we can configure/build just fine, but cannot generate graphviz for it due to the filenames being very long. $ cmake -DATLAS\_PACKAGE\_FILTER\_FILE=package\_filters.txt -S colum…

---

## [Force find\_package to fail if required library type (shared vs. static) is not found](https://discourse.cmake.org/t/force-find-package-to-fail-if-required-library-type-shared-vs-static-is-not-found/15612)

<div class="topic-metadata">

**Author:** [@Lars](https://discourse.cmake.org/u/Lars)\
**Replies:** 2\
**Last updated:** [April 21, 2026, 5:34pm UTC](https://discourse.cmake.org/t/force-find-package-to-fail-if-required-library-type-shared-vs-static-is-not-found/15612 "2026-04-21T17:34:13Z")

</div>

Note: a similar issue is described in Choose between shared/static library after find\_package() but the answer is inadequate for some scenarios in my opinion. Near trivial task: I want to link a shared library against d…

---

## [problem using gfortran with MSVC 18](https://discourse.cmake.org/t/problem-using-gfortran-with-msvc-18/15608)

<div class="topic-metadata">

**Author:** [@BillG](https://discourse.cmake.org/u/BillG)\
**Replies:** 0\
**Last updated:** [April 19, 2026, 7:59pm UTC](https://discourse.cmake.org/t/problem-using-gfortran-with-msvc-18/15608 "2026-04-19T19:59:38Z")

</div>

I am trying to use cmake 4.3.0 to build a project with -G “Visual Studio 18 2026” and gfortran. My CMakeLists.txt file includes: set(CMake\_ARCHIVE\_OUTPUT\_DIRECTORY ./my\_fortran\_lib) set(CMake\_RUNTIME\_OUTPUT\_DIRECTOR…

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

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