# Code

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

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

**Page:** 16

---

## [force SwiftSupport folder generate](https://discourse.cmake.org/t/force-swiftsupport-folder-generate/12860)

<div class="topic-metadata">

**Author:** [@shokarta](https://discourse.cmake.org/u/shokarta)\
**Replies:** 0\
**Last updated:** [October 29, 2024, 12:48pm UTC](https://discourse.cmake.org/t/force-swiftsupport-folder-generate/12860 "2024-10-29T12:48:00Z")

</div>

hello guys, since I included firebase to me Qt Creator project which also uses Swift language, I can build and deploy just find in Xcode (xproject generated by cmake). However when I try to publish the app to TestFlig…

---

## [BEGINNER: command line option is not working on deps \[SOLVED\]](https://discourse.cmake.org/t/beginner-command-line-option-is-not-working-on-deps-solved/12844)

<div class="topic-metadata">

**Author:** [@bugblatterbeast](https://discourse.cmake.org/u/bugblatterbeast)\
**Replies:** 1\
**Last updated:** [October 26, 2024, 12:45pm UTC](https://discourse.cmake.org/t/beginner-command-line-option-is-not-working-on-deps-solved/12844 "2024-10-26T12:45:33Z")

</div>

I have a very large project with modules that each have their own repository. The projects are using FetchContent like this: FetchContent\_Declare( ModuleA GIT\_REPOSITORY git@URL:ModuleA.git GIT\_TAG HEAD …

---

## [How to set a DEFER CALL for the directory added with add\_subdirectory()](https://discourse.cmake.org/t/how-to-set-a-defer-call-for-the-directory-added-with-add-subdirectory/12843)

<div class="topic-metadata">

**Author:** [@petk](https://discourse.cmake.org/u/petk)\
**Replies:** 0\
**Last updated:** [October 26, 2024, 8:50am UTC](https://discourse.cmake.org/t/how-to-set-a-defer-call-for-the-directory-added-with-add-subdirectory/12843 "2024-10-26T08:50:25Z")

</div>

Hello, is there any option perhaps to set a DEFER CALL in the scope of the directory that will be added with add\_subdirectory()? Or if there is any other way to “inject” some CMake module or code into the scope of the …

---

## [Install without building tests](https://discourse.cmake.org/t/install-without-building-tests/10336)

<div class="topic-metadata">

**Author:** [@geertj](https://discourse.cmake.org/u/geertj)\
**Replies:** 2\
**Last updated:** [October 26, 2024, 2:57am UTC](https://discourse.cmake.org/t/install-without-building-tests/10336 "2024-10-26T02:57:42Z")

</div>

Hi, I would like to achieve the following: The default target builds all artifacts. The “install” target only builds the artifacts that it installs. My use case that I want to improve “install” times by not building …

---

## [Include paths not working with Shared library](https://discourse.cmake.org/t/include-paths-not-working-with-shared-library/12817)

<div class="topic-metadata">

**Author:** [@UserAJ](https://discourse.cmake.org/u/UserAJ)\
**Replies:** 5\
**Last updated:** [October 26, 2024, 2:41am UTC](https://discourse.cmake.org/t/include-paths-not-working-with-shared-library/12817 "2024-10-26T02:41:16Z")

</div>

Hi, I recently got a task to move our codebase from using static builds to using shared libraries. I was able to do the task and the code is building and working for the executables (bar some code I commented out becau…

---

## [Failed recompaction error in add\_custom\_command](https://discourse.cmake.org/t/failed-recompaction-error-in-add-custom-command/10762)

<div class="topic-metadata">

**Author:** [@ra-kal](https://discourse.cmake.org/u/ra-kal)\
**Replies:** 9\
**Last updated:** [October 25, 2024, 10:05pm UTC](https://discourse.cmake.org/t/failed-recompaction-error-in-add-custom-command/10762 "2024-10-25T22:05:20Z")

</div>

Hi, I’m using following code to automatically create a dependency graph during build add\_custom\_command( OUTPUT ${CMAKE\_BINARY\_DIR}/\_graphviz COMMAND ${CMAKE\_COMMAND} "--graphviz=graphviz/deps.dot" …

---

## [How to install CXX\_MODULES\_BMI right without strange errors?](https://discourse.cmake.org/t/how-to-install-cxx-modules-bmi-right-without-strange-errors/9675)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 4\
**Last updated:** [October 25, 2024, 8:04am UTC](https://discourse.cmake.org/t/how-to-install-cxx-modules-bmi-right-without-strange-errors/9675 "2024-10-25T08:04:49Z")

</div>

with this code # # module with partitions # add\_library(mod3 SHARED) # cmake-format: off target\_sources( mod3 PRIVATE mod3/mod3price.cpp mod3/mod3io.cpp PUBLIC FILE\_SET cxx\_modules3 TYPE CXX\_MODULES …

---

## [the usage of include with cmake](https://discourse.cmake.org/t/the-usage-of-include-with-cmake/12803)

<div class="topic-metadata">

**Author:** [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Replies:** 2\
**Last updated:** [October 21, 2024, 8:36am UTC](https://discourse.cmake.org/t/the-usage-of-include-with-cmake/12803 "2024-10-21T08:36:39Z")

</div>

For case2, it happen the message #include errors detected. Please update your includePath. Squiggles are disabled for this translation unit // main.cpp #include "shared/main.hpp" Folder test/src/main.cpp test/includ…

---

## [Dealing with Fortran include files](https://discourse.cmake.org/t/dealing-with-fortran-include-files/11777)

<div class="topic-metadata">

**Author:** [@ivan-pi](https://discourse.cmake.org/u/ivan-pi)\
**Replies:** 3\
**Last updated:** [October 20, 2024, 8:48pm UTC](https://discourse.cmake.org/t/dealing-with-fortran-include-files/11777 "2024-10-20T20:48:28Z")

</div>

I am building a Fortran project that contains numerous include files (extension .inc). These are not public include files, but rather implementation details which were generated by a template mechanism. Where do these f…

---

## [Error trying to compile HLSL "FXC : error X3506: unrecognized compiler target 'vs'"](https://discourse.cmake.org/t/error-trying-to-compile-hlsl-fxc-error-x3506-unrecognized-compiler-target-vs/12805)

<div class="topic-metadata">

**Author:** [@Wallby](https://discourse.cmake.org/u/Wallby)\
**Replies:** 2\
**Last updated:** [October 20, 2024, 1:07pm UTC](https://discourse.cmake.org/t/error-trying-to-compile-hlsl-fxc-error-x3506-unrecognized-compiler-target-vs/12805 "2024-10-20T13:07:09Z")

</div>

I added the following in my CMakeLists.txt… set(PATH\_PER\_VERTEXSHADER ${VERTEXSHADERS}) set(PATH\_PER\_PIXELSHADER ${PIXELSHADERS}) list(TRANSFORM PATH\_PER\_PIXELSHADER PREPEND Source/) list(TRANSFORM PATH\_PER\_VERTEXSHADER…

---

## [Chromium Embedded Framework build](https://discourse.cmake.org/t/chromium-embedded-framework-build/12796)

<div class="topic-metadata">

**Author:** [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Replies:** 6\
**Last updated:** [October 20, 2024, 1:33am UTC](https://discourse.cmake.org/t/chromium-embedded-framework-build/12796 "2024-10-20T01:33:27Z")

</div>

Using windows and vs2022 prompt. I try to download CEF binary distribution and build the libcef\_dll\_wrapper I use this to download cef builds and command cmake -G Ninja -S . -B build -DCMAKE\_BUILD\_TYPE="Release" cmak…

---

## [Static runtime library](https://discourse.cmake.org/t/static-runtime-library/12721)

<div class="topic-metadata">

**Author:** [@ilyaplay2509](https://discourse.cmake.org/u/ilyaplay2509)\
**Replies:** 2\
**Last updated:** [October 18, 2024, 6:50am UTC](https://discourse.cmake.org/t/static-runtime-library/12721 "2024-10-18T06:50:32Z")

</div>

I need to compile executable with static runtime library for compilers msvc, gcc, clang. For msvc I do and it completely work set(CMAKE\_C\_FLAGS\_DEBUG "${CMAKE\_C\_FLAGS\_DEBUG} /MTd") set(CMAKE\_CXX\_FLAGS\_DEBUG "${C…

---

## [add\_custom\_command with CMake commands](https://discourse.cmake.org/t/add-custom-command-with-cmake-commands/12790)

<div class="topic-metadata">

**Author:** [@ibaned](https://discourse.cmake.org/u/ibaned)\
**Replies:** 3\
**Last updated:** [October 17, 2024, 7:58pm UTC](https://discourse.cmake.org/t/add-custom-command-with-cmake-commands/12790 "2024-10-17T19:58:12Z")

</div>

Hello, I’m trying to mimic the functionality of C23’s #embed by having CMake generate a source file containing a C++11 raw string: function(embed data\_file symbol) file(READ ${data\_file} the\_content) configure\_file…

---

## [CMake Error: install(EXPORT "ProjectTargets" ...) includes target "xxx" which requires target "yyy" that is not in any export set.](https://discourse.cmake.org/t/cmake-error-install-export-projecttargets-includes-target-xxx-which-requires-target-yyy-that-is-not-in-any-export-set/7344)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 6\
**Last updated:** [October 17, 2024, 3:53pm UTC](https://discourse.cmake.org/t/cmake-error-install-export-projecttargets-includes-target-xxx-which-requires-target-yyy-that-is-not-in-any-export-set/7344 "2024-10-17T15:53:19Z")

</div>

Why does my project with static libs NOT work, but with shared libs it works? clausklein$ cmake --version cmake version 3.25.0 bash-3.2$ make build cmake -B ../build-agent++-4.5.1-x86\_64-Debug -S . -G Ninja -D BUILD\_SHA…

---

## [How to implement Make pattern rules in CMake?](https://discourse.cmake.org/t/how-to-implement-make-pattern-rules-in-cmake/12792)

<div class="topic-metadata">

**Author:** [@petk](https://discourse.cmake.org/u/petk)\
**Replies:** 0\
**Last updated:** [October 17, 2024, 3:35pm UTC](https://discourse.cmake.org/t/how-to-implement-make-pattern-rules-in-cmake/12792 "2024-10-17T15:35:58Z")

</div>

Hello, what would be the recommended approach in CMake to implement the so-called pattern rules as known in Make: For example, the source files \*.stub.php are used to generate the \_arginfo.h files with PHP. A follow …

---

## [Problem to link with Boost](https://discourse.cmake.org/t/problem-to-link-with-boost/12787)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 5\
**Last updated:** [October 16, 2024, 7:58pm UTC](https://discourse.cmake.org/t/problem-to-link-with-boost/12787 "2024-10-16T19:58:21Z")

</div>

Hello, I am on CMake 3.29.3, and I want to link to Boost, on a Visual Studio environment. Previously, I used Boost for only one version of MS C++ compiler, so the Boost directory structure was: C:\\boost\\include C:\\boo…

---

## [How to transform a list of relative paths into absolute paths using generator expressions?](https://discourse.cmake.org/t/how-to-transform-a-list-of-relative-paths-into-absolute-paths-using-generator-expressions/12784)

<div class="topic-metadata">

**Author:** [@petk](https://discourse.cmake.org/u/petk)\
**Replies:** 3\
**Last updated:** [October 16, 2024, 3:08pm UTC](https://discourse.cmake.org/t/how-to-transform-a-list-of-relative-paths-into-absolute-paths-using-generator-expressions/12784 "2024-10-16T15:08:09Z")

</div>

Is perhaps today already available some either hacky or recommended way to transform a list of paths to their absolute paths using generator expressions? Because this would be needed in add\_custom\_command and similar ca…

---

## [How to know the generator previously used ?](https://discourse.cmake.org/t/how-to-know-the-generator-previously-used/12748)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 8\
**Last updated:** [October 16, 2024, 9:13am UTC](https://discourse.cmake.org/t/how-to-know-the-generator-previously-used/12748 "2024-10-16T09:13:31Z")

</div>

CMake version: 3.29.3 Hello, I develop on Windows, and use a batch file to tun the build. This script calls the CMake command : REM positionning in the CMake bin directory cd "%BIN\_DIR%" REM remove the previous CMake…

---

## [pkg\_check\_modules() imported target does not propagate](https://discourse.cmake.org/t/pkg-check-modules-imported-target-does-not-propagate/12777)

<div class="topic-metadata">

**Author:** [@anik01ic](https://discourse.cmake.org/u/anik01ic)\
**Replies:** 2\
**Last updated:** [October 16, 2024, 7:40am UTC](https://discourse.cmake.org/t/pkg-check-modules-imported-target-does-not-propagate/12777 "2024-10-16T07:40:33Z")

</div>

Greetings, I have an issue with pkg\_check\_modules() (cmake version 3.22.3) and I seem not to be able to solve it (been trying for more than a week). I have two CMake projects, lets call them A and B. Project A add\_lib…

---

## [Usage of object libraries](https://discourse.cmake.org/t/usage-of-object-libraries/12764)

<div class="topic-metadata">

**Author:** [@pevsonic](https://discourse.cmake.org/u/pevsonic)\
**Replies:** 1\
**Last updated:** [October 15, 2024, 10:03pm UTC](https://discourse.cmake.org/t/usage-of-object-libraries/12764 "2024-10-15T22:03:15Z")

</div>

Ive got a project Im converting over to CMake. One of the more unusual things that it involves are some custom binary config data objects it creates from object files. In the old make project it would take the .o’s, objc…

---

## [powershell call cmake script, but some var it empty](https://discourse.cmake.org/t/powershell-call-cmake-script-but-some-var-it-empty/12767)

<div class="topic-metadata">

**Author:** [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Replies:** 3\
**Last updated:** [October 12, 2024, 3:32pm UTC](https://discourse.cmake.org/t/powershell-call-cmake-script-but-some-var-it-empty/12767 "2024-10-12T15:32:10Z")

</div>

cmake -P install.cmake -DHELLO=“hello” #install.cmake echo "result: ${CMAKE\_SYSTEM\_NAME}" echo "result: ${HELLO}" #output result: result:

---

## [file GET\_RUNTIME\_DEPENDENCIES in generated cmake\_install.cmake fails to find dependencies](https://discourse.cmake.org/t/file-get-runtime-dependencies-in-generated-cmake-install-cmake-fails-to-find-dependencies/12761)

<div class="topic-metadata">

**Author:** [@Anton\_Kryukov](https://discourse.cmake.org/u/Anton_Kryukov)\
**Replies:** 2\
**Last updated:** [October 12, 2024, 12:37pm UTC](https://discourse.cmake.org/t/file-get-runtime-dependencies-in-generated-cmake-install-cmake-fails-to-find-dependencies/12761 "2024-10-12T12:37:44Z")

</div>

I am trying to use install(TARGETS...RUNTIME\_DEPENDENCIES...) with CMake 3.30 in an Ubuntu 14 Docker container. When I try to run the generated cmake\_install.cmake file with cmake -P, I get an error file Could not re…

---

## [\-mllvm and -bitcode\_bundle (Xcode setting ENABLE\_BITCODE=YES) cannot be used together](https://discourse.cmake.org/t/mllvm-and-bitcode-bundle-xcode-setting-enable-bitcode-yes-cannot-be-used-together/11741)

<div class="topic-metadata">

**Author:** [@wander](https://discourse.cmake.org/u/wander)\
**Replies:** 2\
**Last updated:** [October 11, 2024, 6:29pm UTC](https://discourse.cmake.org/t/mllvm-and-bitcode-bundle-xcode-setting-enable-bitcode-yes-cannot-be-used-together/11741 "2024-10-11T18:29:25Z")

</div>

Hi, I am getting the following error while building my project: -mllvm and -bitcode\_bundle (Xcode setting ENABLE\_BITCODE=YES) cannot be used together Even though I do not set (manually) the -mllvm option anywhere in my…

---

## [CMAKE\_CURRENT\_LIST\_DIR not working/understood ?](https://discourse.cmake.org/t/cmake-current-list-dir-not-working-understood/12757)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 2\
**Last updated:** [October 11, 2024, 12:15pm UTC](https://discourse.cmake.org/t/cmake-current-list-dir-not-working-understood/12757 "2024-10-11T12:15:14Z")

</div>

Hello, I have a CMakeLists.txt in DirA, calling a .cmake in DirB. When I ask for the value of CMAKE\_CURRENT\_LIST\_DIR in the .cmake script, I expect it points to DirB. But its value is DirA. According @brad.king , is i…

---

## [Confusion using cmake\_path(HAS\_FILENAME \<path-var\> \<out-var\>)](https://discourse.cmake.org/t/confusion-using-cmake-path-has-filename-path-var-out-var/12749)

<div class="topic-metadata">

**Author:** [@octopus42](https://discourse.cmake.org/u/octopus42)\
**Replies:** 2\
**Last updated:** [October 10, 2024, 4:27pm UTC](https://discourse.cmake.org/t/confusion-using-cmake-path-has-filename-path-var-out-var/12749 "2024-10-10T16:27:26Z")

</div>

I’m attempting to use cmake\_path(HAS\_FILENAME ) to determine if a file exists within a path. I’m either using it incorrectly or something else is going on because it always return ‘ON’. Basically, I’m doing this (an ex…

---

## [How to configure multiple cmake projects with CMakePresets.json?](https://discourse.cmake.org/t/how-to-configure-multiple-cmake-projects-with-cmakepresets-json/12673)

<div class="topic-metadata">

**Author:** [@agostini01](https://discourse.cmake.org/u/agostini01)\
**Replies:** 3\
**Last updated:** [October 9, 2024, 8:21pm UTC](https://discourse.cmake.org/t/how-to-configure-multiple-cmake-projects-with-cmakepresets-json/12673 "2024-10-09T20:21:16Z")

</div>

I recently found out about CMakePresets.json. I am trying to enable it in my workspace that has two CMakeLists.txt based projects. The structure of my workspace is: ├── myproject │ └── CMakeLists.txt ├── external │ …

---

## [CMake incorrectly links to nvrtc-builtins](https://discourse.cmake.org/t/cmake-incorrectly-links-to-nvrtc-builtins/12723)

<div class="topic-metadata">

**Author:** [@peastman](https://discourse.cmake.org/u/peastman)\
**Replies:** 5\
**Last updated:** [October 9, 2024, 3:51pm UTC](https://discourse.cmake.org/t/cmake-incorrectly-links-to-nvrtc-builtins/12723 "2024-10-09T15:51:26Z")

</div>

I have a program that uses CUDA, and more specifically the nvrtc runtime compiler. In my build script, I call find\_package(CUDAToolkit), then use target\_link\_libraries() to link to CUDA::nvrtc. It is supposed to be bin…

---

## [What is the cause of undefined references? (NEWBIE)](https://discourse.cmake.org/t/what-is-the-cause-of-undefined-references-newbie/12705)

<div class="topic-metadata">

**Author:** [@BenEngbers](https://discourse.cmake.org/u/BenEngbers)\
**Replies:** 1\
**Last updated:** [October 9, 2024, 3:40pm UTC](https://discourse.cmake.org/t/what-is-the-cause-of-undefined-references-newbie/12705 "2024-10-09T15:40:59Z")

</div>

In Eclipse I developed a C++ - client for Basex (an Open source XML-database) and it is my intention to deploy that client as shared library. A simple CMakelists.txt is enough to build an so. However, according to this…

---

## [Is there special command to replace \<CONFIG\> with the result of IMPORTED\_CONFIGURATIONS](https://discourse.cmake.org/t/is-there-special-command-to-replace-config-with-the-result-of-imported-configurations/12706)

<div class="topic-metadata">

**Author:** [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Replies:** 0\
**Last updated:** [October 8, 2024, 1:57am UTC](https://discourse.cmake.org/t/is-there-special-command-to-replace-config-with-the-result-of-imported-configurations/12706 "2024-10-08T01:57:53Z")

</div>

include(CMakePrintHelpers) cmake\_print\_properties(TARGETS "opencv\_world" PROPERTIES IMPORTED\_CONFIGURATIONS IMPORTED\_IMPLIB\_\<CONFIG\> IMPORTED\_IMPLIB\_RELEASE ) Is there special command to replace with the re…

---

## [Question about yaml](https://discourse.cmake.org/t/question-about-yaml/12698)

<div class="topic-metadata">

**Author:** [@Sea\_Sea](https://discourse.cmake.org/u/Sea_Sea)\
**Replies:** 4\
**Last updated:** [October 8, 2024, 7:30am UTC](https://discourse.cmake.org/t/question-about-yaml/12698 "2024-10-08T07:30:15Z")

</div>

include(FetchContent) FetchContent\_Declare( yaml-cpp GIT\_REPOSITORY https://github.com/jbeder/yaml-cpp.git GIT\_TAG \<tag\_name\> # Can be a tag (yaml-cpp-x.x.x), a commit hash, or a branch name (master) ) FetchCont…

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

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