# Usage

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

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

**Page:** 21

---

## [Error MSB4057 The target "GetResolvedWinMD" does not exist in the project.](https://discourse.cmake.org/t/error-msb4057-the-target-getresolvedwinmd-does-not-exist-in-the-project/11668)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 3\
**Last updated:** [October 9, 2024, 7:05pm UTC](https://discourse.cmake.org/t/error-msb4057-the-target-getresolvedwinmd-does-not-exist-in-the-project/11668 "2024-10-09T19:05:16Z")

</div>

Our tools are cmake v3.25.2 and MSBuild-Version 17.11.2+c078802d4 für .NET Framework Microsoft Visual Studio Professional 2022 (64-bit) - Current Version 17.11.2 on Windows 11 We create a visual studio 2022 project w…

---

## [Automatic reconfiguration when CMakeLists.txt files change](https://discourse.cmake.org/t/automatic-reconfiguration-when-cmakelists-txt-files-change/12712)

<div class="topic-metadata">

**Author:** [@shukron](https://discourse.cmake.org/u/shukron)\
**Replies:** 1\
**Last updated:** [October 8, 2024, 9:32pm UTC](https://discourse.cmake.org/t/automatic-reconfiguration-when-cmakelists-txt-files-change/12712 "2024-10-08T21:32:45Z")

</div>

We have a very large project built by gnu make at the top level. One of the components in the project is a CMake-based application. The rule to build the app from the top level makefile looks something like: app: $(AP…

---

## [Using testPresets to filter gtest\_discover\_tests to ctest on android via adb push and adb shell](https://discourse.cmake.org/t/using-testpresets-to-filter-gtest-discover-tests-to-ctest-on-android-via-adb-push-and-adb-shell/12703)

<div class="topic-metadata">

**Author:** [@Gornhoth](https://discourse.cmake.org/u/Gornhoth)\
**Replies:** 2\
**Last updated:** [October 8, 2024, 11:39am UTC](https://discourse.cmake.org/t/using-testpresets-to-filter-gtest-discover-tests-to-ctest-on-android-via-adb-push-and-adb-shell/12703 "2024-10-08T11:39:32Z")

</div>

I am trying to use presets to solve a particular testing need in a codebase of mine. Specifically, my C++ code relies on lots of macros that are passed from CMake to conditionally compile code. In order to be able to pro…

---

## [DEPFILEs generation for GHS compiler](https://discourse.cmake.org/t/depfiles-generation-for-ghs-compiler/11601)

<div class="topic-metadata">

**Author:** [@mykhayloscherbak](https://discourse.cmake.org/u/mykhayloscherbak)\
**Replies:** 5\
**Last updated:** [October 8, 2024, 9:00am UTC](https://discourse.cmake.org/t/depfiles-generation-for-ghs-compiler/11601 "2024-10-08T09:00:01Z")

</div>

Hi! I’m trying to convert a makefile GHS project to a Cmake one and get issues with .h files dependencies. As far as I understand GHS(201355) does not support .d files generation. Existing makefile project uses gcc as a…

---

## [${MPI\_C\_INCLUDE\_DIRS} not working when the compiler is also set to mpicc](https://discourse.cmake.org/t/mpi-c-include-dirs-not-working-when-the-compiler-is-also-set-to-mpicc/12697)

<div class="topic-metadata">

**Author:** [@abhinavsns](https://discourse.cmake.org/u/abhinavsns)\
**Replies:** 1\
**Last updated:** [October 7, 2024, 3:55am UTC](https://discourse.cmake.org/t/mpi-c-include-dirs-not-working-when-the-compiler-is-also-set-to-mpicc/12697 "2024-10-07T03:55:49Z")

</div>

I have a CMake Project where I specify to find the include dirs using target\_include\_directories (project PUBLIC ${MPI\_C\_INCLUDE\_DIRS}) The following message results in an empty output if I set -DCMAKE\_C\_COMPILER=/path…

---

## [Lone dollar sign passed to target\_link\_libraries](https://discourse.cmake.org/t/lone-dollar-sign-passed-to-target-link-libraries/12692)

<div class="topic-metadata">

**Author:** [@howprice](https://discourse.cmake.org/u/howprice)\
**Replies:** 3\
**Last updated:** [October 6, 2024, 9:12pm UTC](https://discourse.cmake.org/t/lone-dollar-sign-passed-to-target-link-libraries/12692 "2024-10-06T21:12:54Z")

</div>

vcpkgx.com provides CMake snippets for using packages in a project. They all seem to include a lone dollar sign $ in the code. For example, for the SDL2 package: sdl2 provides CMake targets: find\_package(SDL2 CONFI…

---

## [Probably bug for InstallRequiredSystemLibraries in Windows with oneAPI](https://discourse.cmake.org/t/probably-bug-for-installrequiredsystemlibraries-in-windows-with-oneapi/12680)

<div class="topic-metadata">

**Author:** [@Fabian188](https://discourse.cmake.org/u/Fabian188)\
**Replies:** 1\
**Last updated:** [October 6, 2024, 9:12pm UTC](https://discourse.cmake.org/t/probably-bug-for-installrequiredsystemlibraries-in-windows-with-oneapi/12680 "2024-10-06T21:12:45Z")

</div>

Probably this is a bug or wrong usage from me. On a fresh Win10 with current VC, Intel oneAPI and cmake (see below) I get for cmake\_minimum\_required(VERSION 3.12) project(test) enable\_language(Fortran) find\_package(MKL…

---

## [CMake Environment Variables for QNX Toolchain](https://discourse.cmake.org/t/cmake-environment-variables-for-qnx-toolchain/4778)

<div class="topic-metadata">

**Author:** [@developer](https://discourse.cmake.org/u/developer)\
**Replies:** 5\
**Last updated:** [October 6, 2024, 7:57pm UTC](https://discourse.cmake.org/t/cmake-environment-variables-for-qnx-toolchain/4778 "2024-10-06T19:57:04Z")

</div>

QNX QCC requires QNX\_HOST and QNX\_TARGET environment variables to be set. I’m leveraging CPM.cmake to pull down the respective QNX toolchain. So I end up have a toolchain file like CPMAddPackage(qnx-url@my-tag-7.0.0) …

---

## [CMake adds -fPIC for all shared libraries](https://discourse.cmake.org/t/cmake-adds-fpic-for-all-shared-libraries/12690)

<div class="topic-metadata">

**Author:** [@RedNicStone](https://discourse.cmake.org/u/RedNicStone)\
**Replies:** 0\
**Last updated:** [October 6, 2024, 4:52am UTC](https://discourse.cmake.org/t/cmake-adds-fpic-for-all-shared-libraries/12690 "2024-10-06T04:52:40Z")

</div>

Hello there. For a project I am trying to build an elf relocatable binary that has no PLT/GOT and relies purely on relocations. I’m aware that this can be archived in gcc (possibly with -mcmodel=large). However the gen…

---

## [Using C++20 modules with Objective C++ / Clang](https://discourse.cmake.org/t/using-c-20-modules-with-objective-c-clang/12676)

<div class="topic-metadata">

**Author:** [@mizvekov](https://discourse.cmake.org/u/mizvekov)\
**Replies:** 0\
**Last updated:** [October 3, 2024, 8:16pm UTC](https://discourse.cmake.org/t/using-c-20-modules-with-objective-c-clang/12676 "2024-10-03T20:16:58Z")

</div>

Hello. My project configuration uses same Clang binary as compiler for C++ and Objective C++. However, C++20 related module flags are not propagated through the dependencies, when importing a C++20 module into a Objec…

---

## [toolchain's CMAKE\_CXX\_STANDARD\_LIBRARIES\_INIT get overridden](https://discourse.cmake.org/t/toolchains-cmake-cxx-standard-libraries-init-get-overridden/12672)

<div class="topic-metadata">

**Author:** [@redbaron](https://discourse.cmake.org/u/redbaron)\
**Replies:** 0\
**Last updated:** [October 3, 2024, 12:48pm UTC](https://discourse.cmake.org/t/toolchains-cmake-cxx-standard-libraries-init-get-overridden/12672 "2024-10-03T12:48:12Z")

</div>

Following advice, I am altering toolchain to include just \_INIT vars, but I seem to hit a problem where what looks like Windows-MSVC platform file overrides CMAKE\_CXX\_STANDARD\_LIBRARIES\_INIT. Do I do something wrong? I…

---

## [\_common\_patterns FAIL\_REGEX error on running cmake](https://discourse.cmake.org/t/common-patterns-fail-regex-error-on-running-cmake/12671)

<div class="topic-metadata">

**Author:** [@obioradiegwu](https://discourse.cmake.org/u/obioradiegwu)\
**Replies:** 6\
**Last updated:** [October 3, 2024, 8:58am UTC](https://discourse.cmake.org/t/common-patterns-fail-regex-error-on-running-cmake/12671 "2024-10-03T08:58:08Z")

</div>

I am migrating my dev boxes from RHEL8 (gcc11) to RHEL9 (gcc13) while maintaining the version of my cmake (3.21.3). Wile testing the migration, i’ve noticed the following error /usr/share/cmake/Modules/Internal/CheckCom…

---

## [Get verbosity from within CMake scripts?](https://discourse.cmake.org/t/get-verbosity-from-within-cmake-scripts/5392)

<div class="topic-metadata">

**Author:** [@benthevining](https://discourse.cmake.org/u/benthevining)\
**Replies:** 4\
**Last updated:** [October 1, 2024, 10:23pm UTC](https://discourse.cmake.org/t/get-verbosity-from-within-cmake-scripts/5392 "2024-10-01T22:23:41Z")

</div>

Is it possible to tell what verbosity level was passed to cmake with the command-line --log-level option? I’m aware of the CMAKE\_MESSAGE\_LOG\_LEVEL variable, I had assumed that it would be set to the value of the --log-…

---

## [Is there a downside for a toolchain to set vars in cache instead of \_INIT?](https://discourse.cmake.org/t/is-there-a-downside-for-a-toolchain-to-set-vars-in-cache-instead-of-init/12034)

<div class="topic-metadata">

**Author:** [@redbaron](https://discourse.cmake.org/u/redbaron)\
**Replies:** 3\
**Last updated:** [September 30, 2024, 10:06pm UTC](https://discourse.cmake.org/t/is-there-a-downside-for-a-toolchain-to-set-vars-in-cache-instead-of-init/12034 "2024-09-30T22:06:37Z")

</div>

One of game console vendor official toolchains sets variables like CMAKE\_CXX\_FLAGS as CACHE vars, instead of setting CMAKE\_CXX\_FLAGS\_INIT and let CMake propagate it. I found it when tried to create wrapper for vendor to…

---

## [CUDA setup not found with update-alternatives symlinks on ubuntu](https://discourse.cmake.org/t/cuda-setup-not-found-with-update-alternatives-symlinks-on-ubuntu/11745)

<div class="topic-metadata">

**Author:** [@maichmueller](https://discourse.cmake.org/u/maichmueller)\
**Replies:** 2\
**Last updated:** [September 30, 2024, 6:47pm UTC](https://discourse.cmake.org/t/cuda-setup-not-found-with-update-alternatives-symlinks-on-ubuntu/11745 "2024-09-30T18:47:36Z")

</div>

Hi, cmake (26.5 and also 30.3) seem to fail searching for the cuda toolkit when it is symlinked by ubuntu’s update-alternatives. More precisely, I have this sample project cmakelists.txt from CLion: cmake\_minimum\_requi…

---

## [CPack, RPM, and build-id](https://discourse.cmake.org/t/cpack-rpm-and-build-id/11788)

<div class="topic-metadata">

**Author:** [@jwm](https://discourse.cmake.org/u/jwm)\
**Replies:** 2\
**Last updated:** [September 30, 2024, 7:56am UTC](https://discourse.cmake.org/t/cpack-rpm-and-build-id/11788 "2024-09-30T07:56:18Z")

</div>

It’s been a few years since I used CMake/CPack to generate RPMs, but the requirement arose recently, so I grabbed the packaging section from a previous project and voila I had an RPM. However, when I examine the RPM wit…

---

## [Avoid libraries and header files from zlib-ng-compat-devel](https://discourse.cmake.org/t/avoid-libraries-and-header-files-from-zlib-ng-compat-devel/11738)

<div class="topic-metadata">

**Author:** [@Manuel1997](https://discourse.cmake.org/u/Manuel1997)\
**Replies:** 1\
**Last updated:** [September 28, 2024, 6:40pm UTC](https://discourse.cmake.org/t/avoid-libraries-and-header-files-from-zlib-ng-compat-devel/11738 "2024-09-28T18:40:14Z")

</div>

Hey everyone. I’m compiling hdf5 as a part of a project and want to link it with my own zlib. The problem is that cmake always tries to link it with /usr/lib64/libz.a, even though I specify my own zlib. Notice that in th…

---

## [Propagate C++ standard to export](https://discourse.cmake.org/t/propagate-c-standard-to-export/11785)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 3\
**Last updated:** [September 28, 2024, 1:59am UTC](https://discourse.cmake.org/t/propagate-c-standard-to-export/11785 "2024-09-28T01:59:28Z")

</div>

Hi, I have a project that uses std::string\_view in the interfaces. Therefore I need to propagate the standard to the export so that users using find\_package() will automatically set their standard right. How to do this…

---

## [IMPORTED\_TARGET versus old-style ${XYZ\_LIBRARIES} linking](https://discourse.cmake.org/t/imported-target-versus-old-style-xyz-libraries-linking/11784)

<div class="topic-metadata">

**Author:** [@kpeeters](https://discourse.cmake.org/u/kpeeters)\
**Replies:** 0\
**Last updated:** [September 27, 2024, 8:06am UTC](https://discourse.cmake.org/t/imported-target-versus-old-style-xyz-libraries-linking/11784 "2024-09-27T08:06:12Z")

</div>

I am struggling to find the proper way to setup target\_link\_libraries when some of my third-party code uses old style ${XYZ\_LIBRARIES}, while other code finds the library using IMPORTED\_TARGET and then uses PkgConfig::XY…

---

## [CMakeDetermineCompilerFeatures.cmake is no more in 3.30 : bug or not ?](https://discourse.cmake.org/t/cmakedeterminecompilerfeatures-cmake-is-no-more-in-3-30-bug-or-not/11176)

<div class="topic-metadata">

**Author:** [@Lieven](https://discourse.cmake.org/u/Lieven)\
**Replies:** 6\
**Last updated:** [September 27, 2024, 1:02am UTC](https://discourse.cmake.org/t/cmakedeterminecompilerfeatures-cmake-is-no-more-in-3-30-bug-or-not/11176 "2024-09-27T01:02:42Z")

</div>

It seems this file is now called CMakeDetermineCompilerSupport.cmake, with a similar rename for the function it brings. What is the adviced migration path in case this is not a bug ? I know of cmakelists files that do …

---

## [One CMakeLists.txt file creating multiple relocatable install packages.](https://discourse.cmake.org/t/one-cmakelists-txt-file-creating-multiple-relocatable-install-packages/11715)

<div class="topic-metadata">

**Author:** [@JRR](https://discourse.cmake.org/u/JRR)\
**Replies:** 4\
**Last updated:** [September 23, 2024, 7:44pm UTC](https://discourse.cmake.org/t/one-cmakelists-txt-file-creating-multiple-relocatable-install-packages/11715 "2024-09-23T19:44:05Z")

</div>

I have a CMake project that is something like: top CMakeLists.txt +---foo | CMakeLists.txt | source/header files +---bar CMakeLists.txt source/header files In this configuration the fo…

---

## [Merge libraries to save on size](https://discourse.cmake.org/t/merge-libraries-to-save-on-size/11750)

<div class="topic-metadata">

**Author:** [@ZweiEuro](https://discourse.cmake.org/u/ZweiEuro)\
**Replies:** 0\
**Last updated:** [September 23, 2024, 10:16am UTC](https://discourse.cmake.org/t/merge-libraries-to-save-on-size/11750 "2024-09-23T10:16:32Z")

</div>

Hi! I have a project with CEF library (GitHub - chromiumembedded/cef: Chromium Embedded Framework (CEF). A simple framework for embedding Chromium-based browsers in other applications.) which is quite large. At the mome…

---

## [xcodebuild build -quiet](https://discourse.cmake.org/t/xcodebuild-build-quiet/11742)

<div class="topic-metadata">

**Author:** [@jasonaylward](https://discourse.cmake.org/u/jasonaylward)\
**Replies:** 2\
**Last updated:** [September 22, 2024, 12:51pm UTC](https://discourse.cmake.org/t/xcodebuild-build-quiet/11742 "2024-09-22T12:51:15Z")

</div>

Does anyone know of a way to pass the -quiet flag into xcodebuild build via CMake? Thanks!

---

## [Best way to consum a binary XCFramework (zip)](https://discourse.cmake.org/t/best-way-to-consum-a-binary-xcframework-zip/11721)

<div class="topic-metadata">

**Author:** [@a4z](https://discourse.cmake.org/u/a4z)\
**Replies:** 8\
**Last updated:** [September 21, 2024, 7:30am UTC](https://discourse.cmake.org/t/best-way-to-consum-a-binary-xcframework-zip/11721 "2024-09-21T07:30:54Z")

</div>

Hi, I have a download url to a CoolLib.xcframwork.zip, the zip contains CoolLib.xcframwork, a folder with the xcframewrok content, what is the CMake way to download and extract and have the path added to the search, so…

---

## [How to add multiple test cases (Unity)](https://discourse.cmake.org/t/how-to-add-multiple-test-cases-unity/11726)

<div class="topic-metadata">

**Author:** [@kuch3n](https://discourse.cmake.org/u/kuch3n)\
**Replies:** 1\
**Last updated:** [September 19, 2024, 4:16pm UTC](https://discourse.cmake.org/t/how-to-add-multiple-test-cases-unity/11726 "2024-09-19T16:16:33Z")

</div>

CTest is called with /usr/bin/ctest -j6 -C Debug -T test --output-on-failure --output-junit TestResults.xml and the exectuable is added with add\_test(${test\_name} ${test\_runner\_name}). The TestResults.xml does containt o…

---

## [How to handle header-only-libraries exported through INTERFACE\_LINK\_LIBRARIES?](https://discourse.cmake.org/t/how-to-handle-header-only-libraries-exported-through-interface-link-libraries/11704)

<div class="topic-metadata">

**Author:** [@tonh](https://discourse.cmake.org/u/tonh)\
**Replies:** 1\
**Last updated:** [September 17, 2024, 4:43pm UTC](https://discourse.cmake.org/t/how-to-handle-header-only-libraries-exported-through-interface-link-libraries/11704 "2024-09-17T16:43:10Z")

</div>

Suppose I have some library foo that is exported, and depends on some header-only library target Bar::header-only privately: add\_library(foo) target\_link\_libraries(foo PRIVATE Bar::header-only ) Now, when expo…

---

## [correct command line to build and install](https://discourse.cmake.org/t/correct-command-line-to-build-and-install/11708)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 0\
**Last updated:** [September 17, 2024, 10:43am UTC](https://discourse.cmake.org/t/correct-command-line-to-build-and-install/11708 "2024-09-17T10:43:12Z")

</div>

I can’t remember where I get it but I’m currently using: cmake --build . -- install --no-print-directory To build and install my projects. Yet I have repeatedly read that the only correct syntax should be: cmake --bu…

---

## [How to compile cmake with custom installed GCC](https://discourse.cmake.org/t/how-to-compile-cmake-with-custom-installed-gcc/11699)

<div class="topic-metadata">

**Author:** [@joeyskeys](https://discourse.cmake.org/u/joeyskeys)\
**Replies:** 0\
**Last updated:** [September 16, 2024, 5:14pm UTC](https://discourse.cmake.org/t/how-to-compile-cmake-with-custom-installed-gcc/11699 "2024-09-16T17:14:55Z")

</div>

The problem I encountered is that during the build, some system include conflicts with the system headers and the compiler complains redefinition of enum like fsconfig\_command. I tried to set -nostdinc into CXXFLAGS and…

---

## [FetchContent\_Declare multiple projects cause dependency conflicts](https://discourse.cmake.org/t/fetchcontent-declare-multiple-projects-cause-dependency-conflicts/11690)

<div class="topic-metadata">

**Author:** [@Gwkang](https://discourse.cmake.org/u/Gwkang)\
**Replies:** 3\
**Last updated:** [September 16, 2024, 11:56am UTC](https://discourse.cmake.org/t/fetchcontent-declare-multiple-projects-cause-dependency-conflicts/11690 "2024-09-16T11:56:20Z")

</div>

cmake\_minimum\_required(VERSION 3.20) project(test) include(FetchContent) # snappy FetchContent\_Declare( snappy GIT\_REPOSITORY https://github.com/google/snappy.git GIT\_TAG 1.2.1 ) # leveldb FetchContent\_Dec…

---

## [How downloading a single file from GitHub/GitLab using FetchContent](https://discourse.cmake.org/t/how-downloading-a-single-file-from-github-gitlab-using-fetchcontent/11652)

<div class="topic-metadata">

**Author:** [@RSin](https://discourse.cmake.org/u/RSin)\
**Replies:** 2\
**Last updated:** [September 16, 2024, 7:12am UTC](https://discourse.cmake.org/t/how-downloading-a-single-file-from-github-gitlab-using-fetchcontent/11652 "2024-09-16T07:12:01Z")

</div>

Hello all, I’m failing using FetchContent\_Declare( myArchive URL https://somerepo\_on\_gitlab/link\_of\_an\_archive.zip) to provide an archive for my project. What is downloaded is the website, not the archive. Us…

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

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