# Usage

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

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

**Page:** 73

---

## [Makefiles generator on WSL works significantly slower](https://discourse.cmake.org/t/makefiles-generator-on-wsl-works-significantly-slower/4177)

<div class="topic-metadata">

**Author:** [@Semyon\_Kolton](https://discourse.cmake.org/u/Semyon_Kolton)\
**Replies:** 2\
**Last updated:** [October 1, 2021, 11:38am UTC](https://discourse.cmake.org/t/makefiles-generator-on-wsl-works-significantly-slower/4177 "2021-10-01T11:38:39Z")

</div>

Hi, I’ve got a WSL 2 machine with LLVM project under /mnt directory. I’ve noticed that running CMake on this project with Unix Makefile generator takes significantly more time than with Ninja generator. With Ninja it ta…

---

## [Print out compile options of a target within a function](https://discourse.cmake.org/t/print-out-compile-options-of-a-target-within-a-function/4175)

<div class="topic-metadata">

**Author:** [@mscofield0](https://discourse.cmake.org/u/mscofield0)\
**Replies:** 2\
**Last updated:** [October 1, 2021, 11:05am UTC](https://discourse.cmake.org/t/print-out-compile-options-of-a-target-within-a-function/4175 "2021-10-01T11:05:31Z")

</div>

I have a enable\_sanitizers() function like this: function(enable\_sanitizers project\_name) ... target\_compile\_options(${project\_name} INTERFACE -fsanitize=${LIST\_OF\_SANITIZERS} -fno-optimize-sibling-calls -lr…

---

## [MSBUILD : error MSB1009: Project file does not exist. Switch: ALL\_BUILD.vcxproj](https://discourse.cmake.org/t/msbuild-error-msb1009-project-file-does-not-exist-switch-all-build-vcxproj/4107)

<div class="topic-metadata">

**Author:** [@EricksBr](https://discourse.cmake.org/u/EricksBr)\
**Replies:** 5\
**Last updated:** [September 30, 2021, 5:55pm UTC](https://discourse.cmake.org/t/msbuild-error-msb1009-project-file-does-not-exist-switch-all-build-vcxproj/4107 "2021-09-30T17:55:59Z")

</div>

Goal: I am trying to use CMake to run a series of msbuild commands to build multiple Visual Studio C++ projects. I have done this using nmake. The long term plan is to bring the projects up to date, using latest tool…

---

## [Odd FindMPI output: Bug? Feature?](https://discourse.cmake.org/t/odd-findmpi-output-bug-feature/4168)

<div class="topic-metadata">

**Author:** [@mathomp4](https://discourse.cmake.org/u/mathomp4)\
**Replies:** 2\
**Last updated:** [September 29, 2021, 7:42pm UTC](https://discourse.cmake.org/t/odd-findmpi-output-bug-feature/4168 "2021-09-29T19:42:30Z")

</div>

All, Recently on the NASA NAS supercomputer, I noticed something in my CMake output that surprised me when using HPE MPT as the MPI stack. As an example, I whipped up a simple hello world CMakeLists.txt: project(hello…

---

## [Bug in CMake tutorial](https://discourse.cmake.org/t/bug-in-cmake-tutorial/4162)

<div class="topic-metadata">

**Author:** [@Christophe\_Bernard](https://discourse.cmake.org/u/Christophe_Bernard)\
**Replies:** 3\
**Last updated:** [September 29, 2021, 7:26pm UTC](https://discourse.cmake.org/t/bug-in-cmake-tutorial/4162 "2021-09-29T19:26:39Z")

</div>

Hi. The example tests in Step3 of the CMake tutorial suggest to use the following regexp to verify the output of an executable call. do\_test(Tutorial -25 “-25 is \[-nan|nan|0\]”) I think this does not what was intende…

---

## [Setting \`CMAKE\_CXX\_FLAGS\` within a function](https://discourse.cmake.org/t/setting-cmake-cxx-flags-within-a-function/4163)

<div class="topic-metadata">

**Author:** [@mscofield0](https://discourse.cmake.org/u/mscofield0)\
**Replies:** 8\
**Last updated:** [September 29, 2021, 6:33pm UTC](https://discourse.cmake.org/t/setting-cmake-cxx-flags-within-a-function/4163 "2021-09-29T18:33:14Z")

</div>

It seems that CMAKE\_CXX\_FLAGS isn’t being set when I set it inside of a function. I tried checking the contents, it is empty before and after, even within the same function. These are all things I’ve tried, neither work…

---

## [Visual Studio fails to reload properly upon CMake changes](https://discourse.cmake.org/t/visual-studio-fails-to-reload-properly-upon-cmake-changes/4108)

<div class="topic-metadata">

**Author:** [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)\
**Replies:** 2\
**Last updated:** [September 29, 2021, 2:10pm UTC](https://discourse.cmake.org/t/visual-studio-fails-to-reload-properly-upon-cmake-changes/4108 "2021-09-29T14:10:53Z")

</div>

Here is a basic C++ project # CMakeLists.txt cmake\_minimum\_required(VERSION 3.21) project(FOOBAR LANGUAGES "CXX") add\_executable(baz) target\_sources(baz PRIVATE main.cpp) // main.cpp #include \<iostream\> int main() { st…

---

## [Windows configure error when using the command line: "The C/CXX compiler identification is unknown.."](https://discourse.cmake.org/t/windows-configure-error-when-using-the-command-line-the-c-cxx-compiler-identification-is-unknown/4053)

<div class="topic-metadata">

**Author:** [@StevenWang](https://discourse.cmake.org/u/StevenWang)\
**Replies:** 8\
**Last updated:** [September 10, 2021, 1:31am UTC](https://discourse.cmake.org/t/windows-configure-error-when-using-the-command-line-the-c-cxx-compiler-identification-is-unknown/4053 "2021-09-10T01:31:25Z")

</div>

I fail to use the command line to configure, reporting errors as “The C compiler identification is unknown and The CXX compiler identification is unknown”. But for the same project, it is successful when using the cma…

---

## [When user has VS2019/VS2022 installed it defaults to the VS2019 toolset](https://discourse.cmake.org/t/when-user-has-vs2019-vs2022-installed-it-defaults-to-the-vs2019-toolset/4142)

<div class="topic-metadata">

**Author:** [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)\
**Replies:** 5\
**Last updated:** [September 27, 2021, 8:43pm UTC](https://discourse.cmake.org/t/when-user-has-vs2019-vs2022-installed-it-defaults-to-the-vs2019-toolset/4142 "2021-09-27T20:43:23Z")

</div>

I was trying out VS 2022 and happened to come across this. I have both VS 2019/2022 installed but it defaults to using the VS 2019 toolset. # CMakeLists.txt cmake\_minimum\_required(VERSION 3.21) project(FOOBAR LANGUAGES…

---

## [How do I set up a CMAKE\_TOOLCHAIN\_FILE toolchain file](https://discourse.cmake.org/t/how-do-i-set-up-a-cmake-toolchain-file-toolchain-file/4150)

<div class="topic-metadata">

**Author:** [@boxerab](https://discourse.cmake.org/u/boxerab)\
**Replies:** 0\
**Last updated:** [September 27, 2021, 2:34pm UTC](https://discourse.cmake.org/t/how-do-i-set-up-a-cmake-toolchain-file-toolchain-file/4150 "2021-09-27T14:34:48Z")

</div>

I am cross-compiling on x86 for aarch64 target. I use ${CMAKE\_HOST\_SYSTEM\_PROCESSOR} currently to detect the host processor, and set variables accordingly, but I would like instead to use the target processor in my CM…

---

## [CMake error with armclang](https://discourse.cmake.org/t/cmake-error-with-armclang/4149)

<div class="topic-metadata">

**Author:** [@1113](https://discourse.cmake.org/u/1113)\
**Replies:** 1\
**Last updated:** [September 27, 2021, 7:50am UTC](https://discourse.cmake.org/t/cmake-error-with-armclang/4149 "2021-09-27T07:50:43Z")

</div>

Hi I would like to use ARMCLANG to build Mbedtls-3.0.0 library. A strange error comes: My command is cmake .. -DCMAKE\_C\_COMPILER=armclang -DCMAKE\_SYSTEM\_PROCESSOR=cortex-m33 -DCMAKE\_SYSTEM\_ARCH=armv8-m.main However…

---

## [target\_compilation\_options moves to parent project](https://discourse.cmake.org/t/target-compilation-options-moves-to-parent-project/4144)

<div class="topic-metadata">

**Author:** [@peter](https://discourse.cmake.org/u/peter)\
**Replies:** 3\
**Last updated:** [September 25, 2021, 9:00pm UTC](https://discourse.cmake.org/t/target-compilation-options-moves-to-parent-project/4144 "2021-09-25T21:00:06Z")

</div>

Hello, I have C++ project tree with CMakeLists.txt in the root and another CMakeLists.txt in subdirectories with C++ sources/headers. Subprojects are added with command add\_subdirectory(). One of subproject is Botan li…

---

## [How to detect symbolic links?](https://discourse.cmake.org/t/how-to-detect-symbolic-links/4139)

<div class="topic-metadata">

**Author:** [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)\
**Replies:** 3\
**Last updated:** [September 24, 2021, 2:19pm UTC](https://discourse.cmake.org/t/how-to-detect-symbolic-links/4139 "2021-09-24T14:19:58Z")

</div>

Does CMake provide the ability to detect if paths or portions of paths/files contain symbolic links?

---

## [CMake ITK issue, HDF5 CXX compiler wrapper, ANTs installation](https://discourse.cmake.org/t/cmake-itk-issue-hdf5-cxx-compiler-wrapper-ants-installation/4135)

<div class="topic-metadata">

**Author:** [@Surendra\_Maharjan](https://discourse.cmake.org/u/Surendra_Maharjan)\
**Replies:** 1\
**Last updated:** [September 23, 2021, 1:23pm UTC](https://discourse.cmake.org/t/cmake-itk-issue-hdf5-cxx-compiler-wrapper-ants-installation/4135 "2021-09-23T13:23:15Z")

</div>

Hello CMakers, My name is Suren. I am having an issue while compiling ANTs in Mac Big Sur using ccmake. It says "HDF5 CXX compiler wrapper is unable to compile a minimal HDF5 program. “HDF5 C compiler wrapper is unabl…

---

## [Compile objc and c](https://discourse.cmake.org/t/compile-objc-and-c/4094)

<div class="topic-metadata">

**Author:** [@Adonis](https://discourse.cmake.org/u/Adonis)\
**Replies:** 2\
**Last updated:** [September 23, 2021, 1:19pm UTC](https://discourse.cmake.org/t/compile-objc-and-c/4094 "2021-09-23T13:19:07Z")

</div>

Hi, I want to build a dylib. but when I build it , I get error as follow: In file included from /Users/apple/Documents/TEST/bluepulse-plugin/window-capture/library.c:3: In file included from /Users/apple/Documents/TEST/…

---

## [Could not find CMAKE\_ROOT](https://discourse.cmake.org/t/could-not-find-cmake-root/216)

<div class="topic-metadata">

**Author:** [@PeterX](https://discourse.cmake.org/u/PeterX)\
**Replies:** 29\
**Last updated:** [September 23, 2021, 11:32am UTC](https://discourse.cmake.org/t/could-not-find-cmake-root/216 "2021-09-23T11:32:40Z")

</div>

When I envoke cmake I get this error: CMake Error: Could not find CMAKE\_ROOT !!! CMake has most likely not been installed correctly. I use cmake version 3.10.2 on Xubuntu 18.04 64bit. What can I do? Greetings Peter

---

## [cmake code coverage (ExperimentalCoverage)](https://discourse.cmake.org/t/cmake-code-coverage-experimentalcoverage/4078)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 6\
**Last updated:** [September 22, 2021, 8:21am UTC](https://discourse.cmake.org/t/cmake-code-coverage-experimentalcoverage/4078 "2021-09-22T08:21:15Z")

</div>

Want to add code coverage and integrate that to the target ExperimentalCoverage. It fails to the find the source code, searching under ${CMAKE\_BINARY\_DIR}/Testing instead of under ${CMAKE\_SOURCE\_DIR}. Tried to set CTEST\_…

---

## [How/why does this work? Setup for cross-compiling and unit tests on host](https://discourse.cmake.org/t/how-why-does-this-work-setup-for-cross-compiling-and-unit-tests-on-host/4120)

<div class="topic-metadata">

**Author:** [@andresovela](https://discourse.cmake.org/u/andresovela)\
**Replies:** 5\
**Last updated:** [September 21, 2021, 7:43am UTC](https://discourse.cmake.org/t/how-why-does-this-work-setup-for-cross-compiling-and-unit-tests-on-host/4120 "2021-09-21T07:43:57Z")

</div>

Hi all, first timer here. I am a CMake newbie and I’ve been trying to set up a project in CMake in which I can cross-compile for ARM Cortex-M targets, and compile some unit tests to run on the host machine. In my resea…

---

## [cmake when generate Xcode project, clang-tidy command is missing](https://discourse.cmake.org/t/cmake-when-generate-xcode-project-clang-tidy-command-is-missing/4115)

<div class="topic-metadata">

**Author:** [@zohar81](https://discourse.cmake.org/u/zohar81)\
**Replies:** 3\
**Last updated:** [September 21, 2021, 5:37am UTC](https://discourse.cmake.org/t/cmake-when-generate-xcode-project-clang-tidy-command-is-missing/4115 "2021-09-21T05:37:52Z")

</div>

Hi, I’ve added clang-tidy capability to my command line that will be set upon activation. before running it, I’ve made sure that my setup has clang-tidy installed. here’s the CMake code option(ENABLE\_CLANG\_TIDY "defa…

---

## [rule about package variable naming](https://discourse.cmake.org/t/rule-about-package-variable-naming/4087)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 3\
**Last updated:** [September 20, 2021, 11:48am UTC](https://discourse.cmake.org/t/rule-about-package-variable-naming/4087 "2021-09-20T11:48:02Z")

</div>

Hi, is there a rule with respect to case for naming variables \_INCLUDE\_DIRS and \_LIBRARIES I have a non consistent behavior with Eigen3 where: package name is Eigen3 and variables set after find\_package are Eigen3\_V…

---

## [How to see "message(VERBOSE ...)" output?](https://discourse.cmake.org/t/how-to-see-message-verbose-output/2821)

<div class="topic-metadata">

**Author:** [@oliver](https://discourse.cmake.org/u/oliver)\
**Replies:** 3\
**Last updated:** [September 20, 2021, 6:49am UTC](https://discourse.cmake.org/t/how-to-see-message-verbose-output/2821 "2021-09-20T06:49:30Z")

</div>

According to https://cmake.org/cmake/help/latest/command/message.html I can use message(VERBOSE "some text") to log “Detailed informational messages intended for project users”. But somehow I can’t manage to get these me…

---

## [Can not install cmake in Rstudio](https://discourse.cmake.org/t/can-not-install-cmake-in-rstudio/4070)

<div class="topic-metadata">

**Author:** [@1115](https://discourse.cmake.org/u/1115)\
**Replies:** 3\
**Last updated:** [September 18, 2021, 3:10pm UTC](https://discourse.cmake.org/t/can-not-install-cmake-in-rstudio/4070 "2021-09-18T15:10:01Z")

</div>

installr::install.cmake() Warning message: In download\_fun(exe\_URL, destfile = exe\_filename, quiet = FALSE, : cannot open URL ‘https://github.com/Kitware/CMake/releases/download/v3.21.2/cmake-3.21.2-win-x86\_64.msi’…

---

## [With modern cmake, does transtive dependency needs \`find\_package\`?](https://discourse.cmake.org/t/with-modern-cmake-does-transtive-dependency-needs-find-package/4073)

<div class="topic-metadata">

**Author:** [@Ronald](https://discourse.cmake.org/u/Ronald)\
**Replies:** 10\
**Last updated:** [September 16, 2021, 9:36pm UTC](https://discourse.cmake.org/t/with-modern-cmake-does-transtive-dependency-needs-find-package/4073 "2021-09-16T21:36:46Z")

</div>

A find\_package(CURL REQUIRED) target\_link\_libraries(A PUBLIC CURL::libcurl) B target\_link\_libraries(B PRIVATE A) When configure for B CMake Error at CMakeLists.txt:53 (add\_executable): Target "B" links to target "…

---

## [where can i find documentation of old CMake versions?](https://discourse.cmake.org/t/where-can-i-find-documentation-of-old-cmake-versions/4099)

<div class="topic-metadata">

**Author:** [@hex](https://discourse.cmake.org/u/hex)\
**Replies:** 1\
**Last updated:** [September 16, 2021, 9:23am UTC](https://discourse.cmake.org/t/where-can-i-find-documentation-of-old-cmake-versions/4099 "2021-09-16T09:23:50Z")

</div>

where can i find documentation for CMake versions prior to 3?

---

## [export reproducible content from ccmake while in use](https://discourse.cmake.org/t/export-reproducible-content-from-ccmake-while-in-use/4096)

<div class="topic-metadata">

**Author:** [@kayarre](https://discourse.cmake.org/u/kayarre)\
**Replies:** 2\
**Last updated:** [September 16, 2021, 4:01am UTC](https://discourse.cmake.org/t/export-reproducible-content-from-ccmake-while-in-use/4096 "2021-09-16T04:01:09Z")

</div>

How to export manually modified configurations in am more compact format than CMakeCache.txt? or is there an easy way to go from ccmake configuration to a command line version that generates the same configuration? I t…

---

## [CMake : vtk\_module\_autoinit](https://discourse.cmake.org/t/cmake-vtk-module-autoinit/3715)

<div class="topic-metadata">

**Author:** [@tdchen](https://discourse.cmake.org/u/tdchen)\
**Replies:** 4\
**Last updated:** [September 16, 2021, 12:02am UTC](https://discourse.cmake.org/t/cmake-vtk-module-autoinit/3715 "2021-09-16T00:02:33Z")

</div>

I encountered this problem: CMake Error at CMakeLists.txt:47 (vtk\_module\_autoinit): Unknown CMake command “vtk\_module\_autoinit”. How to deal with it? I use CMake 3.20.5 and vtk9.03, and I want to use qt GUI. thanks.

---

## [Exclude paths for compile\_commands.json](https://discourse.cmake.org/t/exclude-paths-for-compile-commands-json/4082)

<div class="topic-metadata">

**Author:** [@Krishna](https://discourse.cmake.org/u/Krishna)\
**Replies:** 2\
**Last updated:** [September 14, 2021, 2:56pm UTC](https://discourse.cmake.org/t/exclude-paths-for-compile-commands-json/4082 "2021-09-14T14:56:48Z")

</div>

Hi, We are generating compile\_commands.json using CMAKE\_EXPORT\_COMPILE\_COMMANDS in CMake for passing to cppcheck tool. Now we would like to exclude some paths which we don’t want to see in the database file. How to set…

---

## [How to generate a one-cabfile-per-component package when using CPack+WIX](https://discourse.cmake.org/t/how-to-generate-a-one-cabfile-per-component-package-when-using-cpack-wix/4085)

<div class="topic-metadata">

**Author:** [@joy365](https://discourse.cmake.org/u/joy365)\
**Replies:** 0\
**Last updated:** [September 14, 2021, 7:18am UTC](https://discourse.cmake.org/t/how-to-generate-a-one-cabfile-per-component-package-when-using-cpack-wix/4085 "2021-09-14T07:18:55Z")

</div>

Now I am trying packaging my project by using CPack+WIX, and I need to split my files into multiple cab files. I know that after adding these elements: \<Media Id="2" Cabinet="media2.cab" EmbedCab="no"/\> \<Media Id="…

---

## [Symlinks on macOS can result in "error: still dirty after 100 tries" when using Ninja](https://discourse.cmake.org/t/symlinks-on-macos-can-result-in-error-still-dirty-after-100-tries-when-using-ninja/3647)

<div class="topic-metadata">

**Author:** [@mantognini](https://discourse.cmake.org/u/mantognini)\
**Replies:** 6\
**Last updated:** [September 13, 2021, 7:05am UTC](https://discourse.cmake.org/t/symlinks-on-macos-can-result-in-error-still-dirty-after-100-tries-when-using-ninja/3647 "2021-09-13T07:05:58Z")

</div>

Hello, I’ve noticed the following behaviour: when using symbolic links on macOS (11.4 in my case), with CMake 3.20.5 and Ninja 1.10.2 (from homebrew), building can result in “ninja: error: manifest ‘build.ninja’ still d…

---

## [Regexing for 2 periods? \`..\`](https://discourse.cmake.org/t/regexing-for-2-periods/4066)

<div class="topic-metadata">

**Author:** [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)\
**Replies:** 3\
**Last updated:** [September 12, 2021, 10:17am UTC](https://discourse.cmake.org/t/regexing-for-2-periods/4066 "2021-09-12T10:17:32Z")

</div>

I’m trying to detecting when a path contains .. For example: D:/foobar/../ However I can’t seem to write the correct regex. # regex.cmake cmake\_minimum\_required(VERSION 3.21) if ("D:/foobar" MATCHES "\\.\\.") messa…

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

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