# Usage

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

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

**Page:** 54

---

## [CMake Presets Best Practices -- Toolchains vs Cache Variables](https://discourse.cmake.org/t/cmake-presets-best-practices-toolchains-vs-cache-variables/6822)

<div class="topic-metadata">

**Author:** [@Drue\_Peters](https://discourse.cmake.org/u/Drue_Peters)\
**Replies:** 3\
**Last updated:** [November 15, 2022, 8:55pm UTC](https://discourse.cmake.org/t/cmake-presets-best-practices-toolchains-vs-cache-variables/6822 "2022-11-15T20:55:42Z")

</div>

Hey, I’ve googled and search this site, but can’t find much on this. What is the preferred method for setting compilers and other settings? We don’t do any cross compilation, but have been using toolchains to make cer…

---

## [CMake generated Targerts file and staging areas](https://discourse.cmake.org/t/cmake-generated-targerts-file-and-staging-areas/6873)

<div class="topic-metadata">

**Author:** [@JanWielemaker](https://discourse.cmake.org/u/JanWielemaker)\
**Replies:** 0\
**Last updated:** [November 15, 2022, 2:47pm UTC](https://discourse.cmake.org/t/cmake-generated-targerts-file-and-staging-areas/6873 "2022-11-15T14:47:22Z")

</div>

When I look at a \<Project\>Targets.cmake generated by CMake 22.1, I see that it compensates for the fact that the file may not be in its final destination (e.g., it may be in some staging area). Here is the relevant snip…

---

## [fetchcontent vs vcpkg, conan?](https://discourse.cmake.org/t/fetchcontent-vs-vcpkg-conan/6578)

<div class="topic-metadata">

**Author:** [@RobN](https://discourse.cmake.org/u/RobN)\
**Replies:** 15\
**Last updated:** [November 14, 2022, 6:05pm UTC](https://discourse.cmake.org/t/fetchcontent-vs-vcpkg-conan/6578 "2022-11-14T18:05:22Z")

</div>

Newbie question… I’m starting some C++ projects of my own, and figuring out how to use CMake and related tools. I see people use vcpkg or conan for bringing in 3rd party libraries. Then I see FetchContent, which appears …

---

## [cmake build command fails with output "Error: is not a directory"](https://discourse.cmake.org/t/cmake-build-command-fails-with-output-error-is-not-a-directory/6854)

<div class="topic-metadata">

**Author:** [@stephengtuggy](https://discourse.cmake.org/u/stephengtuggy)\
**Replies:** 3\
**Last updated:** [November 12, 2022, 11:00pm UTC](https://discourse.cmake.org/t/cmake-build-command-fails-with-output-error-is-not-a-directory/6854 "2022-11-12T23:00:30Z")

</div>

Hi, I’m having major issues with CMake on my system. At least half the time, after I configure a project and when I go to build it, I get just one line of output: Error: is not a directory Note that there are two spa…

---

## [CMake grouping/combining -include directives/flags](https://discourse.cmake.org/t/cmake-grouping-combining-include-directives-flags/6852)

<div class="topic-metadata">

**Author:** [@nilsdeppe](https://discourse.cmake.org/u/nilsdeppe)\
**Replies:** 6\
**Last updated:** [November 12, 2022, 8:36pm UTC](https://discourse.cmake.org/t/cmake-grouping-combining-include-directives-flags/6852 "2022-11-12T20:36:47Z")

</div>

Hi! I’m trying to specify multiple -include blah includes via generator expressions. CMake is not generating the expected compilation command, i.e. -include cstddef -include csignal but instead -include cstddef csign…

---

## [Included cmak files as system?](https://discourse.cmake.org/t/included-cmak-files-as-system/6838)

<div class="topic-metadata">

**Author:** [@TJO\_BIT](https://discourse.cmake.org/u/TJO_BIT)\
**Replies:** 1\
**Last updated:** [November 11, 2022, 1:58pm UTC](https://discourse.cmake.org/t/included-cmak-files-as-system/6838 "2022-11-11T13:58:33Z")

</div>

HI I include a CMAKE file from a vendor in my own cmake file with: include($ENV{VENDOR\_PATH}/tools/low/cmake/gpg.cmake) If I build I get all warnings when the files are builded. I can disable all warnings in my cmake …

---

## [How to differentiate settings for armclang and assembler/C++ files?](https://discourse.cmake.org/t/how-to-differentiate-settings-for-armclang-and-assembler-c-files/6833)

<div class="topic-metadata">

**Author:** [@DavidA](https://discourse.cmake.org/u/DavidA)\
**Replies:** 4\
**Last updated:** [November 10, 2022, 5:26pm UTC](https://discourse.cmake.org/t/how-to-differentiate-settings-for-armclang-and-assembler-c-files/6833 "2022-11-10T17:26:14Z")

</div>

Hi, I have a working CMakeLists.txt to build a C++ project using armclang. I have now added an assembler file. Here is my CMakeLists.txt (cut down a bit): cmake\_minimum\_required(VERSION 3.24.1) project(my\_arm) set(EXEC…

---

## [cmake hangs while configuring just after the message Found Threads: TRUE](https://discourse.cmake.org/t/cmake-hangs-while-configuring-just-after-the-message-found-threads-true/6821)

<div class="topic-metadata">

**Author:** [@hamlatzis](https://discourse.cmake.org/u/hamlatzis)\
**Replies:** 2\
**Last updated:** [November 10, 2022, 7:01am UTC](https://discourse.cmake.org/t/cmake-hangs-while-configuring-just-after-the-message-found-threads-true/6821 "2022-11-10T07:01:32Z")

</div>

I have my CMakeLists.txt and want to configure my program before compiling it. I call cmake passing all the parameters I need for configuring my c++ code and it hangs after the message “-- Found Threads: TRUE”, so canno…

---

## [Why is USE\_FOLDERS not ON by default?](https://discourse.cmake.org/t/why-is-use-folders-not-on-by-default/2497)

<div class="topic-metadata">

**Author:** [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)\
**Replies:** 7\
**Last updated:** [November 9, 2022, 2:16am UTC](https://discourse.cmake.org/t/why-is-use-folders-not-on-by-default/2497 "2022-11-09T02:16:42Z")

</div>

Every single project I have the same line of code. set\_property(GLOBAL PROPERTY USE\_FOLDERS ON) Why is this not just on by default for users? I’ll admit the 2 generators I primarily use are Visual Studio / Ninja. So …

---

## [try\_compile fails when used within find\_program](https://discourse.cmake.org/t/try-compile-fails-when-used-within-find-program/6815)

<div class="topic-metadata">

**Author:** [@rwi](https://discourse.cmake.org/u/rwi)\
**Replies:** 0\
**Last updated:** [November 8, 2022, 7:33pm UTC](https://discourse.cmake.org/t/try-compile-fails-when-used-within-find-program/6815 "2022-11-08T19:33:49Z")

</div>

Hi, I have been redirected from the issue tracker to this place. Apparently the following still warrants some discussion. So, I am trying to cross compile from linux x86-64 to linux armv7. When using find\_program(CMAKE…

---

## [Strange problem when using qt\_add\_qml\_module in module being brought in via FetchContent](https://discourse.cmake.org/t/strange-problem-when-using-qt-add-qml-module-in-module-being-brought-in-via-fetchcontent/6781)

<div class="topic-metadata">

**Author:** [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)\
**Replies:** 4\
**Last updated:** [November 7, 2022, 8:03pm UTC](https://discourse.cmake.org/t/strange-problem-when-using-qt-add-qml-module-in-module-being-brought-in-via-fetchcontent/6781 "2022-11-07T20:03:47Z")

</div>

Going thru a CMake restructure. As part of this many internal dependencies, some of which are QML modules, are being brought in via FetchContent. With Qt6, these QML modules use qt\_add\_qml\_module(). These modules had …

---

## [CMAKE\_OPTIMIZE\_DEPENDENCIES increases the number of deps for a target](https://discourse.cmake.org/t/cmake-optimize-dependencies-increases-the-number-of-deps-for-a-target/6773)

<div class="topic-metadata">

**Author:** [@Zachary\_Turner](https://discourse.cmake.org/u/Zachary_Turner)\
**Replies:** 4\
**Last updated:** [November 7, 2022, 1:00pm UTC](https://discourse.cmake.org/t/cmake-optimize-dependencies-increases-the-number-of-deps-for-a-target/6773 "2022-11-07T13:00:00Z")

</div>

I am trying out CMAKE\_OPTIMIZE\_DEPENDENCIES. I did an experiment where I configured twice, once with COD=0, and again with COD=1. Then I wrote a little tool in Python that parsed the cmake-file-api reply for the codemo…

---

## [Run a test in an air gap?](https://discourse.cmake.org/t/run-a-test-in-an-air-gap/6799)

<div class="topic-metadata">

**Author:** [@benthevining](https://discourse.cmake.org/u/benthevining)\
**Replies:** 1\
**Last updated:** [November 6, 2022, 1:13pm UTC](https://discourse.cmake.org/t/run-a-test-in-an-air-gap/6799 "2022-11-06T13:13:24Z")

</div>

Using CTest, is it possible to run a single test case in an air gapped environment (not allowing any network access)? I’m assuming this would actually involve running some kind of wrapper script or tool that sets up the …

---

## [Benchmarking data: CTest or something else?](https://discourse.cmake.org/t/benchmarking-data-ctest-or-something-else/6785)

<div class="topic-metadata">

**Author:** [@benthevining](https://discourse.cmake.org/u/benthevining)\
**Replies:** 2\
**Last updated:** [November 4, 2022, 5:04pm UTC](https://discourse.cmake.org/t/benchmarking-data-ctest-or-something-else/6785 "2022-11-04T17:04:15Z")

</div>

I’ve successfully gotten my CDash dashboard up and running with data from CTest, and now I’m thinking about creating benchmarks for my library. I’m wondering what the typical approach is to handling benchmarks within th…

---

## [Static linking depencies and position](https://discourse.cmake.org/t/static-linking-depencies-and-position/6795)

<div class="topic-metadata">

**Author:** [@lancethepants](https://discourse.cmake.org/u/lancethepants)\
**Replies:** 0\
**Last updated:** [November 4, 2022, 4:58pm UTC](https://discourse.cmake.org/t/static-linking-depencies-and-position/6795 "2022-11-04T16:58:41Z")

</div>

So I’ve come on the issue several times where I want to compile statically linked binaries in projects that use cmake. Sometimes a library dependency will have a dependency on another library. For example here is a cmak…

---

## [Are generator expressions supported in set\_target\_properties / IMPORTED\_LOCATION](https://discourse.cmake.org/t/are-generator-expressions-supported-in-set-target-properties-imported-location/6790)

<div class="topic-metadata">

**Author:** [@Chris\_Apple](https://discourse.cmake.org/u/Chris_Apple)\
**Replies:** 3\
**Last updated:** [November 4, 2022, 4:58pm UTC](https://discourse.cmake.org/t/are-generator-expressions-supported-in-set-target-properties-imported-location/6790 "2022-11-04T16:58:02Z")

</div>

Wondering if this is supported, or I’m doing something wrong. I have a line that works: set\_target\_properties(NSPR::NSPR PROPERTIES IMPORTED\_LOCATION "${CMAKE\_CURRENT\_SOURCE\_DIR}/lib/darwin\_arm64/libnspr4.a" ) Bu…

---

## [CMake Target Unity Builds](https://discourse.cmake.org/t/cmake-target-unity-builds/6776)

<div class="topic-metadata">

**Author:** [@Drue\_Peters](https://discourse.cmake.org/u/Drue_Peters)\
**Replies:** 5\
**Last updated:** [November 4, 2022, 4:20pm UTC](https://discourse.cmake.org/t/cmake-target-unity-builds/6776 "2022-11-04T16:20:56Z")

</div>

I’ve looked at the documentation, but it’s not obvious to me. Our codebase has multiple libraries. A couple of them have a lot of source files and need to be updated often. Is it possible to enable a unity build just on…

---

## [Visual Studio 2019 generator check\_symbol\_exists sometimes fails](https://discourse.cmake.org/t/visual-studio-2019-generator-check-symbol-exists-sometimes-fails/6787)

<div class="topic-metadata">

**Author:** [@memecode](https://discourse.cmake.org/u/memecode)\
**Replies:** 1\
**Last updated:** [November 4, 2022, 3:10am UTC](https://discourse.cmake.org/t/visual-studio-2019-generator-check-symbol-exists-sometimes-fails/6787 "2022-11-04T03:10:03Z")

</div>

I’m trying to include libssh into my project via add\_subdirectory(…) with cmake 3.24.2 using the Visual Studio 2019 generator. And all the calls to check\_symbol\_exists fail. My configure cmd is: cmake -G "Visual Studio…

---

## [Presets and \_deps folder question](https://discourse.cmake.org/t/presets-and-deps-folder-question/6768)

<div class="topic-metadata">

**Author:** [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)\
**Replies:** 7\
**Last updated:** [November 3, 2022, 7:09pm UTC](https://discourse.cmake.org/t/presets-and-deps-folder-question/6768 "2022-11-03T19:09:52Z")

</div>

I’m looking for a good link to any specific part of the documentation that talks about when the \_deps folder might be wiped out. I’ve had a number of coworkers who like to use presets from within their IDE and in doing …

---

## [Swift module support](https://discourse.cmake.org/t/swift-module-support/5195)

<div class="topic-metadata">

**Author:** [@Lectem](https://discourse.cmake.org/u/Lectem)\
**Replies:** 1\
**Last updated:** [November 3, 2022, 12:16pm UTC](https://discourse.cmake.org/t/swift-module-support/5195 "2022-11-03T12:16:44Z")

</div>

I’m trying to build a project using Swift with the Xcode generator, but I can not get it to import a class from another target (that is correctly linked). I also tried this example swift-cmake-examples/HelloWorld at mai…

---

## [Is CMakeCCompilerId.c used on the target or host system? How to tell Cmake which build system to use?](https://discourse.cmake.org/t/is-cmakeccompilerid-c-used-on-the-target-or-host-system-how-to-tell-cmake-which-build-system-to-use/6731)

<div class="topic-metadata">

**Author:** [@VBruceHunt](https://discourse.cmake.org/u/VBruceHunt)\
**Replies:** 12\
**Last updated:** [November 3, 2022, 6:33am UTC](https://discourse.cmake.org/t/is-cmakeccompilerid-c-used-on-the-target-or-host-system-how-to-tell-cmake-which-build-system-to-use/6731 "2022-11-03T06:33:15Z")

</div>

Newbie here. My question appears to be a variant of: Cross compiling a Qt application for arm but the target rcc and moc executables are used instead of the host versions My question is about specific operation of th…

---

## [Link test to target being tested?](https://discourse.cmake.org/t/link-test-to-target-being-tested/6772)

<div class="topic-metadata">

**Author:** [@RedDwarf](https://discourse.cmake.org/u/RedDwarf)\
**Replies:** 0\
**Last updated:** [November 2, 2022, 10:36am UTC](https://discourse.cmake.org/t/link-test-to-target-being-tested/6772 "2022-11-02T10:36:59Z")

</div>

I have a project with multiple optional components and, sometimes, two of those components have code in common. So we have a structure like this lib/common src/comp1 src/comp2 src/comp3 With let’s say lib/common used …

---

## [ngsolve deinstallation confuses cmake on Windows 10](https://discourse.cmake.org/t/ngsolve-deinstallation-confuses-cmake-on-windows-10/6758)

<div class="topic-metadata">

**Author:** [@Kai](https://discourse.cmake.org/u/Kai)\
**Replies:** 5\
**Last updated:** [November 2, 2022, 9:07am UTC](https://discourse.cmake.org/t/ngsolve-deinstallation-confuses-cmake-on-windows-10/6758 "2022-11-02T09:07:13Z")

</div>

Hi Guys, there is a weird behavior on Windows 10 after uninstalling some old version of ngsolve (ngsolve-v6.2.2104). If i want to compile some C++ program, that is not ngsolve related, in the linking stage zlib.lib is …

---

## [findblas with MKL and gnu compilers](https://discourse.cmake.org/t/findblas-with-mkl-and-gnu-compilers/6764)

<div class="topic-metadata">

**Author:** [@noam.bernstein](https://discourse.cmake.org/u/noam.bernstein)\
**Replies:** 4\
**Last updated:** [November 1, 2022, 9:42pm UTC](https://discourse.cmake.org/t/findblas-with-mkl-and-gnu-compilers/6764 "2022-11-01T21:42:28Z")

</div>

I’m using cmake with findblas to compile LAMMPS, and while it finds the correct compiler (g++/gfortran) and BLAS (MKL), it gets the wrong set of libraries. In particular, it appears that the name of the “top level” blas…

---

## [Where are default compile flags set?](https://discourse.cmake.org/t/where-are-default-compile-flags-set/6754)

<div class="topic-metadata">

**Author:** [@Andrew\_Beers](https://discourse.cmake.org/u/Andrew_Beers)\
**Replies:** 3\
**Last updated:** [October 30, 2022, 3:42pm UTC](https://discourse.cmake.org/t/where-are-default-compile-flags-set/6754 "2022-10-30T15:42:37Z")

</div>

I’ve inherited a c++ project that had a custom build script written in JavaScript. I’m looking to convert this build script into a CMake build script so I can debug the project in CLion. This custom build script does not…

---

## [Access to any relative binaryDir path is denied inside Visual Studio](https://discourse.cmake.org/t/access-to-any-relative-binarydir-path-is-denied-inside-visual-studio/6742)

<div class="topic-metadata">

**Author:** [@mojca](https://discourse.cmake.org/u/mojca)\
**Replies:** 2\
**Last updated:** [October 30, 2022, 8:35am UTC](https://discourse.cmake.org/t/access-to-any-relative-binarydir-path-is-denied-inside-visual-studio/6742 "2022-10-30T08:35:06Z")

</div>

When I open a CMake project with Visual Studio 2022 Preview (17.4.0 Preview 3) and use "binaryDir": "foo" inside a preset in CMakePresets.json, I get an error when configuring the project 1\> Access to the path 'foo' …

---

## [a lot of the last cmake installed aren't understand by the system](https://discourse.cmake.org/t/a-lot-of-the-last-cmake-installed-arent-understand-by-the-system/6688)

<div class="topic-metadata">

**Author:** [@Azaretdodo](https://discourse.cmake.org/u/Azaretdodo)\
**Replies:** 5\
**Last updated:** [October 28, 2022, 9:43pm UTC](https://discourse.cmake.org/t/a-lot-of-the-last-cmake-installed-arent-understand-by-the-system/6688 "2022-10-28T21:43:04Z")

</div>

hello, a lot of the last cmake installed aren’t understand by the system below the program i try to compile : ~/snort\_src/snort3-3.1.43.0$ ./configure\_cmake.sh --prefix=/usr/bin/ --with-luajit-libraries=~/snort\_src/Lu…

---

## [How to link executable with object created in another CMakeLists.txt in the same project?](https://discourse.cmake.org/t/how-to-link-executable-with-object-created-in-another-cmakelists-txt-in-the-same-project/6751)

<div class="topic-metadata">

**Author:** [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)\
**Replies:** 1\
**Last updated:** [October 28, 2022, 6:46pm UTC](https://discourse.cmake.org/t/how-to-link-executable-with-object-created-in-another-cmakelists-txt-in-the-same-project/6751 "2022-10-28T18:46:46Z")

</div>

My project builds multiple programs in different directories. E.g. suppose the project includes source files in src/progA and src/progB, and there is a CMakeLists.txt file in each of those directories. Further suppose th…

---

## [Weird variable behaviour with find\_package](https://discourse.cmake.org/t/weird-variable-behaviour-with-find-package/3313)

<div class="topic-metadata">

**Author:** [@LaXiS](https://discourse.cmake.org/u/LaXiS)\
**Replies:** 6\
**Last updated:** [October 28, 2022, 5:47pm UTC](https://discourse.cmake.org/t/weird-variable-behaviour-with-find-package/3313 "2022-10-28T17:47:49Z")

</div>

Hello there, I have already posted for help on Reddit (here), but I believe I might get more insightful help here. My environment: Windows 10, latest MSYS2/MinGW64, CMake 3.20.2, Intel IPP 2021.2.0 My objective: inclu…

---

## [Using Custom Makefile as add\_custom\_command and propogate compilation/linking properties](https://discourse.cmake.org/t/using-custom-makefile-as-add-custom-command-and-propogate-compilation-linking-properties/6737)

<div class="topic-metadata">

**Author:** [@vkhristenko](https://discourse.cmake.org/u/vkhristenko)\
**Replies:** 3\
**Last updated:** [October 28, 2022, 12:34pm UTC](https://discourse.cmake.org/t/using-custom-makefile-as-add-custom-command-and-propogate-compilation-linking-properties/6737 "2022-10-28T12:34:36Z")

</div>

Hello, I have an external library (a single .so to be generated) that i am building as part of my cmake project. This library is to be built with a custom makefile. This library is meant to depend on some other librari…

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

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