# Code

**URL:** https://discourse.cmake.org/c/code/11.md?page=21

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

**Page:** 22

---

## [Boost\_LIBRARIES differs for module mode vs config mode.](https://discourse.cmake.org/t/boost-libraries-differs-for-module-mode-vs-config-mode/10792)

<div class="topic-metadata">

**Author:** [@jwuttke](https://discourse.cmake.org/u/jwuttke)\
**Replies:** 4\
**Last updated:** [May 3, 2024, 5:33pm UTC](https://discourse.cmake.org/t/boost-libraries-differs-for-module-mode-vs-config-mode/10792 "2024-05-03T17:33:19Z")

</div>

BoostConfig.cmake \[1\] is meant as drop-in replacement for CMake’ FindBoost module \[2,3\]. Instead of find\_package(Boost ...) we just use find\_package(Boost CONFIG ...). However, the result variable Boost\_LIBRARIES differs…

---

## [How to prevent clang-tidy to check sources added with FetchContents?](https://discourse.cmake.org/t/how-to-prevent-clang-tidy-to-check-sources-added-with-fetchcontents/2871)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 23\
**Last updated:** [May 3, 2024, 8:48am UTC](https://discourse.cmake.org/t/how-to-prevent-clang-tidy-to-check-sources-added-with-fetchcontents/2871 "2024-05-03T08:48:08Z")

</div>

The example use cxxopts which was fetched with CPM.cmake using FetchContents: builddriver executing: 'run-clang-tidy.py -p build/standalone -checks=-\*,modernize-\*,misc-\*,hicpp-\*,cert-\*,readability-\*,portability-\*,perfor…

---

## [Error when linking a shared library on Windows using Clang, CUDA and Ninja](https://discourse.cmake.org/t/error-when-linking-a-shared-library-on-windows-using-clang-cuda-and-ninja/6377)

<div class="topic-metadata">

**Author:** [@harrytodorov](https://discourse.cmake.org/u/harrytodorov)\
**Replies:** 2\
**Last updated:** [April 30, 2024, 3:38pm UTC](https://discourse.cmake.org/t/error-when-linking-a-shared-library-on-windows-using-clang-cuda-and-ninja/6377 "2024-04-30T15:38:02Z")

</div>

I have recently worked on integrating CUDA in a project and have stumbled upon a couple of problems on Windows in combination with Clang (using the GNU-like command-line) and Ninja. To demonstrate the problems there is …

---

## [Library Versioning best Practise](https://discourse.cmake.org/t/library-versioning-best-practise/10759)

<div class="topic-metadata">

**Author:** [@pedahl](https://discourse.cmake.org/u/pedahl)\
**Replies:** 1\
**Last updated:** [April 29, 2024, 2:25pm UTC](https://discourse.cmake.org/t/library-versioning-best-practise/10759 "2024-04-29T14:25:04Z")

</div>

Hi, i have source code libraries in different Versions. What is the best practice for integrating the different versions in different projects? For example: A-Lib Version:1.0.0 A-Lib Version: 2.0.0 Target Program A…

---

## [CMAKE\_SYSTEM variable incorrect in Jenkins Docker container](https://discourse.cmake.org/t/cmake-system-variable-incorrect-in-jenkins-docker-container/10758)

<div class="topic-metadata">

**Author:** [@bp7878](https://discourse.cmake.org/u/bp7878)\
**Replies:** 2\
**Last updated:** [April 29, 2024, 2:20pm UTC](https://discourse.cmake.org/t/cmake-system-variable-incorrect-in-jenkins-docker-container/10758 "2024-04-29T14:20:15Z")

</div>

I’m running a build pipeline within a redhat 8 docker container on jenkins. Part of the cmake build is doing OS checks. When running natively, on a RHEL 8 system, I get the expected current kernel version and el8\_x ver…

---

## [FetchContent & CMP0135](https://discourse.cmake.org/t/fetchcontent-cmp0135/10422)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 4\
**Last updated:** [April 29, 2024, 9:29am UTC](https://discourse.cmake.org/t/fetchcontent-cmp0135/10422 "2024-04-29T09:29:09Z")

</div>

Hello, In Professional CMake 17th, I read some stuff about CMP0135. The book and the documentation talk only about ExternalProject\_Add(), but not about FetchContent. And then I found the following ticket : https://git…

---

## [Must CPACK\_BINARY\_\<generator\> be set even if \<generator\> is set through CPACK\_GENERATOR?](https://discourse.cmake.org/t/must-cpack-binary-generator-be-set-even-if-generator-is-set-through-cpack-generator/10645)

<div class="topic-metadata">

**Author:** [@jwuttke](https://discourse.cmake.org/u/jwuttke)\
**Replies:** 2\
**Last updated:** [April 28, 2024, 5:21am UTC](https://discourse.cmake.org/t/must-cpack-binary-generator-be-set-even-if-generator-is-set-through-cpack-generator/10645 "2024-04-28T05:21:17Z")

</div>

This code fragment looks somewhat repetitive: set(CPACK\_BINARY\_DRAGNDROP ON) set(CPACK\_GENERATOR "DragNDrop") So line 2 does not make line 1 redundant?

---

## [Request for Minimal Working Example of BLAS in FORTRAN 77 with CMake and Package Managers](https://discourse.cmake.org/t/request-for-minimal-working-example-of-blas-in-fortran-77-with-cmake-and-package-managers/10752)

<div class="topic-metadata">

**Author:** [@fsffarimani](https://discourse.cmake.org/u/fsffarimani)\
**Replies:** 3\
**Last updated:** [April 28, 2024, 4:40pm UTC](https://discourse.cmake.org/t/request-for-minimal-working-example-of-blas-in-fortran-77-with-cmake-and-package-managers/10752 "2024-04-28T16:40:00Z")

</div>

I am working on a project to integrate Basic Linear Algebra Subprograms (BLAS) into a FORTRAN 77 application. I aim to set up this project on Windows using Intel’s ifort.exe compiler. To streamline the development proces…

---

## [Why \\$\<LINK\_ONLY...\> genex is escaped?](https://discourse.cmake.org/t/why-link-only-genex-is-escaped/10674)

<div class="topic-metadata">

**Author:** [@silverqx](https://discourse.cmake.org/u/silverqx)\
**Replies:** 6\
**Last updated:** [April 28, 2024, 6:39am UTC](https://discourse.cmake.org/t/why-link-only-genex-is-escaped/10674 "2024-04-28T06:39:03Z")

</div>

I see in package config files that \\$\<LINK\_ONLY:...\> genex is escaped, why? I’ve been using cmake ~2 years and I never escaped genex and I don’t even remember that I would read something about it. Genex docs doesn’t eve…

---

## [Can NOT find out dynamic header file generated by configure\_file.](https://discourse.cmake.org/t/can-not-find-out-dynamic-header-file-generated-by-configure-file/10722)

<div class="topic-metadata">

**Author:** [@evilroach](https://discourse.cmake.org/u/evilroach)\
**Replies:** 2\
**Last updated:** [April 24, 2024, 10:27am UTC](https://discourse.cmake.org/t/can-not-find-out-dynamic-header-file-generated-by-configure-file/10722 "2024-04-24T10:27:03Z")

</div>

I have a dynamic header Version.hpp generated by configure\_file command of cmake-3.25. I can normally use it at the top of the source tree as is, but can NOT use it in a subdirectory of the tree. Like this: The top l…

---

## [cmake 3.29.0-rc3 getting error-Selecting Windows SDK version...](https://discourse.cmake.org/t/cmake-3-29-0-rc3-getting-error-selecting-windows-sdk-version/10366)

<div class="topic-metadata">

**Author:** [@waylab](https://discourse.cmake.org/u/waylab)\
**Replies:** 4\
**Last updated:** [April 24, 2024, 12:26am UTC](https://discourse.cmake.org/t/cmake-3-29-0-rc3-getting-error-selecting-windows-sdk-version/10366 "2024-04-24T00:26:10Z")

</div>

Hi, what changes do I need in to do computer windows 11 home x64 vs community 2022 orbbecsdk 1.9.4 cmake 3.29.0-rc3 cmake window shows current generator:visual studio 17 2022 in red make\_configuation\_types …

---

## [Using file sets for both public and private headers](https://discourse.cmake.org/t/using-file-sets-for-both-public-and-private-headers/10725)

<div class="topic-metadata">

**Author:** [@gracicot](https://discourse.cmake.org/u/gracicot)\
**Replies:** 2\
**Last updated:** [April 23, 2024, 2:41pm UTC](https://discourse.cmake.org/t/using-file-sets-for-both-public-and-private-headers/10725 "2024-04-23T14:41:25Z")

</div>

Hi! I tried using file sets for my project and I’m not sure how to proceed. I have public headers that I have inside include/, and some private headers in src/. I tried using file sets to describe both like so: target\_s…

---

## [propagation of include paths through targets](https://discourse.cmake.org/t/propagation-of-include-paths-through-targets/10692)

<div class="topic-metadata">

**Author:** [@jwm](https://discourse.cmake.org/u/jwm)\
**Replies:** 2\
**Last updated:** [April 23, 2024, 12:46am UTC](https://discourse.cmake.org/t/propagation-of-include-paths-through-targets/10692 "2024-04-23T00:46:21Z")

</div>

I created a project (see here) and am using it in another project through FetchContent. In my new project, I create a base library that depends on one of my fetched targets, we’ll call it fetchTarget. Here I have add\_l…

---

## [Possible regression related to INTERFACE\_INCLUDE\_DIRECTORIES in 2.29.1](https://discourse.cmake.org/t/possible-regression-related-to-interface-include-directories-in-2-29-1/10705)

<div class="topic-metadata">

**Author:** [@mschwaig](https://discourse.cmake.org/u/mschwaig)\
**Replies:** 3\
**Last updated:** [April 21, 2024, 12:03am UTC](https://discourse.cmake.org/t/possible-regression-related-to-interface-include-directories-in-2-29-1/10705 "2024-04-21T00:03:51Z")

</div>

Hello! :wave: I am on of the maintainers of ROCm for the Nix package manager and NixOS Linux distribution. We have this big monorepo for all of our packages at GitHub - NixOS/nixpkgs: Nix Packages collection & NixOS an…

---

## [Brand, Spankin' New...Trying to Understand gpiod.h and riscv-64](https://discourse.cmake.org/t/brand-spankin-new-trying-to-understand-gpiod-h-and-riscv-64/10702)

<div class="topic-metadata">

**Author:** [@silver2row](https://discourse.cmake.org/u/silver2row)\
**Replies:** 1\
**Last updated:** [April 20, 2024, 9:45am UTC](https://discourse.cmake.org/t/brand-spankin-new-trying-to-understand-gpiod-h-and-riscv-64/10702 "2024-04-20T09:45:55Z")

</div>

Hello, I have a BeagleV-Ahead I am using to natively compile via cmake .. && make and then using libgpiod-dev libs. via #include \<gpiod.h\> to get things going. I am receiving this error after cmake and make commands. R…

---

## [FetchContent and FIND\_PACKAGE\_ARGS not linking correctly](https://discourse.cmake.org/t/fetchcontent-and-find-package-args-not-linking-correctly/10653)

<div class="topic-metadata">

**Author:** [@dbonattoj](https://discourse.cmake.org/u/dbonattoj)\
**Replies:** 2\
**Last updated:** [April 20, 2024, 9:47am UTC](https://discourse.cmake.org/t/fetchcontent-and-find-package-args-not-linking-correctly/10653 "2024-04-20T09:47:16Z")

</div>

I’m currently working on a project where I aim to use find\_package() to check if a library is available in the system. If the library is not available, I intend to fetch it and compile it using FetchContent . I’ve manage…

---

## [Struggling to export a project](https://discourse.cmake.org/t/struggling-to-export-a-project/10491)

<div class="topic-metadata">

**Author:** [@jwm](https://discourse.cmake.org/u/jwm)\
**Replies:** 5\
**Last updated:** [April 19, 2024, 12:32am UTC](https://discourse.cmake.org/t/struggling-to-export-a-project/10491 "2024-04-19T00:32:43Z")

</div>

I hate starting a topic that is so similar to so many others, but I haven’t found a clear explanation of how to get from where I am to where I want to be. I’ve read the Importing and Exporting Guide and all the questions…

---

## [Generating a MY\_APP.vcxproj.user file](https://discourse.cmake.org/t/generating-a-my-app-vcxproj-user-file/10498)

<div class="topic-metadata">

**Author:** [@Mark](https://discourse.cmake.org/u/Mark)\
**Replies:** 3\
**Last updated:** [April 18, 2024, 4:50pm UTC](https://discourse.cmake.org/t/generating-a-my-app-vcxproj-user-file/10498 "2024-04-18T16:50:05Z")

</div>

I’m trying to use CMake to configure some parameters for the Visual Studio debugger to make it easier to start a debug session. I have the following code in a file that is included in the top CMakeLists.txt file. The inc…

---

## [Technical name for CXX, Fortran](https://discourse.cmake.org/t/technical-name-for-cxx-fortran/10682)

<div class="topic-metadata">

**Author:** [@mredenti](https://discourse.cmake.org/u/mredenti)\
**Replies:** 1\
**Last updated:** [April 17, 2024, 7:15pm UTC](https://discourse.cmake.org/t/technical-name-for-cxx-fortran/10682 "2024-04-17T19:15:27Z")

</div>

The language identifiers CXX, Fortran, CUDA, ... that for instance are passed to the CMake built-in command project are not keywords but …? Are they called identifiers?

---

## [RPATH via LINK\_OPTIONS or per default?](https://discourse.cmake.org/t/rpath-via-link-options-or-per-default/10677)

<div class="topic-metadata">

**Author:** [@jwuttke](https://discourse.cmake.org/u/jwuttke)\
**Replies:** 1\
**Last updated:** [April 16, 2024, 10:18pm UTC](https://discourse.cmake.org/t/rpath-via-link-options-or-per-default/10677 "2024-04-16T22:18:40Z")

</div>

We have CMake code like this: set(link\_flags "--disable-new-dtags,-rpath,\\$ORIGIN/../lib") set\_target\_properties(${executable\_name} PROPERTIES LINK\_OPTIONS ${link\_flags}) Is this needed? The CMake docs indicate…

---

## [Hdden compiler and link options being added to compile and link line](https://discourse.cmake.org/t/hdden-compiler-and-link-options-being-added-to-compile-and-link-line/10629)

<div class="topic-metadata">

**Author:** [@loopless](https://discourse.cmake.org/u/loopless)\
**Replies:** 2\
**Last updated:** [April 15, 2024, 3:49pm UTC](https://discourse.cmake.org/t/hdden-compiler-and-link-options-being-added-to-compile-and-link-line/10629 "2024-04-15T15:49:29Z")

</div>

I am using Conan/CMake with QT 6.5.3 When running CMake 3.24.4 to generate Ninja files for a Release build I am finding “hidden” options added to the compile and link line. For example, I note the link flags in ninja.…

---

## [PACKAGE\_INIT generates PACKAGE\_PREFIX\_DIR with the wrong directory](https://discourse.cmake.org/t/package-init-generates-package-prefix-dir-with-the-wrong-directory/10453)

<div class="topic-metadata">

**Author:** [@josiest](https://discourse.cmake.org/u/josiest)\
**Replies:** 17\
**Last updated:** [April 15, 2024, 11:21am UTC](https://discourse.cmake.org/t/package-init-generates-package-prefix-dir-with-the-wrong-directory/10453 "2024-04-15T11:21:38Z")

</div>

I have a very small library called pi-events, and I’m trying to install it locally to another project I have called sdl-sandbox, which lives in D:/projects/sdl-sandbox My pi-events-config.cmake.in file looks like this: …

---

## [\[Nitpicking\] Making generator expression evaluates to null/nil/nothing/nada/zilch rather than empty/blank/""?](https://discourse.cmake.org/t/nitpicking-making-generator-expression-evaluates-to-null-nil-nothing-nada-zilch-rather-than-empty-blank/10627)

<div class="topic-metadata">

**Author:** [@emaschino](https://discourse.cmake.org/u/emaschino)\
**Replies:** 2\
**Last updated:** [April 12, 2024, 6:18pm UTC](https://discourse.cmake.org/t/nitpicking-making-generator-expression-evaluates-to-null-nil-nothing-nada-zilch-rather-than-empty-blank/10627 "2024-04-12T18:18:46Z")

</div>

Hi, Thanks to this great post and SO answer, I have CMake writes FooConfig.cmake file whose content varies depending on target type (STATIC, SHARED) evaluated by generator expression. To this end, FooConfig.cmake.in re…

---

## [C++20 module seems to be broken (missing transitive usage) in a very specific case](https://discourse.cmake.org/t/c-20-module-seems-to-be-broken-missing-transitive-usage-in-a-very-specific-case/9537)

<div class="topic-metadata">

**Author:** [@cpplearner](https://discourse.cmake.org/u/cpplearner)\
**Replies:** 7\
**Last updated:** [April 12, 2024, 5:25pm UTC](https://discourse.cmake.org/t/c-20-module-seems-to-be-broken-missing-transitive-usage-in-a-very-specific-case/9537 "2024-04-12T17:25:01Z")

</div>

I am learning to use C++20 module with CMake 2.38.0-rc4, and I noticed a possible bug in CMake. CMakeLists.txt: cmake\_minimum\_required(VERSION 3.28.0) project(MyLib LANGUAGES CXX) set(CMAKE\_CXX\_STANDARD 23) add\_libr…

---

## [Headers not found in coremodel\_v2 (2.6) when installed with library](https://discourse.cmake.org/t/headers-not-found-in-coremodel-v2-2-6-when-installed-with-library/10591)

<div class="topic-metadata">

**Author:** [@MementoRC](https://discourse.cmake.org/u/MementoRC)\
**Replies:** 2\
**Last updated:** [April 11, 2024, 6:39pm UTC](https://discourse.cmake.org/t/headers-not-found-in-coremodel-v2-2-6-when-installed-with-library/10591 "2024-04-11T18:39:31Z")

</div>

Using this syntax: install(TARGETS \_core\_lib LIBRARY DESTINATION lib FILE\_SET HEADERS DESTINATION include ) The headers in the FILE\_SET are installed correctly, however they do not appear in the coremodel\_v2 (2…

---

## [FetchContent\_MakeAvailable single-threaded and slow. Any way to parallelize?](https://discourse.cmake.org/t/fetchcontent-makeavailable-single-threaded-and-slow-any-way-to-parallelize/8493)

<div class="topic-metadata">

**Author:** [@dwarwick](https://discourse.cmake.org/u/dwarwick)\
**Replies:** 4\
**Last updated:** [April 11, 2024, 5:14pm UTC](https://discourse.cmake.org/t/fetchcontent-makeavailable-single-threaded-and-slow-any-way-to-parallelize/8493 "2024-04-11T17:14:21Z")

</div>

We recently started to move some of the manual dependent-repo fetching we were doing over to be automatically pulled in via FetchContent. It’s definitely a lot easier when everything’s automatic, but the initial fetching…

---

## [Have a problems setting GTK in CMake correctly.](https://discourse.cmake.org/t/have-a-problems-setting-gtk-in-cmake-correctly/10570)

<div class="topic-metadata">

**Author:** [@WaltOnline](https://discourse.cmake.org/u/WaltOnline)\
**Replies:** 1\
**Last updated:** [April 11, 2024, 4:41pm UTC](https://discourse.cmake.org/t/have-a-problems-setting-gtk-in-cmake-correctly/10570 "2024-04-11T16:41:52Z")

</div>

Hello! I cloned vcpkg from git repo it created “vcpkg” directory in E:\\ I launched a bootstrap-vcpkg.bat and it downloaded vcpkg.exe PS E:\\vcpkg\> .\\bootstrap-vcpkg.bat Downloading https://github.com/microsoft/vcpk…

---

## [I keep getting a linker error](https://discourse.cmake.org/t/i-keep-getting-a-linker-error/10557)

<div class="topic-metadata">

**Author:** [@Shepard](https://discourse.cmake.org/u/Shepard)\
**Replies:** 2\
**Last updated:** [April 11, 2024, 4:30pm UTC](https://discourse.cmake.org/t/i-keep-getting-a-linker-error/10557 "2024-04-11T16:30:16Z")

</div>

Slowly losing my sanity over here… My root is: . ├── apps │ ├── app.cpp │ └── CMakeLists.txt ├── CMakeLists.txt ├── include │ └── modern │ └── logging\_helper.hpp ├── README.md ├── src │ ├── CMakeLists.txt…

---

## [Gracefully create symbolic link for static libs like for shared libs](https://discourse.cmake.org/t/gracefully-create-symbolic-link-for-static-libs-like-for-shared-libs/10458)

<div class="topic-metadata">

**Author:** [@evilroach](https://discourse.cmake.org/u/evilroach)\
**Replies:** 3\
**Last updated:** [April 11, 2024, 3:40pm UTC](https://discourse.cmake.org/t/gracefully-create-symbolic-link-for-static-libs-like-for-shared-libs/10458 "2024-04-11T15:40:58Z")

</div>

As we know, only for Shared Libs, a symbolic link is created automatically, not for Static Libs. For example: If we have a target libLeonLog.so.1.2.3, we will get a symbolic link libLeonlog.so and libLeonLog.so.1 that …

---

## [Is it possible to implicitly find nested component dependencies after installation?](https://discourse.cmake.org/t/is-it-possible-to-implicitly-find-nested-component-dependencies-after-installation/10465)

<div class="topic-metadata">

**Author:** [@josiest](https://discourse.cmake.org/u/josiest)\
**Replies:** 1\
**Last updated:** [April 11, 2024, 12:23am UTC](https://discourse.cmake.org/t/is-it-possible-to-implicitly-find-nested-component-dependencies-after-installation/10465 "2024-04-11T00:23:46Z")

</div>

I have a package called pi which consists of several small libraries that I’ve written as components. So for example I can install the package to a project and write find\_package(pi COMPONENTS system-graph yaml-config s…

[Previous page](https://discourse.cmake.org/c/code/11.md?page=20)

[Next page](https://discourse.cmake.org/c/code/11.md?page=22)
