# Usage

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

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

**Page:** 23

---

## [Calling CMake from Powershell does not process files correctly](https://discourse.cmake.org/t/calling-cmake-from-powershell-does-not-process-files-correctly/4556)

<div class="topic-metadata">

**Author:** [@Kerstin\_Keller](https://discourse.cmake.org/u/Kerstin_Keller)\
**Replies:** 4\
**Last updated:** [August 17, 2024, 3:36am UTC](https://discourse.cmake.org/t/calling-cmake-from-powershell-does-not-process-files-correctly/4556 "2024-08-17T03:36:10Z")

</div>

When I am invoking CMake from the Powershell, it behaves differently then when calling from cmd. Mainly, it doesn’t parse any files specified by -DCMAKE\_TOOLCHAIN\_FILE=.... When e.g. I run cmake .. -DCMAKE\_TOOLCHAIN\_F…

---

## [Unable to set ctest specific property for parameterized gtest tests](https://discourse.cmake.org/t/unable-to-set-ctest-specific-property-for-parameterized-gtest-tests/11251)

<div class="topic-metadata">

**Author:** [@andi\_schacherbauer](https://discourse.cmake.org/u/andi_schacherbauer)\
**Replies:** 5\
**Last updated:** [August 15, 2024, 7:36am UTC](https://discourse.cmake.org/t/unable-to-set-ctest-specific-property-for-parameterized-gtest-tests/11251 "2024-08-15T07:36:42Z")

</div>

Hi! I have parameterized GTest tests and struggle to set CTest properties on them. The problems seems to be the parameter type. If I have tests with string parameters, everything is fine. As soon as the parameter type i…

---

## ["file Paths to dependencies are not supported" on cpack with RUNTIME\_DEPENDENCY\_SET](https://discourse.cmake.org/t/file-paths-to-dependencies-are-not-supported-on-cpack-with-runtime-dependency-set/11434)

<div class="topic-metadata">

**Author:** [@codeling](https://discourse.cmake.org/u/codeling)\
**Replies:** 5\
**Last updated:** [August 14, 2024, 3:07pm UTC](https://discourse.cmake.org/t/file-paths-to-dependencies-are-not-supported-on-cpack-with-runtime-dependency-set/11434 "2024-08-14T15:07:17Z")

</div>

Continuing my migration to RUNTIME\_DEPENDENCY\_SET, I am now testing on Linux. There, I get an error message: CMake Error at /home/....../bin/cmake\_install.cmake:46 (file): file Paths to dependencies are not supported…

---

## [СмакеPresets.json - conditional inheritance](https://discourse.cmake.org/t/presets-json-conditional-inheritance/11386)

<div class="topic-metadata">

**Author:** [@KSergeyP](https://discourse.cmake.org/u/KSergeyP)\
**Replies:** 1\
**Last updated:** [August 9, 2024, 7:12am UTC](https://discourse.cmake.org/t/presets-json-conditional-inheritance/11386 "2024-08-09T07:12:12Z")

</div>

It is necessary to build the project on different hosts (Windows, Linux). Target - bare metal and does not depend on the host. I made a nested PresetsJson which has 2 subconfigurations with platform-specific settings: …

---

## [How to use CMAKE\_SHARED\_LIBRARY\_PREFIX in command line?](https://discourse.cmake.org/t/how-to-use-cmake-shared-library-prefix-in-command-line/11410)

<div class="topic-metadata">

**Author:** [@ikspress](https://discourse.cmake.org/u/ikspress)\
**Replies:** 1\
**Last updated:** [August 9, 2024, 12:50am UTC](https://discourse.cmake.org/t/how-to-use-cmake-shared-library-prefix-in-command-line/11410 "2024-08-09T00:50:15Z")

</div>

I am trying to specify a prefix for a project to resolve naming conflicts issues. However, CMAKE\_SHARED\_LIBRARY\_PREFIX only works within CMake scripts (set(CMAKE\_SHARED\_LIBRARY\_PREFIX …)) and not on the command line (-DC…

---

## [vs test explorer and gtest\_discover\_test working directory](https://discourse.cmake.org/t/vs-test-explorer-and-gtest-discover-test-working-directory/11296)

<div class="topic-metadata">

**Author:** [@gbug](https://discourse.cmake.org/u/gbug)\
**Replies:** 10\
**Last updated:** [August 9, 2024, 12:16am UTC](https://discourse.cmake.org/t/vs-test-explorer-and-gtest-discover-test-working-directory/11296 "2024-08-09T00:16:02Z")

</div>

Hi! I have a strange issue with gtest\_discovery\_tests and custom working directory with VS Test Explorer – on some machines the working directory is set as expected and on some it doesn’t. In my project I have a tests d…

---

## [multiple inner @ variable in config](https://discourse.cmake.org/t/multiple-inner-variable-in-config/11376)

<div class="topic-metadata">

**Author:** [@kingloxxy](https://discourse.cmake.org/u/kingloxxy)\
**Replies:** 8\
**Last updated:** [August 6, 2024, 3:32pm UTC](https://discourse.cmake.org/t/multiple-inner-variable-in-config/11376 "2024-08-06T15:32:24Z")

</div>

I am currently writing this line on my Config.cmake.in set\_and\_check(@MYVAR@ "@PACKAGE\_@PROJECT\_NAME@@") I would like both my variable to be interpreted but @PROJECT\_NAME@ is not I know there is a way to do it but i d…

---

## [Why didn't my use of \`target\_link\_libraries\` produce the expected result?](https://discourse.cmake.org/t/why-didnt-my-use-of-target-link-libraries-produce-the-expected-result/11394)

<div class="topic-metadata">

**Author:** [@lamb007](https://discourse.cmake.org/u/lamb007)\
**Replies:** 0\
**Last updated:** [August 6, 2024, 2:22pm UTC](https://discourse.cmake.org/t/why-didnt-my-use-of-target-link-libraries-produce-the-expected-result/11394 "2024-08-06T14:22:19Z")

</div>

Here’s the structure of my project: root ├── CMakeLists.txt ├── lib1 │ ├── CMakeLists.txt │ └── lib1.cpp ├── lib2 │ ├── CMakeLists.txt │ └── lib2.cpp └── main.cpp This is lib2/lib2.cpp: #include \<iostream\> voi…

---

## [Unit testing internal functions of a DLL](https://discourse.cmake.org/t/unit-testing-internal-functions-of-a-dll/3805)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 5\
**Last updated:** [August 3, 2024, 12:33am UTC](https://discourse.cmake.org/t/unit-testing-internal-functions-of-a-dll/3805 "2024-08-03T00:33:42Z")

</div>

Hi, you all know the problem, that you only want to define public interfaces as visible in shared libraries (with \_\_declspec(dllexport/import) or equivalent gcc properties). But then, you may only access these symbols …

---

## [Uploading images to CDash: ATTACHED\_FILES vs. CTestMeasurement](https://discourse.cmake.org/t/uploading-images-to-cdash-attached-files-vs-ctestmeasurement/11351)

<div class="topic-metadata">

**Author:** [@codeling](https://discourse.cmake.org/u/codeling)\
**Replies:** 2\
**Last updated:** [August 2, 2024, 7:13am UTC](https://discourse.cmake.org/t/uploading-images-to-cdash-attached-files-vs-ctestmeasurement/11351 "2024-08-02T07:13:04Z")

</div>

TL;DR: 2 issues and 1 question for uploading files to CDash: Images uploaded via ATTACHED\_FILES are not shown directly but are presented as .tgz Images uploaded via CTestMeasurement... are truncated to 64kb in a defaul…

---

## [CMake C++ Toolchain Changing during crosscompile Projekt Build with vcpkg](https://discourse.cmake.org/t/cmake-c-toolchain-changing-during-crosscompile-projekt-build-with-vcpkg/11365)

<div class="topic-metadata">

**Author:** [@fwlff](https://discourse.cmake.org/u/fwlff)\
**Replies:** 1\
**Last updated:** [August 1, 2024, 6:14am UTC](https://discourse.cmake.org/t/cmake-c-toolchain-changing-during-crosscompile-projekt-build-with-vcpkg/11365 "2024-08-01T06:14:48Z")

</div>

Hello there, im trying to compile a c++ Project with vcpkg in manifestmode with a cross compiler on a debian linux. I configured the toolchain file in the CMakeLists to use the vcpkg.cmake. In the vcpkg triplet i refer…

---

## [How to consume usage requirements of a target without exporting LINK\_ONLY](https://discourse.cmake.org/t/how-to-consume-usage-requirements-of-a-target-without-exporting-link-only/11352)

<div class="topic-metadata">

**Author:** [@alcroito](https://discourse.cmake.org/u/alcroito)\
**Replies:** 3\
**Last updated:** [July 31, 2024, 9:33am UTC](https://discourse.cmake.org/t/how-to-consume-usage-requirements-of-a-target-without-exporting-link-only/11352 "2024-07-31T09:33:05Z")

</div>

Hi, I have the following sample project. cmake\_minimum\_required(VERSION 3.21) project(proj LANGUAGES CXX) include(GNUInstallDirs) set(source\_file "${CMAKE\_CURRENT\_BINARY\_DIR}/lib.cpp") file(WRITE "${source\_file}" "in…

---

## [CMake + Ninja is using Windows short paths which causes CCache misses](https://discourse.cmake.org/t/cmake-ninja-is-using-windows-short-paths-which-causes-ccache-misses/11332)

<div class="topic-metadata">

**Author:** [@pablo.odorico](https://discourse.cmake.org/u/pablo.odorico)\
**Replies:** 1\
**Last updated:** [July 31, 2024, 8:19am UTC](https://discourse.cmake.org/t/cmake-ninja-is-using-windows-short-paths-which-causes-ccache-misses/11332 "2024-07-31T08:19:29Z")

</div>

Hello, Is there a way I can prevent CMake from using Windows “8.3” short paths when invoking cl.exe? For example: C:\\\\PROGRA~2\\\\MIB055~1\\\\2022\\\\BUILDT~1\\\\VC\\\\Tools\\\\MSVC\\\\1439~1.335\\\\bin\\\\Hostx64\\\\x64\\\\cl.exe I’m tryi…

---

## [Xcode just ignore generated files?](https://discourse.cmake.org/t/xcode-just-ignore-generated-files/11325)

<div class="topic-metadata">

**Author:** [@davemilter](https://discourse.cmake.org/u/davemilter)\
**Replies:** 1\
**Last updated:** [July 29, 2024, 7:04pm UTC](https://discourse.cmake.org/t/xcode-just-ignore-generated-files/11325 "2024-07-29T19:04:54Z")

</div>

I have external project build by script and also this script generates header file. And this generated file is problem, when it changed (script produced modified file), then Xcode just ignore this change. If I change …

---

## [How can I install a custom target?](https://discourse.cmake.org/t/how-can-i-install-a-custom-target/11340)

<div class="topic-metadata">

**Author:** [@cjdb](https://discourse.cmake.org/u/cjdb)\
**Replies:** 2\
**Last updated:** [July 29, 2024, 1:52am UTC](https://discourse.cmake.org/t/how-can-i-install-a-custom-target/11340 "2024-07-29T01:52:09Z")

</div>

tl;dr I want to run a tool that writes to a file during the install step, and then install that file. I can’t work out how to do this. I’d like to be able to install split debug info alongside my targets. Improving C++ …

---

## [What is use and significance of environment inherit in CMake Build Preset.](https://discourse.cmake.org/t/what-is-use-and-significance-of-environment-inherit-in-cmake-build-preset/8830)

<div class="topic-metadata">

**Author:** [@siddmohsin](https://discourse.cmake.org/u/siddmohsin)\
**Replies:** 3\
**Last updated:** [July 26, 2024, 12:51pm UTC](https://discourse.cmake.org/t/what-is-use-and-significance-of-environment-inherit-in-cmake-build-preset/8830 "2024-07-26T12:51:24Z")

</div>

In CMake Build Preset inside CMakePresets.json also we can have environment and us inherit keyword to inherit properties from inherited build presets. Now in regard with CMake Config Preset these environment and inherits…

---

## [Specifying Toolset with Ninja Generator in Visual Studio vs Vanilla CMake](https://discourse.cmake.org/t/specifying-toolset-with-ninja-generator-in-visual-studio-vs-vanilla-cmake/11238)

<div class="topic-metadata">

**Author:** [@KStocky](https://discourse.cmake.org/u/KStocky)\
**Replies:** 2\
**Last updated:** [July 25, 2024, 9:19pm UTC](https://discourse.cmake.org/t/specifying-toolset-with-ninja-generator-in-visual-studio-vs-vanilla-cmake/11238 "2024-07-25T21:19:09Z")

</div>

Hi all! Given the following CMakeLists.txt cmake\_minimum\_required(VERSION 3.26) project(MyProj LANGUAGES CXX) add\_executable(MyProj src.cpp) and CMakePresets.json { "version": 6, "configurePresets": \[ {…

---

## [How to solve this error](https://discourse.cmake.org/t/how-to-solve-this-error/11316)

<div class="topic-metadata">

**Author:** [@gordafarid\_M](https://discourse.cmake.org/u/gordafarid_M)\
**Replies:** 1\
**Last updated:** [July 24, 2024, 9:33pm UTC](https://discourse.cmake.org/t/how-to-solve-this-error/11316 "2024-07-24T21:33:23Z")

</div>

CMake Error at CMakeLists.txt:4 (project): GHS\_TOOLSET\_ROOT directory “/usr/ghs” does not exist.

---

## [How to target a specific version of a Linux distro with CPack?](https://discourse.cmake.org/t/how-to-target-a-specific-version-of-a-linux-distro-with-cpack/11282)

<div class="topic-metadata">

**Author:** [@ajbclarfu](https://discourse.cmake.org/u/ajbclarfu)\
**Replies:** 1\
**Last updated:** [July 24, 2024, 8:10pm UTC](https://discourse.cmake.org/t/how-to-target-a-specific-version-of-a-linux-distro-with-cpack/11282 "2024-07-24T20:10:59Z")

</div>

How to target a specific version of a Linux distro with CPack? Suppose I want to generate several deb files each one targeting a different version of a Linux distro. How do I do that? My hypothesis is that CPack packages…

---

## [Source directory does not appear to contain CMakeLists.txt?](https://discourse.cmake.org/t/source-directory-does-not-appear-to-contain-cmakelists-txt/3654)

<div class="topic-metadata">

**Author:** [@bc19](https://discourse.cmake.org/u/bc19)\
**Replies:** 17\
**Last updated:** [July 23, 2024, 3:29am UTC](https://discourse.cmake.org/t/source-directory-does-not-appear-to-contain-cmakelists-txt/3654 "2024-07-23T03:29:52Z")

</div>

I am not sure why I am getting an error when I try this command: cmake -D OpenBLAS\_DIR=/usr/local/opt/openblas -D CMAKE\_BUILD\_TYPE=RELEASE … It then says: CMake Error: The source directory “/Users/biancacaproni” does …

---

## [CMake Error at CMakeLists.txt:29](https://discourse.cmake.org/t/cmake-error-at-cmakelists-txt-29/11302)

<div class="topic-metadata">

**Author:** [@gordafarid\_M](https://discourse.cmake.org/u/gordafarid_M)\
**Replies:** 0\
**Last updated:** [July 22, 2024, 6:20pm UTC](https://discourse.cmake.org/t/cmake-error-at-cmakelists-txt-29/11302 "2024-07-22T18:20:11Z")

</div>

GHS\_TOOLSET\_ROOT directory “/usr/ghs” does not exist.

---

## [Find\_program not finding ccache installed via scoop](https://discourse.cmake.org/t/find-program-not-finding-ccache-installed-via-scoop/11299)

<div class="topic-metadata">

**Author:** [@LarryOates](https://discourse.cmake.org/u/LarryOates)\
**Replies:** 1\
**Last updated:** [July 22, 2024, 3:44pm UTC](https://discourse.cmake.org/t/find-program-not-finding-ccache-installed-via-scoop/11299 "2024-07-22T15:44:15Z")

</div>

I’ve installed ccache via scoop on my windows machine. I can use ccache on the command line (the program is on my system path) but CMake can’t find it via find\_program. Any ideas?

---

## [Swift + C/C++ Interop with CMake](https://discourse.cmake.org/t/swift-c-c-interop-with-cmake/11301)

<div class="topic-metadata">

**Author:** [@pusewicz](https://discourse.cmake.org/u/pusewicz)\
**Replies:** 0\
**Last updated:** [July 22, 2024, 2:45pm UTC](https://discourse.cmake.org/t/swift-c-c-interop-with-cmake/11301 "2024-07-22T14:45:21Z")

</div>

I’m trying to setup CMake with Swift and running into issues when compiling cute . Here’s the repo: GitHub - pusewicz/dungeon\_loop\_cute And the command I use: cmake -Bbuild -G Ninja . && cmake --build build. Unfortun…

---

## [What should the DESTINATION be for a header only library's CMake config file?](https://discourse.cmake.org/t/what-should-the-destination-be-for-a-header-only-librarys-cmake-config-file/8473)

<div class="topic-metadata">

**Author:** [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)\
**Replies:** 5\
**Last updated:** [July 21, 2024, 12:43pm UTC](https://discourse.cmake.org/t/what-should-the-destination-be-for-a-header-only-librarys-cmake-config-file/8473 "2024-07-21T12:43:42Z")

</div>

I have the following CMake code for a header only library that uses FILE\_SET. My question is what is the optimal DESTINATION for the CMake config file generated. It’s unclear to me what it should be for a header only l…

---

## [Cannot have per config CTestCustom files](https://discourse.cmake.org/t/cannot-have-per-config-ctestcustom-files/11152)

<div class="topic-metadata">

**Author:** [@Ahmet\_Bilgili](https://discourse.cmake.org/u/Ahmet_Bilgili)\
**Replies:** 1\
**Last updated:** [July 20, 2024, 1:40pm UTC](https://discourse.cmake.org/t/cannot-have-per-config-ctestcustom-files/11152 "2024-07-20T13:40:45Z")

</div>

I would like to execute some scripts before starting ctest via the CTestCustom file and CTEST\_CUSTOM\_PRE\_TEST. But I cannot differentiate between configurations meaning; if I do “ctest -C RelWithDebInfo”, I would like t…

---

## ["note" messages from MSVC are filtered out from cmake output](https://discourse.cmake.org/t/note-messages-from-msvc-are-filtered-out-from-cmake-output/10892)

<div class="topic-metadata">

**Author:** [@jeanga](https://discourse.cmake.org/u/jeanga)\
**Replies:** 2\
**Last updated:** [July 19, 2024, 2:10pm UTC](https://discourse.cmake.org/t/note-messages-from-msvc-are-filtered-out-from-cmake-output/10892 "2024-07-19T14:10:13Z")

</div>

recently (VS 2022 17.10&17.11), MSVC has been using “note” messages to detail the context of an error message: Blockquote C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.39.33519\\include\\memo…

---

## [Disable CMake Warnings for FetchContent](https://discourse.cmake.org/t/disable-cmake-warnings-for-fetchcontent/11263)

<div class="topic-metadata">

**Author:** [@MarcelKoch](https://discourse.cmake.org/u/MarcelKoch)\
**Replies:** 4\
**Last updated:** [July 17, 2024, 1:50pm UTC](https://discourse.cmake.org/t/disable-cmake-warnings-for-fetchcontent/11263 "2024-07-17T13:50:22Z")

</div>

Hello, Is it possible to disable CMake warning (-Wdev) only for a package that is added via FetchContent? The documentation for the -Wdev option doesn’t offer any suggestion for this, and neither does the documentation …

---

## [CMake Error at CMakeLists.txt:108 (message): Could not find sqlite3.lib. Check SQLITE\_LIB\_DIR. Call Stack (most recent call first): CMakeLists.txt:239 (findLib)](https://discourse.cmake.org/t/cmake-error-at-cmakelists-txt-108-message-could-not-find-sqlite3-lib-check-sqlite-lib-dir-call-stack-most-recent-call-first-cmakelists-txt-239-findlib/11256)

<div class="topic-metadata">

**Author:** [@dollPrincess](https://discourse.cmake.org/u/dollPrincess)\
**Replies:** 0\
**Last updated:** [July 16, 2024, 2:28am UTC](https://discourse.cmake.org/t/cmake-error-at-cmakelists-txt-108-message-could-not-find-sqlite3-lib-check-sqlite-lib-dir-call-stack-most-recent-call-first-cmakelists-txt-239-findlib/11256 "2024-07-16T02:28:20Z")

</div>

I have downloaded a project called Febio Studio, for which I can have no help of those who I downloaded it from, and am running into a wall that I cannot comprehend. I hope someone here can shed some light to help this a…

---

## [Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'MSBuild.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format.](https://discourse.cmake.org/t/unhandled-exception-system-badimageformatexception-could-not-load-file-or-assembly-msbuild-exe-or-one-of-its-dependencies-an-attempt-was-made-to-load-a-program-with-an-incorrect-format/11244)

<div class="topic-metadata">

**Author:** [@Zorono](https://discourse.cmake.org/u/Zorono)\
**Replies:** 3\
**Last updated:** [July 15, 2024, 10:22pm UTC](https://discourse.cmake.org/t/unhandled-exception-system-badimageformatexception-could-not-load-file-or-assembly-msbuild-exe-or-one-of-its-dependencies-an-attempt-was-made-to-load-a-program-with-an-incorrect-format/11244 "2024-07-15T22:22:55Z")

</div>

when i try to build this samp-gps-plugin/CMakeLists.txt at master · kristoisberg/samp-gps-plugin · GitHub which is built normally with everyone without any problem CMake Deprecation Warning at CMakeLists.txt:1 (cmake\_mi…

---

## [cmake does not detect fmt package](https://discourse.cmake.org/t/cmake-does-not-detect-fmt-package/11248)

<div class="topic-metadata">

**Author:** [@solomoncyj](https://discourse.cmake.org/u/solomoncyj)\
**Replies:** 2\
**Last updated:** [July 15, 2024, 5:19pm UTC](https://discourse.cmake.org/t/cmake-does-not-detect-fmt-package/11248 "2024-07-15T17:19:43Z")

</div>

\> cmake -S . -B build -G Ninja Running CMake on dnf5... Building dnf5 version 5.2.4.0 -- Checking for module 'fmt' -- Package 'fmt' not found CMake Error at /usr/local/share/cmake-3.30/Modules/FindPkgConfig.cmake:645…

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

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