# Usage

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

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

**Page:** 11

---

## [PCH: Don't understand that part of the doc](https://discourse.cmake.org/t/pch-dont-understand-that-part-of-the-doc/7321)

<div class="topic-metadata">

**Author:** [@Glad](https://discourse.cmake.org/u/Glad)\
**Replies:** 18\
**Last updated:** [June 19, 2025, 8:12pm UTC](https://discourse.cmake.org/t/pch-dont-understand-that-part-of-the-doc/7321 "2025-06-19T20:12:43Z")

</div>

Hi, I don’t clearly understand that part of the precompiler header: Public / Private Specifically that sentence: A notable exception to this is where an interface library is created to define a commonly used set of …

---

## [Unexpected behavior when regenerating a project with Ninja Multi-Config and MSVC](https://discourse.cmake.org/t/unexpected-behavior-when-regenerating-a-project-with-ninja-multi-config-and-msvc/14099)

<div class="topic-metadata">

**Author:** [@aeart](https://discourse.cmake.org/u/aeart)\
**Replies:** 1\
**Last updated:** [June 19, 2025, 1:37am UTC](https://discourse.cmake.org/t/unexpected-behavior-when-regenerating-a-project-with-ninja-multi-config-and-msvc/14099 "2025-06-19T01:37:59Z")

</div>

I have encountered an unusual behavior when regenerating a project using Ninja Multi-Config as the generator and Microsoft Visual C++ (MSVC) as the compiler. Here is a minimal example project consisting of three files: …

---

## [When is started build of target with dependency ?](https://discourse.cmake.org/t/when-is-started-build-of-target-with-dependency/14259)

<div class="topic-metadata">

**Author:** [@cmpeter](https://discourse.cmake.org/u/cmpeter)\
**Replies:** 0\
**Last updated:** [June 18, 2025, 7:23pm UTC](https://discourse.cmake.org/t/when-is-started-build-of-target-with-dependency/14259 "2025-06-18T19:23:13Z")

</div>

Hello, I have first\_target building executable binary and it’s CMakeLists.txt contains add\_custom\_command(TARGET first\_target POST\_BUILD…) Parent CMakeLists.txt contains second\_target which is dependent on first\_target…

---

## [compile\_commands.json and absolute paths in Windows](https://discourse.cmake.org/t/compile-commands-json-and-absolute-paths-in-windows/14257)

<div class="topic-metadata">

**Author:** [@pozz](https://discourse.cmake.org/u/pozz)\
**Replies:** 1\
**Last updated:** [June 18, 2025, 1:54pm UTC](https://discourse.cmake.org/t/compile-commands-json-and-absolute-paths-in-windows/14257 "2025-06-18T13:54:11Z")

</div>

{ "directory": "C:/cmake-vscode-embedded-sample/build/full-sim", "command": "C:\\\\mingw64\\\\bin\\\\gcc.exe -DCONFIG\_FULL -DDEBUG -DPRINT\_INTRO @CMakeFiles/hello.dir/includes\_C.rsp -g3 -Wmissing-declarations -Wextra -Wall…

---

## [How can I introduce external non-CMake project?](https://discourse.cmake.org/t/how-can-i-introduce-external-non-cmake-project/14253)

<div class="topic-metadata">

**Author:** [@ikspress](https://discourse.cmake.org/u/ikspress)\
**Replies:** 3\
**Last updated:** [June 18, 2025, 11:34am UTC](https://discourse.cmake.org/t/how-can-i-introduce-external-non-cmake-project/14253 "2025-06-18T11:34:16Z")

</div>

I’m attempted to introduce flat\_hash\_map and emhash to my CMake project. As you can see, flat\_hash\_map is a header-only library and doesn’t support any build system, so there is unneeded to build. I think add the source…

---

## [External Project and debug/release builds with multi-config generators](https://discourse.cmake.org/t/external-project-and-debug-release-builds-with-multi-config-generators/7469)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 6\
**Last updated:** [June 17, 2025, 8:38pm UTC](https://discourse.cmake.org/t/external-project-and-debug-release-builds-with-multi-config-generators/7469 "2025-06-17T20:38:21Z")

</div>

Hi, I’m struggling a bit with ExternalProject and multi-config generators (MSVC). How do I “tell” ExternalProject\_Add() whether I need a debug or a release build depending on the currently selected build type ? The ex…

---

## [Set VS to debug a child process](https://discourse.cmake.org/t/set-vs-to-debug-a-child-process/14225)

<div class="topic-metadata">

**Author:** [@Zohar](https://discourse.cmake.org/u/Zohar)\
**Replies:** 0\
**Last updated:** [June 11, 2025, 9:52pm UTC](https://discourse.cmake.org/t/set-vs-to-debug-a-child-process/14225 "2025-06-11T21:52:50Z")

</div>

How can I enable the following with cmake:

---

## [Proper way to set and consume boolean settings for a library?](https://discourse.cmake.org/t/proper-way-to-set-and-consume-boolean-settings-for-a-library/14203)

<div class="topic-metadata">

**Author:** [@bmcdonnell-fb](https://discourse.cmake.org/u/bmcdonnell-fb)\
**Replies:** 6\
**Last updated:** [June 11, 2025, 3:16pm UTC](https://discourse.cmake.org/t/proper-way-to-set-and-consume-boolean-settings-for-a-library/14203 "2025-06-11T15:16:30Z")

</div>

I have two CMake application projects, with libraries they share in Git submodules. I include the libraries in the CMake applications using add\_subdirectory() and target\_link\_libraries(). One application uses an RTOS; t…

---

## [Import std in clang with custom stdlibc++](https://discourse.cmake.org/t/import-std-in-clang-with-custom-stdlibc/14042)

<div class="topic-metadata">

**Author:** [@krzysztofkortas](https://discourse.cmake.org/u/krzysztofkortas)\
**Replies:** 3\
**Last updated:** [June 5, 2025, 7:28pm UTC](https://discourse.cmake.org/t/import-std-in-clang-with-custom-stdlibc/14042 "2025-06-05T19:28:42Z")

</div>

Merge request 10727 added support for import std using clang and stdlibc++. I use clang with a custom gcc installation passed through a flag --gcc-install-dir via CMAKE\_CXX\_FLAGS. In the Clang-CXX-CXXImportStd.cmake fil…

---

## [Disable OpenMP (without modifying CMakeLists.txt)](https://discourse.cmake.org/t/disable-openmp-without-modifying-cmakelists-txt/5205)

<div class="topic-metadata">

**Author:** [@jsf](https://discourse.cmake.org/u/jsf)\
**Replies:** 6\
**Last updated:** [June 4, 2025, 5:12pm UTC](https://discourse.cmake.org/t/disable-openmp-without-modifying-cmakelists-txt/5205 "2025-06-04T17:12:33Z")

</div>

I am building a debug build of a project with an existing complicated set of cmake files: https://sourceforge.net/projects/hugin/ I want to avoid OpenMP for the debug build. I strongly prefer to NOT accomplish that by…

---

## [GCC picks up wrong version of the C compiler (MySQL server)](https://discourse.cmake.org/t/gcc-picks-up-wrong-version-of-the-c-compiler-mysql-server/14193)

<div class="topic-metadata">

**Author:** [@Yan\_Titarenko](https://discourse.cmake.org/u/Yan_Titarenko)\
**Replies:** 2\
**Last updated:** [June 3, 2025, 2:29pm UTC](https://discourse.cmake.org/t/gcc-picks-up-wrong-version-of-the-c-compiler-mysql-server/14193 "2025-06-03T14:29:03Z")

</div>

Hi there. I was compiling MySQL server sources on OpenSUSE Leap 15.6. I was specifying compilers like this: cmake -DCMAKE\_CXX\_COMPILER=g+±16 \_DCMAKE\_C\_COMPILER=gcc-16 -DWITH\_SYSTEM\_LIBS=TRUE .. Here is what I get: …

---

## [Include guards in toolchain files](https://discourse.cmake.org/t/include-guards-in-toolchain-files/3376)

<div class="topic-metadata">

**Author:** [@petwu](https://discourse.cmake.org/u/petwu)\
**Replies:** 2\
**Last updated:** [May 31, 2025, 5:30am UTC](https://discourse.cmake.org/t/include-guards-in-toolchain-files/3376 "2025-05-31T05:30:05Z")

</div>

I recently came accross some (rare) examples/code snippets, where the include\_guard(\[GLOBAL\]) command is used inside a toolchain file, e.g. \[1\], \[2\], \[3\]. I understand the general purpose of include guards in modules, b…

---

## [CMake in NixOS with Catch2](https://discourse.cmake.org/t/cmake-in-nixos-with-catch2/14183)

<div class="topic-metadata">

**Author:** [@csfahey](https://discourse.cmake.org/u/csfahey)\
**Replies:** 0\
**Last updated:** [May 30, 2025, 3:30pm UTC](https://discourse.cmake.org/t/cmake-in-nixos-with-catch2/14183 "2025-05-30T15:30:44Z")

</div>

Does anyone have any experience with using these 3 together? I have a project that I am trying to get to work but NixOS is giving me fits because it tries to pull Catch2 from github and because of how it does that, resu…

---

## [How to compile a single source file from list of sources set in a static library](https://discourse.cmake.org/t/how-to-compile-a-single-source-file-from-list-of-sources-set-in-a-static-library/13957)

<div class="topic-metadata">

**Author:** [@siddmohsin](https://discourse.cmake.org/u/siddmohsin)\
**Replies:** 5\
**Last updated:** [May 29, 2025, 1:26pm UTC](https://discourse.cmake.org/t/how-to-compile-a-single-source-file-from-list-of-sources-set-in-a-static-library/13957 "2025-05-29T13:26:02Z")

</div>

Let’s say I have the following CMakeLists.txt cmake\_minimum\_required(VERSION 3.22.0) project(TallyWorld DESCRIPTION “” LANGUAGES CXX) add\_library(LibraryA STATIC “POC/file1.cpp” “POC/file2.cpp” “POC/file3.cpp” ) N…

---

## [CMake able to find libuv on Linux but not on Windows if installed via vcpkg](https://discourse.cmake.org/t/cmake-able-to-find-libuv-on-linux-but-not-on-windows-if-installed-via-vcpkg/14173)

<div class="topic-metadata">

**Author:** [@HallofFamer](https://discourse.cmake.org/u/HallofFamer)\
**Replies:** 1\
**Last updated:** [May 29, 2025, 2:44am UTC](https://discourse.cmake.org/t/cmake-able-to-find-libuv-on-linux-but-not-on-windows-if-installed-via-vcpkg/14173 "2025-05-29T02:44:19Z")

</div>

Hi, I am running into a strange issue building my project using CMake. The project depends on curl and libuv, and it works perfectly good on Linux once I install them both manually. On windows however, I use vcpkg toget…

---

## [FindPython package from pyenv on Windows](https://discourse.cmake.org/t/findpython-package-from-pyenv-on-windows/13467)

<div class="topic-metadata">

**Author:** [@habersaa](https://discourse.cmake.org/u/habersaa)\
**Replies:** 1\
**Last updated:** [May 28, 2025, 2:32pm UTC](https://discourse.cmake.org/t/findpython-package-from-pyenv-on-windows/13467 "2025-05-28T14:32:50Z")

</div>

Hello. On Windows 11, we are using pyenv to install different versions of python without headache (until now). However, when using CMake (3.27) to do: find\_package(Python3 COMPONENTS Interpreter REQUIRED) It does not…

---

## [Finding pyenv python package using CMake](https://discourse.cmake.org/t/finding-pyenv-python-package-using-cmake/3586)

<div class="topic-metadata">

**Author:** [@David\_Bernstein](https://discourse.cmake.org/u/David_Bernstein)\
**Replies:** 2\
**Last updated:** [May 28, 2025, 2:59pm UTC](https://discourse.cmake.org/t/finding-pyenv-python-package-using-cmake/3586 "2025-05-28T14:59:46Z")

</div>

Hi, We are using pyenv to manage python versions in a project that mixes python and C++ code. We have one item whose CMakeLists file needs to find the python package which is specified by the project pyenv version. Right…

---

## [/usr/bin/ld: unable to find -lstdc++: No such file or directory](https://discourse.cmake.org/t/usr-bin-ld-unable-to-find-lstdc-no-such-file-or-directory/14145)

<div class="topic-metadata">

**Author:** [@Yan\_Titarenko](https://discourse.cmake.org/u/Yan_Titarenko)\
**Replies:** 0\
**Last updated:** [May 23, 2025, 4:05pm UTC](https://discourse.cmake.org/t/usr-bin-ld-unable-to-find-lstdc-no-such-file-or-directory/14145 "2025-05-23T16:05:10Z")

</div>

Hi there. I was trying to build mysql server: https://github.com/mysql/mysql-server I have created a folder “build” and tried to run cmake from there: yantitarenko5@localhost:~/mysql-server/build\> cmake .. – Running…

---

## [Portable install packages with find package on frameworks?](https://discourse.cmake.org/t/portable-install-packages-with-find-package-on-frameworks/8809)

<div class="topic-metadata">

**Author:** [@rebpdx](https://discourse.cmake.org/u/rebpdx)\
**Replies:** 10\
**Last updated:** [May 27, 2025, 7:40am UTC](https://discourse.cmake.org/t/portable-install-packages-with-find-package-on-frameworks/8809 "2025-05-27T07:40:35Z")

</div>

I’m seeing conflicting information and wondering what the best practice is for handling frameworks with installed packages. Since find\_package is setting a hard coded path on some of the macOS system frameworks I’m seein…

---

## [Documenation issue on policy CMP0127](https://discourse.cmake.org/t/documenation-issue-on-policy-cmp0127/14164)

<div class="topic-metadata">

**Author:** [@czertyaka](https://discourse.cmake.org/u/czertyaka)\
**Replies:** 0\
**Last updated:** [May 26, 2025, 5:44pm UTC](https://discourse.cmake.org/t/documenation-issue-on-policy-cmp0127/14164 "2025-05-26T17:44:13Z")

</div>

Hello! I am confused with description of CMP0127. It says that: requires expressions like: "FOO MATCHES (UPPER|lower)" to be re-written as: "FOO MATCHES \\"(UPPER|lower)\\"" I’ve written CMakeLists.txt like this: c…

---

## [Experimental support for \`import std;\` is incompatible with Clang's experimental library](https://discourse.cmake.org/t/experimental-support-for-import-std-is-incompatible-with-clangs-experimental-library/14154)

<div class="topic-metadata">

**Author:** [@aacfox](https://discourse.cmake.org/u/aacfox)\
**Replies:** 1\
**Last updated:** [May 26, 2025, 6:17am UTC](https://discourse.cmake.org/t/experimental-support-for-import-std-is-incompatible-with-clangs-experimental-library/14154 "2025-05-26T06:17:57Z")

</div>

To use clang’s experimental library one has to add -fexperimental-library compiler flag but that brokes otherwise perfectly working import std; and vice versa. Here goes MRE: # CMakeLists.txt cmake\_minimum\_required(VER…

---

## [Generated Xcode project APP packaging problem in XCode 16.3](https://discourse.cmake.org/t/generated-xcode-project-app-packaging-problem-in-xcode-16-3/14149)

<div class="topic-metadata">

**Author:** [@SFENCE](https://discourse.cmake.org/u/SFENCE)\
**Replies:** 0\
**Last updated:** [May 24, 2025, 2:48pm UTC](https://discourse.cmake.org/t/generated-xcode-project-app-packaging-problem-in-xcode-16-3/14149 "2025-05-24T14:48:19Z")

</div>

Cmake generated Xcode project produces macos app as appname.app/Contexts/APPFILES in XCode 16.2 and lower. Starts with XCode 16.3, same project produces macos app as appname.app/APPFILES. Looks like iOS app format. Wha…

---

## [Using cmake for Microware os9 Compiler xcc(cross-compile) and g++(Linux)](https://discourse.cmake.org/t/using-cmake-for-microware-os9-compiler-xcc-cross-compile-and-g-linux/14147)

<div class="topic-metadata">

**Author:** [@mkneppe](https://discourse.cmake.org/u/mkneppe)\
**Replies:** 0\
**Last updated:** [May 24, 2025, 10:25am UTC](https://discourse.cmake.org/t/using-cmake-for-microware-os9-compiler-xcc-cross-compile-and-g-linux/14147 "2025-05-24T10:25:31Z")

</div>

I am trying to use cmake to use the toolchain from Microware. The only post i found about this is: but this did not help me. The xcc compiler generates .ii and .r files and the libgen links those to a .l file. As I h…

---

## [FetchContent Does Not Isolate Host from Target](https://discourse.cmake.org/t/fetchcontent-does-not-isolate-host-from-target/14134)

<div class="topic-metadata">

**Author:** [@Drue\_Peters](https://discourse.cmake.org/u/Drue_Peters)\
**Replies:** 2\
**Last updated:** [May 23, 2025, 5:23pm UTC](https://discourse.cmake.org/t/fetchcontent-does-not-isolate-host-from-target/14134 "2025-05-23T17:23:53Z")

</div>

Hey, I’m not sure how to word the title correctly. I’m working on integrating libarchive (GitHub - libarchive/libarchive: Multi-format archive and compression library) for a project. Because of the nature of the projec…

---

## [CMakePresets.json and ZERO\_CHECK](https://discourse.cmake.org/t/cmakepresets-json-and-zero-check/14135)

<div class="topic-metadata">

**Author:** [@marco1475](https://discourse.cmake.org/u/marco1475)\
**Replies:** 2\
**Last updated:** [May 22, 2025, 7:00am UTC](https://discourse.cmake.org/t/cmakepresets-json-and-zero-check/14135 "2025-05-22T07:00:18Z")

</div>

I am using CMake presets defined in CMakePresets.json to build my application. I have noticed, however, that changing a value in CMakePresets.json does not cause cmake to automatically re-run the way any modification to,…

---

## [Customize CMAKE\_XXX\_LINK\_EXECUTABLE with -Wl options when linking shared libraries](https://discourse.cmake.org/t/customize-cmake-xxx-link-executable-with-wl-options-when-linking-shared-libraries/14124)

<div class="topic-metadata">

**Author:** [@Believer](https://discourse.cmake.org/u/Believer)\
**Replies:** 2\
**Last updated:** [May 21, 2025, 9:13am UTC](https://discourse.cmake.org/t/customize-cmake-xxx-link-executable-with-wl-options-when-linking-shared-libraries/14124 "2025-05-21T09:13:53Z")

</div>

Hi, I am a new beginner who is trying to write a new language in cmake, writing files such as CMakeXXXInformation.cmake. I am confused at how -Wl option is passed in CMAKE\_CXX\_LINK\_EXECUTABLE. Among those variables I saw…

---

## [FetchContent with svn hangs in update](https://discourse.cmake.org/t/fetchcontent-with-svn-hangs-in-update/14120)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 0\
**Last updated:** [May 19, 2025, 7:40pm UTC](https://discourse.cmake.org/t/fetchcontent-with-svn-hangs-in-update/14120 "2025-05-19T19:40:47Z")

</div>

Hi, my project which pulls in one subproject via svn hangs when updating this project. It calls “svn update”, but without the “–non-interactive” option. How can I enforce the --non-interactive ? Settings UPDATE\_USES\_TE…

---

## [add\_subdirectory() for Git Submodules without CMakeLists.txt?](https://discourse.cmake.org/t/add-subdirectory-for-git-submodules-without-cmakelists-txt/14085)

<div class="topic-metadata">

**Author:** [@bmcdonnell-fb](https://discourse.cmake.org/u/bmcdonnell-fb)\
**Replies:** 7\
**Last updated:** [May 17, 2025, 8:26pm UTC](https://discourse.cmake.org/t/add-subdirectory-for-git-submodules-without-cmakelists-txt/14085 "2025-05-17T20:26:28Z")

</div>

I have a CMake project using the Ninja generator and GNU Arm Embedded Toolchain, with libraries in Git submodules. I’d like to be able to add the libraries using add\_subdirectory() or similar, with its scoping features, …

---

## [Hello...I have been using cmake for sometime but now I am building more/ELDK](https://discourse.cmake.org/t/hello-i-have-been-using-cmake-for-sometime-but-now-i-am-building-more-eldk/14088)

<div class="topic-metadata">

**Author:** [@For\_Ward](https://discourse.cmake.org/u/For_Ward)\
**Replies:** 3\
**Last updated:** [May 17, 2025, 9:14am UTC](https://discourse.cmake.org/t/hello-i-have-been-using-cmake-for-sometime-but-now-i-am-building-more-eldk/14088 "2025-05-17T09:14:17Z")

</div>

Hello, I am using cmake but ELDK is not available it seems. I am trying to cross compile via cmake from WSL2 Debian Bookworm to an armhf machine. It is a single core machine that needs the build. So far, this is what I…

---

## [creating a standalone STATIC/SHARED top level target from other targets](https://discourse.cmake.org/t/creating-a-standalone-static-shared-top-level-target-from-other-targets/14112)

<div class="topic-metadata">

**Author:** [@cargo\_run](https://discourse.cmake.org/u/cargo_run)\
**Replies:** 0\
**Last updated:** [May 17, 2025, 12:32am UTC](https://discourse.cmake.org/t/creating-a-standalone-static-shared-top-level-target-from-other-targets/14112 "2025-05-17T00:32:14Z")

</div>

cmake\_minimum\_required(VERSION 3.10.2) hey, I was wondering what is the best way to achieve the following goals (given the folder structure below): create a shared/static lib from each sub project, sdk::a and sdk::b. …

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

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