# Code

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

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

**Page:** 55

---

## [Metadata (\`git describe') in OUTPUT\_DIRECTORY](https://discourse.cmake.org/t/metadata-git-describe-in-output-directory/4182)

<div class="topic-metadata">

**Author:** [@jjELT](https://discourse.cmake.org/u/jjELT)\
**Replies:** 3\
**Last updated:** [October 5, 2021, 5:27pm UTC](https://discourse.cmake.org/t/metadata-git-describe-in-output-directory/4182 "2021-10-05T17:27:28Z")

</div>

Problem Description I would like to use metadata, like the result of git describe, in the \*OUTPUT\_DIRECTORY\_\<CONFIG\> variables. I am already using metadata, which is constant and can therefore be added in the configurat…

---

## [Static analyzers as seperate targets](https://discourse.cmake.org/t/static-analyzers-as-seperate-targets/4074)

<div class="topic-metadata">

**Author:** [@Leon0402](https://discourse.cmake.org/u/Leon0402)\
**Replies:** 8\
**Last updated:** [October 4, 2021, 7:54am UTC](https://discourse.cmake.org/t/static-analyzers-as-seperate-targets/4074 "2021-10-04T07:54:47Z")

</div>

Hi, I currently use clang-tidy, cppcheck and incldue-what-you-use cmake integrations, but there are a few problems: It’s somewhat annoying when just prototyping because of all the output It’s slow as hell when recompi…

---

## ["Custom" language setup on Windows](https://discourse.cmake.org/t/custom-language-setup-on-windows/4194)

<div class="topic-metadata">

**Author:** [@krasznaa](https://discourse.cmake.org/u/krasznaa)\
**Replies:** 0\
**Last updated:** [October 3, 2021, 8:24am UTC](https://discourse.cmake.org/t/custom-language-setup-on-windows/4194 "2021-10-03T08:24:08Z")

</div>

Dear All, I’m playing with something a bit convoluted… I am setting up a custom language for my project through a set of CMakeDetermine\<LANG\>Compiler.cmake, CMake\<LANG\>Information.cmake, etc. modules. A bit unwillingly,…

---

## [Undefined reference problems - C++](https://discourse.cmake.org/t/undefined-reference-problems-c/4189)

<div class="topic-metadata">

**Author:** [@UltraBlack](https://discourse.cmake.org/u/UltraBlack)\
**Replies:** 7\
**Last updated:** [October 1, 2021, 6:06pm UTC](https://discourse.cmake.org/t/undefined-reference-problems-c/4189 "2021-10-01T18:06:01Z")

</div>

Hey there, I’m facing some issues with undefined references in my code and I’ve come to the conclusion, that CMake must be some kind of error source - There are no compiling problems, it just fails to … do stuff wheneve…

---

## [Compiler warning flags for all except ExternalProjects](https://discourse.cmake.org/t/compiler-warning-flags-for-all-except-externalprojects/4176)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 4\
**Last updated:** [October 1, 2021, 12:27pm UTC](https://discourse.cmake.org/t/compiler-warning-flags-for-all-except-externalprojects/4176 "2021-10-01T12:27:55Z")

</div>

I have an old cmake project and want to apply compiler warning flags for all targets except externals built with ExternalProject\_Add. Is there any easy way to retro fit this?

---

## [set interpreter path at install?](https://discourse.cmake.org/t/set-interpreter-path-at-install/4158)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 4\
**Last updated:** [October 1, 2021, 11:43am UTC](https://discourse.cmake.org/t/set-interpreter-path-at-install/4158 "2021-10-01T11:43:22Z")

</div>

Is it possible to have cmake set the interpreter path at install step? I want to rewrite the interpreter path when installing. Currently I’m doing patchelf --set-interpreter to achieve this. There is a CMAKE\_INSTALL\_RPAT…

---

## [find\_library so and all symlinks](https://discourse.cmake.org/t/find-library-so-and-all-symlinks/4160)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 6\
**Last updated:** [October 1, 2021, 11:35am UTC](https://discourse.cmake.org/t/find-library-so-and-all-symlinks/4160 "2021-10-01T11:35:27Z")

</div>

How to find a library (find\_library) and all associated symlinks to that library? E.g. a library typically looks like libfoo.so libfoo.so.1 libfoo.so.1.0.0 where the latter two are symlinks. Is there a better way than…

---

## [How to determine if \`clang\` or \`clang-cl\` is used on Windows?](https://discourse.cmake.org/t/how-to-determine-if-clang-or-clang-cl-is-used-on-windows/4129)

<div class="topic-metadata">

**Author:** [@dbahadir](https://discourse.cmake.org/u/dbahadir)\
**Replies:** 9\
**Last updated:** [September 27, 2021, 7:25pm UTC](https://discourse.cmake.org/t/how-to-determine-if-clang-or-clang-cl-is-used-on-windows/4129 "2021-09-27T19:25:25Z")

</div>

Lately, I started developing more on Windows and I now want to determine if I am using clang or clang-cl? While googling I became aware of CMAKE\_\<LANG\>\_COMPILER\_FRONTEND\_VARIANT. However, I am not finding any documentat…

---

## [link two static libraries to a shared library](https://discourse.cmake.org/t/link-two-static-libraries-to-a-shared-library/4132)

<div class="topic-metadata">

**Author:** [@NePutin94](https://discourse.cmake.org/u/NePutin94)\
**Replies:** 2\
**Last updated:** [September 24, 2021, 9:30am UTC](https://discourse.cmake.org/t/link-two-static-libraries-to-a-shared-library/4132 "2021-09-24T09:30:19Z")

</div>

The structure of my project: +--ROOT -CmakeLists.txt +--imgui -CmakeLists.txt +--core -CmakeLists.txt +--imgui\_glfw -CmakeLists.txt Root CmakeLists.txt adds imgui, imgui\_glfw, and core as subdirectory: ... a…

---

## [Avoid false positives from check\_symbol\_exists()](https://discourse.cmake.org/t/avoid-false-positives-from-check-symbol-exists/4133)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 5\
**Last updated:** [September 24, 2021, 9:27am UTC](https://discourse.cmake.org/t/avoid-false-positives-from-check-symbol-exists/4133 "2021-09-24T09:27:29Z")

</div>

When cross-compiling what’s a good practice for using check\_symbol\_exists against only the toolchain, that is avoiding that it finds the symbol on the host system as a false positive? To elaborate, today we do those che…

---

## [cmake picks up LDFLAGS from environment](https://discourse.cmake.org/t/cmake-picks-up-ldflags-from-environment/4130)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 17\
**Last updated:** [September 23, 2021, 7:13pm UTC](https://discourse.cmake.org/t/cmake-picks-up-ldflags-from-environment/4130 "2021-09-23T19:13:06Z")

</div>

If LDFLAGS are set in environment, then cmake picks that up and adds it to the list of linker flags. What is the way to avoid that? I tried to define CMAKE\_EXE\_LINKER\_FLAGS\_INIT, CMAKE\_CXX\_LINK\_FLAGS etc in the toolchain…

---

## [CMake project cross-compiling Error: variables set to NOTFOUND](https://discourse.cmake.org/t/cmake-project-cross-compiling-error-variables-set-to-notfound/4101)

<div class="topic-metadata">

**Author:** [@hela](https://discourse.cmake.org/u/hela)\
**Replies:** 1\
**Last updated:** [September 21, 2021, 1:23pm UTC](https://discourse.cmake.org/t/cmake-project-cross-compiling-error-variables-set-to-notfound/4101 "2021-09-21T13:23:22Z")

</div>

Hello, I am trying to cross compile a cmake project with static library but getting error: CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they …

---

## [ExternalProject BUILD\_BYPRODUCTS generator expression](https://discourse.cmake.org/t/externalproject-build-byproducts-generator-expression/4124)

<div class="topic-metadata">

**Author:** [@scivision](https://discourse.cmake.org/u/scivision)\
**Replies:** 1\
**Last updated:** [September 20, 2021, 8:06pm UTC](https://discourse.cmake.org/t/externalproject-build-byproducts-generator-expression/4124 "2021-09-20T20:06:47Z")

</div>

Can ExternalProject BUILD\_BYPRODUCTS use generator expressions? It seems maybe not as I get errors about “\<” and “\>” not being allowed. This is to account for a library that may be built by the externalproject, or not bu…

---

## [avoid performing update step for externalproject](https://discourse.cmake.org/t/avoid-performing-update-step-for-externalproject/4117)

<div class="topic-metadata">

**Author:** [@hex](https://discourse.cmake.org/u/hex)\
**Replies:** 1\
**Last updated:** [September 20, 2021, 2:19pm UTC](https://discourse.cmake.org/t/avoid-performing-update-step-for-externalproject/4117 "2021-09-20T14:19:19Z")

</div>

the following code performs an update step even so the git hash is up to date: cmake\_minimum\_required(VERSION 3.20) project(MyProj) include(ExternalProject) ExternalProject\_Add(foo LOG\_DOWNLOAD ON LOG\_UPDATE ON L…

---

## [What is the best way to make data files available to my executable at runtime?](https://discourse.cmake.org/t/what-is-the-best-way-to-make-data-files-available-to-my-executable-at-runtime/4113)

<div class="topic-metadata">

**Author:** [@Chrinkus](https://discourse.cmake.org/u/Chrinkus)\
**Replies:** 2\
**Last updated:** [September 20, 2021, 2:09pm UTC](https://discourse.cmake.org/t/what-is-the-best-way-to-make-data-files-available-to-my-executable-at-runtime/4113 "2021-09-20T14:09:34Z")

</div>

I have a project that wants to read PNGs from a /images folder. I’ve done a few different things in the past but they all depend on where the executable is called from. My most recent attempt should make this clear: Pro…

---

## [ninja error: multiple rules generate](https://discourse.cmake.org/t/ninja-error-multiple-rules-generate/4018)

<div class="topic-metadata">

**Author:** [@kerim](https://discourse.cmake.org/u/kerim)\
**Replies:** 2\
**Last updated:** [September 18, 2021, 9:14pm UTC](https://discourse.cmake.org/t/ninja-error-multiple-rules-generate/4018 "2021-09-18T21:14:39Z")

</div>

Hi, I’m not sure wether the error is connected with CMake or ninja but still I try to ask here. I have a big project (based on Slicer 3D) and I’m trying to build it with CMake 3.19.2 (I also tested 3.21.2 master branch…

---

## [how does COMMAND\_CONFIG work for other generators?](https://discourse.cmake.org/t/how-does-command-config-work-for-other-generators/4089)

<div class="topic-metadata">

**Author:** [@hex](https://discourse.cmake.org/u/hex)\
**Replies:** 1\
**Last updated:** [September 18, 2021, 3:03pm UTC](https://discourse.cmake.org/t/how-does-command-config-work-for-other-generators/4089 "2021-09-18T15:03:28Z")

</div>

the documentation has new generator expression OUTPUT\_CONFIG and COMMAND\_CONFIG. I am not familiar with Ninja, it seems like it supports configuration files for file-level dependencies. I am mostly interested in this par…

---

## [Cross compile for DevkitPPC](https://discourse.cmake.org/t/cross-compile-for-devkitppc/3899)

<div class="topic-metadata">

**Author:** [@Lgreen9800](https://discourse.cmake.org/u/Lgreen9800)\
**Replies:** 6\
**Last updated:** [September 14, 2021, 8:18pm UTC](https://discourse.cmake.org/t/cross-compile-for-devkitppc/3899 "2021-09-14T20:18:50Z")

</div>

Hello, I am trying to build a cmake project that will use the devkitppc toolchain inorder to cross compile from windows to Nintendo Wii. This involves using the powerpc-eabi-gcc compiler, I include the toolchain file t…

---

## [Disable valgrind per target?](https://discourse.cmake.org/t/disable-valgrind-per-target/4079)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 2\
**Last updated:** [September 14, 2021, 5:24pm UTC](https://discourse.cmake.org/t/disable-valgrind-per-target/4079 "2021-09-14T17:24:00Z")

</div>

If I run ‘ctest -T memcheck’ it runs valgrind on all unit tests. But how to programmatically disable valgrind per target?

---

## [MSVC\_RUNTIME\_LIBRARY defaults to dynamic linking for static libraries?!](https://discourse.cmake.org/t/msvc-runtime-library-defaults-to-dynamic-linking-for-static-libraries/4084)

<div class="topic-metadata">

**Author:** [@walki](https://discourse.cmake.org/u/walki)\
**Replies:** 6\
**Last updated:** [September 14, 2021, 2:08pm UTC](https://discourse.cmake.org/t/msvc-runtime-library-defaults-to-dynamic-linking-for-static-libraries/4084 "2021-09-14T14:08:02Z")

</div>

Hi, I use CMake with CMAKE\_WINDOWS\_EXPORT\_ALL\_SYMBOLS to automatically generate both a shared dll and static .lib library on Windows when building with MSVC. I found out yesterday that the static .lib uses dynamic linki…

---

## [How to support multiple unique configurations of a project in a monorpeo?](https://discourse.cmake.org/t/how-to-support-multiple-unique-configurations-of-a-project-in-a-monorpeo/4081)

<div class="topic-metadata">

**Author:** [@nslogan](https://discourse.cmake.org/u/nslogan)\
**Replies:** 0\
**Last updated:** [September 13, 2021, 6:44pm UTC](https://discourse.cmake.org/t/how-to-support-multiple-unique-configurations-of-a-project-in-a-monorpeo/4081 "2021-09-13T18:44:23Z")

</div>

I am working in a monorepo that utilizes an RTOS for multiple embedded targets. This RTOS project does not use CMake as its build system, so I am providing the integration into CMake. To build a firmware binary, the RTOS…

---

## [find\_library won't find DLLs](https://discourse.cmake.org/t/find-library-wont-find-dlls/4050)

<div class="topic-metadata">

**Author:** [@samw](https://discourse.cmake.org/u/samw)\
**Replies:** 4\
**Last updated:** [September 11, 2021, 5:35pm UTC](https://discourse.cmake.org/t/find-library-wont-find-dlls/4050 "2021-09-11T17:35:40Z")

</div>

I’m trying to write a FindGigeSim.cmake module that creates imported targets for a 3rd party library. I’m having trouble getting it to work on Windows. Specifically, the following command fails to find the gigesimsdk64.…

---

## [Weird warning about yasm assembler not found:](https://discourse.cmake.org/t/weird-warning-about-yasm-assembler-not-found/4039)

<div class="topic-metadata">

**Author:** [@serge](https://discourse.cmake.org/u/serge)\
**Replies:** 4\
**Last updated:** [September 11, 2021, 12:56pm UTC](https://discourse.cmake.org/t/weird-warning-about-yasm-assembler-not-found/4039 "2021-09-11T12:56:16Z")

</div>

Hello everybody, Some strange warning. I am setting the following in order to have assembler running properly: set(CMAKE\_ASM\_COMPILER /usr/local/bin/yasm) set(CMAKE\_ASM\_COMPILE\_OBJECT "\<CMAKE\_ASM\_COMPILER\> -f macho64 …

---

## [find\_library or add\_library does not work with xcframework for iOS/Mac](https://discourse.cmake.org/t/find-library-or-add-library-does-not-work-with-xcframework-for-ios-mac/4065)

<div class="topic-metadata">

**Author:** [@skandpal](https://discourse.cmake.org/u/skandpal)\
**Replies:** 1\
**Last updated:** [September 11, 2021, 7:54am UTC](https://discourse.cmake.org/t/find-library-or-add-library-does-not-work-with-xcframework-for-ios-mac/4065 "2021-09-11T07:54:26Z")

</div>

If we are building a framework containing an iOS and iOS simulator slice then we have to use xcframework (Xcode 13 only supports xcframeworks) but cmake does not look like support it. Is there a way to use xcframework in…

---

## [How to handle more than 10 config flags in if statement?](https://discourse.cmake.org/t/how-to-handle-more-than-10-config-flags-in-if-statement/3800)

<div class="topic-metadata">

**Author:** [@tbacarrot](https://discourse.cmake.org/u/tbacarrot)\
**Replies:** 9\
**Last updated:** [September 6, 2021, 9:09pm UTC](https://discourse.cmake.org/t/how-to-handle-more-than-10-config-flags-in-if-statement/3800 "2021-09-06T21:09:50Z")

</div>

Hi all, In my project, an execution step is controlled by about 10 ~ 15 config flags. Currently I implement a piece of ugly code as shown below: if (CONFIG\_A OR CONFIG\_B OR CONFIG\_C OR CONFIG\_D OR …

---

## [CMake Multiline Function Code Style](https://discourse.cmake.org/t/cmake-multiline-function-code-style/4023)

<div class="topic-metadata">

**Author:** [@jjj](https://discourse.cmake.org/u/jjj)\
**Replies:** 6\
**Last updated:** [September 6, 2021, 12:46pm UTC](https://discourse.cmake.org/t/cmake-multiline-function-code-style/4023 "2021-09-06T12:46:12Z")

</div>

Currently there is no definition of a standard CMake code style, the closest thing are the vim/emacs plugins. What should be the preferred indentation scheme? a) some\_function( LOL rofl ASDF stuff ) b) some\_…

---

## [\[BUG\] Failed to print elements of a list one by one](https://discourse.cmake.org/t/bug-failed-to-print-elements-of-a-list-one-by-one/4036)

<div class="topic-metadata">

**Author:** [@Ronald](https://discourse.cmake.org/u/Ronald)\
**Replies:** 4\
**Last updated:** [September 5, 2021, 3:04am UTC](https://discourse.cmake.org/t/bug-failed-to-print-elements-of-a-list-one-by-one/4036 "2021-09-05T03:04:11Z")

</div>

Code set(INCLUDE\_DIRS $\<TARGET\_PROPERTY:${TARGET\_NAME},INCLUDE\_DIRECTORIES\>) foreach(PATH ${INCLUDE\_DIRS}) string(CONCAT OUT\_TMP ${OUT\_TMP} "${PATH}\\n") endforeach() Expected Output /path/a /path/b /path/c Practica…

---

## [the cmake of scripts is empty](https://discourse.cmake.org/t/the-cmake-of-scripts-is-empty/4037)

<div class="topic-metadata">

**Author:** [@Azaretdodo](https://discourse.cmake.org/u/Azaretdodo)\
**Replies:** 1\
**Last updated:** [September 4, 2021, 5:30pm UTC](https://discourse.cmake.org/t/the-cmake-of-scripts-is-empty/4037 "2021-09-04T17:30:08Z")

</div>

hello, the scripts folder has a CMakeLists empty, I have tried this following but it miss the tingting syntactic and the file isn’t enough typed : cmake\_minimum\_required( VERSION 3.6 ) cmake\_policy( SET CMP0046 NEW )…

---

## [Is there any method to extract downloaded archives when using FetchContent\_Declare with DOWNLOAD\_COMMAND?](https://discourse.cmake.org/t/is-there-any-method-to-extract-downloaded-archives-when-using-fetchcontent-declare-with-download-command/4026)

<div class="topic-metadata">

**Author:** [@you74674](https://discourse.cmake.org/u/you74674)\
**Replies:** 4\
**Last updated:** [September 3, 2021, 2:36pm UTC](https://discourse.cmake.org/t/is-there-any-method-to-extract-downloaded-archives-when-using-fetchcontent-declare-with-download-command/4026 "2021-09-03T14:36:46Z")

</div>

I’m trying to use FetchContent\_Declare and DOWNLOAD\_COMMAND to download my dependency. My dependency is a zip file(which contains a big pre-built library) on release of my private github repo, so I’m using github cli to…

---

## [Cmake generates invalid linker tasks with clang on arm64](https://discourse.cmake.org/t/cmake-generates-invalid-linker-tasks-with-clang-on-arm64/4019)

<div class="topic-metadata">

**Author:** [@Pierre\_Joye](https://discourse.cmake.org/u/Pierre_Joye)\
**Replies:** 2\
**Last updated:** [September 3, 2021, 2:28am UTC](https://discourse.cmake.org/t/cmake-generates-invalid-linker-tasks-with-clang-on-arm64/4019 "2021-09-03T02:28:32Z")

</div>

Hello, I initially thought it was a bug but apparently not https://gitlab.kitware.com/cmake/cmake/-/issues/22589 It works on other platform but somehow on arm64, cmake generates something different and the linker fail…

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

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