# Code

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

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

**Page:** 6

---

## [using cmake causing rdynamic in link.txt](https://discourse.cmake.org/t/using-cmake-causing-rdynamic-in-link-txt/15263)

<div class="topic-metadata">

**Author:** [@ggcmk900](https://discourse.cmake.org/u/ggcmk900)\
**Replies:** 1\
**Last updated:** [October 26, 2025, 9:22am UTC](https://discourse.cmake.org/t/using-cmake-causing-rdynamic-in-link-txt/15263 "2025-10-26T09:22:54Z")

</div>

Can someone point out why cmake is introducing -rdynamic in linker file? link.txt. This is causing nvcc linker to file. I know cmake is causing it because if I dont use cmake (shell script), it does not exhibit this pro…

---

## [Detect a variable changed between configure runs](https://discourse.cmake.org/t/detect-a-variable-changed-between-configure-runs/15264)

<div class="topic-metadata">

**Author:** [@risto](https://discourse.cmake.org/u/risto)\
**Replies:** 2\
**Last updated:** [October 26, 2025, 7:42am UTC](https://discourse.cmake.org/t/detect-a-variable-changed-between-configure-runs/15264 "2025-10-26T07:42:35Z")

</div>

Hello, I am trying to detect if a variable in the CMakeLists.txt was changed compared to the previous configure run. At first I tried using the cache variables, but it didn’t work, then I tried writing it to a file lik…

---

## [The trace section of CMake configurePresets has no effect?](https://discourse.cmake.org/t/the-trace-section-of-cmake-configurepresets-has-no-effect/15259)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 6\
**Last updated:** [October 25, 2025, 7:21am UTC](https://discourse.cmake.org/t/the-trace-section-of-cmake-configurepresets-has-no-effect/15259 "2025-10-25T07:21:43Z")

</div>

I have this CMakePresets.jsonfile { "version": 8, "cmakeMinimumRequired": { "major": 3, "minor": 28, "patch": 0 }, "configurePresets": \[ { "name": "cmake-pedantic", "hidden": true, …

---

## [C# SDK style projects Any CPU](https://discourse.cmake.org/t/c-sdk-style-projects-any-cpu/5913)

<div class="topic-metadata">

**Author:** [@mattsnowboard](https://discourse.cmake.org/u/mattsnowboard)\
**Replies:** 6\
**Last updated:** [October 21, 2025, 10:08pm UTC](https://discourse.cmake.org/t/c-sdk-style-projects-any-cpu/5913 "2025-10-21T22:08:22Z")

</div>

I can now generate SDK style projects for my C# projects in my c++/C# program. This has enabled me to use .NET6, which is nice. But my one problem is that the sln file generated for Visual Studio forces all of the proje…

---

## [Cycle Warning in CMake output](https://discourse.cmake.org/t/cycle-warning-in-cmake-output/15258)

<div class="topic-metadata">

**Author:** [@imikejackson](https://discourse.cmake.org/u/imikejackson)\
**Replies:** 1\
**Last updated:** [October 21, 2025, 4:50pm UTC](https://discourse.cmake.org/t/cycle-warning-in-cmake-output/15258 "2025-10-21T16:50:25Z")

</div>

I am starting to get lots of the following warnings when configuring our project: CMake Warning at /opt/local/vcpkg/scripts/buildsystems/vcpkg.cmake:649 (\_add\_library): Cannot generate a safe runtime search path for ta…

---

## [Is there a provided abstraction for LLVM tools like llvm-profdata?](https://discourse.cmake.org/t/is-there-a-provided-abstraction-for-llvm-tools-like-llvm-profdata/15255)

<div class="topic-metadata">

**Author:** [@david-fong](https://discourse.cmake.org/u/david-fong)\
**Replies:** 0\
**Last updated:** [October 20, 2025, 11:53am UTC](https://discourse.cmake.org/t/is-there-a-provided-abstraction-for-llvm-tools-like-llvm-profdata/15255 "2025-10-20T11:53:53Z")

</div>

I know there are some variables like CMAKE\_AR that could be set by a toolchain. Are there any such variables for LLVM tools like llvm-profdata? I’m working on PGO builds and this would be useful for that. I also see that…

---

## [Should a change to CMAKE\_PREFIX\_PATH invalidate find\_package()](https://discourse.cmake.org/t/should-a-change-to-cmake-prefix-path-invalidate-find-package/15249)

<div class="topic-metadata">

**Author:** [@pboettch](https://discourse.cmake.org/u/pboettch)\
**Replies:** 3\
**Last updated:** [October 19, 2025, 1:31am UTC](https://discourse.cmake.org/t/should-a-change-to-cmake-prefix-path-invalidate-find-package/15249 "2025-10-19T01:31:24Z")

</div>

In a super-build I’m switching sub-cmake-project’s CMAKE\_PREFIX\_PATH to different versions of my support packages. However, when changing from one version to another, the cmake-configure-step is executed, but the find\_p…

---

## [Bracket arguments feature broken?](https://discourse.cmake.org/t/bracket-arguments-feature-broken/15250)

<div class="topic-metadata">

**Author:** [@Renek](https://discourse.cmake.org/u/Renek)\
**Replies:** 6\
**Last updated:** [October 16, 2025, 12:00pm UTC](https://discourse.cmake.org/t/bracket-arguments-feature-broken/15250 "2025-10-16T12:00:09Z")

</div>

I’m reading the documentation and came across the bracket argument example here. However, the example does not even work and I’m getting an error: CMake Error at RGFramework/CMakeLists.txt:10: Parse error. Expected a …

---

## [CMAKE\_AUTO{MOC,RCC,UIC}\_EXECUTABLE behavior in older versions of cmake](https://discourse.cmake.org/t/cmake-auto-moc-rcc-uic-executable-behavior-in-older-versions-of-cmake/15239)

<div class="topic-metadata">

**Author:** [@sergeniously](https://discourse.cmake.org/u/sergeniously)\
**Replies:** 4\
**Last updated:** [October 15, 2025, 8:43am UTC](https://discourse.cmake.org/t/cmake-auto-moc-rcc-uic-executable-behavior-in-older-versions-of-cmake/15239 "2025-10-15T08:43:01Z")

</div>

For some reasons I cannot use find\_package to configure Qt5 in my project. In last versions of cmake I just could write something like that set(CMAKE\_AUTOMOC\_EXECUTABLE "${QT\_BIN\_DIR}/moc") set(CMAKE\_AUTOUIC\_EXECUTABLE…

---

## [Passing complie definitions to a include\_external\_msproject target](https://discourse.cmake.org/t/passing-complie-definitions-to-a-include-external-msproject-target/15233)

<div class="topic-metadata">

**Author:** [@Tarun](https://discourse.cmake.org/u/Tarun)\
**Replies:** 0\
**Last updated:** [October 11, 2025, 8:30am UTC](https://discourse.cmake.org/t/passing-complie-definitions-to-a-include-external-msproject-target/15233 "2025-10-11T08:30:54Z")

</div>

I have an external csproj which I want build in both linux and windows alongside other regular targets(non-custom targets) that are created using cmake. The idea was to create a custom target and use dotnet 8.0 and it’s …

---

## [Why would cmake reject an available SDL2Config.cmake?](https://discourse.cmake.org/t/why-would-cmake-reject-an-available-sdl2config-cmake/15213)

<div class="topic-metadata">

**Author:** [@Joymaker](https://discourse.cmake.org/u/Joymaker)\
**Replies:** 3\
**Last updated:** [October 9, 2025, 6:03pm UTC](https://discourse.cmake.org/t/why-would-cmake-reject-an-available-sdl2config-cmake/15213 "2025-10-09T18:03:28Z")

</div>

I’m trying to build my game with SDL2 on Windows, and a build that used to work has quit working. It is now rejecting the available SDL2Config.cmake with this message: \[{ “resource”: “/c:/Users/ken/Desktop/prog24/HallO…

---

## [Adding libraries from FetchContent to find\_package lookup?](https://discourse.cmake.org/t/adding-libraries-from-fetchcontent-to-find-package-lookup/15214)

<div class="topic-metadata">

**Author:** [@nerudaj](https://discourse.cmake.org/u/nerudaj)\
**Replies:** 13\
**Last updated:** [October 9, 2025, 5:58pm UTC](https://discourse.cmake.org/t/adding-libraries-from-fetchcontent-to-find-package-lookup/15214 "2025-10-09T17:58:15Z")

</div>

I am trying to understand the underlying mechanisms behind dependency management in CMake, particularly with regards to FetchContent. FetchContent can be set up to first call find\_package and if that doesn’t find anythin…

---

## [CUDA CCCL integration](https://discourse.cmake.org/t/cuda-cccl-integration/15229)

<div class="topic-metadata">

**Author:** [@jwm](https://discourse.cmake.org/u/jwm)\
**Replies:** 4\
**Last updated:** [October 9, 2025, 3:45pm UTC](https://discourse.cmake.org/t/cuda-cccl-integration/15229 "2025-10-09T15:45:53Z")

</div>

I recently tried to upgrade my CUDA version from 12.8.0 to 13.1 (then dropped back to 12.9.1). Apparently I’ve been hit by the upgrade to the CCCL. My immediate symptom is that \<thrust/xxx\> is no longer found. At the sa…

---

## [ExternalProject logging mystery](https://discourse.cmake.org/t/externalproject-logging-mystery/15226)

<div class="topic-metadata">

**Author:** [@sergeniously](https://discourse.cmake.org/u/sergeniously)\
**Replies:** 1\
**Last updated:** [October 9, 2025, 3:23am UTC](https://discourse.cmake.org/t/externalproject-logging-mystery/15226 "2025-10-09T03:23:43Z")

</div>

Look at this: ExternalProject\_Add(boost PATCH\_COMMAND echo "using gcc : ${CMAKE\_SYSTEM\_PROCESSOR} : ${CMAKE\_CXX\_COMPILER\_CMD} $\<SEMICOLON\>" \> \<SOURCE\_DIR\>/user-config.jam LOG\_PATCH OFF ... ) This works well. Now lo…

---

## [CMake CUDA opinions](https://discourse.cmake.org/t/cmake-cuda-opinions/13160)

<div class="topic-metadata">

**Author:** [@eduardz1](https://discourse.cmake.org/u/eduardz1)\
**Replies:** 1\
**Last updated:** [October 8, 2025, 8:01pm UTC](https://discourse.cmake.org/t/cmake-cuda-opinions/13160 "2025-10-08T20:01:46Z")

</div>

This is a cross post from the CUDA discourse, it was suggested that I ask here instead. I have a repository that is structured in this way, following the example from ModernCMake - Extended example. I’m replacing with .…

---

## [Project root folder CMakeLists file being ignored when trying to build Windows desktop app](https://discourse.cmake.org/t/project-root-folder-cmakelists-file-being-ignored-when-trying-to-build-windows-desktop-app/15228)

<div class="topic-metadata">

**Author:** [@shrink\_tubing](https://discourse.cmake.org/u/shrink_tubing)\
**Replies:** 3\
**Last updated:** [October 8, 2025, 6:55pm UTC](https://discourse.cmake.org/t/project-root-folder-cmakelists-file-being-ignored-when-trying-to-build-windows-desktop-app/15228 "2025-10-08T18:55:12Z")

</div>

Hi there, I have interesting dilemma. I’m following this book: “Modern Cmake for C++” authored by Rafal Swidzinski - and in the chapter where they’re discussing the proper partitioning and organisation of a project the …

---

## [VSCode formatting issue on .h.in file](https://discourse.cmake.org/t/vscode-formatting-issue-on-h-in-file/9838)

<div class="topic-metadata">

**Author:** [@KRISCHOMAT](https://discourse.cmake.org/u/KRISCHOMAT)\
**Replies:** 3\
**Last updated:** [October 5, 2025, 10:00pm UTC](https://discourse.cmake.org/t/vscode-formatting-issue-on-h-in-file/9838 "2025-10-05T22:00:55Z")

</div>

I just started the cmake tutorial and ran into an issue. When I want to set the .h.in file to #define Tutorial\_VERSION\_MAJOR @Tutorial\_VERSION\_MAJOR@ #define Tutorial\_VERSION\_MINOR @Tutorial\_VERSION\_MINOR@ and then sa…

---

## [Passing list variables to external project commands](https://discourse.cmake.org/t/passing-list-variables-to-external-project-commands/15210)

<div class="topic-metadata">

**Author:** [@sergeniously](https://discourse.cmake.org/u/sergeniously)\
**Replies:** 3\
**Last updated:** [October 3, 2025, 12:28pm UTC](https://discourse.cmake.org/t/passing-list-variables-to-external-project-commands/15210 "2025-10-03T12:28:18Z")

</div>

Hello, everyone. For some reason in my project I need to set a compiler launcher this way: set(CMAKE\_C\_COMPILER\_LAUNCHER env DIR=/path/to/dir) But when I try to configure an external cmake project with the same launch…

---

## [configure\_file in add\_custom\_command?](https://discourse.cmake.org/t/configure-file-in-add-custom-command/15207)

<div class="topic-metadata">

**Author:** [@sdbbs](https://discourse.cmake.org/u/sdbbs)\
**Replies:** 1\
**Last updated:** [October 3, 2025, 11:35am UTC](https://discourse.cmake.org/t/configure-file-in-add-custom-command/15207 "2025-10-03T11:35:57Z")

</div>

In a CMakeLists.txt of a project of mine, I had a configure\_file that converted MyHeader.h.in to MyHeader.h while doing transformations of CMake variables - and that worked great. My problem now is that I ended up gener…

---

## [Question about Xcode project generator for Frameworks, Libraries and Embedded Content](https://discourse.cmake.org/t/question-about-xcode-project-generator-for-frameworks-libraries-and-embedded-content/15100)

<div class="topic-metadata">

**Author:** [@Seto](https://discourse.cmake.org/u/Seto)\
**Replies:** 1\
**Last updated:** [September 30, 2025, 6:20pm UTC](https://discourse.cmake.org/t/question-about-xcode-project-generator-for-frameworks-libraries-and-embedded-content/15100 "2025-09-30T18:20:41Z")

</div>

Hi. For static libraries, I found that the .a files are added as Other Linker Flags instead of adding them to Frameworks, Libraries and Embedded Content in General tab of Xcode projects if I use target\_link\_libraries(). …

---

## [How to set ZLIB\_ROOT](https://discourse.cmake.org/t/how-to-set-zlib-root/9765)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 5\
**Last updated:** [September 30, 2025, 4:33pm UTC](https://discourse.cmake.org/t/how-to-set-zlib-root/9765 "2025-09-30T16:33:12Z")

</div>

Hello, I am trying to install/build the ZLib library on Windows through CMake, in order to install/use libpng afterwards. First of all, I am on Windows, and I can’t use a package manager as Conan or vcpkg. So I tried …

---

## [Undefined reference to "sin" and "crypt" errors prevent building of Wt project](https://discourse.cmake.org/t/undefined-reference-to-sin-and-crypt-errors-prevent-building-of-wt-project/15165)

<div class="topic-metadata">

**Author:** [@CFan](https://discourse.cmake.org/u/CFan)\
**Replies:** 5\
**Last updated:** [September 27, 2025, 2:19pm UTC](https://discourse.cmake.org/t/undefined-reference-to-sin-and-crypt-errors-prevent-building-of-wt-project/15165 "2025-09-27T14:19:52Z")

</div>

I have been trying to build Wt(a c++ web framework library) from source for days.I am trying to build it on a Vps with Ubuntu Linux 22.04 OS, using Clang 11 as compiler. It uses Cmake to build. I use: cmake .. -DCMAK…

---

## [What is the proper configuration-dependent location for files created by add\_custom\_target or add\_custom\_command?](https://discourse.cmake.org/t/what-is-the-proper-configuration-dependent-location-for-files-created-by-add-custom-target-or-add-custom-command/15198)

<div class="topic-metadata">

**Author:** [@AytonDew](https://discourse.cmake.org/u/AytonDew)\
**Replies:** 0\
**Last updated:** [September 25, 2025, 7:02pm UTC](https://discourse.cmake.org/t/what-is-the-proper-configuration-dependent-location-for-files-created-by-add-custom-target-or-add-custom-command/15198 "2025-09-25T19:02:31Z")

</div>

Hello, I have been struggling with intermediate directories and where to place temporary files during the build when running custom commands. Is there a configuration-dependent location that a custom command can create …

---

## [How to set SYSTEM property to included directories coming from AUTOMOC ?](https://discourse.cmake.org/t/how-to-set-system-property-to-included-directories-coming-from-automoc/14922)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 3\
**Last updated:** [September 26, 2025, 8:23am UTC](https://discourse.cmake.org/t/how-to-set-system-property-to-included-directories-coming-from-automoc/14922 "2025-09-26T08:23:15Z")

</div>

Hello, I use for C++: CMake 3.31.6 Qt 5.15 Visual Studio 2022 When using Qt and AUTOMOC, the relevant directory is automatically added to the included directories, without being declared/used in the CMakeLists.txt. B…

---

## [CMake-built executable is missing rpath for shared lib it uses](https://discourse.cmake.org/t/cmake-built-executable-is-missing-rpath-for-shared-lib-it-uses/15194)

<div class="topic-metadata">

**Author:** [@manuel](https://discourse.cmake.org/u/manuel)\
**Replies:** 3\
**Last updated:** [September 25, 2025, 7:37am UTC](https://discourse.cmake.org/t/cmake-built-executable-is-missing-rpath-for-shared-lib-it-uses/15194 "2025-09-25T07:37:14Z")

</div>

Greetings! I’m writing an application that links against a shared library libaes.so. libaes.so is available here: /usr/local/include/libaes/aes.hpp /usr/local/include/libaes/message.hpp /usr/local/include/libaes/octet\_…

---

## [Problems with the CMake files for CFITSIO](https://discourse.cmake.org/t/problems-with-the-cmake-files-for-cfitsio/13178)

<div class="topic-metadata">

**Author:** [@perdrix](https://discourse.cmake.org/u/perdrix)\
**Replies:** 7\
**Last updated:** [September 19, 2025, 11:08am UTC](https://discourse.cmake.org/t/problems-with-the-cmake-files-for-cfitsio/13178 "2025-09-19T11:08:52Z")

</div>

Not long ago I pulled down the CFITSIO repository and built it. The exact sequence of commands was: # # Download CFITSIO from \<https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-4.5.0.tar.gz\> # to your Downloa…

---

## [Order of defining variables and including CPack](https://discourse.cmake.org/t/order-of-defining-variables-and-including-cpack/15178)

<div class="topic-metadata">

**Author:** [@chriskot870](https://discourse.cmake.org/u/chriskot870)\
**Replies:** 7\
**Last updated:** [September 18, 2025, 3:04pm UTC](https://discourse.cmake.org/t/order-of-defining-variables-and-including-cpack/15178 "2025-09-18T15:04:28Z")

</div>

I am a bit confused regarding cpack\_add\_component() and various CPACK\_COMPONENT\_ in comparison to when CPack is included. I am just looking for some clarity here. It seems that cpack\_add\_component() essentially defines …

---

## [Cmake outputting release build in debug folder and doesnt apply compiler flags](https://discourse.cmake.org/t/cmake-outputting-release-build-in-debug-folder-and-doesnt-apply-compiler-flags/15170)

<div class="topic-metadata">

**Author:** [@Sifro](https://discourse.cmake.org/u/Sifro)\
**Replies:** 0\
**Last updated:** [September 17, 2025, 1:40am UTC](https://discourse.cmake.org/t/cmake-outputting-release-build-in-debug-folder-and-doesnt-apply-compiler-flags/15170 "2025-09-17T01:40:40Z")

</div>

Hello everyone, im trying to setup a two different build modes for my c++ project. Im fairly new to “low”level programming in general, and especially when it comes to compiling etc. so I appreciate every bit of help …

---

## [FetchContent issue finding a fetched project's transitive dependency](https://discourse.cmake.org/t/fetchcontent-issue-finding-a-fetched-projects-transitive-dependency/15163)

<div class="topic-metadata">

**Author:** [@tonh](https://discourse.cmake.org/u/tonh)\
**Replies:** 0\
**Last updated:** [September 11, 2025, 9:30am UTC](https://discourse.cmake.org/t/fetchcontent-issue-finding-a-fetched-projects-transitive-dependency/15163 "2025-09-11T09:30:23Z")

</div>

We have scenario where binary artifacts of a CMake project Foo are pulled in through FetchContent. The project has some transitive dependency Bar that is bundled within the project. The structure of the binary artifact o…

---

## [PATCH\_COMMAND with ExternalProject works but with FetchContent an error is triggered](https://discourse.cmake.org/t/patch-command-with-externalproject-works-but-with-fetchcontent-an-error-is-triggered/15157)

<div class="topic-metadata">

**Author:** [@snoriman](https://discourse.cmake.org/u/snoriman)\
**Replies:** 4\
**Last updated:** [September 10, 2025, 9:35pm UTC](https://discourse.cmake.org/t/patch-command-with-externalproject-works-but-with-fetchcontent-an-error-is-triggered/15157 "2025-09-10T21:35:44Z")

</div>

I’ve got a PATCH\_COMMAND which fails with FetchContent but works with ExternalProject. The only difference (I can see at least) is that I change FetchContent\_Declare to ExternalProject\_Add and remove FetchContent\_Make…

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

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