# Code

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

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

**Page:** 11

---

## [CMAKE\_HIP\_KNOWN\_FEATURES](https://discourse.cmake.org/t/cmake-hip-known-features/10907)

<div class="topic-metadata">

**Author:** [@elliottslaughter](https://discourse.cmake.org/u/elliottslaughter)\
**Replies:** 2\
**Last updated:** [March 13, 2025, 6:48pm UTC](https://discourse.cmake.org/t/cmake-hip-known-features/10907 "2025-03-13T18:48:15Z")

</div>

Apparently, we have: https://cmake.org/cmake/help/latest/prop\_gbl/CMAKE\_CXX\_KNOWN\_FEATURES.html and https://cmake.org/cmake/help/latest/prop\_gbl/CMAKE\_CUDA\_KNOWN\_FEATURES.html but there is no equivalent for HIP. Is …

---

## [CMAKE MODULE TO FATAL ERROR MUTUALLY EXCLUSIVE OPTIONS](https://discourse.cmake.org/t/cmake-module-to-fatal-error-mutually-exclusive-options/10911)

<div class="topic-metadata">

**Author:** [@mredenti](https://discourse.cmake.org/u/mredenti)\
**Replies:** 1\
**Last updated:** [March 13, 2025, 6:24pm UTC](https://discourse.cmake.org/t/cmake-module-to-fatal-error-mutually-exclusive-options/10911 "2025-03-13T18:24:16Z")

</div>

I would like to set three mutually exclusive options in CMake where an error is raised if more than one of the three options is enables option(TPL\_ENABLE\_MPI "enable MPI" OFF) option(TPL\_ENABLE\_FFTW "enable Fast Fourier…

---

## [C++ Header Files and Dependency Management in CMake](https://discourse.cmake.org/t/c-header-files-and-dependency-management-in-cmake/10909)

<div class="topic-metadata">

**Author:** [@mredenti](https://discourse.cmake.org/u/mredenti)\
**Replies:** 4\
**Last updated:** [March 13, 2025, 6:23pm UTC](https://discourse.cmake.org/t/c-header-files-and-dependency-management-in-cmake/10909 "2025-03-13T18:23:16Z")

</div>

When creating targets in CMake using the add\_executable or add\_library commands, do I need to explicitly specify header files in order to create the dependency tree for automatic build triggering, or does CMake handle th…

---

## [CPack Debian Packaging and RUNPATH/RPATH for dependencies picked up from IMPORTED\_RUNTIME\_ARTIFACTS](https://discourse.cmake.org/t/cpack-debian-packaging-and-runpath-rpath-for-dependencies-picked-up-from-imported-runtime-artifacts/8721)

<div class="topic-metadata">

**Author:** [@Joel](https://discourse.cmake.org/u/Joel)\
**Replies:** 1\
**Last updated:** [March 13, 2025, 3:32pm UTC](https://discourse.cmake.org/t/cpack-debian-packaging-and-runpath-rpath-for-dependencies-picked-up-from-imported-runtime-artifacts/8721 "2025-03-13T15:32:33Z")

</div>

Hi, I’m trying to get cmake to package my Linux executable (+ dependent libraries) as a deb package. The executable should live in /opt/foo/bin and the libraries it depends on should live in /opt/foo/lib. However, I’m…

---

## [How to manage hierarchical dependencies ?](https://discourse.cmake.org/t/how-to-manage-hierarchical-dependencies/13637)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 1\
**Last updated:** [March 13, 2025, 8:23am UTC](https://discourse.cmake.org/t/how-to-manage-hierarchical-dependencies/13637 "2025-03-13T08:23:44Z")

</div>

Hello, We have some internal pieces of codes we have to organize as static library/libraries. This code could be splitted as several libraries, organizes as a hierarchy, or put in only one library. If tend to choose th…

---

## [Escape hell, and how to escape it](https://discourse.cmake.org/t/escape-hell-and-how-to-escape-it/13737)

<div class="topic-metadata">

**Author:** [@w3sip](https://discourse.cmake.org/u/w3sip)\
**Replies:** 2\
**Last updated:** [March 12, 2025, 10:46pm UTC](https://discourse.cmake.org/t/escape-hell-and-how-to-escape-it/13737 "2025-03-12T22:46:12Z")

</div>

I’m trying to make the following code work: foreach(module ${CXXMODULES}) set(MODULE\_MAP\_FLAGS "") string(APPEND MODULE\_MAP\_FLAGS ";-Xcc;-fmodule-map-file=${MODULE\_SOURCE\_DIR}/module.modulemap") …

---

## [Add cpp files from sub directories in target\_sources or not](https://discourse.cmake.org/t/add-cpp-files-from-sub-directories-in-target-sources-or-not/13708)

<div class="topic-metadata">

**Author:** [@JVApen](https://discourse.cmake.org/u/JVApen)\
**Replies:** 1\
**Last updated:** [March 12, 2025, 8:23pm UTC](https://discourse.cmake.org/t/add-cpp-files-from-sub-directories-in-target-sources-or-not/13708 "2025-03-12T20:23:46Z")

</div>

We are moving from some build system to CMake for a large project. We have everything working, though we are now cleaning up some stuff. Currently we have something like: target\_sources(target\_o PRIVATE very/long/…

---

## [Silent installation of NSIS installer from CPACK with modifying PATH](https://discourse.cmake.org/t/silent-installation-of-nsis-installer-from-cpack-with-modifying-path/13720)

<div class="topic-metadata">

**Author:** [@t-b](https://discourse.cmake.org/u/t-b)\
**Replies:** 0\
**Last updated:** [March 11, 2025, 1:45pm UTC](https://discourse.cmake.org/t/silent-installation-of-nsis-installer-from-cpack-with-modifying-path/13720 "2025-03-11T13:45:04Z")

</div>

I’ve created an NSIS installer via cmake/cpack for a command line application on Windows. It has the setting set(CPACK\_NSIS\_MODIFY\_PATH ON) so it allows the interactive user to add the installation location to the PATH v…

---

## [Linking shared library fails on MacOS](https://discourse.cmake.org/t/linking-shared-library-fails-on-macos/13706)

<div class="topic-metadata">

**Author:** [@shmuel](https://discourse.cmake.org/u/shmuel)\
**Replies:** 0\
**Last updated:** [March 9, 2025, 9:09pm UTC](https://discourse.cmake.org/t/linking-shared-library-fails-on-macos/13706 "2025-03-09T21:09:45Z")

</div>

There are 2 targets (the code is simplified): far2m - an executable that also exports symbols, e.g. if(${CMAKE\_SYSTEM\_NAME} MATCHES "Darwin") add\_executable(far2m MACOSX\_BUNDLE ${SOURCES} "DE/Far.icns") else() …

---

## [C++20 modules API example](https://discourse.cmake.org/t/c-20-modules-api-example/7303)

<div class="topic-metadata">

**Author:** [@scivision](https://discourse.cmake.org/u/scivision)\
**Replies:** 4\
**Last updated:** [March 5, 2025, 9:12am UTC](https://discourse.cmake.org/t/c-20-modules-api-example/7303 "2025-03-05T09:12:55Z")

</div>

The recent Kitware CMake blog post on C++20 modules gives a standalone example for MSVC, GCC and Clang. Note that CMake \>= 3.25.3 (i.e. Nightly) is necessary for this to work. And to make it simple use MSVC if on Window…

---

## [Linking library to library...](https://discourse.cmake.org/t/linking-library-to-library/10854)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 5\
**Last updated:** [March 4, 2025, 9:17am UTC](https://discourse.cmake.org/t/linking-library-to-library/10854 "2025-03-04T09:17:38Z")

</div>

Hello, I am trying to do a hierarchy of static libraries : Executable → libC → libB → libA Each target retrieves the used library with FetchContent. The problem is that target\_link\_directories() and target\_link\_libra…

---

## [BUILD\_INTERFACE or INSTALL\_INTERFACE genex with target\_link\_libraries?](https://discourse.cmake.org/t/build-interface-or-install-interface-genex-with-target-link-libraries/10765)

<div class="topic-metadata">

**Author:** [@emaschino](https://discourse.cmake.org/u/emaschino)\
**Replies:** 1\
**Last updated:** [March 4, 2025, 9:09am UTC](https://discourse.cmake.org/t/build-interface-or-install-interface-genex-with-target-link-libraries/10765 "2025-03-04T09:09:11Z")

</div>

Hi, While BUILD\_INTERFACE and INSTALL\_INTERFACE are explicitely mentioned in target\_include\_directories documentation, they don’t appear in target\_link\_libraries documentation. I’m thus wondering if their use is valid …

---

## [Test C Compiler failing in Nix Shell because it can't find libclang\_rt](https://discourse.cmake.org/t/test-c-compiler-failing-in-nix-shell-because-it-cant-find-libclang-rt/10729)

<div class="topic-metadata">

**Author:** [@abalu](https://discourse.cmake.org/u/abalu)\
**Replies:** 1\
**Last updated:** [March 4, 2025, 9:03am UTC](https://discourse.cmake.org/t/test-c-compiler-failing-in-nix-shell-because-it-cant-find-libclang-rt/10729 "2025-03-04T09:03:04Z")

</div>

When I run cmake -GNinja I get the error /nix/store/vj57s3h2za2qrfccrvc9b6i7s8mw3ndn-binutils-2.41/bin/ld: cannot find /nix/store/r3cfvnc01wssfqhp5kg8725v94idkysy-clang-18.1.3/lib/clang/18/lib/linux/libclang\_rt.asan\_sta…

---

## [Combine two independent cmake projects into a single project](https://discourse.cmake.org/t/combine-two-independent-cmake-projects-into-a-single-project/10505)

<div class="topic-metadata">

**Author:** [@Adwait\_Naik](https://discourse.cmake.org/u/Adwait_Naik)\
**Replies:** 1\
**Last updated:** [March 4, 2025, 9:01am UTC](https://discourse.cmake.org/t/combine-two-independent-cmake-projects-into-a-single-project/10505 "2025-03-04T09:01:12Z")

</div>

So I’ve two projects Azure C++ IOT SDK(used to send robot data like joint angles and positions to IotHub) and libfranka(used to interact with the robotic arm). The purpose is to real-time data or telemetry from the robo…

---

## [Integrating CSharp unit tests with add\_test](https://discourse.cmake.org/t/integrating-csharp-unit-tests-with-add-test/10288)

<div class="topic-metadata">

**Author:** [@Nino\_Stanusic](https://discourse.cmake.org/u/Nino_Stanusic)\
**Replies:** 1\
**Last updated:** [March 3, 2025, 4:04pm UTC](https://discourse.cmake.org/t/integrating-csharp-unit-tests-with-add-test/10288 "2025-03-03T16:04:58Z")

</div>

Hello everytone, The goal: I want to achieve csharp unit testing alongside C++ tests in cmake. we have a C++ project that uses the UseSWIG module to generate our C# bindings. And we would like to test them. The curre…

---

## [Difficulty importing a library](https://discourse.cmake.org/t/difficulty-importing-a-library/13663)

<div class="topic-metadata">

**Author:** [@CBreak](https://discourse.cmake.org/u/CBreak)\
**Replies:** 4\
**Last updated:** [March 2, 2025, 11:00pm UTC](https://discourse.cmake.org/t/difficulty-importing-a-library/13663 "2025-03-02T23:00:30Z")

</div>

Hi, as will be apparent I am new to using CMake. I’m using CLion in Windows with the visual studio 2019 toolchain, and I’m trying to import a library to use and I’m having trouble. The library is copied to the top of th…

---

## [CMake with Boost and policy CMP0167](https://discourse.cmake.org/t/cmake-with-boost-and-policy-cmp0167/13613)

<div class="topic-metadata">

**Author:** [@rwan](https://discourse.cmake.org/u/rwan)\
**Replies:** 6\
**Last updated:** [March 1, 2025, 7:15pm UTC](https://discourse.cmake.org/t/cmake-with-boost-and-policy-cmp0167/13613 "2025-03-01T19:15:05Z")

</div>

Hi all, I have seen various posts across the Internet about getting CMake to work with Boost 1.70+ and it seems like everyone has an easier time than I am. I think I must be doing something wrong. So, I am using CMake…

---

## [Linking a dll to an other dll with DllMain](https://discourse.cmake.org/t/linking-a-dll-to-an-other-dll-with-dllmain/13653)

<div class="topic-metadata">

**Author:** [@bcafarth](https://discourse.cmake.org/u/bcafarth)\
**Replies:** 0\
**Last updated:** [February 28, 2025, 3:10pm UTC](https://discourse.cmake.org/t/linking-a-dll-to-an-other-dll-with-dllmain/13653 "2025-02-28T15:10:27Z")

</div>

Hello, I have a main, and I can link a library (Called DynLib) to that main, dynamically (SHARED). Now I have another library (Called SubDynLib), that i want to link to DynLib. If I build SubDynLib alone, and then put t…

---

## [Concurrent Pythons for different things in same project](https://discourse.cmake.org/t/concurrent-pythons-for-different-things-in-same-project/13650)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 1\
**Last updated:** [February 27, 2025, 9:29pm UTC](https://discourse.cmake.org/t/concurrent-pythons-for-different-things-in-same-project/13650 "2025-02-27T21:29:06Z")

</div>

Crosscompiling a Poky toolchain that comes with its own python (2) to perform setup/relocation. Later in the project we have internal processes requiring a recent Python 3. The Python3 we have is incompatible with the t…

---

## [Disable Fetch Content lib and header file Installation](https://discourse.cmake.org/t/disable-fetch-content-lib-and-header-file-installation/13646)

<div class="topic-metadata">

**Author:** [@acraft](https://discourse.cmake.org/u/acraft)\
**Replies:** 1\
**Last updated:** [February 27, 2025, 10:32am UTC](https://discourse.cmake.org/t/disable-fetch-content-lib-and-header-file-installation/13646 "2025-02-27T10:32:47Z")

</div>

Hello, I use FetchContent and can build and link the libraries I need. When I install my project, I would like to skip or control library installations. For the following example, what is the right way to skip library …

---

## [Linkin an imported library](https://discourse.cmake.org/t/linkin-an-imported-library/13636)

<div class="topic-metadata">

**Author:** [@noahdav](https://discourse.cmake.org/u/noahdav)\
**Replies:** 1\
**Last updated:** [February 26, 2025, 4:50pm UTC](https://discourse.cmake.org/t/linkin-an-imported-library/13636 "2025-02-26T16:50:09Z")

</div>

Hi, Let me start off by saying that I have some 3ed party code that I do not want to modify if possible. We are trying to move to use the Ninja generators from visual studio generators. I have ran into a problem with …

---

## [Running target from post build](https://discourse.cmake.org/t/running-target-from-post-build/13624)

<div class="topic-metadata">

**Author:** [@noahdav](https://discourse.cmake.org/u/noahdav)\
**Replies:** 4\
**Last updated:** [February 26, 2025, 12:25pm UTC](https://discourse.cmake.org/t/running-target-from-post-build/13624 "2025-02-26T12:25:53Z")

</div>

Hi, I am trying to get a project to invoke a target after the build completes. I do not want a separate target but instead the target should be invoked after the build completes (compile and link). In my case we do so…

---

## [Tips on project organization](https://discourse.cmake.org/t/tips-on-project-organization/13627)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 0\
**Last updated:** [February 24, 2025, 10:26pm UTC](https://discourse.cmake.org/t/tips-on-project-organization/13627 "2025-02-24T22:26:21Z")

</div>

Sorry for an open-ended question, but I’m interested in tips on how to organize a medium sized cmake project in a structed way (or tips of good cmake projects to be inspired by). More concretely it seems a lot of projec…

---

## [specifying dependency between two third-party libraries](https://discourse.cmake.org/t/specifying-dependency-between-two-third-party-libraries/13620)

<div class="topic-metadata">

**Author:** [@Roberto\_Putzu](https://discourse.cmake.org/u/Roberto_Putzu)\
**Replies:** 0\
**Last updated:** [February 22, 2025, 6:56pm UTC](https://discourse.cmake.org/t/specifying-dependency-between-two-third-party-libraries/13620 "2025-02-22T18:56:42Z")

</div>

Dear All, I’ve starting using cmake only a couple of days ago to upgrade the build system (Makefiles pretty much) of my Fortran projects. I’ve run into the problem described below and apparently it has not been treated…

---

## [Checking macOS SDK version with Xcode generator on CMake 4.0?](https://discourse.cmake.org/t/checking-macos-sdk-version-with-xcode-generator-on-cmake-4-0/13618)

<div class="topic-metadata">

**Author:** [@jcm](https://discourse.cmake.org/u/jcm)\
**Replies:** 0\
**Last updated:** [February 22, 2025, 4:15pm UTC](https://discourse.cmake.org/t/checking-macos-sdk-version-with-xcode-generator-on-cmake-4-0/13618 "2025-02-22T16:15:41Z")

</div>

It seems that when using the Xcode generator with CMake 4.0, CMAKE\_OSX\_SYSROOT is no longer set at any point in the configuration/generation process by default. Previously, we would use the value of this variable to veri…

---

## [Adding support for go](https://discourse.cmake.org/t/adding-support-for-go/13518)

<div class="topic-metadata">

**Author:** [@noahdav](https://discourse.cmake.org/u/noahdav)\
**Replies:** 2\
**Last updated:** [February 21, 2025, 5:46pm UTC](https://discourse.cmake.org/t/adding-support-for-go/13518 "2025-02-21T17:46:54Z")

</div>

Hi we have some go projects that we need to build. We have ben using custom commands which calls go build and custom targets to like them together. For the most part this works but our post build scripts (signing, inst…

---

## [Building C++ modules with GCC and Clang for presentatoins](https://discourse.cmake.org/t/building-c-modules-with-gcc-and-clang-for-presentatoins/13601)

<div class="topic-metadata">

**Author:** [@rmerriam](https://discourse.cmake.org/u/rmerriam)\
**Replies:** 1\
**Last updated:** [February 20, 2025, 6:40pm UTC](https://discourse.cmake.org/t/building-c-modules-with-gcc-and-clang-for-presentatoins/13601 "2025-02-20T18:40:38Z")

</div>

I’m working on a presentation about C++ modules using CMake to build them. Here are my two CMakeLists.txt files for GCC which works fine. What changes for Clang? Any improvements on the overall CMake code so it is good …

---

## [Getting CMake error regarding add\_subdirectory()](https://discourse.cmake.org/t/getting-cmake-error-regarding-add-subdirectory/13610)

<div class="topic-metadata">

**Author:** [@nishantrana](https://discourse.cmake.org/u/nishantrana)\
**Replies:** 2\
**Last updated:** [February 20, 2025, 9:28am UTC](https://discourse.cmake.org/t/getting-cmake-error-regarding-add-subdirectory/13610 "2025-02-20T09:28:20Z")

</div>

Getting the following error when trying to bazel build jpegli using CMake. I can see that after downloading via http\_archive, tools folder is there in the downloaded folder but not present in the sandbox folder. Not sure…

---

## [How to handle manpages that have multiple items?](https://discourse.cmake.org/t/how-to-handle-manpages-that-have-multiple-items/13567)

<div class="topic-metadata">

**Author:** [@rsalz](https://discourse.cmake.org/u/rsalz)\
**Replies:** 8\
**Last updated:** [February 18, 2025, 9:39pm UTC](https://discourse.cmake.org/t/how-to-handle-manpages-that-have-multiple-items/13567 "2025-02-18T21:39:18Z")

</div>

man malloc, man realloc, etc., all point to the same page – they’re ln’d together. How do I handle it in cmake?

---

## [Question re. CMAKE\_BUILD\_WITH\_INSTALL\_RPATH](https://discourse.cmake.org/t/question-re-cmake-build-with-install-rpath/13568)

<div class="topic-metadata">

**Author:** [@poldi](https://discourse.cmake.org/u/poldi)\
**Replies:** 6\
**Last updated:** [February 18, 2025, 9:18am UTC](https://discourse.cmake.org/t/question-re-cmake-build-with-install-rpath/13568 "2025-02-18T09:18:31Z")

</div>

I’m trying to build a product and am getting the following error CMake Error at CMakeLists.txt:410 (add\_executable): \[cmake\] The install of the strawberry target requires changing an RPATH from the \[cmake\] build tree, b…

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

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