# Code

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

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

**Page:** 3

---

## [Unable to build Eigen & OpenXLSX on windows](https://discourse.cmake.org/t/unable-to-build-eigen-openxlsx-on-windows/10868)

<div class="topic-metadata">

**Author:** [@Shepard](https://discourse.cmake.org/u/Shepard)\
**Replies:** 2\
**Last updated:** [March 19, 2026, 11:27am UTC](https://discourse.cmake.org/t/unable-to-build-eigen-openxlsx-on-windows/10868 "2026-03-19T11:27:22Z")

</div>

Well, I’m working on a C++ project where I am using linear algebra from Eigen. This is how I fetch the Eigen library from my root CmakeLists.txt: message(\[STATUS\] "Fetching eigen.") block(SCOPE\_FOR VARIABLES) set(E…

---

## [Having difficulty compiling with import std; support; cmake can't build std.cppm](https://discourse.cmake.org/t/having-difficulty-compiling-with-import-std-support-cmake-cant-build-std-cppm/15557)

<div class="topic-metadata">

**Author:** [@sebjames](https://discourse.cmake.org/u/sebjames)\
**Replies:** 10\
**Last updated:** [March 15, 2026, 8:41am UTC](https://discourse.cmake.org/t/having-difficulty-compiling-with-import-std-support-cmake-cant-build-std-cppm/15557 "2026-03-15T08:41:15Z")

</div>

Hi there, I’m looking for some help with a cmake-directed build of a C++ modules project containing import std; I’ve followed along with: https://www.kitware.com/import-std-in-cmake-3-30/ The sample provided there co…

---

## [add\_subdirectory() and target\_link\_libraries() ordering](https://discourse.cmake.org/t/add-subdirectory-and-target-link-libraries-ordering/15539)

<div class="topic-metadata">

**Author:** [@Diltsman](https://discourse.cmake.org/u/Diltsman)\
**Replies:** 7\
**Last updated:** [March 13, 2026, 5:40pm UTC](https://discourse.cmake.org/t/add-subdirectory-and-target-link-libraries-ordering/15539 "2026-03-13T17:40:24Z")

</div>

When writing a CMakeLists.txt file, I have always called target\_link\_libraries() with a list of targets that I am generating in other directories, then I call add\_subdirectory() to add the files that create the targets. …

---

## [Forcing a locally installed Boost to be used instead of the system-level one](https://discourse.cmake.org/t/forcing-a-locally-installed-boost-to-be-used-instead-of-the-system-level-one/15549)

<div class="topic-metadata">

**Author:** [@rwan](https://discourse.cmake.org/u/rwan)\
**Replies:** 12\
**Last updated:** [March 11, 2026, 11:44pm UTC](https://discourse.cmake.org/t/forcing-a-locally-installed-boost-to-be-used-instead-of-the-system-level-one/15549 "2026-03-11T23:44:01Z")

</div>

Hi all, I have been trying to get Boost working with CMake. What I did almost a year ago is detailed here: CMake with Boost and policy CMP0167 . And that still works, thankfully. :slight\_smile: There is just one pr…

---

## [Correctly link libraries with specific soname on linux](https://discourse.cmake.org/t/correctly-link-libraries-with-specific-soname-on-linux/15552)

<div class="topic-metadata">

**Author:** [@nickvdbroeck](https://discourse.cmake.org/u/nickvdbroeck)\
**Replies:** 1\
**Last updated:** [March 11, 2026, 1:56pm UTC](https://discourse.cmake.org/t/correctly-link-libraries-with-specific-soname-on-linux/15552 "2026-03-11T13:56:35Z")

</div>

My project uses other libraries on linux x86\_64. The other libraries are available as precompiled library files. Meaning I have a folder with 34 .so files. Most of these have full version numbers. For example: \`libgentl.…

---

## [INTERFACE library target and CXX\_MODULES file set](https://discourse.cmake.org/t/interface-library-target-and-cxx-modules-file-set/15550)

<div class="topic-metadata">

**Author:** [@matwey](https://discourse.cmake.org/u/matwey)\
**Replies:** 0\
**Last updated:** [March 10, 2026, 8:47am UTC](https://discourse.cmake.org/t/interface-library-target-and-cxx-modules-file-set/15550 "2026-03-10T08:47:01Z")

</div>

Hello, I am completely confused with correct usage of C++ modules and INTERFACE targets. Let me please first describe what I currently have and what I want to achieve. I have a project consisting multiple firmwares for…

---

## [Code injection at the end of the processing of each CMakeLists.txt file](https://discourse.cmake.org/t/code-injection-at-the-end-of-the-processing-of-each-cmakelists-txt-file/15541)

<div class="topic-metadata">

**Author:** [@nappl](https://discourse.cmake.org/u/nappl)\
**Replies:** 2\
**Last updated:** [March 9, 2026, 9:46am UTC](https://discourse.cmake.org/t/code-injection-at-the-end-of-the-processing-of-each-cmakelists-txt-file/15541 "2026-03-09T09:46:32Z")

</div>

Hi, We have a bit of a weird use-case where we occasionally need to inject code at the end of the processing of each CMakeLists.txt file. This extra CMake code is very bespoke and most of it we do not have any control o…

---

## [How best to handle installation of public headers in ${CMAKE\_INSTALL\_INCLUDEDIR} and a subdirectory thereof](https://discourse.cmake.org/t/how-best-to-handle-installation-of-public-headers-in-cmake-install-includedir-and-a-subdirectory-thereof/15525)

<div class="topic-metadata">

**Author:** [@MarkCallow](https://discourse.cmake.org/u/MarkCallow)\
**Replies:** 5\
**Last updated:** [March 5, 2026, 9:14am UTC](https://discourse.cmake.org/t/how-best-to-handle-installation-of-public-headers-in-cmake-install-includedir-and-a-subdirectory-thereof/15525 "2026-03-05T09:14:00Z")

</div>

I have a library with two public header files that need to be installed: one in ${CMAKE\_INSTALL\_INCLUDEDIR} and one in ${CMAKE\_INSTALL\_INCLUDEDIR}/SUBDIR. If I do set\_target\_properties(mylib PROPERTIES PUBLI…

---

## [Trouble with RPATH when building netcdf for Fedora](https://discourse.cmake.org/t/trouble-with-rpath-when-building-netcdf-for-fedora/15532)

<div class="topic-metadata">

**Author:** [@opoplawski](https://discourse.cmake.org/u/opoplawski)\
**Replies:** 2\
**Last updated:** [March 4, 2026, 12:30am UTC](https://discourse.cmake.org/t/trouble-with-rpath-when-building-netcdf-for-fedora/15532 "2026-03-04T00:30:26Z")

</div>

I package netcdf for Fedora. I’m working on switching to cmake for building the project and having trouble with RPATHs ending up in installed files. Fedora forbids rpath in installed files. I get the following message…

---

## [How can I be sure that a C++20 module is not re-compiled after a non-module code change?](https://discourse.cmake.org/t/how-can-i-be-sure-that-a-c-20-module-is-not-re-compiled-after-a-non-module-code-change/15535)

<div class="topic-metadata">

**Author:** [@sebjames](https://discourse.cmake.org/u/sebjames)\
**Replies:** 11\
**Last updated:** [March 2, 2026, 6:38pm UTC](https://discourse.cmake.org/t/how-can-i-be-sure-that-a-c-20-module-is-not-re-compiled-after-a-non-module-code-change/15535 "2026-03-02T18:38:44Z")

</div>

Hi Cmakers, This is a question about compiling C++ code with modules. I’ve built an example that is based on some existing C++ code I have. The class is called sm::range . I have made a CMakeLists to compile an executa…

---

## [Problem with linking on static libraries](https://discourse.cmake.org/t/problem-with-linking-on-static-libraries/10665)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 4\
**Last updated:** [February 25, 2026, 8:11pm UTC](https://discourse.cmake.org/t/problem-with-linking-on-static-libraries/10665 "2026-02-25T20:11:07Z")

</div>

Hello, I have a simple library project, which consumes an other library, provided as a CMake installation configuration (throught a ZIP and a call to FetchContent). The question is at the end. Here is the files struct…

---

## [How to set policy version globally for \`cmake\_install.cmake\`](https://discourse.cmake.org/t/how-to-set-policy-version-globally-for-cmake-install-cmake/15528)

<div class="topic-metadata">

**Author:** [@huangqinjin](https://discourse.cmake.org/u/huangqinjin)\
**Replies:** 0\
**Last updated:** [February 24, 2026, 5:21pm UTC](https://discourse.cmake.org/t/how-to-set-policy-version-globally-for-cmake-install-cmake/15528 "2026-02-24T17:21:03Z")

</div>

I use if(PATH\_EQUAL) inside install(CODE) for custom install logic. But it trigger the error about Policy CMP0139 is not set. How the enable it globally for cmake\_install.cmake? Why does cmake\_install.cmake not use sam…

---

## [How to traverse \`target\_link\_libraries\` dependencies in the file api?](https://discourse.cmake.org/t/how-to-traverse-target-link-libraries-dependencies-in-the-file-api/14384)

<div class="topic-metadata">

**Author:** [@Zachary\_Turner](https://discourse.cmake.org/u/Zachary_Turner)\
**Replies:** 4\
**Last updated:** [February 21, 2026, 12:16am UTC](https://discourse.cmake.org/t/how-to-traverse-target-link-libraries-dependencies-in-the-file-api/14384 "2026-02-21T00:16:35Z")

</div>

I’m using cmake 3.26.3. I have three targets A, B, and C. And I have target\_link\_libraries(A PRIVATE B PUBLIC C). I use the file api and traverse to the codemodel object for target A, and it’s dependencies field is com…

---

## [\`SYSTEM\` flag hides header warnings but not sources](https://discourse.cmake.org/t/system-flag-hides-header-warnings-but-not-sources/15517)

<div class="topic-metadata">

**Author:** [@DaAwesomeP](https://discourse.cmake.org/u/DaAwesomeP)\
**Replies:** 1\
**Last updated:** [February 20, 2026, 5:24pm UTC](https://discourse.cmake.org/t/system-flag-hides-header-warnings-but-not-sources/15517 "2026-02-20T17:24:42Z")

</div>

Hi, I’m using add\_subdirectory via CPM to add a library: CPMAddPackage( NAME JUCE GITHUB\_REPOSITORY juce-framework/JUCE SYSTEM YES ) target\_link\_libraries(${PROJECT\_NAME} PRIVATE juce\_osc ) # O…

---

## [Custom targets that use terminal individually, but can be run parallel in batch](https://discourse.cmake.org/t/custom-targets-that-use-terminal-individually-but-can-be-run-parallel-in-batch/14054)

<div class="topic-metadata">

**Author:** [@mahrud](https://discourse.cmake.org/u/mahrud)\
**Replies:** 7\
**Last updated:** [February 20, 2026, 2:36pm UTC](https://discourse.cmake.org/t/custom-targets-that-use-terminal-individually-but-can-be-run-parallel-in-batch/14054 "2026-02-20T14:36:26Z")

</div>

Say I have 10 custom targets build-package-{1..10} that I can run in with an umbrella target build-all. I really appreciate that CMake + Ninja allow me to run these in parallel and have them print their result only when …

---

## [Add settings to visual studio, e.g., an exception or a plugin property](https://discourse.cmake.org/t/add-settings-to-visual-studio-e-g-an-exception-or-a-plugin-property/14374)

<div class="topic-metadata">

**Author:** [@Zohar](https://discourse.cmake.org/u/Zohar)\
**Replies:** 3\
**Last updated:** [February 20, 2026, 2:32pm UTC](https://discourse.cmake.org/t/add-settings-to-visual-studio-e-g-an-exception-or-a-plugin-property/14374 "2026-02-20T14:32:57Z")

</div>

I’d like to add settings to Visual Studio such as: An exception (e.g., std::exception) to the “Exception Settings.” I have a list of them. Set a plugin property: “Child Process Debugging”, enable. Every time I run a c…

---

## [Can I make two separate library packages in one CMakelIsts.txt file?](https://discourse.cmake.org/t/can-i-make-two-separate-library-packages-in-one-cmakelists-txt-file/15168)

<div class="topic-metadata">

**Author:** [@chriskot870](https://discourse.cmake.org/u/chriskot870)\
**Replies:** 2\
**Last updated:** [February 20, 2026, 2:26pm UTC](https://discourse.cmake.org/t/can-i-make-two-separate-library-packages-in-one-cmakelists-txt-file/15168 "2026-02-20T14:26:04Z")

</div>

I am currently creating one library built from two source files. I want to generate both shared library and static library. The static libraries and headers only get loaded when loading a dev version of the package. set…

---

## [Best way to have a library package install a main.cpp and run add\_executable in context of user project when it calls my CMake function?](https://discourse.cmake.org/t/best-way-to-have-a-library-package-install-a-main-cpp-and-run-add-executable-in-context-of-user-project-when-it-calls-my-cmake-function/11200)

<div class="topic-metadata">

**Author:** [@Dennis\_Ferron](https://discourse.cmake.org/u/Dennis_Ferron)\
**Replies:** 3\
**Last updated:** [February 20, 2026, 2:09pm UTC](https://discourse.cmake.org/t/best-way-to-have-a-library-package-install-a-main-cpp-and-run-add-executable-in-context-of-user-project-when-it-calls-my-cmake-function/11200 "2026-02-20T14:09:06Z")

</div>

The ANTLR4 parser project provides a TestRig (Java) class which helps you debug your grammar, but running it from CMake via add\_custom\_command (or similar) only runs it at configure or build time. To run a command from …

---

## [Import std - cmake 3.30 - "config mismatch" error](https://discourse.cmake.org/t/import-std-cmake-3-30-config-mismatch-error/12908)

<div class="topic-metadata">

**Author:** [@Kelarov](https://discourse.cmake.org/u/Kelarov)\
**Replies:** 3\
**Last updated:** [February 20, 2026, 5:48am UTC](https://discourse.cmake.org/t/import-std-cmake-3-30-config-mismatch-error/12908 "2026-02-20T05:48:14Z")

</div>

Hi all. I am trying to apply what the import std in CMake 3.30 post does to use in a project, but am facing errors. My setup: CMakeLists.txt CMakePresets.json src/CMakeLists.txt src/kk-intro.cppm src/kk-intro.cc src/m…

---

## [Automatically discovering the minimal header install set](https://discourse.cmake.org/t/automatically-discovering-the-minimal-header-install-set/13832)

<div class="topic-metadata">

**Author:** [@sketch34](https://discourse.cmake.org/u/sketch34)\
**Replies:** 3\
**Last updated:** [February 20, 2026, 4:55am UTC](https://discourse.cmake.org/t/automatically-discovering-the-minimal-header-install-set/13832 "2026-02-20T04:55:05Z")

</div>

I have an install component ae\_sdk that produces the client-facing SDK. We want the SDK to contains the minimal set of headers required. Currently we achieve this by compiling a sample SDK project with the gcc -H flag (p…

---

## [Need help with the issue I am facing](https://discourse.cmake.org/t/need-help-with-the-issue-i-am-facing/13845)

<div class="topic-metadata">

**Author:** [@Tanishka](https://discourse.cmake.org/u/Tanishka)\
**Replies:** 3\
**Last updated:** [February 20, 2026, 4:53am UTC](https://discourse.cmake.org/t/need-help-with-the-issue-i-am-facing/13845 "2026-02-20T04:53:29Z")

</div>

I am using cmake with ccache in my code. Although the temporary file is generated by ccache exists on the agent with the same name and in the same path(C:/Users/bamboo.vmBAPrd03TLCWEW/AppData/Local/ccache/tmp/cmd\_args.t…

---

## [set xcode "Library Search Paths" form cmake?](https://discourse.cmake.org/t/set-xcode-library-search-paths-form-cmake/12846)

<div class="topic-metadata">

**Author:** [@shokarta](https://discourse.cmake.org/u/shokarta)\
**Replies:** 4\
**Last updated:** [February 20, 2026, 3:34am UTC](https://discourse.cmake.org/t/set-xcode-library-search-paths-form-cmake/12846 "2026-02-20T03:34:42Z")

</div>

Hello guys, after I configure the project from QT, in xcode I need to manualy go to project BUILD SETTINGS, locate LIBRARY SEARCH PATHS and set some stuff manualy… can this be automated from cmake? I need to set follo…

---

## [Multiple shared libs, alternative implementations of common interface, \*minimal\* cmake/c++ example?](https://discourse.cmake.org/t/multiple-shared-libs-alternative-implementations-of-common-interface-minimal-cmake-c-example/15161)

<div class="topic-metadata">

**Author:** [@dunc](https://discourse.cmake.org/u/dunc)\
**Replies:** 5\
**Last updated:** [February 20, 2026, 3:10am UTC](https://discourse.cmake.org/t/multiple-shared-libs-alternative-implementations-of-common-interface-minimal-cmake-c-example/15161 "2026-02-20T03:10:11Z")

</div>

Hi all, new user here, my name is Jörg, but I usually go as “dunc” online… this is my first post here, and it’s really more of a very generic/basic cmake tutorial question, so you gents might consider it “too basic”. Th…

---

## [Retrieving compile definitions with genex evaluated](https://discourse.cmake.org/t/retrieving-compile-definitions-with-genex-evaluated/9425)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 7\
**Last updated:** [February 20, 2026, 3:04am UTC](https://discourse.cmake.org/t/retrieving-compile-definitions-with-genex-evaluated/9425 "2026-02-20T03:04:27Z")

</div>

I have a build which uses the unifdef tool and hence is dependent on having the compile definitions for built targets available as input to this. Now that I was adding the compile definitions using genexes I’d like to le…

---

## [Find module variables naming conventions](https://discourse.cmake.org/t/find-module-variables-naming-conventions/13266)

<div class="topic-metadata">

**Author:** [@petk](https://discourse.cmake.org/u/petk)\
**Replies:** 4\
**Last updated:** [February 20, 2026, 3:00am UTC](https://discourse.cmake.org/t/find-module-variables-naming-conventions/13266 "2026-02-20T03:00:33Z")

</div>

Hello, Apologies for asking so many questions lately. This community has been of enormous help so I have another question about find modules. In CMake there is trend to use find modules like this: find\_package(Foobar)…

---

## [CMake not building module partition that builds with command lines](https://discourse.cmake.org/t/cmake-not-building-module-partition-that-builds-with-command-lines/13758)

<div class="topic-metadata">

**Author:** [@rmerriam](https://discourse.cmake.org/u/rmerriam)\
**Replies:** 6\
**Last updated:** [February 19, 2026, 9:53pm UTC](https://discourse.cmake.org/t/cmake-not-building-module-partition-that-builds-with-command-lines/13758 "2026-02-19T21:53:33Z")

</div>

I am encountering this problem with CMake on Ubuntu 24.04, Clang 19, GCC 14 and CLion 2024.3.4. These are examples for talk and book so the partition module needs to be done with an MIU and implementation file. Other non…

---

## [How to correctly generate compile\_commands.json for library dependency using PkgConfig?](https://discourse.cmake.org/t/how-to-correctly-generate-compile-commands-json-for-library-dependency-using-pkgconfig/15135)

<div class="topic-metadata">

**Author:** [@skittishdev](https://discourse.cmake.org/u/skittishdev)\
**Replies:** 3\
**Last updated:** [February 19, 2026, 9:01pm UTC](https://discourse.cmake.org/t/how-to-correctly-generate-compile-commands-json-for-library-dependency-using-pkgconfig/15135 "2026-02-19T21:01:24Z")

</div>

Hi, I am on MacOS, and I use nix as my package manager. I am building a C project, and I’d like to use Criterion for my tests. I am able to build my project and run the tests, but my compile\_commands.json file is not ge…

---

## [Is setting empty-named variable defined behaviour?](https://discourse.cmake.org/t/is-setting-empty-named-variable-defined-behaviour/15305)

<div class="topic-metadata">

**Author:** [@Angew](https://discourse.cmake.org/u/Angew)\
**Replies:** 2\
**Last updated:** [February 19, 2026, 8:52pm UTC](https://discourse.cmake.org/t/is-setting-empty-named-variable-defined-behaviour/15305 "2026-02-19T20:52:51Z")

</div>

Hi all. Short version: set("" value PARENT\_SCOPE) currently works, and does nothing. Is that behaviour well-defined and can it be relied on? Long version: I’m simplifying some CMake code in a project and there are se…

---

## [Why \`ARGV\` got \`aa;"bb"\` when I call \`func("aa";"bb")\`?](https://discourse.cmake.org/t/why-argv-got-aa-bb-when-i-call-func-aa-bb/15325)

<div class="topic-metadata">

**Author:** [@dingcurie](https://discourse.cmake.org/u/dingcurie)\
**Replies:** 3\
**Last updated:** [February 19, 2026, 8:49pm UTC](https://discourse.cmake.org/t/why-argv-got-aa-bb-when-i-call-func-aa-bb/15325 "2026-02-19T20:49:20Z")

</div>

Why the following code outputs aa;”bb”, instead of aa;bb or “aa”;”bb”? function(func) message("${ARGV}") endfunction() func("aa";"bb")

---

## [Where can a project install its CMake modules when using CPS](https://discourse.cmake.org/t/where-can-a-project-install-its-cmake-modules-when-using-cps/15515)

<div class="topic-metadata">

**Author:** [@petk](https://discourse.cmake.org/u/petk)\
**Replies:** 2\
**Last updated:** [February 18, 2026, 9:52pm UTC](https://discourse.cmake.org/t/where-can-a-project-install-its-cmake-modules-when-using-cps/15515 "2026-02-18T21:52:30Z")

</div>

This is a follow-up question to Where can a project install its CMake modules To briefly describe the issue again: Main project provides CMake modules and configuration that extensions (built as separate projects) need…

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

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