# Usage

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

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

**Page:** 50

---

## [cmake --build show exact command executed](https://discourse.cmake.org/t/cmake-build-show-exact-command-executed/7408)

<div class="topic-metadata">

**Author:** [@ignus2](https://discourse.cmake.org/u/ignus2)\
**Replies:** 2\
**Last updated:** [February 8, 2023, 7:33pm UTC](https://discourse.cmake.org/t/cmake-build-show-exact-command-executed/7408 "2023-02-08T19:33:06Z")

</div>

I use VS generator. How can I see the exact command line cmake --build issues when it invokes msbuild.exe to build the project? Even if I use the -v (verbose) flag, it only displays msbuild output, but not how msbuild wa…

---

## [Using dh-cmake with CPack for Debian packaging](https://discourse.cmake.org/t/using-dh-cmake-with-cpack-for-debian-packaging/3725)

<div class="topic-metadata">

**Author:** [@cerna](https://discourse.cmake.org/u/cerna)\
**Replies:** 8\
**Last updated:** [February 8, 2023, 6:22pm UTC](https://discourse.cmake.org/t/using-dh-cmake-with-cpack-for-debian-packaging/3725 "2023-02-08T18:22:31Z")

</div>

Hello, the last few days I have been trying to set up Debian packaging for a bigger project which should have multiple binary packages. I have been using Ubuntu 21.04 Hirsute as my test platform and the latest release 0…

---

## [HPE-Cray environment and OpenMP linking issue](https://discourse.cmake.org/t/hpe-cray-environment-and-openmp-linking-issue/7420)

<div class="topic-metadata">

**Author:** [@etiennemlb](https://discourse.cmake.org/u/etiennemlb)\
**Replies:** 1\
**Last updated:** [February 8, 2023, 5:14pm UTC](https://discourse.cmake.org/t/hpe-cray-environment-and-openmp-linking-issue/7420 "2023-02-08T17:14:43Z")

</div>

I use CMake 3.20.2, CPE/22/11 (cce/15.0.2) and ROCm 5.2.3. Assuming the following CMake script: cmake\_minimum\_required(VERSION 3.20) project("test" CXX) find\_package(OpenMP REQUIRED) add\_executable(test\_executable test…

---

## [Cmake cannot identifies my llvm toolchain on windows](https://discourse.cmake.org/t/cmake-cannot-identifies-my-llvm-toolchain-on-windows/7418)

<div class="topic-metadata">

**Author:** [@Dr-Itachi](https://discourse.cmake.org/u/Dr-Itachi)\
**Replies:** 1\
**Last updated:** [February 8, 2023, 5:12pm UTC](https://discourse.cmake.org/t/cmake-cannot-identifies-my-llvm-toolchain-on-windows/7418 "2023-02-08T17:12:12Z")

</div>

Hello. I have a problem. Cmake can’t identify my LLVM/Clang installation on Windows. I am configuring a project for cross-compilation using clang but Cmake cannot configure my project. Here is the output from cmake: \[m…

---

## [Dropped support for MSYS Makefiles generator?](https://discourse.cmake.org/t/dropped-support-for-msys-makefiles-generator/7405)

<div class="topic-metadata">

**Author:** [@jeffythedragonslayer](https://discourse.cmake.org/u/jeffythedragonslayer)\
**Replies:** 4\
**Last updated:** [February 8, 2023, 4:44pm UTC](https://discourse.cmake.org/t/dropped-support-for-msys-makefiles-generator/7405 "2023-02-08T16:44:49Z")

</div>

When did CMake drop support for the MSYS Makefiles generator? When I try to build WLA-DX in PVSnesLib, by issuing this command in MINGW32: # make wla I get this error: cd wla-dx ; \\ cmake -G "MSYS Makefiles" . ; \\ ma…

---

## [Got warning "Cannot generate a safe runtime search"](https://discourse.cmake.org/t/got-warning-cannot-generate-a-safe-runtime-search/7398)

<div class="topic-metadata">

**Author:** [@zhiqiu](https://discourse.cmake.org/u/zhiqiu)\
**Replies:** 1\
**Last updated:** [February 8, 2023, 4:39pm UTC](https://discourse.cmake.org/t/got-warning-cannot-generate-a-safe-runtime-search/7398 "2023-02-08T16:39:54Z")

</div>

I write two lines of find\_library in my project, find\_library(CUDASTUB libcuda.so HINTS ${CUDA\_TOOLKIT\_ROOT\_DIR}/lib64/stubs/ REQUIRED) find\_library(CUDASO libcuda.so.1 HINTS ${CUDASO\_LIB} REQUIRED) the first one f…

---

## [Windows: Generate/config fail to capture all required properties for Ninja](https://discourse.cmake.org/t/windows-generate-config-fail-to-capture-all-required-properties-for-ninja/7381)

<div class="topic-metadata">

**Author:** [@kfsone](https://discourse.cmake.org/u/kfsone)\
**Replies:** 1\
**Last updated:** [February 8, 2023, 4:33pm UTC](https://discourse.cmake.org/t/windows-generate-config-fail-to-capture-all-required-properties-for-ninja/7381 "2023-02-08T16:33:12Z")

</div>

This may be by design, but I had expected that if I configured a project on Windows from within the developer environment, I wouldn’t need to be in the developer environment later to build it. Simple use case: cmake\_mi…

---

## [multitarget build and include\_guard(GLOBAL) question...](https://discourse.cmake.org/t/multitarget-build-and-include-guard-global-question/7427)

<div class="topic-metadata">

**Author:** [@pavel\_krupets](https://discourse.cmake.org/u/pavel_krupets)\
**Replies:** 0\
**Last updated:** [February 7, 2023, 11:55pm UTC](https://discourse.cmake.org/t/multitarget-build-and-include-guard-global-question/7427 "2023-02-07T23:55:18Z")

</div>

I am probably using it wrong (or not as intended). I have libraries lib-A and lib-B which can be built for different ARM devices (M4, M7, etc.) CMakeLists.txt inside of lib-A and lib-B handles conditional building. Let’…

---

## [How to enable version requirement checks in combination with FetchContent's OVERRIDE\_FIND\_PACKAGE](https://discourse.cmake.org/t/how-to-enable-version-requirement-checks-in-combination-with-fetchcontents-override-find-package/7384)

<div class="topic-metadata">

**Author:** [@ton](https://discourse.cmake.org/u/ton)\
**Replies:** 1\
**Last updated:** [February 7, 2023, 3:21am UTC](https://discourse.cmake.org/t/how-to-enable-version-requirement-checks-in-combination-with-fetchcontents-override-find-package/7384 "2023-02-07T03:21:27Z")

</div>

We use FetchContent\_MakeAvailable to include our own sub-libraries from different repos in the build. The user specifies these sub-libraries through a configure script which drives CMake. The CMake files of these sub-lib…

---

## [googletest discovery and environment](https://discourse.cmake.org/t/googletest-discovery-and-environment/7363)

<div class="topic-metadata">

**Author:** [@hsattler](https://discourse.cmake.org/u/hsattler)\
**Replies:** 2\
**Last updated:** [February 6, 2023, 1:13am UTC](https://discourse.cmake.org/t/googletest-discovery-and-environment/7363 "2023-02-06T01:13:19Z")

</div>

Hi, I am trying to use googletest tests on Windows that need external Qt DLLs. So I tried: gtest\_discover\_tests ( ${targetName}UnitTests TEST\_PREFIX ${targetName}. PROPERTIES ENVIRONMENT\_MODIFICATION "PA…

---

## [Does a static library target not expose include directories?](https://discourse.cmake.org/t/does-a-static-library-target-not-expose-include-directories/7371)

<div class="topic-metadata">

**Author:** [@JuliusCaesar](https://discourse.cmake.org/u/JuliusCaesar)\
**Replies:** 1\
**Last updated:** [February 5, 2023, 9:57pm UTC](https://discourse.cmake.org/t/does-a-static-library-target-not-expose-include-directories/7371 "2023-02-05T21:57:49Z")

</div>

Hey guys, I need to create static library, which itself links to other pre compiled static libraries My CMakeLists.txt to build this static lib looks like this set(MODULE\_LINK\_LIBS “”) set(RESSOURCE\_FILES “”) if(MS…

---

## [What is the preferred method of allowing both bundled and system dependencies on older cmake versions?](https://discourse.cmake.org/t/what-is-the-preferred-method-of-allowing-both-bundled-and-system-dependencies-on-older-cmake-versions/7391)

<div class="topic-metadata">

**Author:** [@dundargoc](https://discourse.cmake.org/u/dundargoc)\
**Replies:** 2\
**Last updated:** [February 4, 2023, 7:38pm UTC](https://discourse.cmake.org/t/what-is-the-preferred-method-of-allowing-both-bundled-and-system-dependencies-on-older-cmake-versions/7391 "2023-02-04T19:38:10Z")

</div>

What is the best/idiomatic way to allow users to either choose to use a dependency they already have, or to let cmake download it themselves? I’m thinking of doing something like the following, where I use externalprojec…

---

## [best practice directory structure with libraries](https://discourse.cmake.org/t/best-practice-directory-structure-with-libraries/7345)

<div class="topic-metadata">

**Author:** [@parrst](https://discourse.cmake.org/u/parrst)\
**Replies:** 4\
**Last updated:** [February 3, 2023, 1:07pm UTC](https://discourse.cmake.org/t/best-practice-directory-structure-with-libraries/7345 "2023-02-03T13:07:45Z")

</div>

I have done VERY little in the way of compiled programing and having to learn the likes of cmake is part of why. For now the context of my questions are all Raspberry Pico projects. I may delve into Pi or windows later…

---

## [\`add\_custom\_command\` and Generated Header Dependencies](https://discourse.cmake.org/t/add-custom-command-and-generated-header-dependencies/7393)

<div class="topic-metadata">

**Author:** [@marstaik](https://discourse.cmake.org/u/marstaik)\
**Replies:** 1\
**Last updated:** [February 2, 2023, 11:25pm UTC](https://discourse.cmake.org/t/add-custom-command-and-generated-header-dependencies/7393 "2023-02-02T23:25:00Z")

</div>

Context: I have been struggling with this for a while, and it was working when I happened to be generating “.cpp” files, but now with c++17 and the ability to move everything generated to static inline, I no longer requ…

---

## [Module support for G++ and Clang](https://discourse.cmake.org/t/module-support-for-g-and-clang/7367)

<div class="topic-metadata">

**Author:** [@Johan511](https://discourse.cmake.org/u/Johan511)\
**Replies:** 5\
**Last updated:** [February 2, 2023, 2:15pm UTC](https://discourse.cmake.org/t/module-support-for-g-and-clang/7367 "2023-02-02T14:15:22Z")

</div>

I am trying to work on improving the HPX build system to support modules. I have tried following the guide in the CMake repo. I have received the following errors. g++: error: unrecognized command-line option ‘-fdep-fi…

---

## [Best Practice for Ninja build Visual Studio?](https://discourse.cmake.org/t/best-practice-for-ninja-build-visual-studio/4653)

<div class="topic-metadata">

**Author:** [@kfsone](https://discourse.cmake.org/u/kfsone)\
**Replies:** 13\
**Last updated:** [February 1, 2023, 11:11pm UTC](https://discourse.cmake.org/t/best-practice-for-ninja-build-visual-studio/4653 "2023-02-01T23:11:15Z")

</div>

Note: CMAKE\_MINIMUM\_REQUIRED(VERSION 3.21) What is the recommended way to configure/invoke CMake such that it will use Ninja as the build tool but still locate the compiler/etc the way it would if you had specified the …

---

## [GENERATOR\_IS\_MULTI\_CONFIG doesn't get set in VS Code with ninja multi-config generator](https://discourse.cmake.org/t/generator-is-multi-config-doesnt-get-set-in-vs-code-with-ninja-multi-config-generator/7372)

<div class="topic-metadata">

**Author:** [@sampsont](https://discourse.cmake.org/u/sampsont)\
**Replies:** 2\
**Last updated:** [February 1, 2023, 7:23pm UTC](https://discourse.cmake.org/t/generator-is-multi-config-doesnt-get-set-in-vs-code-with-ninja-multi-config-generator/7372 "2023-02-01T19:23:28Z")

</div>

(VS Code running on Ubuntu 20.04) With this code in CMakeLists.txt: message(“The Generator is ${CMAKE\_GENERATOR}”) if(GENERATOR\_IS\_MULTI\_CONFIG) message(“The Generator is multi-config”) else() message(“The Generat…

---

## [Best practices when providing CMake functions in a library](https://discourse.cmake.org/t/best-practices-when-providing-cmake-functions-in-a-library/2092)

<div class="topic-metadata">

**Author:** [@eiband](https://discourse.cmake.org/u/eiband)\
**Replies:** 4\
**Last updated:** [February 1, 2023, 6:10pm UTC](https://discourse.cmake.org/t/best-practices-when-providing-cmake-functions-in-a-library/2092 "2023-02-01T18:10:26Z")

</div>

My library has CMake functions which add build steps of a code generator to a target. I would like users of my library to be able to use these functions. However I’m unsure how I should provide them. The most simple solu…

---

## [CMake sometimes not rerun automatically from Visual Studio?](https://discourse.cmake.org/t/cmake-sometimes-not-rerun-automatically-from-visual-studio/7366)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 2\
**Last updated:** [January 31, 2023, 10:22pm UTC](https://discourse.cmake.org/t/cmake-sometimes-not-rerun-automatically-from-visual-studio/7366 "2023-01-31T22:22:23Z")

</div>

Hi, I’m still new to MSVC… Sometimes I edit one of the CMakeLists.txt, and when building then in Visual Studio (not VSCode), it does not rerun cmake so the project files are not regenerated. Also building “ZERO\_CHECK” …

---

## [Solution for CMP0024](https://discourse.cmake.org/t/solution-for-cmp0024/7370)

<div class="topic-metadata">

**Author:** [@scalpel4k](https://discourse.cmake.org/u/scalpel4k)\
**Replies:** 0\
**Last updated:** [January 31, 2023, 3:58pm UTC](https://discourse.cmake.org/t/solution-for-cmp0024/7370 "2023-01-31T15:58:45Z")

</div>

Hi experts, I am getting the CMP0024 error and I don’t quite understand what the alternative really is. My use case is that I’m developing multiple features in parallel that will eventually become separate projects. I…

---

## [Why is cflags appended to link flags?](https://discourse.cmake.org/t/why-is-cflags-appended-to-link-flags/7356)

<div class="topic-metadata">

**Author:** [@wdyichen](https://discourse.cmake.org/u/wdyichen)\
**Replies:** 3\
**Last updated:** [January 30, 2023, 3:27am UTC](https://discourse.cmake.org/t/why-is-cflags-appended-to-link-flags/7356 "2023-01-30T03:27:30Z")

</div>

I set set(CMAKE\_SYSTEM\_NAME Generic), then set CMAKE\_C\_FLAGS and CMAKE\_EXE\_LINKER\_FLAGS, I found that in addition to using the CMAKE\_EXE\_LINKER\_FLAGS I set, the parameter CMAKE\_C\_FLAGS was also appended automatically wh…

---

## [TLS version mismatch](https://discourse.cmake.org/t/tls-version-mismatch/7350)

<div class="topic-metadata">

**Author:** [@Sven](https://discourse.cmake.org/u/Sven)\
**Replies:** 2\
**Last updated:** [January 29, 2023, 8:03pm UTC](https://discourse.cmake.org/t/tls-version-mismatch/7350 "2023-01-29T20:03:31Z")

</div>

I try to Download googletest cia my cmake project, but i have trouble connecting to github: include(FetchContent) FetchContent\_Declare( googletest GIT\_REPOSITORY https://github.com/google/googletest.git GIT\_TAG …

---

## [Tell CMake where to find the compiler by setting either the environment variable "CC" or the CMake cache entry CMAKE\_ASM\_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH.](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342)

<div class="topic-metadata">

**Author:** [@lalarukh](https://discourse.cmake.org/u/lalarukh)\
**Replies:** 10\
**Last updated:** [January 29, 2023, 6:13pm UTC](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342 "2023-01-29T18:13:32Z")

</div>

Hello! I have recently installed the ClickHouse from here: (How to Build ClickHouse on Mac OS X - ClickHouse Documentation). Successfully I have download the Clickhouse but when I run this command from documentation: …

---

## [target\_link\_libraries is adding -l when I don't want it to](https://discourse.cmake.org/t/target-link-libraries-is-adding-l-when-i-dont-want-it-to/7335)

<div class="topic-metadata">

**Author:** [@Barry\_Revzin](https://discourse.cmake.org/u/Barry_Revzin)\
**Replies:** 3\
**Last updated:** [January 29, 2023, 1:23pm UTC](https://discourse.cmake.org/t/target-link-libraries-is-adding-l-when-i-dont-want-it-to/7335 "2023-01-29T13:23:19Z")

</div>

Sorry I don’t have a short repro for this, but hopefully I can provide enough information to explain the issue. I have code like this, using cmake 3.21: cmake\_policy(SET CMP0060 NEW) add\_custom\_command( OUTPUT …

---

## [MS Visual Studio: menu entry "Compile file (Ctrl+F7)" missing in cmake-generated project](https://discourse.cmake.org/t/ms-visual-studio-menu-entry-compile-file-ctrl-f7-missing-in-cmake-generated-project/7329)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 3\
**Last updated:** [January 28, 2023, 9:37pm UTC](https://discourse.cmake.org/t/ms-visual-studio-menu-entry-compile-file-ctrl-f7-missing-in-cmake-generated-project/7329 "2023-01-28T21:37:24Z")

</div>

Hi, recently I started using Visual Studio (not Visual Studio Code) with an CMake-generated project (3.24). I noticed that in the “Build” menu the “Compile file (Ctrl+F7)” entry is missing, which is quite useful. Does …

---

## [Is FindPackageHandleStandardArgs included by default in find modules?](https://discourse.cmake.org/t/is-findpackagehandlestandardargs-included-by-default-in-find-modules/7336)

<div class="topic-metadata">

**Author:** [@dundargoc](https://discourse.cmake.org/u/dundargoc)\
**Replies:** 3\
**Last updated:** [January 27, 2023, 1:43pm UTC](https://discourse.cmake.org/t/is-findpackagehandlestandardargs-included-by-default-in-find-modules/7336 "2023-01-27T13:43:35Z")

</div>

I’m using the following find module in my project: find\_path(LIBVTERM\_INCLUDE\_DIR vterm.h) find\_library(LIBVTERM\_LIBRARY vterm) find\_package\_handle\_standard\_args(libvterm REQUIRED\_VARS LIBVTERM\_INCLUDE\_DIR LIBVTERM\_L…

---

## [Add custom command INTERFACE?](https://discourse.cmake.org/t/add-custom-command-interface/7236)

<div class="topic-metadata">

**Author:** [@kfsone](https://discourse.cmake.org/u/kfsone)\
**Replies:** 5\
**Last updated:** [January 26, 2023, 10:25pm UTC](https://discourse.cmake.org/t/add-custom-command-interface/7236 "2023-01-26T22:25:28Z")

</div>

Trying to refactor and streamline a mid-size (~800 cmake files, 30k lines of cmake code, 26k C++ files) 15 year old, multi-platform project with a lot of old cmake. Recurring issue has been people don’t \[know to\] call t…

---

## [Combining two third party libraries into a single imported target](https://discourse.cmake.org/t/combining-two-third-party-libraries-into-a-single-imported-target/5695)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 10\
**Last updated:** [January 26, 2023, 3:49pm UTC](https://discourse.cmake.org/t/combining-two-third-party-libraries-into-a-single-imported-target/5695 "2023-01-26T15:49:12Z")

</div>

Hi My need as described in the topic subject is occurring with the GMP library (Gnu Multiple Precision). On my system it does not seem to be detectable by find\_package so I tried to make it detectable through a Findgmp…

---

## [Does adding \`.natvis\` files via target\_sources work on Ninja?](https://discourse.cmake.org/t/does-adding-natvis-files-via-target-sources-work-on-ninja/7316)

<div class="topic-metadata">

**Author:** [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)\
**Replies:** 1\
**Last updated:** [January 26, 2023, 2:17pm UTC](https://discourse.cmake.org/t/does-adding-natvis-files-via-target-sources-work-on-ninja/7316 "2023-01-26T14:17:24Z")

</div>

According to the docs as of CMake 3.7 Visual Studio Generators for VS 2010 and above learned to place .natvis source files into VS project files properly. Which means the following will work correctly with Visual Stu…

---

## [Can't use cmake with sudo on ubuntu](https://discourse.cmake.org/t/cant-use-cmake-with-sudo-on-ubuntu/7320)

<div class="topic-metadata">

**Author:** [@Elliot2636](https://discourse.cmake.org/u/Elliot2636)\
**Replies:** 1\
**Last updated:** [January 26, 2023, 8:45am UTC](https://discourse.cmake.org/t/cant-use-cmake-with-sudo-on-ubuntu/7320 "2023-01-26T08:45:31Z")

</div>

I download cmake source code then I run sudo env CC="/usr/local/bin/clang -fuse-ld=gold -flto" CXX="/usr/local/bin/clang++ -fuse-ld=gold -flto" ./bootstrap --prefix=/usr/local/cmake -- -DCMAKE\_BUILD\_TYPE:STRING=Release &&…

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

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