# Code

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

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

**Page:** 57

---

## [How to use BullseyeCoverage with armclang cross-compiling?](https://discourse.cmake.org/t/how-to-use-bullseyecoverage-with-armclang-cross-compiling/3829)

<div class="topic-metadata">

**Author:** [@oscarh](https://discourse.cmake.org/u/oscarh)\
**Replies:** 0\
**Last updated:** [July 25, 2021, 12:04pm UTC](https://discourse.cmake.org/t/how-to-use-bullseyecoverage-with-armclang-cross-compiling/3829 "2021-07-25T12:04:19Z")

</div>

Hi, All, We chose to use BullseyeCoverage tool to collect test coverage data for our embedded system. It works well with our traditional Makefile build system. But with CMake, we haven’t been able to make it work. Basi…

---

## [RUNTIME\_DEPENDENCIES cannot find dll](https://discourse.cmake.org/t/runtime-dependencies-cannot-find-dll/3782)

<div class="topic-metadata">

**Author:** [@Leon0402](https://discourse.cmake.org/u/Leon0402)\
**Replies:** 4\
**Last updated:** [July 24, 2021, 8:45am UTC](https://discourse.cmake.org/t/runtime-dependencies-cannot-find-dll/3782 "2021-07-24T08:45:50Z")

</div>

Hi, I’m using RUNTIME\_DEPENDENCIES with CMake 3.21 as follow: install(TARGETS MyApp RUNTIME\_DEPENDENCIES PRE\_EXCLUDE\_REGEXES "api-ms-" "ext-ms-" POST\_EXCLUDE\_REGEXES ".\*system32/.\*\\\\.dll" ) But it says "file…

---

## [External Include on MSVC](https://discourse.cmake.org/t/external-include-on-msvc/3824)

<div class="topic-metadata">

**Author:** [@Leon0402](https://discourse.cmake.org/u/Leon0402)\
**Replies:** 4\
**Last updated:** [July 23, 2021, 5:49pm UTC](https://discourse.cmake.org/t/external-include-on-msvc/3824 "2021-07-23T17:49:02Z")

</div>

Hi, I found that cmake seems to support -external:I since https://gitlab.kitware.com/cmake/cmake/-/merge\_requests/4766. I have something something like this in my project: get\_property(date\_include\_dirs TARGET date PR…

---

## [Exporting packages with a custom Find module](https://discourse.cmake.org/t/exporting-packages-with-a-custom-find-module/3820)

<div class="topic-metadata">

**Author:** [@steve2510](https://discourse.cmake.org/u/steve2510)\
**Replies:** 3\
**Last updated:** [July 23, 2021, 2:00pm UTC](https://discourse.cmake.org/t/exporting-packages-with-a-custom-find-module/3820 "2021-07-23T14:00:05Z")

</div>

Hello, I’m currently in the process of creating a CMake export package for a library we develop. This library has a public dependency on several other libraries, one of which doesn’t have package config files or a find …

---

## [Avoiding duplicate symbols when linking a library multiple times](https://discourse.cmake.org/t/avoiding-duplicate-symbols-when-linking-a-library-multiple-times/3816)

<div class="topic-metadata">

**Author:** [@jsuthe](https://discourse.cmake.org/u/jsuthe)\
**Replies:** 2\
**Last updated:** [July 23, 2021, 12:52pm UTC](https://discourse.cmake.org/t/avoiding-duplicate-symbols-when-linking-a-library-multiple-times/3816 "2021-07-23T12:52:00Z")

</div>

This may be a silly question, but here it goes. I have a library (call it myLib) that depends on yaml as well as another third-party library, libA, which internally builds a version of yaml. Dependency looks like: myL…

---

## [How to refine "if(flag) set(flag) endif()" code](https://discourse.cmake.org/t/how-to-refine-if-flag-set-flag-endif-code/3802)

<div class="topic-metadata">

**Author:** [@1113](https://discourse.cmake.org/u/1113)\
**Replies:** 2\
**Last updated:** [July 23, 2021, 2:22am UTC](https://discourse.cmake.org/t/how-to-refine-if-flag-set-flag-endif-code/3802 "2021-07-23T02:22:56Z")

</div>

Hi I want to move the code below into one line: if(NOT CONFIG\_A) set(CONFIG\_B OFF CACHE BOOL "test") endif() As I researched the document, I can use set $\<NOT:$\<CONFIG\_A\>\>, how to embed it into the code? Like…

---

## [deb Depends deb](https://discourse.cmake.org/t/deb-depends-deb/3788)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 12\
**Last updated:** [July 21, 2021, 2:02pm UTC](https://discourse.cmake.org/t/deb-depends-deb/3788 "2021-07-21T14:02:37Z")

</div>

I use cpack to generate two deb A.deb depends on B.deb I want to install A.deb with double click and the process of installation(A.deb) will check if the B.deb exist. If no exist , it will download the B.deb and instal…

---

## [Integrate large repositories into your project.](https://discourse.cmake.org/t/integrate-large-repositories-into-your-project/3740)

<div class="topic-metadata">

**Author:** [@xhustango](https://discourse.cmake.org/u/xhustango)\
**Replies:** 14\
**Last updated:** [July 21, 2021, 12:30pm UTC](https://discourse.cmake.org/t/integrate-large-repositories-into-your-project/3740 "2021-07-21T12:30:28Z")

</div>

Hi there, In my project, I need to work with wxWidgets and OpenCV to implement GUI functionalities. Right now, I am using the FetchContent module to integrate the libraries mentioned, and, as you may know, they are quit…

---

## [Base filename gets set to compiler\_depend.ts after update to CMake 3.20](https://discourse.cmake.org/t/base-filename-gets-set-to-compiler-depend-ts-after-update-to-cmake-3-20/3075)

<div class="topic-metadata">

**Author:** [@cristi](https://discourse.cmake.org/u/cristi)\
**Replies:** 8\
**Last updated:** [July 19, 2021, 7:12pm UTC](https://discourse.cmake.org/t/base-filename-gets-set-to-compiler-depend-ts-after-update-to-cmake-3-20/3075 "2021-07-19T19:12:05Z")

</div>

One project I work on used to add a \_\_FILENAME\_\_ macro definition when the generator used was GNU Make, as follows: set(CMAKE\_C\_FLAGS "${CMAKE\_C\_FLAGS} -D\_\_FILENAME\_\_='\\"$(notdir $(abspath $\<))\\"'") This is similar to …

---

## [command for install dependency lib](https://discourse.cmake.org/t/command-for-install-dependency-lib/3780)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 2\
**Last updated:** [July 19, 2021, 3:20pm UTC](https://discourse.cmake.org/t/command-for-install-dependency-lib/3780 "2021-07-19T15:20:37Z")

</div>

If my project have the dependency lib and my system doesnt install it, how to process it with cmake when double click .deb file?

---

## [Propagating usage requirements to object libraries](https://discourse.cmake.org/t/propagating-usage-requirements-to-object-libraries/3771)

<div class="topic-metadata">

**Author:** [@Zomgrolf](https://discourse.cmake.org/u/Zomgrolf)\
**Replies:** 5\
**Last updated:** [July 17, 2021, 2:55pm UTC](https://discourse.cmake.org/t/propagating-usage-requirements-to-object-libraries/3771 "2021-07-17T14:55:33Z")

</div>

Hi all, I’m seeing some rather surprising behaviour and would greatly appreciate if someone could explain it to me: this is a 3rd party library that sets the CMake minimum version at 3.12 (I’m using 3.20.5). The ‘issue…

---

## [Forcing variable expansion](https://discourse.cmake.org/t/forcing-variable-expansion/3769)

<div class="topic-metadata">

**Author:** [@Zomgrolf](https://discourse.cmake.org/u/Zomgrolf)\
**Replies:** 2\
**Last updated:** [July 16, 2021, 10:21am UTC](https://discourse.cmake.org/t/forcing-variable-expansion/3769 "2021-07-16T10:21:21Z")

</div>

Is there a way to force variable expansion on a string that contains a variable reference? In my case I have a variable SOME\_VAR that is set by the user on the command line and contains a reference to a variable that is…

---

## [recommended workaround for parallel make executes command multiple times does not work with CMP0071](https://discourse.cmake.org/t/recommended-workaround-for-parallel-make-executes-command-multiple-times-does-not-work-with-cmp0071/2276)

<div class="topic-metadata">

**Author:** [@sdettmer](https://discourse.cmake.org/u/sdettmer)\
**Replies:** 10\
**Last updated:** [July 15, 2021, 7:01pm UTC](https://discourse.cmake.org/t/recommended-workaround-for-parallel-make-executes-command-multiple-times-does-not-work-with-cmp0071/2276 "2021-07-15T19:01:15Z")

</div>

Hi! I have custom command to create C++ sources to be compiled. One simple example is having part of the sources in a tarball (there are very specific requirements, I know that this is not normal), or have them generate…

---

## [CMAKE\_UNITY\_BUILD\_BATCH\_SIZE seens not has any effect in windows & linux](https://discourse.cmake.org/t/cmake-unity-build-batch-size-seens-not-has-any-effect-in-windows-linux/3761)

<div class="topic-metadata">

**Author:** [@1112](https://discourse.cmake.org/u/1112)\
**Replies:** 1\
**Last updated:** [July 15, 2021, 8:19am UTC](https://discourse.cmake.org/t/cmake-unity-build-batch-size-seens-not-has-any-effect-in-windows-linux/3761 "2021-07-15T08:19:25Z")

</div>

Our team open the unity build in cmake, unity build is work right, but the batch size seens not have any effect for our. test code is like: set\_target\_properties(TableReader PROPERTIES UNITY\_BUILD\_MODE BATCH CMAKE\_UN…

---

## [how to process object file before create static library](https://discourse.cmake.org/t/how-to-process-object-file-before-create-static-library/3754)

<div class="topic-metadata">

**Author:** [@tiandisuixin](https://discourse.cmake.org/u/tiandisuixin)\
**Replies:** 2\
**Last updated:** [July 15, 2021, 1:51am UTC](https://discourse.cmake.org/t/how-to-process-object-file-before-create-static-library/3754 "2021-07-15T01:51:54Z")

</div>

To build a static library: Common process: add\_library(name source-list ) #xx.c-\> xx.o, xx.o-\>xx.a My problem: I need run command "${CMAKE\_OBJCOPY} --prefix-alloc-sections .sram xx.o " to process xx.o file The p…

---

## [ds store](https://discourse.cmake.org/t/ds-store/3716)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 4\
**Last updated:** [July 14, 2021, 1:52am UTC](https://discourse.cmake.org/t/ds-store/3716 "2021-07-14T01:52:14Z")

</div>

How can I open the ds\_store and edit it ? I try to open it with text edit but it show the " Budi @@A E…" By the way, I am using https://cmake.org/cmake/help/v3.0/module/CPackDMG.html#variable:CPACK\_DMG\_DS\_STORE

---

## [fatal error: rs\_test/types/all\_types.h: No such file or directory](https://discourse.cmake.org/t/fatal-error-rs-test-types-all-types-h-no-such-file-or-directory/3746)

<div class="topic-metadata">

**Author:** [@Agile](https://discourse.cmake.org/u/Agile)\
**Replies:** 0\
**Last updated:** [July 13, 2021, 4:39pm UTC](https://discourse.cmake.org/t/fatal-error-rs-test-types-all-types-h-no-such-file-or-directory/3746 "2021-07-13T16:39:40Z")

</div>

Hello guys, I am new to Cmake programming and stuff. I working on this Tutorials — RoboSherlock 0.1 documentation tutorial, in section, “Add new type to the type system” when I compile it after editing it all I got…

---

## [launched just after the user clicked on the "Install" button.](https://discourse.cmake.org/t/launched-just-after-the-user-clicked-on-the-install-button/3738)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 0\
**Last updated:** [July 12, 2021, 2:16am UTC](https://discourse.cmake.org/t/launched-just-after-the-user-clicked-on-the-install-button/3738 "2021-07-12T02:16:23Z")

</div>

This script is launched just after the user clicked on the “Install” button. Do you have the function with cmake on macos and linux？

---

## [postinstall with cmake](https://discourse.cmake.org/t/postinstall-with-cmake/3701)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 3\
**Last updated:** [July 11, 2021, 3:38am UTC](https://discourse.cmake.org/t/postinstall-with-cmake/3701 "2021-07-11T03:38:58Z")

</div>

How to create a postinstall or preinstall with cmake (macOS

---

## [Naming pattern for \`Find\*.cmake\` module variables](https://discourse.cmake.org/t/naming-pattern-for-find-cmake-module-variables/3713)

<div class="topic-metadata">

**Author:** [@KartikSoneji](https://discourse.cmake.org/u/KartikSoneji)\
**Replies:** 8\
**Last updated:** [July 9, 2021, 11:05pm UTC](https://discourse.cmake.org/t/naming-pattern-for-find-cmake-module-variables/3713 "2021-07-09T23:05:36Z")

</div>

Hi I am still new to CMake, so apologies if I have missed something obvious The find\_package command (https://cmake.org/cmake/help/latest/command/find\_package.html) doesn’t specify any conventions for the variables tha…

---

## [\`generate\_export\_header\` + \`target\_include\_directories\` leaves \`fatal error C1083: Cannot open include file\`](https://discourse.cmake.org/t/generate-export-header-target-include-directories-leaves-fatal-error-c1083-cannot-open-include-file/3708)

<div class="topic-metadata">

**Author:** [@SamuelMarks](https://discourse.cmake.org/u/SamuelMarks)\
**Replies:** 3\
**Last updated:** [July 8, 2021, 1:13pm UTC](https://discourse.cmake.org/t/generate-export-header-target-include-directories-leaves-fatal-error-c1083-cannot-open-include-file/3708 "2021-07-08T13:13:12Z")

</div>

I added these lines to my cmake-example-with-vcpkg/versions/CMakeLists.txt at 993ec593d7b0f26dbd2c7eac3953a894081e69bd · SamuelMarks/cmake-example-with-vcpkg · GitHub # set(LIBRARY\_NAME "versions") include(GenerateExpor…

---

## [Toggle shared/static library: MSVC fails (linker); but AppleClang, gcc (Linux, MinGW) work](https://discourse.cmake.org/t/toggle-shared-static-library-msvc-fails-linker-but-appleclang-gcc-linux-mingw-work/3706)

<div class="topic-metadata">

**Author:** [@SamuelMarks](https://discourse.cmake.org/u/SamuelMarks)\
**Replies:** 4\
**Last updated:** [July 8, 2021, 1:12pm UTC](https://discourse.cmake.org/t/toggle-shared-static-library-msvc-fails-linker-but-appleclang-gcc-linux-mingw-work/3706 "2021-07-08T13:12:16Z")

</div>

I made a little GitHub repo based off the official cmake\\Help\\guide\\tutorial\\Complete at 0fdfd6bf. Kept things simple, all C code, two CMakeLists.txt (one library; one executable). And GitHub Actions so you can replicate…

---

## [Visual studio install path and directory query](https://discourse.cmake.org/t/visual-studio-install-path-and-directory-query/3684)

<div class="topic-metadata">

**Author:** [@serge](https://discourse.cmake.org/u/serge)\
**Replies:** 11\
**Last updated:** [July 8, 2021, 5:02am UTC](https://discourse.cmake.org/t/visual-studio-install-path-and-directory-query/3684 "2021-07-08T05:02:33Z")

</div>

Probably a basic question. Through couldn’t find a good answer. Suppose I am running a cmake project for visual studio build engine. Sometimes, you need the sdk directory and others VS directories to set the include pa…

---

## [Getting all PUBLIC & INTERFACE definitions including from dependencies](https://discourse.cmake.org/t/getting-all-public-interface-definitions-including-from-dependencies/3697)

<div class="topic-metadata">

**Author:** [@themarpe](https://discourse.cmake.org/u/themarpe)\
**Replies:** 4\
**Last updated:** [July 7, 2021, 12:56pm UTC](https://discourse.cmake.org/t/getting-all-public-interface-definitions-including-from-dependencies/3697 "2021-07-07T12:56:53Z")

</div>

Hi. I have stumbled upon an use case where I think this might come handy, but I am not sure if possible in current CMake. My project specifies a target A which depends on targets B & C. For third party integration, I in…

---

## [it may be damaged or incomplete](https://discourse.cmake.org/t/it-may-be-damaged-or-incomplete/3702)

<div class="topic-metadata">

**Author:** [@alice](https://discourse.cmake.org/u/alice)\
**Replies:** 3\
**Last updated:** [July 7, 2021, 11:26am UTC](https://discourse.cmake.org/t/it-may-be-damaged-or-incomplete/3702 "2021-07-07T11:26:13Z")

</div>

How can I avoid the error？ STEP： git clone GitHub - dev-cafe/cmake-cookbook: CMake Cookbook recipes. cd cmake-cookbook/chapter-11/recipe-01/cxx-example mkdir build cd build cmake … cpack result： click and instal…

---

## [target\_compile\_defintion with $\<INSTALL\_INTERFACE:\>](https://discourse.cmake.org/t/target-compile-defintion-with-install-interface/3677)

<div class="topic-metadata">

**Author:** [@Tudyx](https://discourse.cmake.org/u/Tudyx)\
**Replies:** 5\
**Last updated:** [July 2, 2021, 3:08pm UTC](https://discourse.cmake.org/t/target-compile-defintion-with-install-interface/3677 "2021-07-02T15:08:06Z")

</div>

I have a config file that i want in by project folder in build mode and in /usr/local/etc in install mode. I try to use generator expression for that but it didn’t work, the build mode path is always evaluated, even if …

---

## [Genex JOIN combined with TARGET\_OBJECTS unexpected behavior](https://discourse.cmake.org/t/genex-join-combined-with-target-objects-unexpected-behavior/3673)

<div class="topic-metadata">

**Author:** [@serge](https://discourse.cmake.org/u/serge)\
**Replies:** 3\
**Last updated:** [July 2, 2021, 11:47am UTC](https://discourse.cmake.org/t/genex-join-combined-with-target-objects-unexpected-behavior/3673 "2021-07-02T11:47:02Z")

</div>

xxx is a custom target with custom link command xlib is an OBJECT library with say two objects a.obj and b.obj I am using the following code: add\_custom\_command( TARGET xxx PRE\_BUILD COMMENT ${CMAKE\_COMMAND} -E ech…

---

## [cmake behaviour with add\_subdirectory](https://discourse.cmake.org/t/cmake-behaviour-with-add-subdirectory/3680)

<div class="topic-metadata">

**Author:** [@nakkore](https://discourse.cmake.org/u/nakkore)\
**Replies:** 4\
**Last updated:** [July 2, 2021, 11:10am UTC](https://discourse.cmake.org/t/cmake-behaviour-with-add-subdirectory/3680 "2021-07-02T11:10:12Z")

</div>

Hi guys, I can see a behaviour with a cmake project which I can’t explain. I’ve got the following simplified project layout: . ├── a │ ├── a.cpp │ ├── a.h │ └── CMakeLists.txt ├── b │ ├── b.cpp │ ├── …

---

## [Help with migrating a large project from MSVC on Windows to Linux using CMake](https://discourse.cmake.org/t/help-with-migrating-a-large-project-from-msvc-on-windows-to-linux-using-cmake/3667)

<div class="topic-metadata">

**Author:** [@vaonet](https://discourse.cmake.org/u/vaonet)\
**Replies:** 1\
**Last updated:** [July 1, 2021, 4:57pm UTC](https://discourse.cmake.org/t/help-with-migrating-a-large-project-from-msvc-on-windows-to-linux-using-cmake/3667 "2021-07-01T16:57:35Z")

</div>

I am trying to migrate a somewhat large project consisting of 35 libs and services, and a few external dependent libs (e.g. boost) from Windows platform to Linux. I think I can handle the actual code migration - getting …

---

## [how to get current build type for a multi-config generator ?](https://discourse.cmake.org/t/how-to-get-current-build-type-for-a-multi-config-generator/3638)

<div class="topic-metadata">

**Author:** [@quanzhuo](https://discourse.cmake.org/u/quanzhuo)\
**Replies:** 2\
**Last updated:** [June 30, 2021, 8:27am UTC](https://discourse.cmake.org/t/how-to-get-current-build-type-for-a-multi-config-generator/3638 "2021-06-30T08:27:53Z")

</div>

Hi, All: I need to set a variable only under debug build. I can archive this in a single config generator by check CMAKE\_BUILD\_TYPE. if (CMAKE\_BUILD\_TYPE STREQUAL "Debug") set(CPACK\_RPM\_DEBUGINFO\_PACKAGE ON) endif(…

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

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