# Usage

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

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

**Page:** 71

---

## [How to parse CMakeLists.txt files?](https://discourse.cmake.org/t/how-to-parse-cmakelists-txt-files/4417)

<div class="topic-metadata">

**Author:** [@Giorgi\_Didberidze](https://discourse.cmake.org/u/Giorgi_Didberidze)\
**Replies:** 4\
**Last updated:** [November 17, 2021, 2:44pm UTC](https://discourse.cmake.org/t/how-to-parse-cmakelists-txt-files/4417 "2021-11-17T14:44:18Z")

</div>

I would like to know if there’s a way to parse the content of CMakeLists.txt files and print out the targets and its content. I want to print out the content of set(), add\_executable() and add\_library(). For example: …\_…

---

## [CMake Stackoverflow Top Questions/Answers](https://discourse.cmake.org/t/cmake-stackoverflow-top-questions-answers/4490)

<div class="topic-metadata">

**Author:** [@buildSystemPerson](https://discourse.cmake.org/u/buildSystemPerson)\
**Replies:** 0\
**Last updated:** [November 16, 2021, 2:59pm UTC](https://discourse.cmake.org/t/cmake-stackoverflow-top-questions-answers/4490 "2021-11-16T14:59:11Z")

</div>

Lots of people use stack overflow for reference. I think it’d be useful for CMake maintainers to look at the most popular questions and suggests edits/fixes. I think this would help minimize confusion. Since lots of answ…

---

## [FindBoost ignores all hints and won't find the right installation](https://discourse.cmake.org/t/findboost-ignores-all-hints-and-wont-find-the-right-installation/3883)

<div class="topic-metadata">

**Author:** [@jsuthe](https://discourse.cmake.org/u/jsuthe)\
**Replies:** 7\
**Last updated:** [November 15, 2021, 3:26pm UTC](https://discourse.cmake.org/t/findboost-ignores-all-hints-and-wont-find-the-right-installation/3883 "2021-11-15T15:26:37Z")

</div>

I’m trying to get some software built on CentOS 7 with modules. The boost module is loaded and BOOST\_DIR is set as an environment variable to the appropriate path. I’m trying to get FindBoost to pick up the module inst…

---

## [How can I get the objlist from the generator-expressions $\<TARGET\_OBJECTS:objLib\>](https://discourse.cmake.org/t/how-can-i-get-the-objlist-from-the-generator-expressions-target-objects-objlib/2423)

<div class="topic-metadata">

**Author:** [@dalianduzhi](https://discourse.cmake.org/u/dalianduzhi)\
**Replies:** 10\
**Last updated:** [November 15, 2021, 10:39am UTC](https://discourse.cmake.org/t/how-can-i-get-the-objlist-from-the-generator-expressions-target-objects-objlib/2423 "2021-11-15T10:39:02Z")

</div>

I want to get the obj file location and use it for the depends in the add\_custom\_command. The question is: 1.how to process the $\<TARGET\_OBJECTS:objLib\> to get specific location,like this $\<TARGET\_OBJECTS:objLib\> is …

---

## [How to run a post build script in CMAKE, regardless if any object fails?](https://discourse.cmake.org/t/how-to-run-a-post-build-script-in-cmake-regardless-if-any-object-fails/4476)

<div class="topic-metadata">

**Author:** [@Tom\_Iancovici](https://discourse.cmake.org/u/Tom_Iancovici)\
**Replies:** 1\
**Last updated:** [November 13, 2021, 11:02pm UTC](https://discourse.cmake.org/t/how-to-run-a-post-build-script-in-cmake-regardless-if-any-object-fails/4476 "2021-11-13T23:02:42Z")

</div>

I’m trying to generate a compiler error and warning report post-build. This is all in a CMake Environment. So I created a script, and tied to executable post-build. add\_custom\_command(TARGET ${PROJECT\_NAME} POST\_BUILD …

---

## [How to run clang-tidy with option --fix or --export-fixes](https://discourse.cmake.org/t/how-to-run-clang-tidy-with-option-fix-or-export-fixes/4473)

<div class="topic-metadata">

**Author:** [@jwuttke](https://discourse.cmake.org/u/jwuttke)\
**Replies:** 2\
**Last updated:** [November 12, 2021, 2:44pm UTC](https://discourse.cmake.org/t/how-to-run-clang-tidy-with-option-fix-or-export-fixes/4473 "2021-11-12T14:44:36Z")

</div>

The tool clang-tidy checks code against a vast set of rules, and suggests improvements. In a complex project, however, it is prohibitively difficult to run clang-tidy directly from the command line, since it needs inclu…

---

## [cmake --build --preset gives "file not found"](https://discourse.cmake.org/t/cmake-build-preset-gives-file-not-found/4468)

<div class="topic-metadata">

**Author:** [@DavidA](https://discourse.cmake.org/u/DavidA)\
**Replies:** 8\
**Last updated:** [November 11, 2021, 9:32pm UTC](https://discourse.cmake.org/t/cmake-build-preset-gives-file-not-found/4468 "2021-11-11T21:32:15Z")

</div>

My project tree is: |--CMakeLists.txt CMakePresets.json |--builds |--myBuildDir from myBuildDir I can configure the build with a configure preset: cmake --preset \<myConfigurePreset\> ../.. ... -- Configurin…

---

## [Windows / Find\_Python / Python\_USE\_ABI problems](https://discourse.cmake.org/t/windows-find-python-python-use-abi-problems/4457)

<div class="topic-metadata">

**Author:** [@kfsone](https://discourse.cmake.org/u/kfsone)\
**Replies:** 2\
**Last updated:** [November 11, 2021, 6:38pm UTC](https://discourse.cmake.org/t/windows-find-python-python-use-abi-problems/4457 "2021-11-11T18:38:07Z")

</div>

CMake 3.20 from MSVC, building on Windows, with Python 3.9 and 3.10 installed as (C:/Python39, eg), complete with dev and debug binaries/etc. It can find Python OK unless I specify FIND\_ABI "OFF" "ANY" "ANY". Unfortuna…

---

## [Create a custom target that depends on make test completing](https://discourse.cmake.org/t/create-a-custom-target-that-depends-on-make-test-completing/4463)

<div class="topic-metadata">

**Author:** [@shabiel](https://discourse.cmake.org/u/shabiel)\
**Replies:** 2\
**Last updated:** [November 11, 2021, 2:47pm UTC](https://discourse.cmake.org/t/create-a-custom-target-that-depends-on-make-test-completing/4463 "2021-11-11T14:47:13Z")

</div>

Hello everybody, This question is pretty easy to understand. I have a large bunch of tests. I want to have a target that runs after all the tests are done. # If Valgrind is enabled, create output directory and move err…

---

## [Building and running one test](https://discourse.cmake.org/t/building-and-running-one-test/4454)

<div class="topic-metadata">

**Author:** [@matta](https://discourse.cmake.org/u/matta)\
**Replies:** 4\
**Last updated:** [November 10, 2021, 4:24pm UTC](https://discourse.cmake.org/t/building-and-running-one-test/4454 "2021-11-10T16:24:51Z")

</div>

I am new to CMake and a bit confused. I can do this to build and run all of my tests: cmake --build \_builds --target test I can do this to build one of my tests: cmake --build \_builds --target some-test Is there a way…

---

## [Configure vs build presets](https://discourse.cmake.org/t/configure-vs-build-presets/4461)

<div class="topic-metadata">

**Author:** [@DavidA](https://discourse.cmake.org/u/DavidA)\
**Replies:** 1\
**Last updated:** [November 10, 2021, 3:00pm UTC](https://discourse.cmake.org/t/configure-vs-build-presets/4461 "2021-11-10T15:00:09Z")

</div>

I’m trying to express the difference between Configure and Build presets, other than the obvious fact that they are used at configuration and build time. Is there a good explanation of this in the documentation? Our ty…

---

## [Processing assembly files with C Preprocessor statements](https://discourse.cmake.org/t/processing-assembly-files-with-c-preprocessor-statements/3599)

<div class="topic-metadata">

**Author:** [@Bilal](https://discourse.cmake.org/u/Bilal)\
**Replies:** 4\
**Last updated:** [November 8, 2021, 11:09pm UTC](https://discourse.cmake.org/t/processing-assembly-files-with-c-preprocessor-statements/3599 "2021-11-08T23:09:36Z")

</div>

Hi, I have assembly files(\*.asm extension) with C preprocessor statements. These files are recognized by CMAKE as ASM files. On compilers where the control program/compiler itself supports pre-processing and assembling …

---

## [Is there a a way to force shorter (relative) object file paths?](https://discourse.cmake.org/t/is-there-a-a-way-to-force-shorter-relative-object-file-paths/4430)

<div class="topic-metadata">

**Author:** [@skreyer](https://discourse.cmake.org/u/skreyer)\
**Replies:** 2\
**Last updated:** [November 8, 2021, 6:03pm UTC](https://discourse.cmake.org/t/is-there-a-a-way-to-force-shorter-relative-object-file-paths/4430 "2021-11-08T18:03:42Z")

</div>

Hi, Iam using CMake 3.17.1. My project structure is like this: root/Makefiles/CMakeLists.txt root/Src/AllCSources In the CMakeLists.txt I have to specify all sources relative to the Makefiles directory so I end up…

---

## [Ninja Multi-Config generator works not really intuitive](https://discourse.cmake.org/t/ninja-multi-config-generator-works-not-really-intuitive/4446)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 2\
**Last updated:** [November 7, 2021, 9:04pm UTC](https://discourse.cmake.org/t/ninja-multi-config-generator-works-not-really-intuitive/4446 "2021-11-07T21:04:04Z")

</div>

IMHO in general, a Ninja Multi-Config project works not really intuitive: bash-3.2$ cmake -G "Ninja Multi-Config" -B ../build -S . # ... bash-3.2$ cmake --build ../build --target all ninja: no work to do. bash-3.2$ cma…

---

## [visual studio/cmake funny path can't be read in strings file](https://discourse.cmake.org/t/visual-studio-cmake-funny-path-cant-be-read-in-strings-file/4445)

<div class="topic-metadata">

**Author:** [@Zed](https://discourse.cmake.org/u/Zed)\
**Replies:** 2\
**Last updated:** [November 7, 2021, 4:07pm UTC](https://discourse.cmake.org/t/visual-studio-cmake-funny-path-cant-be-read-in-strings-file/4445 "2021-11-07T16:07:25Z")

</div>

Hi - Do you see the quote after the 0 and before the directory / below - on the error msg about the strings file? I am not sure what is causing that. I am trying to piece this together. I am definitely going to be buy…

---

## [Force addition of a Target specific generated source file / win32 manifests](https://discourse.cmake.org/t/force-addition-of-a-target-specific-generated-source-file-win32-manifests/4424)

<div class="topic-metadata">

**Author:** [@kfsone](https://discourse.cmake.org/u/kfsone)\
**Replies:** 1\
**Last updated:** [November 5, 2021, 2:02pm UTC](https://discourse.cmake.org/t/force-addition-of-a-target-specific-generated-source-file-win32-manifests/4424 "2021-11-05T14:02:21Z")

</div>

Cmake 3.16+ Most of our executables ultimately depend on a target, Base, and for Windows long-path support I’ve introduced a manifest file to the Base sources, but this limits what I can put in that manifest. - executa…

---

## [Is $\<COMPILE\_LANGUAGE:RC\> supported for resource files?](https://discourse.cmake.org/t/is-compile-language-rc-supported-for-resource-files/3142)

<div class="topic-metadata">

**Author:** [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)\
**Replies:** 5\
**Last updated:** [November 4, 2021, 4:04pm UTC](https://discourse.cmake.org/t/is-compile-language-rc-supported-for-resource-files/3142 "2021-11-04T16:04:06Z")

</div>

I have compile definitions I’d like to only enable for .rc files in our msvc project. I’d like to use the generator expression as follows: target\_compile\_definitions(foobar PRIVATE $\<$\<COMPILE\_LANGUAGE:RC\>: …

---

## [I don't know how to setup different configurations (defines) for Windows resouce compiler library.](https://discourse.cmake.org/t/i-dont-know-how-to-setup-different-configurations-defines-for-windows-resouce-compiler-library/4413)

<div class="topic-metadata">

**Author:** [@Stefan\_Koch](https://discourse.cmake.org/u/Stefan_Koch)\
**Replies:** 4\
**Last updated:** [November 4, 2021, 2:11pm UTC](https://discourse.cmake.org/t/i-dont-know-how-to-setup-different-configurations-defines-for-windows-resouce-compiler-library/4413 "2021-11-04T14:11:50Z")

</div>

I have a (Windows visual studio) resource dll (containing just rc files) that I want to build with two different configurations with different preprocessor flags. I have not been able to figure out how to set the flags …

---

## [Possible CMake bug in target\_precompile\_headers() with WindowsStore app](https://discourse.cmake.org/t/possible-cmake-bug-in-target-precompile-headers-with-windowsstore-app/4415)

<div class="topic-metadata">

**Author:** [@Zachary\_Turner](https://discourse.cmake.org/u/Zachary_Turner)\
**Replies:** 1\
**Last updated:** [November 4, 2021, 12:29am UTC](https://discourse.cmake.org/t/possible-cmake-bug-in-target-precompile-headers-with-windowsstore-app/4415 "2021-11-04T00:29:03Z")

</div>

I am trying to use target\_precompile\_headers() with a UWP / WindowsStore project. When I do this I get a compilation error: XamlTypeInfo.Impl.g.cpp Generated Files\\XamlTypeInfo.Impl.g.cpp(9,10): fatal error C1083: Cann…

---

## [How to link library with suffix d for debug?](https://discourse.cmake.org/t/how-to-link-library-with-suffix-d-for-debug/4355)

<div class="topic-metadata">

**Author:** [@zhang-qiang-github](https://discourse.cmake.org/u/zhang-qiang-github)\
**Replies:** 15\
**Last updated:** [November 2, 2021, 12:05pm UTC](https://discourse.cmake.org/t/how-to-link-library-with-suffix-d-for-debug/4355 "2021-11-02T12:05:22Z")

</div>

I want to use a third package (VTK) in my project, and the folder is: Thirdparty VTK bin Debug vtkCommonCore-9.0d.dll ... Release vtkCo…

---

## [Retrieving imported preprocessor definition](https://discourse.cmake.org/t/retrieving-imported-preprocessor-definition/4342)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 5\
**Last updated:** [November 2, 2021, 10:43am UTC](https://discourse.cmake.org/t/retrieving-imported-preprocessor-definition/4342 "2021-11-02T10:43:07Z")

</div>

Hi, I’ve got a library L that may define some preprocessor definition MYDEF with target\_compile\_definitions(L PUBLIC MYDEF). How do I check, in the cmake file of a client application A, if MYDEF is defined ? L is prop…

---

## [Findmodule transitivity?](https://discourse.cmake.org/t/findmodule-transitivity/4333)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 5\
**Last updated:** [November 2, 2021, 10:42am UTC](https://discourse.cmake.org/t/findmodule-transitivity/4333 "2021-11-02T10:42:07Z")

</div>

Hi, I have a library project A that depend on a third-party library B that is not properly packaged (I can’t use find\_package directly on it). Thus I wrote a FindB.cmake file whose path I give to A, using the variable …

---

## [CMAKE\_VS\_PLATFORM\_TOOLSET\_VERSION contains only first two components of version](https://discourse.cmake.org/t/cmake-vs-platform-toolset-version-contains-only-first-two-components-of-version/4400)

<div class="topic-metadata">

**Author:** [@vmware-jabarrett](https://discourse.cmake.org/u/vmware-jabarrett)\
**Replies:** 0\
**Last updated:** [November 2, 2021, 1:11am UTC](https://discourse.cmake.org/t/cmake-vs-platform-toolset-version-contains-only-first-two-components-of-version/4400 "2021-11-02T01:11:45Z")

</div>

When setting cmake ... -Tv142,version=14.20.27508,host=x64 the CMAKE\_VS\_PLATFORM\_TOOLSET\_VERSION variable is only populated with the first two components of the version, “14.20”. I need to pass the entire version, “14.20…

---

## [Creating a macOS App Bundle from several executable and Framework](https://discourse.cmake.org/t/creating-a-macos-app-bundle-from-several-executable-and-framework/4356)

<div class="topic-metadata">

**Author:** [@mrmsdbdl](https://discourse.cmake.org/u/mrmsdbdl)\
**Replies:** 1\
**Last updated:** [November 1, 2021, 3:20pm UTC](https://discourse.cmake.org/t/creating-a-macos-app-bundle-from-several-executable-and-framework/4356 "2021-11-01T15:20:16Z")

</div>

I’m building an app that needs several executables and frameworks. I can built everything just as an executable and that’s fine, but I’m confused about how to get CMake to build a MACOSX\_BUNDLE for me. I can see that I c…

---

## [Setting the debugger type in visual studio](https://discourse.cmake.org/t/setting-the-debugger-type-in-visual-studio/4386)

<div class="topic-metadata">

**Author:** [@Asafs](https://discourse.cmake.org/u/Asafs)\
**Replies:** 1\
**Last updated:** [November 1, 2021, 11:06am UTC](https://discourse.cmake.org/t/setting-the-debugger-type-in-visual-studio/4386 "2021-11-01T11:06:19Z")

</div>

Is there a way, to set the debugger type property for a project (possible values are: auto, native only, etc. ) in visual studio?

---

## [I just want to have autocompletion for glib-2.0 in my IDE!](https://discourse.cmake.org/t/i-just-want-to-have-autocompletion-for-glib-2-0-in-my-ide/4372)

<div class="topic-metadata">

**Author:** [@basinilya](https://discourse.cmake.org/u/basinilya)\
**Replies:** 3\
**Last updated:** [October 31, 2021, 4:54pm UTC](https://discourse.cmake.org/t/i-just-want-to-have-autocompletion-for-glib-2-0-in-my-ide/4372 "2021-10-31T16:54:44Z")

</div>

Hi. Without much success I’m trying to setup an IDE to work with a CMake project that uses glib-2.0. For instance: #include \<gio/gnetworking.h\> void foo() { g\_networking\_init(); } Previously I w…

---

## [Copying dependent DLLs to executable directory?](https://discourse.cmake.org/t/copying-dependent-dlls-to-executable-directory/852)

<div class="topic-metadata">

**Author:** [@thomthom](https://discourse.cmake.org/u/thomthom)\
**Replies:** 18\
**Last updated:** [October 29, 2021, 3:09pm UTC](https://discourse.cmake.org/t/copying-dependent-dlls-to-executable-directory/852 "2021-10-29T15:09:15Z")

</div>

I got a project where I use a third party library (Windows). A.lib A.dll B.dll B.dll is a dependency of A.dll not exposed to the A.dll interface. I’m setting up an imported library: add\_library(Example::LibA SHARED …

---

## [Include sources from subdirectories: target\_sources or object library?](https://discourse.cmake.org/t/include-sources-from-subdirectories-target-sources-or-object-library/4363)

<div class="topic-metadata">

**Author:** [@PlatonCM](https://discourse.cmake.org/u/PlatonCM)\
**Replies:** 1\
**Last updated:** [October 29, 2021, 9:30am UTC](https://discourse.cmake.org/t/include-sources-from-subdirectories-target-sources-or-object-library/4363 "2021-10-29T09:30:20Z")

</div>

I have a fundamental decision to take on how to structure the CMake project layout of our (existing) project (1000+ source files). While there are some libraries, which I will include via add\_subdirectory and add\_library …

---

## [unable to access 'https://github.com/google/googletest.git/'](https://discourse.cmake.org/t/unable-to-access-https-github-com-google-googletest-git/4358)

<div class="topic-metadata">

**Author:** [@yUHaOLiu-tj](https://discourse.cmake.org/u/yUHaOLiu-tj)\
**Replies:** 2\
**Last updated:** [October 28, 2021, 4:12pm UTC](https://discourse.cmake.org/t/unable-to-access-https-github-com-google-googletest-git/4358 "2021-10-28T16:12:49Z")

</div>

Hi all, I am trying to compile a project through Cmake-Gui in the windows 10 OS, but it has some mistakes like the following commands: Checking Build System Creating directories for 'googletest-populate' Building…

---

## [Issues with Setting the RPATH](https://discourse.cmake.org/t/issues-with-setting-the-rpath/4350)

<div class="topic-metadata">

**Author:** [@mrmsdbdl](https://discourse.cmake.org/u/mrmsdbdl)\
**Replies:** 5\
**Last updated:** [October 28, 2021, 4:05pm UTC](https://discourse.cmake.org/t/issues-with-setting-the-rpath/4350 "2021-10-28T16:05:25Z")

</div>

I’m really struggling with the RPATH issues on macOS. I think I read quite some blogposts, etc but I still cannot get it right, and I hope someone could help me a bit. So, here is the problem: I’m trying to build an exe…

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

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