# Usage

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

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

**Page:** 46

---

## [Saving Command Line Configuration](https://discourse.cmake.org/t/saving-command-line-configuration/7981)

<div class="topic-metadata">

**Author:** [@jamesETsmith](https://discourse.cmake.org/u/jamesETsmith)\
**Replies:** 3\
**Last updated:** [April 26, 2023, 3:55pm UTC](https://discourse.cmake.org/t/saving-command-line-configuration/7981 "2023-04-26T15:55:33Z")

</div>

General I’d like to save the command line arguments users pass at configure time into a source file that will be included with my project so that users can access that information at run time when benchmarking. Is there…

---

## [Build HIP binaries on NVIDIA platform](https://discourse.cmake.org/t/build-hip-binaries-on-nvidia-platform/7883)

<div class="topic-metadata">

**Author:** [@wme7](https://discourse.cmake.org/u/wme7)\
**Replies:** 2\
**Last updated:** [April 26, 2023, 1:19pm UTC](https://discourse.cmake.org/t/build-hip-binaries-on-nvidia-platform/7883 "2023-04-26T13:19:30Z")

</div>

I noted that since CMake 3.21, hip is a supported language in CMake. But I don’t seem to get it to work right when build bynaries (either executables or libraries) on NVIDIA platforms. Perphasp, I’m not using the new CM…

---

## [CPack missed dlls copied by windeployqt](https://discourse.cmake.org/t/cpack-missed-dlls-copied-by-windeployqt/7873)

<div class="topic-metadata">

**Author:** [@Joseph](https://discourse.cmake.org/u/Joseph)\
**Replies:** 7\
**Last updated:** [April 26, 2023, 11:10am UTC](https://discourse.cmake.org/t/cpack-missed-dlls-copied-by-windeployqt/7873 "2023-04-26T11:10:35Z")

</div>

In my Qt-based project, I deploy qt dlls by following steps: Run my custom cmake script by install(SCRIPT My cmake script runs windeployqt during installation, and the working directory is set to CMAKE\_INSTALL\_PREFIX s…

---

## [Why does -D on command line work, but -C with file does not?](https://discourse.cmake.org/t/why-does-d-on-command-line-work-but-c-with-file-does-not/7985)

<div class="topic-metadata">

**Author:** [@RobN](https://discourse.cmake.org/u/RobN)\
**Replies:** 1\
**Last updated:** [April 26, 2023, 8:56am UTC](https://discourse.cmake.org/t/why-does-d-on-command-line-work-but-c-with-file-does-not/7985 "2023-04-26T08:56:00Z")

</div>

As part of my ongoing flailing and sanity-eroding attempts to compile clang and libc++ for myself, I tried something like this: % cmake -G Ninja -C phase2.x86.cmake -S runtimes -B build\_phase2\_x86 Where that phase2.x86…

---

## [Create WatchKit extension XCode project structure](https://discourse.cmake.org/t/create-watchkit-extension-xcode-project-structure/7864)

<div class="topic-metadata">

**Author:** [@tqu-dev](https://discourse.cmake.org/u/tqu-dev)\
**Replies:** 7\
**Last updated:** [April 25, 2023, 3:46am UTC](https://discourse.cmake.org/t/create-watchkit-extension-xcode-project-structure/7864 "2023-04-25T03:46:29Z")

</div>

Hi, At the moment I am using cmake for generating a xCode iOS project (using Qt for iOS framework) which is then used for creating an archive and for the app store submission. Now I want to add a WatchKit extension to t…

---

## [clang-tidy + cxx\_modules](https://discourse.cmake.org/t/clang-tidy-cxx-modules/7938)

<div class="topic-metadata">

**Author:** [@Lecris](https://discourse.cmake.org/u/Lecris)\
**Replies:** 11\
**Last updated:** [April 24, 2023, 6:42pm UTC](https://discourse.cmake.org/t/clang-tidy-cxx-modules/7938 "2023-04-24T18:42:17Z")

</div>

I have tried to enable the clang-tidy on cxx\_module project using CMAKE\_CLANG\_TIDY. But it seems to fail and I don’t know if it is an issue in how cmake calls it or an issue on clang-tidy side. Here is a mwe: # CMakeLis…

---

## [Change "quote include" behavior](https://discourse.cmake.org/t/change-quote-include-behavior/7964)

<div class="topic-metadata">

**Author:** [@fry](https://discourse.cmake.org/u/fry)\
**Replies:** 3\
**Last updated:** [April 24, 2023, 4:13pm UTC](https://discourse.cmake.org/t/change-quote-include-behavior/7964 "2023-04-24T16:13:00Z")

</div>

My code rely on a library that has an issue: one of the .h file is missing an include which used to work and now fails with the latest version of Xcode. Unfortunately this library includes this file using the “quote inc…

---

## [force one target to be compiled after a shared library is built](https://discourse.cmake.org/t/force-one-target-to-be-compiled-after-a-shared-library-is-built/7826)

<div class="topic-metadata">

**Author:** [@samuelpmish](https://discourse.cmake.org/u/samuelpmish)\
**Replies:** 6\
**Last updated:** [April 24, 2023, 2:42pm UTC](https://discourse.cmake.org/t/force-one-target-to-be-compiled-after-a-shared-library-is-built/7826 "2023-04-24T14:42:50Z")

</div>

Hi, I’ve got an unusual scenario where I’m trying to build and load a shared library as a plugin to clang, and I’m struggling to figure out how to express this with CMake. The project has two parts: the sources that…

---

## [execute\_process for detecting bash: issues with grep and awk commands arguments](https://discourse.cmake.org/t/execute-process-for-detecting-bash-issues-with-grep-and-awk-commands-arguments/7833)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 6\
**Last updated:** [April 24, 2023, 12:30pm UTC](https://discourse.cmake.org/t/execute-process-for-detecting-bash-issues-with-grep-and-awk-commands-arguments/7833 "2023-04-24T12:30:34Z")

</div>

Hi, I try to detect the running shell with the following cmake command: execute\_process(COMMAND ps COMMAND grep \`echo $$\` COMMAND awk \`{ print $4 }\` OUTPUT\_VARIABLE RUNNING\_SHELL RESULT\_VARIABLE ERROR\_HAPPENED) but I …

---

## [generate\_export\_header: generated file name, issue with case](https://discourse.cmake.org/t/generate-export-header-generated-file-name-issue-with-case/7875)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 2\
**Last updated:** [April 24, 2023, 8:48am UTC](https://discourse.cmake.org/t/generate-export-header-generated-file-name-issue-with-case/7875 "2023-04-24T08:48:42Z")

</div>

Hi, I have an issue with …\_export.h file creation with generate\_export\_header. My targeted library is camel-cased (for instance MyLib). On windows, the generated file is name MyLib\_export.h while on ubuntu 16.04, I ge…

---

## [git and generate\_export\_header](https://discourse.cmake.org/t/git-and-generate-export-header/7869)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 2\
**Last updated:** [April 24, 2023, 7:53am UTC](https://discourse.cmake.org/t/git-and-generate-export-header/7869 "2023-04-24T07:53:38Z")

</div>

Hi, I’m just looking for an advice: should I gitignore files generated by generate\_export\_header? How can I document the fact that my sources are including a file that must first be generated? Thanks A.

---

## [Splitting a multiline string into individual line (at least getting the last one)](https://discourse.cmake.org/t/splitting-a-multiline-string-into-individual-line-at-least-getting-the-last-one/7956)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 2\
**Last updated:** [April 24, 2023, 7:34am UTC](https://discourse.cmake.org/t/splitting-a-multiline-string-into-individual-line-at-least-getting-the-last-one/7956 "2023-04-24T07:34:42Z")

</div>

Hi I’ve got in some variable MYSTRING a multiline string, for instance: CMAKE\_CXX\_FLAGS\_DEBUG: -g CMAKE\_CXX\_FLAGS\_RELWITHDEBINFO: -O2 -g -DNDEBUG CMAKE\_CXX\_FLAGS\_RELEASE: -O3 -DNDEBUG I’d like to get only CMAKE\_CXX\_F…

---

## [CSharp: Generate nupkg from command line](https://discourse.cmake.org/t/csharp-generate-nupkg-from-command-line/7931)

<div class="topic-metadata">

**Author:** [@malaterre](https://discourse.cmake.org/u/malaterre)\
**Replies:** 1\
**Last updated:** [April 24, 2023, 5:32am UTC](https://discourse.cmake.org/t/csharp-generate-nupkg-from-command-line/7931 "2023-04-24T05:32:02Z")

</div>

Dear all, I have a simple cmakelists.txt project: project(Example VERSION 0.1.0 LANGUAGES CSharp) add\_library(foo SHARED bar.cs) I understand I can open Visual Studio 2019, go to project, and click “Pack” to generate …

---

## [How to set PATH to cmake in Visual Studio terminal ?](https://discourse.cmake.org/t/how-to-set-path-to-cmake-in-visual-studio-terminal/7877)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 1\
**Last updated:** [April 24, 2023, 5:01am UTC](https://discourse.cmake.org/t/how-to-set-path-to-cmake-in-visual-studio-terminal/7877 "2023-04-24T05:01:31Z")

</div>

Hi, I think this must be a simple question. When using cmake with Visual Studio from the command line, it is recommended to run cmake from the Visual Studio terminal, where all environment variables are already set up …

---

## [building swift library out of cmake project - how to set the autogenerated bridging header location.](https://discourse.cmake.org/t/building-swift-library-out-of-cmake-project-how-to-set-the-autogenerated-bridging-header-location/7866)

<div class="topic-metadata">

**Author:** [@zohar81](https://discourse.cmake.org/u/zohar81)\
**Replies:** 1\
**Last updated:** [April 24, 2023, 4:52am UTC](https://discourse.cmake.org/t/building-swift-library-out-of-cmake-project-how-to-set-the-autogenerated-bridging-header-location/7866 "2023-04-24T04:52:36Z")

</div>

Hi, I’m building swift based library from cmake project and I’d like to control the location of the objective-c generated interface header name. This file is autogenerated and ends with -Swift.h header to be included in…

---

## [Misleading error message in try\_run](https://discourse.cmake.org/t/misleading-error-message-in-try-run/7831)

<div class="topic-metadata">

**Author:** [@codeling](https://discourse.cmake.org/u/codeling)\
**Replies:** 1\
**Last updated:** [April 24, 2023, 4:22am UTC](https://discourse.cmake.org/t/misleading-error-message-in-try-run/7831 "2023-04-24T04:22:39Z")

</div>

I am trying to run a very simple C++ program during configuration. My first attempt: Test.cxx: #include \<iostream\> int main() { std::cout \<\< "test" \<\< std::endl; } CMakeLists.txt cmake\_minimum\_required(VERSION 3.…

---

## [serial custom\_commands?](https://discourse.cmake.org/t/serial-custom-commands/7821)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 1\
**Last updated:** [April 24, 2023, 4:14am UTC](https://discourse.cmake.org/t/serial-custom-commands/7821 "2023-04-24T04:14:45Z")

</div>

We have a build that sometimes fails, because a executable for a custom command is already in use. How can I make it run serial and never in parallel. Much like RUN\_SERIAL for tests.

---

## [Best Practice to propagate custom targtes](https://discourse.cmake.org/t/best-practice-to-propagate-custom-targtes/7813)

<div class="topic-metadata">

**Author:** [@kpahnke](https://discourse.cmake.org/u/kpahnke)\
**Replies:** 1\
**Last updated:** [April 24, 2023, 4:10am UTC](https://discourse.cmake.org/t/best-practice-to-propagate-custom-targtes/7813 "2023-04-24T04:10:27Z")

</div>

In Modern CMake context all artefacts a package provides should be targets. For libraries and executables, this is obvious, but how to handle custom targets properly? They can’t be installed itself (only the files, whic…

---

## [VSCode "Unable to determine what CMake generator to use. "](https://discourse.cmake.org/t/vscode-unable-to-determine-what-cmake-generator-to-use/7963)

<div class="topic-metadata">

**Author:** [@w9ran](https://discourse.cmake.org/u/w9ran)\
**Replies:** 1\
**Last updated:** [April 23, 2023, 6:58pm UTC](https://discourse.cmake.org/t/vscode-unable-to-determine-what-cmake-generator-to-use/7963 "2023-04-23T18:58:25Z")

</div>

I realize this is a noob issue but hope someone can help me sort out what’s wrong and fix it. I followed a tutorial to create the toolchain needed to do C++ development in VSCode including installing Cmake and the CMake…

---

## [hipcc: CXX\_FILESYSTEM\_CPPFS\_NEEDED test fails - how to add std=c++17](https://discourse.cmake.org/t/hipcc-cxx-filesystem-cppfs-needed-test-fails-how-to-add-std-c-17/7897)

<div class="topic-metadata">

**Author:** [@eugenewalker](https://discourse.cmake.org/u/eugenewalker)\
**Replies:** 1\
**Last updated:** [April 21, 2023, 9:35pm UTC](https://discourse.cmake.org/t/hipcc-cxx-filesystem-cppfs-needed-test-fails-how-to-add-std-c-17/7897 "2023-04-21T21:35:07Z")

</div>

I’m trying to build a code that sets CMAKE\_CXX\_COMPILER=hipcc. The system I am on has GCC 11.2.0 and ROCm 5.4.3 (installed to the standard /opt/rocm). CMake version is 3.25.2. The problem is, cmake check is failing, rep…

---

## [Help converting most of a CI matrix to presets?](https://discourse.cmake.org/t/help-converting-most-of-a-ci-matrix-to-presets/3391)

<div class="topic-metadata">

**Author:** [@claremacrae](https://discourse.cmake.org/u/claremacrae)\
**Replies:** 17\
**Last updated:** [April 20, 2023, 5:56am UTC](https://discourse.cmake.org/t/help-converting-most-of-a-ci-matrix-to-presets/3391 "2023-04-20T05:56:21Z")

</div>

I’m trying to convert this build matrix to CMake presets. My initial experiment has awful repetition, as each configure preset needs a matching build preset and a test preset. To test it, I’m running it like this: $CM…

---

## [\[ExternalData\] ExternalData\_Expand\_Arguments with REGEX arguments - how to get matched files at configure time?](https://discourse.cmake.org/t/externaldata-externaldata-expand-arguments-with-regex-arguments-how-to-get-matched-files-at-configure-time/7907)

<div class="topic-metadata">

**Author:** [@menno](https://discourse.cmake.org/u/menno)\
**Replies:** 1\
**Last updated:** [April 19, 2023, 7:49am UTC](https://discourse.cmake.org/t/externaldata-externaldata-expand-arguments-with-regex-arguments-how-to-get-matched-files-at-configure-time/7907 "2023-04-19T07:49:55Z")

</div>

When I issue the command ExternalData\_Expand\_Arguments with a REGEX argument to match multiple files, I was expecting to get all matched files as a return argument, but it returns the directory on which the REGEX operate…

---

## [generator expression error](https://discourse.cmake.org/t/generator-expression-error/7906)

<div class="topic-metadata">

**Author:** [@KBentley57](https://discourse.cmake.org/u/KBentley57)\
**Replies:** 6\
**Last updated:** [April 19, 2023, 5:05am UTC](https://discourse.cmake.org/t/generator-expression-error/7906 "2023-04-19T05:05:09Z")

</div>

Hi all, I’m having an error that didn’t seem to happen in the past. I’m building HDF5, using externalproject\_add, not that it really matters. The problem is with the generator expression below. SOURCE\_SUBDIR $\<$\<VERS…

---

## [FindBoost.cmake seems to work but adds no include folders to compile line when linked against](https://discourse.cmake.org/t/findboost-cmake-seems-to-work-but-adds-no-include-folders-to-compile-line-when-linked-against/7923)

<div class="topic-metadata">

**Author:** [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)\
**Replies:** 3\
**Last updated:** [April 18, 2023, 2:42pm UTC](https://discourse.cmake.org/t/findboost-cmake-seems-to-work-but-adds-no-include-folders-to-compile-line-when-linked-against/7923 "2023-04-18T14:42:32Z")

</div>

I’m getting boost 1.77 thru conan for my small project. It is downloaded fine and seems to exist in its entirety in my conan cache. My CMakeLists.txt has a find\_package line: find\_package(Boost COMPONENTS thread syste…

---

## [the usage of target\_include\_directories vs target\_link\_libraries](https://discourse.cmake.org/t/the-usage-of-target-include-directories-vs-target-link-libraries/7914)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 9\
**Last updated:** [April 17, 2023, 8:39am UTC](https://discourse.cmake.org/t/the-usage-of-target-include-directories-vs-target-link-libraries/7914 "2023-04-17T08:39:50Z")

</div>

anyone know the reason? why target\_include\_directories need to set the ${FMT\_INCLUDE\_DIRS} but not set the ${OpenCV\_INCLUDE\_DIRS} target\_include\_directories(myapp PUBLIC ${FMT\_INCLUDE\_DIRS} ) target\_link\_libraries(m…

---

## [Overriding CPack version from command line not working](https://discourse.cmake.org/t/overriding-cpack-version-from-command-line-not-working/7008)

<div class="topic-metadata">

**Author:** [@rcoup](https://discourse.cmake.org/u/rcoup)\
**Replies:** 1\
**Last updated:** [April 16, 2023, 3:04pm UTC](https://discourse.cmake.org/t/overriding-cpack-version-from-command-line-not-working/7008 "2023-04-16T15:04:40Z")

</div>

According to the docs, using cpack -R \<version\> should override whatever CPACK\_PACKAGE\_VERSION has been previously deduced/configured. Except as far as I can tell, it doesn’t… -R \<packageVersion\> Override/define the v…

---

## [$\<LOWER\_CASE:...\> doesn't work with VS generator?](https://discourse.cmake.org/t/lower-case-doesnt-work-with-vs-generator/7917)

<div class="topic-metadata">

**Author:** [@studyingegret](https://discourse.cmake.org/u/studyingegret)\
**Replies:** 1\
**Last updated:** [April 16, 2023, 9:59am UTC](https://discourse.cmake.org/t/lower-case-doesnt-work-with-vs-generator/7917 "2023-04-16T09:59:44Z")

</div>

Hello everyone, I am following Step 1 of the CMake tutorial, and I am trying to control the output directory of executables. As the Visual Studio build system creates subdirectories per configuration in the build direct…

---

## [Passing \`-fsanitize=fuzzer\` via the command line or from a \`CMakePresets\` file](https://discourse.cmake.org/t/passing-fsanitize-fuzzer-via-the-command-line-or-from-a-cmakepresets-file/7902)

<div class="topic-metadata">

**Author:** [@cristi](https://discourse.cmake.org/u/cristi)\
**Replies:** 4\
**Last updated:** [April 15, 2023, 8:20am UTC](https://discourse.cmake.org/t/passing-fsanitize-fuzzer-via-the-command-line-or-from-a-cmakepresets-file/7902 "2023-04-15T08:20:43Z")

</div>

When using clang as a compiler and trying to set CMAKE\_C\_FLAGS to include -fsanitize=fuzzer, generation fails with: $ cmake .. -DCMAKE\_C\_COMPILER=clang -DCMAKE\_C\_FLAGS="-fsanitize=fuzzer" -- The C compiler identificatio…

---

## [GHS Multi users](https://discourse.cmake.org/t/ghs-multi-users/3995)

<div class="topic-metadata">

**Author:** [@fdk17](https://discourse.cmake.org/u/fdk17)\
**Replies:** 5\
**Last updated:** [April 14, 2023, 2:32am UTC](https://discourse.cmake.org/t/ghs-multi-users/3995 "2023-04-14T02:32:37Z")

</div>

I was wondering how others are using the Green Hills MULTI generator. It’s been awhile since I’ve touched it. I’ve recently started using CMake again to use with INTEGRITY 178 tump. It took a little trial and error to…

---

## [building a shared library NMAKE : fatal error U1077](https://discourse.cmake.org/t/building-a-shared-library-nmake-fatal-error-u1077/7854)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 3\
**Last updated:** [April 10, 2023, 1:49pm UTC](https://discourse.cmake.org/t/building-a-shared-library-nmake-fatal-error-u1077/7854 "2023-04-10T13:49:29Z")

</div>

Hi, I’m trying to build a simple shared library example. With the included project, I’ve got an error on build: "C:\\Program Files\\CMake\\bin\\cmake.exe" -E \_\_create\_def CMakeFiles\\TestShared.dir\\exports.def CMakeFiles\\T…

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

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