# Code

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

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

**Page:** 9

---

## [Python3\_INCLUDE\_DIRS does not exist](https://discourse.cmake.org/t/python3-include-dirs-does-not-exist/7324)

<div class="topic-metadata">

**Author:** [@2ft](https://discourse.cmake.org/u/2ft)\
**Replies:** 7\
**Last updated:** [June 19, 2025, 8:10pm UTC](https://discourse.cmake.org/t/python3-include-dirs-does-not-exist/7324 "2025-06-19T20:10:39Z")

</div>

Hi CMake, I am trying to use CMake (3.25) on Windows with Visual Studio (2022). I need to include Python3 in my project. When I try to build the project it complains that it cannot find “Python.h”. Both CMake and Pytho…

---

## [Support for reduced bmi in clang?](https://discourse.cmake.org/t/support-for-reduced-bmi-in-clang/14258)

<div class="topic-metadata">

**Author:** [@gracicot](https://discourse.cmake.org/u/gracicot)\
**Replies:** 4\
**Last updated:** [June 18, 2025, 8:28pm UTC](https://discourse.cmake.org/t/support-for-reduced-bmi-in-clang/14258 "2025-06-18T20:28:40Z")

</div>

Hi! Clang now has support for one phase compilation through -fmodules-reduced-bmi, just like GCC and MSVC does. Is there a way to use this new compiler feature in CMake C++20 modules support? I searched and couldn’t find…

---

## [Support for disabling \<Midl\> on vcxproj generation](https://discourse.cmake.org/t/support-for-disabling-midl-on-vcxproj-generation/14252)

<div class="topic-metadata">

**Author:** [@FrayxRulez](https://discourse.cmake.org/u/FrayxRulez)\
**Replies:** 0\
**Last updated:** [June 17, 2025, 3:01pm UTC](https://discourse.cmake.org/t/support-for-disabling-midl-on-vcxproj-generation/14252 "2025-06-17T15:01:09Z")

</div>

Hello, We’re migrating some project in our pipeline from C++/CX to C++/WinRT. Everything is going quite smoothly, apart from the fact that CMake automatically adds tags whenever a \*.idl file is detected and it appears…

---

## [Add code to run notarytool and staple at end of install?](https://discourse.cmake.org/t/add-code-to-run-notarytool-and-staple-at-end-of-install/14243)

<div class="topic-metadata">

**Author:** [@perdrix](https://discourse.cmake.org/u/perdrix)\
**Replies:** 0\
**Last updated:** [June 16, 2025, 3:47pm UTC](https://discourse.cmake.org/t/add-code-to-run-notarytool-and-staple-at-end-of-install/14243 "2025-06-16T15:47:44Z")

</div>

I currently sign my macOS apps using macdeployqt: if(NOT LINUX) set (deploy\_tool\_options\_arg "-verbose=1") if(APPLE) set(deploy\_tool\_options\_arg "${deploy\_tool\_options\_arg} -hardened-runtime -timestamp -…

---

## [Portable checking for libm for embedded use](https://discourse.cmake.org/t/portable-checking-for-libm-for-embedded-use/11506)

<div class="topic-metadata">

**Author:** [@rleigh](https://discourse.cmake.org/u/rleigh)\
**Replies:** 1\
**Last updated:** [June 16, 2025, 11:12am UTC](https://discourse.cmake.org/t/portable-checking-for-libm-for-embedded-use/11506 "2025-06-16T11:12:08Z")

</div>

I have been using a check like this to check for the requirement to link with libm: check\_symbol\_exists(pow "math.h" CMath\_HAVE\_LIBC\_POW) if (NOT CMath\_HAVE\_LIBC\_POW) set(CMAKE\_REQUIRED\_LIBRARIES\_SAVE ${CMAKE\_REQUI…

---

## [CMake for cross-compiling but using VS Code/VS Studio](https://discourse.cmake.org/t/cmake-for-cross-compiling-but-using-vs-code-vs-studio/14091)

<div class="topic-metadata">

**Author:** [@scottaronbloom](https://discourse.cmake.org/u/scottaronbloom)\
**Replies:** 6\
**Last updated:** [June 12, 2025, 9:05am UTC](https://discourse.cmake.org/t/cmake-for-cross-compiling-but-using-vs-code-vs-studio/14091 "2025-06-12T09:05:53Z")

</div>

I use CMake 3.31.6 for building a 2 applications for 2 microcontrollers in the project. Unfortunately, they are two different microcontrollers and required two different toolchain setups. Currently we essentially have …

---

## [Is it good or bad practice to set the CMAKE\_TOOLCHAIN\_FILE from within CMakeLists.txt?](https://discourse.cmake.org/t/is-it-good-or-bad-practice-to-set-the-cmake-toolchain-file-from-within-cmakelists-txt/11297)

<div class="topic-metadata">

**Author:** [@Dennis\_Ferron](https://discourse.cmake.org/u/Dennis_Ferron)\
**Replies:** 3\
**Last updated:** [June 11, 2025, 9:44pm UTC](https://discourse.cmake.org/t/is-it-good-or-bad-practice-to-set-the-cmake-toolchain-file-from-within-cmakelists-txt/11297 "2025-06-11T21:44:26Z")

</div>

…as opposed to passing it on the CMake command line or in CMakePresets.json? I moved from a computer which had VCPKG\_ROOT set to one that did not (although I have vcpkg on here). My CMAKE\_TOOLCHAIN\_FILE from my CMakePr…

---

## [getting generate\_export\_header to create a file usable in MSVC and GCC/Clang](https://discourse.cmake.org/t/getting-generate-export-header-to-create-a-file-usable-in-msvc-and-gcc-clang/14221)

<div class="topic-metadata">

**Author:** [@mattp](https://discourse.cmake.org/u/mattp)\
**Replies:** 2\
**Last updated:** [June 11, 2025, 1:27pm UTC](https://discourse.cmake.org/t/getting-generate-export-header-to-create-a-file-usable-in-msvc-and-gcc-clang/14221 "2025-06-11T13:27:36Z")

</div>

We drive the build of a library product using CMake, and generate binaries for the various platforms. generate\_export\_header() produces an export header file so that we can maintain control of symbol visibility across MS…

---

## [Share target between multiple configs](https://discourse.cmake.org/t/share-target-between-multiple-configs/14216)

<div class="topic-metadata">

**Author:** [@dpikas](https://discourse.cmake.org/u/dpikas)\
**Replies:** 0\
**Last updated:** [June 9, 2025, 2:30pm UTC](https://discourse.cmake.org/t/share-target-between-multiple-configs/14216 "2025-06-09T14:30:44Z")

</div>

If you have a project with multiple configurations (e.g. Debug and Release), is there a way for a target to be shared between multiple configurations so that it is only build once? If you have a add\_custom\_target that j…

---

## [How to write a configurable import target](https://discourse.cmake.org/t/how-to-write-a-configurable-import-target/14197)

<div class="topic-metadata">

**Author:** [@Matthias\_Wiesenberge](https://discourse.cmake.org/u/Matthias_Wiesenberge)\
**Replies:** 8\
**Last updated:** [June 4, 2025, 11:43am UTC](https://discourse.cmake.org/t/how-to-write-a-configurable-import-target/14197 "2025-06-04T11:43:38Z")

</div>

Hi, I have a header-only library mylib consisting of the header mylib.h . Inside the header I have a template function. Given a preprocessor macro USE\_FAST\_LIB the implementation of that function redirects to a third pa…

---

## [Linker configuration in toolchain file for cross-compiling](https://discourse.cmake.org/t/linker-configuration-in-toolchain-file-for-cross-compiling/14192)

<div class="topic-metadata">

**Author:** [@nickvdbroeck](https://discourse.cmake.org/u/nickvdbroeck)\
**Replies:** 0\
**Last updated:** [June 3, 2025, 1:53pm UTC](https://discourse.cmake.org/t/linker-configuration-in-toolchain-file-for-cross-compiling/14192 "2025-06-03T13:53:03Z")

</div>

I am trying to setup cross compilation using cmake. I am working on windows 11. I am using WSL 2 with an Ubuntu-22.04 as host system to build on and my target system is an aarch64 embedded ARM processor running somethin…

---

## [Missing support for XCODE\_EMBED\_APPCLIP and XCODE\_EMBED\_WATCHAPP in CMake for iOS projects](https://discourse.cmake.org/t/missing-support-for-xcode-embed-appclip-and-xcode-embed-watchapp-in-cmake-for-ios-projects/14190)

<div class="topic-metadata">

**Author:** [@execomrt](https://discourse.cmake.org/u/execomrt)\
**Replies:** 0\
**Last updated:** [June 3, 2025, 12:21pm UTC](https://discourse.cmake.org/t/missing-support-for-xcode-embed-appclip-and-xcode-embed-watchapp-in-cmake-for-ios-projects/14190 "2025-06-03T12:21:10Z")

</div>

We’re building a complex iOS app that includes: a main app an App Clip a watchOS app a widget extension a notification service extension We’re using CMake to generate our Xcode project, and we’ve noticed: XCODE\_EMBE…

---

## [Is beman.exemplar/beman.exemplar-version.cmake a vallid package name?](https://discourse.cmake.org/t/is-beman-exemplar-beman-exemplar-version-cmake-a-vallid-package-name/14188)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 1\
**Last updated:** [June 2, 2025, 11:24am UTC](https://discourse.cmake.org/t/is-beman-exemplar-beman-exemplar-version-cmake-a-vallid-package-name/14188 "2025-06-02T11:24:39Z")

</div>

I get always an error like version: unknown error with this: find\_package(beman.exemplar 2.1.1 EXACT REQUIRED) The exported cmake config package: bash-5.2$ tree stagedir/lib/ stagedir/lib/ ├── cmake │ └── beman.exemp…

---

## [How to know about current git branch in preset](https://discourse.cmake.org/t/how-to-know-about-current-git-branch-in-preset/7807)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 2\
**Last updated:** [May 30, 2025, 1:55am UTC](https://discourse.cmake.org/t/how-to-know-about-current-git-branch-in-preset/7807 "2025-05-30T01:55:35Z")

</div>

I’ve had a shell script for local builds that I was hoping to sunset in favour of a CmakeUserPresets.json and it works very well with the exception that this script sets the output dir based on the name of the current gi…

---

## [CMakeDetermineCompilerId.cmake: very strange failure to open file](https://discourse.cmake.org/t/cmakedeterminecompilerid-cmake-very-strange-failure-to-open-file/14177)

<div class="topic-metadata">

**Author:** [@Joymaker](https://discourse.cmake.org/u/Joymaker)\
**Replies:** 0\
**Last updated:** [May 29, 2025, 8:38pm UTC](https://discourse.cmake.org/t/cmakedeterminecompilerid-cmake-very-strange-failure-to-open-file/14177 "2025-05-29T20:38:09Z")

</div>

C:\\msys64\\mingw64\\bin\\cmake.exe -DCMAKE\_BUILD\_TYPE:STRING=Debug -DCMAKE\_EXPORT\_COMPILE\_COMMANDS:BOOL=TRUE -DCMAKE\_C\_COMPILER:FILEPATH=C:\\msys64\\mingw64\\bin\\gcc.exe -DCMAKE\_CXX\_COMPILER:FILEPATH=C:\\msys64\\mingw64\\bin\\g…

---

## [CMAKE\_\<LANG\>\_FLAGS omits Swift?](https://discourse.cmake.org/t/cmake-lang-flags-omits-swift/14101)

<div class="topic-metadata">

**Author:** [@smcdowell](https://discourse.cmake.org/u/smcdowell)\
**Replies:** 1\
**Last updated:** [May 27, 2025, 4:31pm UTC](https://discourse.cmake.org/t/cmake-lang-flags-omits-swift/14101 "2025-05-27T16:31:27Z")

</div>

Looking at the docs for CMAKE\_\<LANG\>\_FLAGS, Swift is not in the list of languages. Is this an omission in the docs or does Swift not use this variable?

---

## [Failing to set LSApplicationCategoryType](https://discourse.cmake.org/t/failing-to-set-lsapplicationcategorytype/14168)

<div class="topic-metadata">

**Author:** [@perdrix](https://discourse.cmake.org/u/perdrix)\
**Replies:** 1\
**Last updated:** [May 27, 2025, 11:27am UTC](https://discourse.cmake.org/t/failing-to-set-lsapplicationcategorytype/14168 "2025-05-27T11:27:51Z")

</div>

I added: set(CMAKE\_XCODE\_ATTRIBUTE\_INFOPLIST\_KEY\_LSApplicationCategoryType "public.app-category.astronomy" CACHE STRING "") to my top level CMake file, but nothing ends up in the Info.plist file? Am I doing this wron…

---

## [How exactly to find Mac Frameworks within app at runtime?](https://discourse.cmake.org/t/how-exactly-to-find-mac-frameworks-within-app-at-runtime/14150)

<div class="topic-metadata">

**Author:** [@Joymaker](https://discourse.cmake.org/u/Joymaker)\
**Replies:** 1\
**Last updated:** [May 27, 2025, 8:27am UTC](https://discourse.cmake.org/t/how-exactly-to-find-mac-frameworks-within-app-at-runtime/14150 "2025-05-27T08:27:40Z")

</div>

I’m trying to build for Mac OS in such a way that the linker finds Frameworks at link time and the executable finds them at runtime. Seems to me this should be absolute boilerplate, since the relative path within the app…

---

## [How to exclude Mac or Apple Vision from destinations of an iOS build?](https://discourse.cmake.org/t/how-to-exclude-mac-or-apple-vision-from-destinations-of-an-ios-build/13978)

<div class="topic-metadata">

**Author:** [@paul.masristone](https://discourse.cmake.org/u/paul.masristone)\
**Replies:** 3\
**Last updated:** [May 20, 2025, 9:32am UTC](https://discourse.cmake.org/t/how-to-exclude-mac-or-apple-vision-from-destinations-of-an-ios-build/13978 "2025-05-20T09:32:09Z")

</div>

In set\_target\_properties I can choose between iPhone and iPad as destinations for my iOS app using XCODE\_ATTRIBUTE\_TARGETED\_DEVICE\_FAMILY. However Xcode also shows destinations Mac (Designed for iPad) and Apple Vision …

---

## [Cmake presets](https://discourse.cmake.org/t/cmake-presets/14118)

<div class="topic-metadata">

**Author:** [@madam\_smith](https://discourse.cmake.org/u/madam_smith)\
**Replies:** 0\
**Last updated:** [May 19, 2025, 2:28pm UTC](https://discourse.cmake.org/t/cmake-presets/14118 "2025-05-19T14:28:18Z")

</div>

I’m working with CMake Presets and want to conditionally enable presets based on whether a specific SDK folder exists on disk. For example, I have presets for building against different SDK versions, and I want the pres…

---

## [How prevent undecorated -fPIC when building w/ hipcc + NVIDIA?](https://discourse.cmake.org/t/how-prevent-undecorated-fpic-when-building-w-hipcc-nvidia/14104)

<div class="topic-metadata">

**Author:** [@derobins](https://discourse.cmake.org/u/derobins)\
**Replies:** 1\
**Last updated:** [May 17, 2025, 5:57pm UTC](https://discourse.cmake.org/t/how-prevent-undecorated-fpic-when-building-w-hipcc-nvidia/14104 "2025-05-17T17:57:37Z")

</div>

I’m building a C++ library with hipcc that can have either an amd or nvidia back-end depending on the HIP\_PLATFORM setting. I’m building both static and shared libraries via building an object library that gets linked in…

---

## [Method to build unit tests with separate toolchain](https://discourse.cmake.org/t/method-to-build-unit-tests-with-separate-toolchain/14097)

<div class="topic-metadata">

**Author:** [@DerekCresswell](https://discourse.cmake.org/u/DerekCresswell)\
**Replies:** 2\
**Last updated:** [May 15, 2025, 3:16pm UTC](https://discourse.cmake.org/t/method-to-build-unit-tests-with-separate-toolchain/14097 "2025-05-15T15:16:48Z")

</div>

Here’s a brief outline of my situation: I’m working on a large Windows Kernel Mode Driver Our unit tests need to run in user mode Our toolchain is setup to support user and kernel mode But we cannot unify the building …

---

## [gcc15 and cmake 4.0.1: errors at cross-building cmake](https://discourse.cmake.org/t/gcc15-and-cmake-4-0-1-errors-at-cross-building-cmake/14048)

<div class="topic-metadata">

**Author:** [@Piotr\_Oniszczuk](https://discourse.cmake.org/u/Piotr_Oniszczuk)\
**Replies:** 4\
**Last updated:** [May 13, 2025, 6:52pm UTC](https://discourse.cmake.org/t/gcc15-and-cmake-4-0-1-errors-at-cross-building-cmake/14048 "2025-05-13T18:52:19Z")

</div>

Hi guys, I’m in upgrade process of gcc from 14.2.0 to 15.1.0 in my distros and have issue with cross-compiling cmake 4.0.1 for my toolchain. Cross-build erorr is like this: gist:d171eaf91b52dd999a2cf9019342d558 · GitHu…

---

## [I need to enforce link order such that a library always appears first in the link command line.](https://discourse.cmake.org/t/i-need-to-enforce-link-order-such-that-a-library-always-appears-first-in-the-link-command-line/8045)

<div class="topic-metadata">

**Author:** [@Alexander\_Goodrich](https://discourse.cmake.org/u/Alexander_Goodrich)\
**Replies:** 9\
**Last updated:** [May 12, 2025, 10:24am UTC](https://discourse.cmake.org/t/i-need-to-enforce-link-order-such-that-a-library-always-appears-first-in-the-link-command-line/8045 "2025-05-12T10:24:14Z")

</div>

Mimalloc on Windows has a clever mechanism for overriding malloc calls via an interception mechanic, but in order for this to work, two libraries must be included first in the link order: mimalloc-redirect.lib and mimall…

---

## [\-isystem fails on centos instead of -I for C++ project](https://discourse.cmake.org/t/isystem-fails-on-centos-instead-of-i-for-c-project/14068)

<div class="topic-metadata">

**Author:** [@ghamu](https://discourse.cmake.org/u/ghamu)\
**Replies:** 0\
**Last updated:** [May 9, 2025, 1:43pm UTC](https://discourse.cmake.org/t/isystem-fails-on-centos-instead-of-i-for-c-project/14068 "2025-05-09T13:43:04Z")

</div>

hello, I have a C++ project that compiles without a problem on Ubuntu 20. The same project won’t compile on a CentOS7, because of “-isystem”. If I replace “-isystem” with “-I” it works. How can I force the use of “-I” i…

---

## [target\_link\_libraries doesn't link sfml libraries](https://discourse.cmake.org/t/target-link-libraries-doesnt-link-sfml-libraries/14060)

<div class="topic-metadata">

**Author:** [@Laurent7601](https://discourse.cmake.org/u/Laurent7601)\
**Replies:** 1\
**Last updated:** [May 9, 2025, 11:36am UTC](https://discourse.cmake.org/t/target-link-libraries-doesnt-link-sfml-libraries/14060 "2025-05-09T11:36:18Z")

</div>

Hi! I’m trying to compile a lib using SFML, so I put this SFML code : include(${PROJECT\_SOURCE\_DIR}/cmake/Macros.cmake) include(${PROJECT\_SOURCE\_DIR}/cmake/Modules/FindSFML.cmake) set(INCROOT ${PROJECT\_SOURCE\_DIR}/incl…

---

## [macOS defining a file association](https://discourse.cmake.org/t/macos-defining-a-file-association/14063)

<div class="topic-metadata">

**Author:** [@perdrix](https://discourse.cmake.org/u/perdrix)\
**Replies:** 2\
**Last updated:** [May 9, 2025, 9:33am UTC](https://discourse.cmake.org/t/macos-defining-a-file-association/14063 "2025-05-09T09:33:50Z")

</div>

I believe that I need to have something in the Info.plist for my application that may look rather like this: \<key\>UTExportedTypeDeclarations\</key\> \<array\> \<dict\> \<key\>UTTypeIdentifier\</key\> \<string\>com.github.deeps…

---

## [Building CUDA code with a Clang host compiler which uses a non-standard GCC installation](https://discourse.cmake.org/t/building-cuda-code-with-a-clang-host-compiler-which-uses-a-non-standard-gcc-installation/14058)

<div class="topic-metadata">

**Author:** [@krasznaa](https://discourse.cmake.org/u/krasznaa)\
**Replies:** 0\
**Last updated:** [May 8, 2025, 8:58am UTC](https://discourse.cmake.org/t/building-cuda-code-with-a-clang-host-compiler-which-uses-a-non-standard-gcc-installation/14058 "2025-05-08T08:58:08Z")

</div>

Hi, The issue I bumped into just now may be a very corner case thing, but I think I found a bug… One of the environments in which I’d like to build CUDA code is one where host code is being compiled with a version of c…

---

## [Undefined Reference error using modules in C++23 with clang and cmake](https://discourse.cmake.org/t/undefined-reference-error-using-modules-in-c-23-with-clang-and-cmake/14045)

<div class="topic-metadata">

**Author:** [@saurabh](https://discourse.cmake.org/u/saurabh)\
**Replies:** 4\
**Last updated:** [May 7, 2025, 10:42pm UTC](https://discourse.cmake.org/t/undefined-reference-error-using-modules-in-c-23-with-clang-and-cmake/14045 "2025-05-07T22:42:51Z")

</div>

Hello, I’m getting started with C++23 modules and trying to use them in a personal project. The plan is to create an executable for the entire project, which would contain the output of all unit tests. Each source cpp …

---

## [Troubles with VS generator](https://discourse.cmake.org/t/troubles-with-vs-generator/14051)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 1\
**Last updated:** [May 7, 2025, 9:41am UTC](https://discourse.cmake.org/t/troubles-with-vs-generator/14051 "2025-05-07T09:41:48Z")

</div>

Hello, I am trying tor resolve a problem about the Visual Studio Generator. In the CMakeLists, there are the following lines: ... add\_executable(${PROJECT\_NAME} WIN32) ... add\_custom\_command( TARGET ${PROJECT\_NAME…

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

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