# Usage

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

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

**Page:** 28

---

## [Find the linking flags of a target](https://discourse.cmake.org/t/find-the-linking-flags-of-a-target/10553)

<div class="topic-metadata">

**Author:** [@k355l3r-5yndr0m3](https://discourse.cmake.org/u/k355l3r-5yndr0m3)\
**Replies:** 1\
**Last updated:** [April 11, 2024, 4:23pm UTC](https://discourse.cmake.org/t/find-the-linking-flags-of-a-target/10553 "2024-04-11T16:23:52Z")

</div>

Is there a way to extract the linking flags required to link to a cmake target? I’m working with a different build system and need to link to a library which use cmake.

---

## [Installing dependencies imported with FetchContent()](https://discourse.cmake.org/t/installing-dependencies-imported-with-fetchcontent/10550)

<div class="topic-metadata">

**Author:** [@Hilton\_Marques\_Santa](https://discourse.cmake.org/u/Hilton_Marques_Santa)\
**Replies:** 7\
**Last updated:** [April 11, 2024, 4:23pm UTC](https://discourse.cmake.org/t/installing-dependencies-imported-with-fetchcontent/10550 "2024-04-11T16:23:06Z")

</div>

Say that I that I have two private projects: A and B. The project B is imported to project A by the FetchContent command, say: #project\_B.cmake in project A FetchContent\_Declare(project\_B GIT\_REPOSITORY "git@proje…

---

## [Find package finds correcly CUDAToolkit but the path is not added](https://discourse.cmake.org/t/find-package-finds-correcly-cudatoolkit-but-the-path-is-not-added/10540)

<div class="topic-metadata">

**Author:** [@Danesh\_Daroui](https://discourse.cmake.org/u/Danesh_Daroui)\
**Replies:** 1\
**Last updated:** [April 11, 2024, 4:13pm UTC](https://discourse.cmake.org/t/find-package-finds-correcly-cudatoolkit-but-the-path-is-not-added/10540 "2024-04-11T16:13:22Z")

</div>

Hi all, I want to make sure that on the target system CUDAToolkit is installed. So I am using: find\_package(CUDAToolkit REQUIRED) This finds correctly CUDAToolkit and returns the include path of the library. Now I nee…

---

## [Getting an error building qt6.3.3 open source](https://discourse.cmake.org/t/getting-an-error-building-qt6-3-3-open-source/10535)

<div class="topic-metadata">

**Author:** [@RickF](https://discourse.cmake.org/u/RickF)\
**Replies:** 1\
**Last updated:** [April 11, 2024, 4:11pm UTC](https://discourse.cmake.org/t/getting-an-error-building-qt6-3-3-open-source/10535 "2024-04-11T16:11:10Z")

</div>

The EXCLUDE\_FROM\_ALL property of target “qtdiag” varies by configuration. This is not supported by the “Visual Studio 17 2022” generator. Is there a way to work around this?

---

## [How to \`target\_include\_directories\`, but for a single header file?](https://discourse.cmake.org/t/how-to-target-include-directories-but-for-a-single-header-file/10514)

<div class="topic-metadata">

**Author:** [@adamscott](https://discourse.cmake.org/u/adamscott)\
**Replies:** 2\
**Last updated:** [April 11, 2024, 3:30pm UTC](https://discourse.cmake.org/t/how-to-target-include-directories-but-for-a-single-header-file/10514 "2024-04-11T15:30:16Z")

</div>

Imagine that I have this tree: . ├── CMakeLists.txt └── subdir ├── CMakeLists.txt ├── dont\_include\_this.h └── include\_this.h How do I setup my CMake project to be able to #include "include\_this.h" but to no…

---

## [cmake 3.29.1 find\_package() problem with ExternalProject\_Add?](https://discourse.cmake.org/t/cmake-3-29-1-find-package-problem-with-externalproject-add/10623)

<div class="topic-metadata">

**Author:** [@Gonzalo\_Garramuno](https://discourse.cmake.org/u/Gonzalo_Garramuno)\
**Replies:** 11\
**Last updated:** [April 11, 2024, 1:01pm UTC](https://discourse.cmake.org/t/cmake-3-29-1-find-package-problem-with-externalproject-add/10623 "2024-04-11T13:01:24Z")

</div>

I run my open C++ source code on github actions. I compile a color library called OpenColorIO. Since github.com updated their macOS 12 and now macOS 14 machines to cmake 3.29.1, I am getting the following errors with e…

---

## [Tutorial Step 8 Visual Studio build steps in wrong order?](https://discourse.cmake.org/t/tutorial-step-8-visual-studio-build-steps-in-wrong-order/10443)

<div class="topic-metadata">

**Author:** [@gaz0](https://discourse.cmake.org/u/gaz0)\
**Replies:** 4\
**Last updated:** [April 11, 2024, 12:20pm UTC](https://discourse.cmake.org/t/tutorial-step-8-visual-studio-build-steps-in-wrong-order/10443 "2024-04-11T12:20:18Z")

</div>

I built and ran Step 8 of the tutorial OK. But if I rebuild SqrtLibrary in Visual Studio I get Rebuild started at 9:08 AM... 1\>------ Rebuild All started: Project: ZERO\_CHECK, Configuration: Debug x64 ------ 1\>1\>Checkin…

---

## [As of vwersion 3.19.8 I get -MD and -MT flags in my gcc makefile](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326)

<div class="topic-metadata">

**Author:** [@BertEzendam](https://discourse.cmake.org/u/BertEzendam)\
**Replies:** 10\
**Last updated:** [April 11, 2024, 10:02am UTC](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326 "2024-04-11T10:02:44Z")

</div>

As of from version 3.19.8 I get makefiles which introduce the -MD and -MT flags in my makefile. It then wants to find a file .d which might exsist, but is not supposed to be used by our (very old) gcc compiler. The comp…

---

## [Include\_directories() add a path that include "-", compile\_commands.json don't include this path, why?](https://discourse.cmake.org/t/include-directories-add-a-path-that-include-compile-commands-json-dont-include-this-path-why/10614)

<div class="topic-metadata">

**Author:** [@Leeto1970](https://discourse.cmake.org/u/Leeto1970)\
**Replies:** 3\
**Last updated:** [April 11, 2024, 6:17am UTC](https://discourse.cmake.org/t/include-directories-add-a-path-that-include-compile-commands-json-dont-include-this-path-why/10614 "2024-04-11T06:17:45Z")

</div>

as title says, when I add a absolute path in my CmakeLists.txt, generated compile\_commands.json don’t include the path. set(INCLUDE\_PATH "D:/gnuarmemb/arm-none-eabi/include") include\_directories(${INCLUDE\_PATH}) This p…

---

## [Intel oneAPI MKL install and how CMake finds a version of MKL](https://discourse.cmake.org/t/intel-oneapi-mkl-install-and-how-cmake-finds-a-version-of-mkl/10039)

<div class="topic-metadata">

**Author:** [@loopless](https://discourse.cmake.org/u/loopless)\
**Replies:** 3\
**Last updated:** [April 11, 2024, 4:06am UTC](https://discourse.cmake.org/t/intel-oneapi-mkl-install-and-how-cmake-finds-a-version-of-mkl/10039 "2024-04-11T04:06:10Z")

</div>

After installing Intel One API MKL, CMake files are installed in C:\\Program Files (x86)\\Intel\\oneAPI\\mkl\\latest\\lib\\cmake\\mkl\\ Also as part of the installation process some change is made so CMake will always look in t…

---

## [Exporting a CTest Project](https://discourse.cmake.org/t/exporting-a-ctest-project/10468)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 3\
**Last updated:** [April 11, 2024, 12:59am UTC](https://discourse.cmake.org/t/exporting-a-ctest-project/10468 "2024-04-11T00:59:54Z")

</div>

Hi, I have the following use case: Multiarch product (x64, arm64) Testcases that need to run on real arch cpus (QEMU fails) arm cpus are sparse Therefore we build both on x64 with cross compiler. We execute the x64 u…

---

## [CMake Flatpak-builder cannot generate executable](https://discourse.cmake.org/t/cmake-flatpak-builder-cannot-generate-executable/10445)

<div class="topic-metadata">

**Author:** [@Jan](https://discourse.cmake.org/u/Jan)\
**Replies:** 1\
**Last updated:** [April 10, 2024, 11:55pm UTC](https://discourse.cmake.org/t/cmake-flatpak-builder-cannot-generate-executable/10445 "2024-04-10T23:55:51Z")

</div>

I’ve tried to use flatpak-builder with cmake as buildsystem and try to generate a flatpak but it have no output. Do anyone has idea? Console output: \[ 83%\] Building CXX object CMakeFiles/blink.dir/Model/CFileItem.cpp.o…

---

## [Running CTests from Child Projects in Parent Project](https://discourse.cmake.org/t/running-ctests-from-child-projects-in-parent-project/10434)

<div class="topic-metadata">

**Author:** [@ChadK](https://discourse.cmake.org/u/ChadK)\
**Replies:** 1\
**Last updated:** [April 10, 2024, 11:49pm UTC](https://discourse.cmake.org/t/running-ctests-from-child-projects-in-parent-project/10434 "2024-04-10T23:49:23Z")

</div>

I have an embedded (ARM Cortex-M) project where I am creating separate projects to compile some of the code for unit testing on a PC (Windows or Linux). I have the child projects (and CTests) working just fine on their …

---

## [File timestamps from RPM created by CPack seems to be wrong](https://discourse.cmake.org/t/file-timestamps-from-rpm-created-by-cpack-seems-to-be-wrong/10404)

<div class="topic-metadata">

**Author:** [@lfcarreon1](https://discourse.cmake.org/u/lfcarreon1)\
**Replies:** 6\
**Last updated:** [April 10, 2024, 11:38pm UTC](https://discourse.cmake.org/t/file-timestamps-from-rpm-created-by-cpack-seems-to-be-wrong/10404 "2024-04-10T23:38:04Z")

</div>

I created an RPM package using CPack. The RPM package contains a C++ header file and HTML documentation generated by doxygen via cmake. The issue I am noticing is when I install the RPM package, the timestamp of create…

---

## [Getting unwanted errors while running the project.](https://discourse.cmake.org/t/getting-unwanted-errors-while-running-the-project/10238)

<div class="topic-metadata">

**Author:** [@Perminder\_123](https://discourse.cmake.org/u/Perminder_123)\
**Replies:** 8\
**Last updated:** [April 10, 2024, 10:13pm UTC](https://discourse.cmake.org/t/getting-unwanted-errors-while-running-the-project/10238 "2024-04-10T22:13:11Z")

</div>

I am getting errors something like $ cmake ../openchemistry CMake Error at CMakeLists.txt:2 (project): Running 'nmake' '-?' failed with: no such file or directory CMake Error: CMAKE\_CXX\_COMPILER not set, …

---

## [Unexpected behavior of TARGET\_RUNTIME\_DLLS when mixing STATIC, SHARED, PUBLIC, PRIVATE libraries](https://discourse.cmake.org/t/unexpected-behavior-of-target-runtime-dlls-when-mixing-static-shared-public-private-libraries/10352)

<div class="topic-metadata">

**Author:** [@rkoning](https://discourse.cmake.org/u/rkoning)\
**Replies:** 2\
**Last updated:** [April 10, 2024, 10:05pm UTC](https://discourse.cmake.org/t/unexpected-behavior-of-target-runtime-dlls-when-mixing-static-shared-public-private-libraries/10352 "2024-04-10T22:05:42Z")

</div>

I’m running into some unexpected behavior when using the TARGET\_RUNTIME\_DLLS generator expression, and I’m wondering if this is something that I’m just not understand properly or if its an unhandled edge case that I shou…

---

## [MEMORYCHECK\_SANITIZER\_OPTIONS, possible options](https://discourse.cmake.org/t/memorycheck-sanitizer-options-possible-options/10354)

<div class="topic-metadata">

**Author:** [@Vincent\_Hamp](https://discourse.cmake.org/u/Vincent_Hamp)\
**Replies:** 1\
**Last updated:** [April 10, 2024, 10:04pm UTC](https://discourse.cmake.org/t/memorycheck-sanitizer-options-possible-options/10354 "2024-04-10T22:04:45Z")

</div>

What are the possible values of MEMORYCHECK\_SANITIZER\_OPTIONS? There is zero documentation on this… /edit How about adding that link to the docs…?

---

## [Setting and restoring variables (or: when you wish \`block()\` worked differently…)](https://discourse.cmake.org/t/setting-and-restoring-variables-or-when-you-wish-block-worked-differently/10333)

<div class="topic-metadata">

**Author:** [@dabrahams](https://discourse.cmake.org/u/dabrahams)\
**Replies:** 2\
**Last updated:** [April 10, 2024, 9:43pm UTC](https://discourse.cmake.org/t/setting-and-restoring-variables-or-when-you-wish-block-worked-differently/10333 "2024-04-10T21:43:39Z")

</div>

I find this idiom awkward. I use if(YES) just to get some visual indication of the scope-like behavior here. Is there a better way to do this? # Not using block() here because FetchContent\_MakeAvailable typically caus…

---

## [Getting errors while using command (\`\`\`cmake --build . --config Release\`\`\`)](https://discourse.cmake.org/t/getting-errors-while-using-command-cmake-build-config-release/10282)

<div class="topic-metadata">

**Author:** [@Perminder\_123](https://discourse.cmake.org/u/Perminder_123)\
**Replies:** 1\
**Last updated:** [April 10, 2024, 9:30pm UTC](https://discourse.cmake.org/t/getting-errors-while-using-command-cmake-build-config-release/10282 "2024-04-10T21:30:11Z")

</div>

p\\naya wala\\openchemistry-build\\thirdparty\\libxml2.vcxproj\] Stop. Performing install step for 'libxml2' Microsoft (R) Program Maintenance Utility Version 14.29.30148.0 Copyright (C) Microsoft Corporation. All…

---

## [MSVC .rc files support](https://discourse.cmake.org/t/msvc-rc-files-support/10626)

<div class="topic-metadata">

**Author:** [@martingalvan-volue](https://discourse.cmake.org/u/martingalvan-volue)\
**Replies:** 3\
**Last updated:** [April 10, 2024, 1:34pm UTC](https://discourse.cmake.org/t/msvc-rc-files-support/10626 "2024-04-10T13:34:00Z")

</div>

Hi, I’d like to know whether CMake supports generating .sln files which use MSVC Resource Files (.rc). I’ve seen several places online implying that CMake supports these .rc files, but the RC language is not mentioned in…

---

## [Generating a proprietary version list](https://discourse.cmake.org/t/generating-a-proprietary-version-list/10391)

<div class="topic-metadata">

**Author:** [@sdettmer](https://discourse.cmake.org/u/sdettmer)\
**Replies:** 2\
**Last updated:** [April 9, 2024, 12:56pm UTC](https://discourse.cmake.org/t/generating-a-proprietary-version-list/10391 "2024-04-09T12:56:10Z")

</div>

Hi, in a cmake project several sub directories have project()s with different proprietary version numbers. We are using a macro called by each affected CMakefile.txt like ARTEFACT\_VERSION(“NAME” “1.2.3”). This writes a …

---

## [How to find directories with a specific name pattern?](https://discourse.cmake.org/t/how-to-find-directories-with-a-specific-name-pattern/10595)

<div class="topic-metadata">

**Author:** [@JRR](https://discourse.cmake.org/u/JRR)\
**Replies:** 7\
**Last updated:** [April 8, 2024, 7:50pm UTC](https://discourse.cmake.org/t/how-to-find-directories-with-a-specific-name-pattern/10595 "2024-04-08T19:50:21Z")

</div>

We have a windows file share folder/directory that warehouses 3rd party packages for us. It has path value such as: //fs1/0.3rdparty I want to find all the subfolders named Win-VS2022. For example, I want the result t…

---

## [\[Newbie\] Help setting up my first CMakeLists.txt](https://discourse.cmake.org/t/newbie-help-setting-up-my-first-cmakelists-txt/10608)

<div class="topic-metadata">

**Author:** [@RaptaG](https://discourse.cmake.org/u/RaptaG)\
**Replies:** 1\
**Last updated:** [April 7, 2024, 5:15pm UTC](https://discourse.cmake.org/t/newbie-help-setting-up-my-first-cmakelists-txt/10608 "2024-04-07T17:15:58Z")

</div>

I am setting up my first CMakeLists.txt and I can’t figure out the following: How can I make CMakeLists.txt read only from the files included inside the (eg.) src/ folder, where src/ is a folder inside the same directo…

---

## [cmake-gui: empty generator or toolset fails on the reconfigure while set inside the toolchain file](https://discourse.cmake.org/t/cmake-gui-empty-generator-or-toolset-fails-on-the-reconfigure-while-set-inside-the-toolchain-file/10482)

<div class="topic-metadata">

**Author:** [@AJIOB](https://discourse.cmake.org/u/AJIOB)\
**Replies:** 1\
**Last updated:** [April 5, 2024, 11:03am UTC](https://discourse.cmake.org/t/cmake-gui-empty-generator-or-toolset-fails-on-the-reconfigure-while-set-inside-the-toolchain-file/10482 "2024-04-05T11:03:22Z")

</div>

Description I need to load default valued inside the main CMakeLists.txt script. If you keep generator & toolset values from CMake GUI empty, they really pass empty values. The problem is a migration from this issue E…

---

## [How to vend dependency information/configuration](https://discourse.cmake.org/t/how-to-vend-dependency-information-configuration/10319)

<div class="topic-metadata">

**Author:** [@dabrahams](https://discourse.cmake.org/u/dabrahams)\
**Replies:** 10\
**Last updated:** [April 3, 2024, 8:01pm UTC](https://discourse.cmake.org/t/how-to-vend-dependency-information-configuration/10319 "2024-04-03T20:01:57Z")

</div>

I am working with a moderately large dependency graph of projects, some pieces of which I control. For example, I control the projects rooted at The Hylo Group · GitHub, and in that org hylo depends on Swifty-LLVM and D…

---

## [Cmake FetchContent fails when git is configured with ssh](https://discourse.cmake.org/t/cmake-fetchcontent-fails-when-git-is-configured-with-ssh/10551)

<div class="topic-metadata">

**Author:** [@K20shores](https://discourse.cmake.org/u/K20shores)\
**Replies:** 1\
**Last updated:** [April 3, 2024, 2:20am UTC](https://discourse.cmake.org/t/cmake-fetchcontent-fails-when-git-is-configured-with-ssh/10551 "2024-04-03T02:20:26Z")

</div>

I setup my github account on my computer to use github’s ssh configuration for cloning. I can git clone any URL, but for some reason Cmake can’t use git. I’m on Ubuntu 22.04, cmake version 3.22.1, and git version 2.34.1. …

---

## ["automatically" update list of source/header files.](https://discourse.cmake.org/t/automatically-update-list-of-source-header-files/10503)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 6\
**Last updated:** [April 2, 2024, 8:21am UTC](https://discourse.cmake.org/t/automatically-update-list-of-source-header-files/10503 "2024-04-02T08:21:40Z")

</div>

Hi, This is a recurring question but it does not seem to have a satisfying “generic answer”: At build time, can I detect that new source or header files have been added? In this case, how can I add them to the project…

---

## [Did not find -fvisibility=hidden when using CMAKE\_CXX\_VISIBILITY\_PRESET](https://discourse.cmake.org/t/did-not-find-fvisibility-hidden-when-using-cmake-cxx-visibility-preset/10526)

<div class="topic-metadata">

**Author:** [@gaz0](https://discourse.cmake.org/u/gaz0)\
**Replies:** 2\
**Last updated:** [March 31, 2024, 2:30am UTC](https://discourse.cmake.org/t/did-not-find-fvisibility-hidden-when-using-cmake-cxx-visibility-preset/10526 "2024-03-31T02:30:37Z")

</div>

In Step 10 of the tutorial, the final challenge is to use a module to generate the export header file. There is an example in this forum that introduces CMAKE\_CXX\_VISIBILITY\_PRESET, so I set that to hidden as in the exa…

---

## [Unable to test Godot GDExtension -- undefined reference to symbol](https://discourse.cmake.org/t/unable-to-test-godot-gdextension-undefined-reference-to-symbol/10538)

<div class="topic-metadata">

**Author:** [@cyberpuffin](https://discourse.cmake.org/u/cyberpuffin)\
**Replies:** 1\
**Last updated:** [March 30, 2024, 11:04am UTC](https://discourse.cmake.org/t/unable-to-test-godot-gdextension-undefined-reference-to-symbol/10538 "2024-03-30T11:04:50Z")

</div>

Hello. I am trying to add doctest unit testing to my Godot GDExtension project with CMake. I am pretty sure my CMakeLists.txt is accurate, but I’m a CMake newb. A minimally viable project is available at GitHub - cyber…

---

## [Add prefix right before "-Wl,rpath,PATH"](https://discourse.cmake.org/t/add-prefix-right-before-wl-rpath-path/10382)

<div class="topic-metadata">

**Author:** [@Danesh\_Daroui](https://discourse.cmake.org/u/Danesh_Daroui)\
**Replies:** 6\
**Last updated:** [March 30, 2024, 10:43am UTC](https://discourse.cmake.org/t/add-prefix-right-before-wl-rpath-path/10382 "2024-03-30T10:43:33Z")

</div>

Hi all, I have a cmake script which works fine with both GNU and Intel compilers. Now I intend to compile my code with nvcc to generate CUDA compatible code and surprisingly nvcc compiler font-end does not understand “-…

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

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