# Usage

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

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

**Page:** 29

---

## [find\_package different result/searches between top CMakelists and cmake file](https://discourse.cmake.org/t/find-package-different-result-searches-between-top-cmakelists-and-cmake-file/10524)

<div class="topic-metadata">

**Author:** [@monamimani](https://discourse.cmake.org/u/monamimani)\
**Replies:** 5\
**Last updated:** [March 30, 2024, 12:05am UTC](https://discourse.cmake.org/t/find-package-different-result-searches-between-top-cmakelists-and-cmake-file/10524 "2024-03-30T00:05:38Z")

</div>

I am trying to use a vcpkg port (“vulkan-headers”) and their usage instruction didn’t work. Well it does work (find\_package find the port) if I do find\_package(VulkanHeaders CONFIG REQUIRED) in a CMakelist but fails if …

---

## [setting c++ standard from target\_compile\_option goes for higher standard](https://discourse.cmake.org/t/setting-c-standard-from-target-compile-option-goes-for-higher-standard/10147)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 10\
**Last updated:** [March 29, 2024, 1:31pm UTC](https://discourse.cmake.org/t/setting-c-standard-from-target-compile-option-goes-for-higher-standard/10147 "2024-03-29T13:31:12Z")

</div>

I recently upgrade my gcc to a version whose default dialect is C++17. Yet, for some specific use cases I’d like to use older standard but with target\_compile\_options(${TARGET\_NAME} PUBLIC $\<$\<COMPILE\_LANGUAGE:CXX\>:cxx\_…

---

## [How to remove BASE\_DIRS of FILE\_SET from INTERFACE\_INCLUDE\_DIRECTORIES property](https://discourse.cmake.org/t/how-to-remove-base-dirs-of-file-set-from-interface-include-directories-property/6505)

<div class="topic-metadata">

**Author:** [@Pei\_Wang](https://discourse.cmake.org/u/Pei_Wang)\
**Replies:** 9\
**Last updated:** [March 29, 2024, 12:15pm UTC](https://discourse.cmake.org/t/how-to-remove-base-dirs-of-file-set-from-interface-include-directories-property/6505 "2024-03-29T12:15:02Z")

</div>

I’m using CMake 3.23.0 to enjoy the FILE\_SET feature. However, I don’t want to add BASE\_DIRS of FILE\_SET into INTERFACE\_INCLUDE\_DIRECTORIES property. I can remove it from BUILD\_INTERFACE, but how to remove from INSTALL…

---

## [Relationship between FetchContent and ExternalProject](https://discourse.cmake.org/t/relationship-between-fetchcontent-and-externalproject/10162)

<div class="topic-metadata">

**Author:** [@dabrahams](https://discourse.cmake.org/u/dabrahams)\
**Replies:** 16\
**Last updated:** [March 29, 2024, 11:59am UTC](https://discourse.cmake.org/t/relationship-between-fetchcontent-and-externalproject/10162 "2024-03-29T11:59:14Z")

</div>

Can someone give a succinct description of the relationship / differences between FetchContent and ExternalProject? It seems like the former adds external dependencies as though they were embedded with add\_subdirectory(…

---

## [Can't generate with cmake](https://discourse.cmake.org/t/cant-generate-with-cmake/10194)

<div class="topic-metadata">

**Author:** [@Nastihan](https://discourse.cmake.org/u/Nastihan)\
**Replies:** 3\
**Last updated:** [March 29, 2024, 11:34am UTC](https://discourse.cmake.org/t/cant-generate-with-cmake/10194 "2024-03-29T11:34:10Z")

</div>

I get this error: PS C:\\dev\\cp-davinci-plugin\> cmake --preset “Windows-Debug” Preset CMake variables: CMAKE\_BUILD\_TYPE=“Debug” CMAKE\_CXX\_COMPILER=“cl” CMAKE\_C\_COMPILER=“cl” EPEN\_AUX\_CMAKE\_DEBUGGING=“ON” – The C…

---

## [suspect bug with configure\_file()](https://discourse.cmake.org/t/suspect-bug-with-configure-file/10245)

<div class="topic-metadata">

**Author:** [@Eivind\_Berntsen](https://discourse.cmake.org/u/Eivind_Berntsen)\
**Replies:** 11\
**Last updated:** [March 29, 2024, 11:19am UTC](https://discourse.cmake.org/t/suspect-bug-with-configure-file/10245 "2024-03-29T11:19:20Z")

</div>

We have a build of Zephyr running in CI (Azure DevOps.) We are running a build that sometimes fails, but then on re-run, it sometimes passes. The failure, when it happens, points to either one of these lines in a CMakeLi…

---

## [\<PackageName\>\_ROOT vs \<Package\>\_DIR](https://discourse.cmake.org/t/packagename-root-vs-package-dir/10361)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 3\
**Last updated:** [March 29, 2024, 7:56am UTC](https://discourse.cmake.org/t/packagename-root-vs-package-dir/10361 "2024-03-29T07:56:06Z")

</div>

Hi, Probably a duplicate, but what is the difference between these two environment variables (regarding find\_package behavior). I’m failling to understand from the documentation. Regards, A.

---

## [tutorial step 12: installation issue](https://discourse.cmake.org/t/tutorial-step-12-installation-issue/10506)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 0\
**Last updated:** [March 27, 2024, 3:16pm UTC](https://discourse.cmake.org/t/tutorial-step-12-installation-issue/10506 "2024-03-27T15:16:59Z")

</div>

Hi, I’ve got the impression that the mentioned tutorial is dealing only with packaging two configurations of a project. But if I try to install them, by calling cmake --install . first from the Step12/debug directory, t…

---

## [What are the interaction guarantees with find\_package and FetchContent\_\*](https://discourse.cmake.org/t/what-are-the-interaction-guarantees-with-find-package-and-fetchcontent/10113)

<div class="topic-metadata">

**Author:** [@etiennemlb](https://discourse.cmake.org/u/etiennemlb)\
**Replies:** 2\
**Last updated:** [March 23, 2024, 3:26am UTC](https://discourse.cmake.org/t/what-are-the-interaction-guarantees-with-find-package-and-fetchcontent/10113 "2024-03-23T03:26:35Z")

</div>

Say, in a large library where not all the dependencies are under the explicit control of someone or some standard, I have: find\_package(xxx VERSION 1.0 REQUIRED) followed, say in a very remote library, by a FetchContent…

---

## [CMakePresets should it automatically create build folder?](https://discourse.cmake.org/t/cmakepresets-should-it-automatically-create-build-folder/10452)

<div class="topic-metadata">

**Author:** [@fzakaria](https://discourse.cmake.org/u/fzakaria)\
**Replies:** 5\
**Last updated:** [March 23, 2024, 3:00am UTC](https://discourse.cmake.org/t/cmakepresets-should-it-automatically-create-build-folder/10452 "2024-03-23T03:00:33Z")

</div>

I was surprised that CMakePresets does not automatically create the build folder. Since presets are trying to simplify the CMake process should this be the case? ❯ cmake --build --preset debug --target check-stablehlo-…

---

## [Object library dependencies don't seem to propagate through target\_link\_libraries?](https://discourse.cmake.org/t/object-library-dependencies-dont-seem-to-propagate-through-target-link-libraries/10419)

<div class="topic-metadata">

**Author:** [@robiwano](https://discourse.cmake.org/u/robiwano)\
**Replies:** 4\
**Last updated:** [March 22, 2024, 8:15am UTC](https://discourse.cmake.org/t/object-library-dependencies-dont-seem-to-propagate-through-target-link-libraries/10419 "2024-03-22T08:15:39Z")

</div>

Having this setup: add\_library(libA OBJECT lib\_a.c) add\_library(libB OBJECT lib\_b.c) target\_link\_libraries(libB PUBLIC libA) add\_executable(myExec main.c) target\_link\_libraries(myExec #libA ??? libB ) does n…

---

## [CMake doesn't recognize the TI ARM Clang toolchain](https://discourse.cmake.org/t/cmake-doesnt-recognize-the-ti-arm-clang-toolchain/7714)

<div class="topic-metadata">

**Author:** [@Dr-Itachi](https://discourse.cmake.org/u/Dr-Itachi)\
**Replies:** 3\
**Last updated:** [March 21, 2024, 2:29am UTC](https://discourse.cmake.org/t/cmake-doesnt-recognize-the-ti-arm-clang-toolchain/7714 "2024-03-21T02:29:57Z")

</div>

Hi. I’m trying to use the Texas instruments Arm Clang (tiarmclang) toolchain for cross-compiling for an ARM device. The problem is that Cmake doesn’t recognize the toolchain and output an error even when i set the compil…

---

## [adding gdal as dependency on windows for msys2 compilers and msvc](https://discourse.cmake.org/t/adding-gdal-as-dependency-on-windows-for-msys2-compilers-and-msvc/10372)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 1\
**Last updated:** [March 15, 2024, 3:50pm UTC](https://discourse.cmake.org/t/adding-gdal-as-dependency-on-windows-for-msys2-compilers-and-msvc/10372 "2024-03-15T15:50:17Z")

</div>

Hi, In order to use gdal library with msvc I used a windows installer from OSGeo4W. Though I couldn’t locate any cmake package files within the installation, it seemed to be correctly detected by find\_package. I put it …

---

## [Documentation of the set() command](https://discourse.cmake.org/t/documentation-of-the-set-command/10416)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 3\
**Last updated:** [March 20, 2024, 8:11am UTC](https://discourse.cmake.org/t/documentation-of-the-set-command/10416 "2024-03-20T08:11:15Z")

</div>

Hello, In the set() command help : If at least one \<value\>... is given, set the variable to that value. Which one, among the n values ? This line should mention that the values are set as an array.

---

## [Possible to exclude ctest label from "default" ctest execution?](https://discourse.cmake.org/t/possible-to-exclude-ctest-label-from-default-ctest-execution/10392)

<div class="topic-metadata">

**Author:** [@mathomp4](https://discourse.cmake.org/u/mathomp4)\
**Replies:** 1\
**Last updated:** [March 19, 2024, 11:34pm UTC](https://discourse.cmake.org/t/possible-to-exclude-ctest-label-from-default-ctest-execution/10392 "2024-03-19T23:34:56Z")

</div>

I was wondering if it is possible to exclude some ctest labels from the “default” ctest execution. That is when I run: ctest it would not run some tests? I ask because in our code we have some tests that are “big”. Fo…

---

## [How to prevent CMake reruns?](https://discourse.cmake.org/t/how-to-prevent-cmake-reruns/10375)

<div class="topic-metadata">

**Author:** [@joint](https://discourse.cmake.org/u/joint)\
**Replies:** 1\
**Last updated:** [March 19, 2024, 11:30pm UTC](https://discourse.cmake.org/t/how-to-prevent-cmake-reruns/10375 "2024-03-19T23:30:02Z")

</div>

Hello dear forum dwellers! I am working on rather a big project which is placed in mercurial repository. I am using Visual Studio 2022. Sadly enough, when I switch between the revisions, CMake reruns and starts a very…

---

## [Getting latest version of cmake using apt-get](https://discourse.cmake.org/t/getting-latest-version-of-cmake-using-apt-get/10401)

<div class="topic-metadata">

**Author:** [@steverb](https://discourse.cmake.org/u/steverb)\
**Replies:** 4\
**Last updated:** [March 19, 2024, 2:58pm UTC](https://discourse.cmake.org/t/getting-latest-version-of-cmake-using-apt-get/10401 "2024-03-19T14:58:09Z")

</div>

I’m building a machine using Vagrant, the box is bionic64. “apt-get install cmake” gives me version 3.10.2. Is that the latest I can use, on Ubuntu 18.04? I was hoping for something closer to 3.29.

---

## [How to add libuv to CMakeLists.txt?](https://discourse.cmake.org/t/how-to-add-libuv-to-cmakelists-txt/10402)

<div class="topic-metadata">

**Author:** [@HallofFamer](https://discourse.cmake.org/u/HallofFamer)\
**Replies:** 1\
**Last updated:** [March 19, 2024, 10:42am UTC](https://discourse.cmake.org/t/how-to-add-libuv-to-cmakelists-txt/10402 "2024-03-19T10:42:22Z")

</div>

Well I’ve tried to add libuv to CMakeLists.txt for my project on Ubuntu, with the below code: find\_package(libuv REQUIRED) target\_link\_libraries(${PROJECT\_NAME} libuv::uv) And it does not work, instead gave…

---

## [Tracking down -no-pie](https://discourse.cmake.org/t/tracking-down-no-pie/10383)

<div class="topic-metadata">

**Author:** [@ramcdona](https://discourse.cmake.org/u/ramcdona)\
**Replies:** 2\
**Last updated:** [March 17, 2024, 5:53am UTC](https://discourse.cmake.org/t/tracking-down-no-pie/10383 "2024-03-17T05:53:27Z")

</div>

I am building a SWIG wrapped Python module (shared library). I build two versions – one without any graphics, another with a GUI that requires linking various graphics and OpenGL libraries. This generally works fine ac…

---

## [Using clang-tidy with cross compilation](https://discourse.cmake.org/t/using-clang-tidy-with-cross-compilation/5435)

<div class="topic-metadata">

**Author:** [@AdamWRichardson](https://discourse.cmake.org/u/AdamWRichardson)\
**Replies:** 6\
**Last updated:** [March 15, 2024, 11:33pm UTC](https://discourse.cmake.org/t/using-clang-tidy-with-cross-compilation/5435 "2024-03-15T23:33:35Z")

</div>

This may be a really silly issue but I’m struggling to get clang-tidy working while cross compiling. I’m using the RSIC-V GCC toolchain to generate the binaries for a small embedded project I have and as part of the bui…

---

## [How to cross compile with the ADSP Sharc Toolchain](https://discourse.cmake.org/t/how-to-cross-compile-with-the-adsp-sharc-toolchain/10368)

<div class="topic-metadata">

**Author:** [@Rob](https://discourse.cmake.org/u/Rob)\
**Replies:** 2\
**Last updated:** [March 16, 2024, 12:46am UTC](https://discourse.cmake.org/t/how-to-cross-compile-with-the-adsp-sharc-toolchain/10368 "2024-03-16T00:46:11Z")

</div>

Hello I would like to cross compile a static library using the ADSP Sharc Toolchain Host platform: Windows Cmake version: 3.29 Ninja version: 1.11.1 Analog Device CrossCore version: 2.12.0 I’ve managed to generate …

---

## [Run bash script in current process](https://discourse.cmake.org/t/run-bash-script-in-current-process/10363)

<div class="topic-metadata">

**Author:** [@EosPengwern](https://discourse.cmake.org/u/EosPengwern)\
**Replies:** 2\
**Last updated:** [March 14, 2024, 10:40pm UTC](https://discourse.cmake.org/t/run-bash-script-in-current-process/10363 "2024-03-14T22:40:47Z")

</div>

This is a long shot, but I’d like to check that I haven’t missed something in the documentation before I embark on a complicated workaround. I’m using a third-party library which, when using it in Linux, requires a bash…

---

## [Cmake cannot find the EXPAT library](https://discourse.cmake.org/t/cmake-cannot-find-the-expat-library/10327)

<div class="topic-metadata">

**Author:** [@BertEzendam](https://discourse.cmake.org/u/BertEzendam)\
**Replies:** 7\
**Last updated:** [March 14, 2024, 9:34pm UTC](https://discourse.cmake.org/t/cmake-cannot-find-the-expat-library/10327 "2024-03-14T21:34:31Z")

</div>

Since version 3.28.x my Cmakefile generation failes, i a way that it cannot find my expat file. The Cmakefile uses find\_package(EXPAT). This always worked up til now. I have a define to Cmake with -DEXPAT\_INCLUDE\_DIR=…

---

## [How can I use cmake with Taskig compiler?](https://discourse.cmake.org/t/how-can-i-use-cmake-with-taskig-compiler/10346)

<div class="topic-metadata">

**Author:** [@xmaze](https://discourse.cmake.org/u/xmaze)\
**Replies:** 1\
**Last updated:** [March 13, 2024, 11:58pm UTC](https://discourse.cmake.org/t/how-can-i-use-cmake-with-taskig-compiler/10346 "2024-03-13T23:58:37Z")

</div>

Hi, I try to create a cmake project to build my static library with the TASKING compiler. I set the compier path but when I run the cmake generator, I have the following error, Compiling the C compiler identification …

---

## [best way to setup CMake with ARMCC (Keil 5) in vscode](https://discourse.cmake.org/t/best-way-to-setup-cmake-with-armcc-keil-5-in-vscode/10357)

<div class="topic-metadata">

**Author:** [@B\_Squar3d](https://discourse.cmake.org/u/B_Squar3d)\
**Replies:** 0\
**Last updated:** [March 13, 2024, 5:05pm UTC](https://discourse.cmake.org/t/best-way-to-setup-cmake-with-armcc-keil-5-in-vscode/10357 "2024-03-13T17:05:45Z")

</div>

Hello everyone, I am quite new to CMake, and vscode. I would like to use CMake to build a projet with armcc (Keil 5). I saw that the way to do is to call a toolchain file, and mine is called armcc.cmake and look like …

---

## [ctest complains about the test executable, but then deletes it?](https://discourse.cmake.org/t/ctest-complains-about-the-test-executable-but-then-deletes-it/10344)

<div class="topic-metadata">

**Author:** [@dtgriscom](https://discourse.cmake.org/u/dtgriscom)\
**Replies:** 8\
**Last updated:** [March 13, 2024, 3:47pm UTC](https://discourse.cmake.org/t/ctest-complains-about-the-test-executable-but-then-deletes-it/10344 "2024-03-13T15:47:17Z")

</div>

I’m taking over some code and trying to use it in a cross-platform compilation environment (building on Linux/x86, compiling to ARM). However, when I try to run the tests, ctest complains about the built executable and t…

---

## [Selection of targets from a superbuild's sub-projects](https://discourse.cmake.org/t/selection-of-targets-from-a-superbuilds-sub-projects/10243)

<div class="topic-metadata">

**Author:** [@Chardrazle](https://discourse.cmake.org/u/Chardrazle)\
**Replies:** 12\
**Last updated:** [March 10, 2024, 10:49am UTC](https://discourse.cmake.org/t/selection-of-targets-from-a-superbuilds-sub-projects/10243 "2024-03-10T10:49:28Z")

</div>

Hi, TL;DR; Is there a way of selecting specific targets (at build time) from the sub-projects that are built as part of a superbuild? Consider the simple scenario where there is a superbuild that builds two sub-project…

---

## [System is unknown to cmake, create: Platform/MINGW64\_NT-10.0-19044](https://discourse.cmake.org/t/system-is-unknown-to-cmake-create-platform-mingw64-nt-10-0-19044/4734)

<div class="topic-metadata">

**Author:** [@SamuelMarks](https://discourse.cmake.org/u/SamuelMarks)\
**Replies:** 7\
**Last updated:** [March 9, 2024, 12:10pm UTC](https://discourse.cmake.org/t/system-is-unknown-to-cmake-create-platform-mingw64-nt-10-0-19044/4734 "2024-03-09T12:10:50Z")

</div>

Running from MSYS2 MinGW 64-bit with CMake 3.22.1 with gcc 11.2.0 on my fork https://github.com/SamuelMarks/fswatch/tree/multi-os-ci: # Run from empty build dir: cmake .. Error: System is unknown to cmake, create: Pla…

---

## [CMake suddenly stopped working macOS Sonoma](https://discourse.cmake.org/t/cmake-suddenly-stopped-working-macos-sonoma/10303)

<div class="topic-metadata">

**Author:** [@SidYaj](https://discourse.cmake.org/u/SidYaj)\
**Replies:** 4\
**Last updated:** [March 6, 2024, 7:39pm UTC](https://discourse.cmake.org/t/cmake-suddenly-stopped-working-macos-sonoma/10303 "2024-03-06T19:39:56Z")

</div>

I recently updated my XCode Command Line Tools. After that, I started getting the following error when running cmake % cmake dyld\[97959\]: weak-def symbol not found '\_\_ZnwmSt19\_\_type\_descriptor\_t’weak-def symbol not fo…

---

## [Cross platform configuration and compilation is tkaing very long (Xtensa on windows/linux)](https://discourse.cmake.org/t/cross-platform-configuration-and-compilation-is-tkaing-very-long-xtensa-on-windows-linux/10293)

<div class="topic-metadata">

**Author:** [@mkyadav](https://discourse.cmake.org/u/mkyadav)\
**Replies:** 0\
**Last updated:** [March 5, 2024, 1:09pm UTC](https://discourse.cmake.org/t/cross-platform-configuration-and-compilation-is-tkaing-very-long-xtensa-on-windows-linux/10293 "2024-03-05T13:09:46Z")

</div>

We are trying to compile a code for Xtensa/Tensilica platform over windows or Linux. The generator we are using is nmake and also tried ninja over windows and on linux we are using unix make files as generator. The time…

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

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