# Code

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

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

**Page:** 26

---

## [How to share precompiled headers via an interface library](https://discourse.cmake.org/t/how-to-share-precompiled-headers-via-an-interface-library/9933)

<div class="topic-metadata">

**Author:** [@Kentzo](https://discourse.cmake.org/u/Kentzo)\
**Replies:** 7\
**Last updated:** [January 27, 2024, 9:04am UTC](https://discourse.cmake.org/t/how-to-share-precompiled-headers-via-an-interface-library/9933 "2024-01-27T09:04:13Z")

</div>

From target\_precompile\_headers: A notable exception to this is where an interface library is created to define a commonly used set of precompile headers in one place and then other targets link to that interface librar…

---

## [FetchContent does not support properly URLs with brackets](https://discourse.cmake.org/t/fetchcontent-does-not-support-properly-urls-with-brackets/8650)

<div class="topic-metadata">

**Author:** [@Yannick\_Daveluy](https://discourse.cmake.org/u/Yannick_Daveluy)\
**Replies:** 4\
**Last updated:** [January 27, 2024, 1:07am UTC](https://discourse.cmake.org/t/fetchcontent-does-not-support-properly-urls-with-brackets/8650 "2024-01-27T01:07:19Z")

</div>

Hello, I tried to fecth this URL : https://ecss.nl/wp-content/uploads/2020/04/ECSS\_SMP\_Issue1(2March2020).zip I think that the correct way would be to write something like: FetchContent\_Declare( ecss\_smp URL “https:…

---

## [Target-dependent linker output location](https://discourse.cmake.org/t/target-dependent-linker-output-location/9923)

<div class="topic-metadata">

**Author:** [@gpanders](https://discourse.cmake.org/u/gpanders)\
**Replies:** 6\
**Last updated:** [January 26, 2024, 8:09pm UTC](https://discourse.cmake.org/t/target-dependent-linker-output-location/9923 "2024-01-26T20:09:12Z")

</div>

We use -Wl,-Map,output.map in add\_link\_options to output a map file in the link stage for all executable targets. This works when using the Makefile generator because Make first changes to the target build directory befo…

---

## [Modules have different types of libraries in different configurations.](https://discourse.cmake.org/t/modules-have-different-types-of-libraries-in-different-configurations/9940)

<div class="topic-metadata">

**Author:** [@aidexie](https://discourse.cmake.org/u/aidexie)\
**Replies:** 1\
**Last updated:** [January 26, 2024, 2:15pm UTC](https://discourse.cmake.org/t/modules-have-different-types-of-libraries-in-different-configurations/9940 "2024-01-26T14:15:52Z")

</div>

I have a vs project that was generated using cmake, now I have a requirement that some modules have different types of libraries under different configs. For example, we have 4 types of config:Debug,Release,DebugEditor,R…

---

## [Partial linking](https://discourse.cmake.org/t/partial-linking/5556)

<div class="topic-metadata">

**Author:** [@ingolf](https://discourse.cmake.org/u/ingolf)\
**Replies:** 8\
**Last updated:** [January 25, 2024, 6:49pm UTC](https://discourse.cmake.org/t/partial-linking/5556 "2024-01-25T18:49:30Z")

</div>

Hi, gcc (and probably other compilers) support the concept of “partial linking” (see the -r switch). While admittedly kind of weird, it appears quite handy when you want to conceal internals from a user of a library. L…

---

## [force configure\_file() on variable change](https://discourse.cmake.org/t/force-configure-file-on-variable-change/9903)

<div class="topic-metadata">

**Author:** [@scivision](https://discourse.cmake.org/u/scivision)\
**Replies:** 3\
**Last updated:** [January 23, 2024, 7:59pm UTC](https://discourse.cmake.org/t/force-configure-file-on-variable-change/9903 "2024-01-23T19:59:45Z")

</div>

Is there a way to force configure\_file() to regenerate the output? I have a big config.h file generated from config.h.in with #cmakedefine that “ccmake” users want to regenerate when they change a relevant variable. Rig…

---

## [Export .dll symbols from dependant library (.lib)](https://discourse.cmake.org/t/export-dll-symbols-from-dependant-library-lib/9901)

<div class="topic-metadata">

**Author:** [@rhubner](https://discourse.cmake.org/u/rhubner)\
**Replies:** 1\
**Last updated:** [January 22, 2024, 3:04pm UTC](https://discourse.cmake.org/t/export-dll-symbols-from-dependant-library-lib/9901 "2024-01-22T15:04:23Z")

</div>

Hello CMake community, I need help with one requirement on our project which recently popped up. We are releasing RocksDBJava for multiple platforms including MS WIndows. Recently C# community contacted us that they wo…

---

## [Importing C++20 module as external DLL in msvc 2022](https://discourse.cmake.org/t/importing-c-20-module-as-external-dll-in-msvc-2022/9763)

<div class="topic-metadata">

**Author:** [@forry](https://discourse.cmake.org/u/forry)\
**Replies:** 12\
**Last updated:** [January 19, 2024, 9:47pm UTC](https://discourse.cmake.org/t/importing-c-20-module-as-external-dll-in-msvc-2022/9763 "2024-01-19T21:47:56Z")

</div>

Hi, I have a testing solution done with one cmake list that simulates the creation of a module as a shared library, installing it, and then an executable that will find and consume it. Before “file sets” it worked fine.…

---

## [Language-specific add\_compile\_options?](https://discourse.cmake.org/t/language-specific-add-compile-options/2643)

<div class="topic-metadata">

**Author:** [@RonRahaman](https://discourse.cmake.org/u/RonRahaman)\
**Replies:** 6\
**Last updated:** [January 19, 2024, 1:08pm UTC](https://discourse.cmake.org/t/language-specific-add-compile-options/2643 "2024-01-19T13:08:09Z")

</div>

What’s the best way to set compiler flags for all objects compiled with a given language? Basically, I’d like to use add\_compile\_options to set flags for a specific language. Or I’d like a best-practices approach to th…

---

## [block(PROPAGATE) doesn't set in the parent directory?](https://discourse.cmake.org/t/block-propagate-doesnt-set-in-the-parent-directory/9853)

<div class="topic-metadata">

**Author:** [@tambre](https://discourse.cmake.org/u/tambre)\
**Replies:** 2\
**Last updated:** [January 18, 2024, 10:11am UTC](https://discourse.cmake.org/t/block-propagate-doesnt-set-in-the-parent-directory/9853 "2024-01-18T10:11:21Z")

</div>

The documentation for set() says: The block(PROPAGATE) and return(PROPAGATE) commands can be used as an alternate method to the set(PARENT\_SCOPE) and unset(PARENT\_SCOPE) commands to update the parent scope. Which to …

---

## [How to modify my Cmake project to generate an elf file that is consistent with the IDE](https://discourse.cmake.org/t/how-to-modify-my-cmake-project-to-generate-an-elf-file-that-is-consistent-with-the-ide/9867)

<div class="topic-metadata">

**Author:** [@Bruce\_Ye](https://discourse.cmake.org/u/Bruce_Ye)\
**Replies:** 0\
**Last updated:** [January 17, 2024, 6:20am UTC](https://discourse.cmake.org/t/how-to-modify-my-cmake-project-to-generate-an-elf-file-that-is-consistent-with-the-ide/9867 "2024-01-17T06:20:45Z")

</div>

I am trying to use Cmake+NinJa instead of IDE to generate executable files. The development board is S32K344, and the compiler is ghs/comp\_ 202114/ccarmxe. Currently, I have successfully generated the elf file, but when …

---

## [Setting VS\_DEBUGGER\_ENVIRONMENT for Ninja Multi-Config](https://discourse.cmake.org/t/setting-vs-debugger-environment-for-ninja-multi-config/9831)

<div class="topic-metadata">

**Author:** [@imikejackson](https://discourse.cmake.org/u/imikejackson)\
**Replies:** 4\
**Last updated:** [January 17, 2024, 9:20am UTC](https://discourse.cmake.org/t/setting-vs-debugger-environment-for-ninja-multi-config/9831 "2024-01-17T09:20:17Z")

</div>

We have cmake code like set\_target\_properties(${PROJECT\_NAME} PROPERTIES VS\_DEBUGGER\_ENVIRONMENT "PATH=%PATH%;${VS\_DEBUGGER\_PATHS}") But when I have Visual Studio 17.8.4 Configure the project …

---

## [FindThreads module with static build?](https://discourse.cmake.org/t/findthreads-module-with-static-build/9846)

<div class="topic-metadata">

**Author:** [@anthonya](https://discourse.cmake.org/u/anthonya)\
**Replies:** 3\
**Last updated:** [January 16, 2024, 2:48pm UTC](https://discourse.cmake.org/t/findthreads-module-with-static-build/9846 "2024-01-16T14:48:34Z")

</div>

Hey there, I was using the FindThreads module in my project, and all is fine when building a dynamic library/executable. The issue comes in when building a fully static binary. If using glibc \< 2.34, the thread library…

---

## [Using execute\_process when one of the arguments contains a space](https://discourse.cmake.org/t/using-execute-process-when-one-of-the-arguments-contains-a-space/9864)

<div class="topic-metadata">

**Author:** [@EosPengwern](https://discourse.cmake.org/u/EosPengwern)\
**Replies:** 3\
**Last updated:** [January 16, 2024, 1:58pm UTC](https://discourse.cmake.org/t/using-execute-process-when-one-of-the-arguments-contains-a-space/9864 "2024-01-16T13:58:16Z")

</div>

There is already an entry with a similar title to what I’m trying to do, but I’m afraid it doesn’t quite answer my question. The situation is this: I’m trying to invoke execute\_process where one of the arguments contain…

---

## [How to properly add link dependencies for an INTERFACE library?](https://discourse.cmake.org/t/how-to-properly-add-link-dependencies-for-an-interface-library/9855)

<div class="topic-metadata">

**Author:** [@MattBas](https://discourse.cmake.org/u/MattBas)\
**Replies:** 1\
**Last updated:** [January 15, 2024, 5:18pm UTC](https://discourse.cmake.org/t/how-to-properly-add-link-dependencies-for-an-interface-library/9855 "2024-01-15T17:18:50Z")

</div>

I have a header-only library that depends on some other library. I would like to define my library in a way that targets linking to it also link to its dependencies. This is the code I have looks something like this: #…

---

## [Modules/Compiler/ADSP-ASM.cmake is missing in the release](https://discourse.cmake.org/t/modules-compiler-adsp-asm-cmake-is-missing-in-the-release/9848)

<div class="topic-metadata">

**Author:** [@MohanY](https://discourse.cmake.org/u/MohanY)\
**Replies:** 1\
**Last updated:** [January 15, 2024, 11:23am UTC](https://discourse.cmake.org/t/modules-compiler-adsp-asm-cmake-is-missing-in-the-release/9848 "2024-01-15T11:23:38Z")

</div>

I have been waiting for Modules/Compiler/ADSP-ASM.cmake to be added to the release. It is still missing in 3.28.1. It would be helpful in migrating our ADSP builds from 3.12 to 3.28.x. Contents of ADSP-ASM.cmake can be …

---

## [Not recognizing passed argument to CMAKE via command prompt at the \`make\` stage](https://discourse.cmake.org/t/not-recognizing-passed-argument-to-cmake-via-command-prompt-at-the-make-stage/9841)

<div class="topic-metadata">

**Author:** [@Victoria\_Malyshkina](https://discourse.cmake.org/u/Victoria_Malyshkina)\
**Replies:** 6\
**Last updated:** [January 12, 2024, 2:45pm UTC](https://discourse.cmake.org/t/not-recognizing-passed-argument-to-cmake-via-command-prompt-at-the-make-stage/9841 "2024-01-12T14:45:45Z")

</div>

I am trying to force the user to pass a parameter before compiling. But I have a problem. After I run : cd .. ;rm -r build; mkdir build; cd build; cmake -DUSER\_DEFINED\_BOARD\_VERSION:STRING="SATNOGS\_COMMS\_VERSION\_0\_2\_1" …

---

## [Conflicting "define" values](https://discourse.cmake.org/t/conflicting-define-values/9825)

<div class="topic-metadata">

**Author:** [@Oodini](https://discourse.cmake.org/u/Oodini)\
**Replies:** 2\
**Last updated:** [January 11, 2024, 2:59pm UTC](https://discourse.cmake.org/t/conflicting-define-values/9825 "2024-01-11T14:59:00Z")

</div>

Hello, The project I am working on uses a lot of scripts (.bat) to define some stuff finally used by CMake, which is called at the end. When CMake is called, a value is defined and passed as argument : cmake -D PLATFO…

---

## [Rely on target in the upper directory using cmake to use precompiled headers](https://discourse.cmake.org/t/rely-on-target-in-the-upper-directory-using-cmake-to-use-precompiled-headers/9770)

<div class="topic-metadata">

**Author:** [@oleg](https://discourse.cmake.org/u/oleg)\
**Replies:** 1\
**Last updated:** [January 11, 2024, 2:13pm UTC](https://discourse.cmake.org/t/rely-on-target-in-the-upper-directory-using-cmake-to-use-precompiled-headers/9770 "2024-01-11T14:13:21Z")

</div>

I have a root cmake which produces me main binary with precompiled headers: cmake\_minimum\_required(VERSION 3.16) project(main\_app) add\_executable( main\_app src/main\_app.cpp ) target\_precompile\_headers( main\_app PUBLIC…

---

## [CMakeLists.txt file for STM32 project setup compilation using VS code](https://discourse.cmake.org/t/cmakelists-txt-file-for-stm32-project-setup-compilation-using-vs-code/9728)

<div class="topic-metadata">

**Author:** [@sridhar](https://discourse.cmake.org/u/sridhar)\
**Replies:** 1\
**Last updated:** [January 11, 2024, 2:06pm UTC](https://discourse.cmake.org/t/cmakelists-txt-file-for-stm32-project-setup-compilation-using-vs-code/9728 "2024-01-11T14:06:51Z")

</div>

cmake\_minimum\_required (VERSION 3.0.0) set(CMAKE\_SYSTEM\_NAME Generic) set(CMAKE\_SYSTEM\_PROCESSOR arm) set(CMAKE\_C\_COMPILER arm-none-eabi-gcc) set(CMAKE\_CXX\_COMPILER arm-none-eabi-g++) set(CMAKE\_ASM\_COMPILER arm-none-eabi…

---

## [I'm having trouble Linking glfw and glm](https://discourse.cmake.org/t/im-having-trouble-linking-glfw-and-glm/9793)

<div class="topic-metadata">

**Author:** [@Greddode](https://discourse.cmake.org/u/Greddode)\
**Replies:** 5\
**Last updated:** [January 11, 2024, 1:41pm UTC](https://discourse.cmake.org/t/im-having-trouble-linking-glfw-and-glm/9793 "2024-01-11T13:41:24Z")

</div>

I’m using VS to add in the Libraries of GLFW and GLM to my project. I’m very new but it gives me an error saying it’s not built. CMake Error at C:\\Users\\patri\\Documents\\Game\_dev\\Engines\\EndBullet\\CMakeLists.txt:42 (targ…

---

## [CMakeLists.txt : clang++ generating WASM ?](https://discourse.cmake.org/t/cmakelists-txt-clang-generating-wasm/9758)

<div class="topic-metadata">

**Author:** [@Nicholas\_Yue](https://discourse.cmake.org/u/Nicholas_Yue)\
**Replies:** 3\
**Last updated:** [January 11, 2024, 1:16pm UTC](https://discourse.cmake.org/t/cmakelists-txt-clang-generating-wasm/9758 "2024-01-11T13:16:20Z")

</div>

I am looking into direct generation of \*.wasm via clang/clang++ (currently using 17) My usage experience with CMake has generally been generating \*.o, \*.so and executable. I do have a Makefile way of doing things (clan…

---

## [Tutorial Ex1 in Step2 fail to build](https://discourse.cmake.org/t/tutorial-ex1-in-step2-fail-to-build/9812)

<div class="topic-metadata">

**Author:** [@newbee](https://discourse.cmake.org/u/newbee)\
**Replies:** 4\
**Last updated:** [January 11, 2024, 1:23am UTC](https://discourse.cmake.org/t/tutorial-ex1-in-step2-fail-to-build/9812 "2024-01-11T01:23:31Z")

</div>

hi, everyone, I just started to learn CMake and run into a problem when I tried to build Excercise 1 in tutorial step2. I am running inside the terminal in VS code on ubuntu and got the following message. cmake --build…

---

## [Importing libraries on Windows and Linux](https://discourse.cmake.org/t/importing-libraries-on-windows-and-linux/9810)

<div class="topic-metadata">

**Author:** [@Bobrov88](https://discourse.cmake.org/u/Bobrov88)\
**Replies:** 4\
**Last updated:** [January 10, 2024, 6:32pm UTC](https://discourse.cmake.org/t/importing-libraries-on-windows-and-linux/9810 "2024-01-10T18:32:08Z")

</div>

I have CmakeLists.txt that below: cmake\_minimum\_required(VERSION 3.2) project(scanner CXX) set(CMAKE\_CXX\_STANDARD 17) set(CONAN\_DISABLE\_CHECK\_COMPILER "1") set(SOURCES src/main.cpp src/utility.cpp) set(HEADERS…

---

## [string list as argument to SET\_TESTS\_PROPERTIES()?](https://discourse.cmake.org/t/string-list-as-argument-to-set-tests-properties/9806)

<div class="topic-metadata">

**Author:** [@wimster](https://discourse.cmake.org/u/wimster)\
**Replies:** 3\
**Last updated:** [January 10, 2024, 4:18pm UTC](https://discourse.cmake.org/t/string-list-as-argument-to-set-tests-properties/9806 "2024-01-10T16:18:33Z")

</div>

I have some cmake code that generates test names. It has a base-test name followed by some identifier. An example would be this: which is in a loop and the id’s and args are different. ADD\_TEST (NAME “${APT\_TEST\_NAME}-$…

---

## [Why doesn't CMake offer the NEWLINE\_STYLE option to file(WRITE|APPEND) as well?](https://discourse.cmake.org/t/why-doesnt-cmake-offer-the-newline-style-option-to-file-write-append-as-well/9787)

<div class="topic-metadata">

**Author:** [@hwhsu1231](https://discourse.cmake.org/u/hwhsu1231)\
**Replies:** 1\
**Last updated:** [January 7, 2024, 7:14pm UTC](https://discourse.cmake.org/t/why-doesnt-cmake-offer-the-newline-style-option-to-file-write-append-as-well/9787 "2024-01-07T19:14:24Z")

</div>

Problem Description Recently, I needed to use CMake commands to create and write content to a file. Initially, I used the file(WRITE) command to write the modified content, but later I wanted to ensure that the line endi…

---

## [I cant test my library due to missing dependencies when I include it in CMake.](https://discourse.cmake.org/t/i-cant-test-my-library-due-to-missing-dependencies-when-i-include-it-in-cmake/9760)

<div class="topic-metadata">

**Author:** [@greenleaf](https://discourse.cmake.org/u/greenleaf)\
**Replies:** 3\
**Last updated:** [January 4, 2024, 6:30am UTC](https://discourse.cmake.org/t/i-cant-test-my-library-due-to-missing-dependencies-when-i-include-it-in-cmake/9760 "2024-01-04T06:30:45Z")

</div>

I have the main CMake file for my project that looks like this: cmake\_minimum\_required(VERSION 3.19...3.25 FATAL\_ERROR) project( Turingforge VERSION 0.1.0 LANGUAGES CXX C ) #add\_compile\_options…

---

## [Cannot build modules using cmake and clang-18: "compiler does not provide a way to discover the import graph dependencies"](https://discourse.cmake.org/t/cannot-build-modules-using-cmake-and-clang-18-compiler-does-not-provide-a-way-to-discover-the-import-graph-dependencies/9757)

<div class="topic-metadata">

**Author:** [@johnworchester](https://discourse.cmake.org/u/johnworchester)\
**Replies:** 9\
**Last updated:** [January 2, 2024, 4:02pm UTC](https://discourse.cmake.org/t/cannot-build-modules-using-cmake-and-clang-18-compiler-does-not-provide-a-way-to-discover-the-import-graph-dependencies/9757 "2024-01-02T16:02:02Z")

</div>

Since the support is now stable (https://www.kitware.com/import-cmake-the-experiment-is-over/), I tried out C++ modules using cmake and clang 18. However, compiling the source gave me: The target named "\<target\>" has C…

---

## [CMake error while trying to file(COPY) framework with FOLLOW\_SYMLINK\_CHAIN](https://discourse.cmake.org/t/cmake-error-while-trying-to-file-copy-framework-with-follow-symlink-chain/9739)

<div class="topic-metadata">

**Author:** [@CompSciDude](https://discourse.cmake.org/u/CompSciDude)\
**Replies:** 2\
**Last updated:** [December 30, 2023, 3:45am UTC](https://discourse.cmake.org/t/cmake-error-while-trying-to-file-copy-framework-with-follow-symlink-chain/9739 "2023-12-30T03:45:07Z")

</div>

I try to copy Qt frameworks with a file(COPY) command with FOLLOW\_SYMLINK\_CHAIN. When it tries copying the Resources symlink, I get this error. CMake Error at /Users/administrator/CMakeProjectTemplate/cmake/CopySymlink…

---

## [The CPACK\_PACKAGE\_VERSION handling is confusing me?](https://discourse.cmake.org/t/the-cpack-package-version-handling-is-confusing-me/9735)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 1\
**Last updated:** [December 29, 2023, 7:11pm UTC](https://discourse.cmake.org/t/the-cpack-package-version-handling-is-confusing-me/9735 "2023-12-29T19:11:44Z")

</div>

I use CPACK for my project: project(Boost-CMake LANGUAGES C CXX VERSION 1.81.0.3) The resulting TGZ package is named: Boost-CMake-1.81.0-Darwin.tar.gz I am missing my last RC number v1.81.0-rc3? And if I use this pro…

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

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