# Code

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

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

**Page:** 64

---

## [Share source folder with other cmake projects](https://discourse.cmake.org/t/share-source-folder-with-other-cmake-projects/2499)

<div class="topic-metadata">

**Author:** [@bugblatterbeast](https://discourse.cmake.org/u/bugblatterbeast)\
**Replies:** 3\
**Last updated:** [January 12, 2021, 5:11pm UTC](https://discourse.cmake.org/t/share-source-folder-with-other-cmake-projects/2499 "2021-01-12T17:11:32Z")

</div>

Hi, how can I set up a source folder that is shared between different cmake projects? I’d like to have a folder structure like that inside my repository Main application (CMake project) Data viewer tool (CMake projec…

---

## [Provide and select Find\*.cmake file](https://discourse.cmake.org/t/provide-and-select-find-cmake-file/2501)

<div class="topic-metadata">

**Author:** [@gruenich](https://discourse.cmake.org/u/gruenich)\
**Replies:** 3\
**Last updated:** [January 11, 2021, 7:48pm UTC](https://discourse.cmake.org/t/provide-and-select-find-cmake-file/2501 "2021-01-11T19:48:18Z")

</div>

CMake 3.20 will introduce Python3\_FIND\_UNVERSIONED\_NAMES and its evaluation are just a couple of lines from Modules/FindPython/Support.cmake. I need this change in my project but I cannot require CMake 3.20, I have to st…

---

## [Issue with TARGETS\_EXPORT\_NAME](https://discourse.cmake.org/t/issue-with-targets-export-name/2508)

<div class="topic-metadata">

**Author:** [@mrmsdbdl](https://discourse.cmake.org/u/mrmsdbdl)\
**Replies:** 4\
**Last updated:** [January 11, 2021, 4:57pm UTC](https://discourse.cmake.org/t/issue-with-targets-export-name/2508 "2021-01-11T16:57:04Z")

</div>

Hi, I’ve this random issue that I don’t really understand why it’s happening. So, while ago, I put some time and improved the mlpack CMake’s script, and I think for the most part I got everything right. But, every now a…

---

## [Poorly-explained cmake\_path() subcommands (CMake 3.19)](https://discourse.cmake.org/t/poorly-explained-cmake-path-subcommands-cmake-3-19/1861)

<div class="topic-metadata">

**Author:** [@ferdnyc](https://discourse.cmake.org/u/ferdnyc)\
**Replies:** 11\
**Last updated:** [January 10, 2021, 1:36am UTC](https://discourse.cmake.org/t/poorly-explained-cmake-path-subcommands-cmake-3-19/1861 "2021-01-10T01:36:34Z")

</div>

I was reading through the documentation for the upcoming cmake\_path() command that will replace most of the file(foo\_PATH ...) subcommands in the next release, and I’m finding some of them… both non-obvious, and unhelpfu…

---

## [Question about add\_custom\_command](https://discourse.cmake.org/t/question-about-add-custom-command/2489)

<div class="topic-metadata">

**Author:** [@ceanwang](https://discourse.cmake.org/u/ceanwang)\
**Replies:** 6\
**Last updated:** [January 9, 2021, 12:47am UTC](https://discourse.cmake.org/t/question-about-add-custom-command/2489 "2021-01-09T00:47:00Z")

</div>

Hi, I am building with cmake + gnu c/c++ (MINGW) under Windows 10. I use add\_custom\_command to let a program (the name is ‘fluid’) to compiler some other resource files. Like this: add\_custom\_command( OUTPUT “${basena…

---

## [Possible bug setting VS\_SETTINGS "ExcludedFromBuild=true" for Wavefornt obj files.](https://discourse.cmake.org/t/possible-bug-setting-vs-settings-excludedfrombuild-true-for-wavefornt-obj-files/2494)

<div class="topic-metadata">

**Author:** [@Manjot\_Bal](https://discourse.cmake.org/u/Manjot_Bal)\
**Replies:** 2\
**Last updated:** [January 8, 2021, 7:53pm UTC](https://discourse.cmake.org/t/possible-bug-setting-vs-settings-excludedfrombuild-true-for-wavefornt-obj-files/2494 "2021-01-08T19:53:24Z")

</div>

Hi, When I include a Wavefront obj file to my project and generate a Visual Studio solution, the generator labels the file as an obj file meant for the c++ linker. See the following from my .vcxproj file. This causes …

---

## [What do the "dep" parameters of include\_external\_msproject() do?](https://discourse.cmake.org/t/what-do-the-dep-parameters-of-include-external-msproject-do/2490)

<div class="topic-metadata">

**Author:** [@Angew](https://discourse.cmake.org/u/Angew)\
**Replies:** 3\
**Last updated:** [January 8, 2021, 8:30am UTC](https://discourse.cmake.org/t/what-do-the-dep-parameters-of-include-external-msproject-do/2490 "2021-01-08T08:30:20Z")

</div>

The documentation of include\_external\_msproject() mentions parameters dep1 dep2 ... in the signature: include\_external\_msproject(projectname location \[TYPE projectTypeGUID\] …

---

## [Different compilers/toolchains for different targets](https://discourse.cmake.org/t/different-compilers-toolchains-for-different-targets/2471)

<div class="topic-metadata">

**Author:** [@asmvolatile](https://discourse.cmake.org/u/asmvolatile)\
**Replies:** 3\
**Last updated:** [January 6, 2021, 8:45pm UTC](https://discourse.cmake.org/t/different-compilers-toolchains-for-different-targets/2471 "2021-01-06T20:45:03Z")

</div>

I have been using CMake as a build system generator to cross compile for ARM Cortex M microcontrollers for a while now, and to great success (well, honestly it was only successful after I bought @craig.scott 's book). N…

---

## [ExternalProject\_Add when only build external libs and when build-install](https://discourse.cmake.org/t/externalproject-add-when-only-build-external-libs-and-when-build-install/2434)

<div class="topic-metadata">

**Author:** [@kerim](https://discourse.cmake.org/u/kerim)\
**Replies:** 3\
**Last updated:** [January 5, 2021, 1:43pm UTC](https://discourse.cmake.org/t/externalproject-add-when-only-build-external-libs-and-when-build-install/2434 "2021-01-05T13:43:55Z")

</div>

Hi, ExternalProject\_Add allows build and install libraries. I experiment with it and as an example I use Slicer 3D. I can see that Slicer builds some libs and other libs Slicer builds-install. What is the logic behind…

---

## [Sending more than pass/fail data to CDash - what is the data format CDash expects?](https://discourse.cmake.org/t/sending-more-than-pass-fail-data-to-cdash-what-is-the-data-format-cdash-expects/2392)

<div class="topic-metadata">

**Author:** [@jverdicchio](https://discourse.cmake.org/u/jverdicchio)\
**Replies:** 7\
**Last updated:** [January 5, 2021, 11:37am UTC](https://discourse.cmake.org/t/sending-more-than-pass-fail-data-to-cdash-what-is-the-data-format-cdash-expects/2392 "2021-01-05T11:37:01Z")

</div>

At my previous employer, we used CDash to display statistics about the tests that were run. When the code was run in “test” mode, additional statistics were recorded about the code and saved to an XML file. These statist…

---

## [arm64 / UWP / WinRT for HoloLens 2](https://discourse.cmake.org/t/arm64-uwp-winrt-for-hololens-2/1497)

<div class="topic-metadata">

**Author:** [@TWHall](https://discourse.cmake.org/u/TWHall)\
**Replies:** 5\
**Last updated:** [January 4, 2021, 8:53pm UTC](https://discourse.cmake.org/t/arm64-uwp-winrt-for-hololens-2/1497 "2021-01-04T20:53:16Z")

</div>

Visual Studio 2019 / CMAKE\_VERSION = 3.16.19112601-MSVC\_2 Trying to build an arm64 / UWP / WinRT package, ultimately for the HoloLens 2. I am successfully building an x64 / UWP / WinRT package for the desktop. I can …

---

## [What's the difference between this PROJ\_DATA\_SUBDIR and DATADIR when cmake is configuring the proj library?](https://discourse.cmake.org/t/whats-the-difference-between-this-proj-data-subdir-and-datadir-when-cmake-is-configuring-the-proj-library/2353)

<div class="topic-metadata">

**Author:** [@mirro187](https://discourse.cmake.org/u/mirro187)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 8:08pm UTC](https://discourse.cmake.org/t/whats-the-difference-between-this-proj-data-subdir-and-datadir-when-cmake-is-configuring-the-proj-library/2353 "2021-01-04T20:08:29Z")

</div>

---

## [Include the bcm2835 library for the Raspberry Pi](https://discourse.cmake.org/t/include-the-bcm2835-library-for-the-raspberry-pi/2396)

<div class="topic-metadata">

**Author:** [@Krakert](https://discourse.cmake.org/u/Krakert)\
**Replies:** 2\
**Last updated:** [January 4, 2021, 6:51pm UTC](https://discourse.cmake.org/t/include-the-bcm2835-library-for-the-raspberry-pi/2396 "2021-01-04T18:51:47Z")

</div>

Hello everyone, I\`m new to this forum and CMake. For a school project, we are working with c++. And we are using CMake to link and build the files. Now a few months in the project I’m working with the MLX90461 IR came…

---

## [Best practice for multi-config build options](https://discourse.cmake.org/t/best-practice-for-multi-config-build-options/2049)

<div class="topic-metadata">

**Author:** [@Dominik\_Charousset](https://discourse.cmake.org/u/Dominik_Charousset)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 6:41pm UTC](https://discourse.cmake.org/t/best-practice-for-multi-config-build-options/2049 "2021-01-04T18:41:17Z")

</div>

I’ve recently added flags to a project to enable sanitizers. To work nicely with multi-config generators, I’ve split the option into one for each configuration type. Much like CMAKE\_CXX\_FLAGS\_\<CONFIG\>. However, the solut…

---

## [Use include paths extracted from an external source](https://discourse.cmake.org/t/use-include-paths-extracted-from-an-external-source/1716)

<div class="topic-metadata">

**Author:** [@dushara](https://discourse.cmake.org/u/dushara)\
**Replies:** 2\
**Last updated:** [January 4, 2021, 3:17pm UTC](https://discourse.cmake.org/t/use-include-paths-extracted-from-an-external-source/1716 "2021-01-04T15:17:06Z")

</div>

Hello all, I’m working on an embedded project built on top of IAR Embedded Workbench. One of the tasks I’m working on here is adding unit tests that will be running in a host environment (Windows for the devs and Linux…

---

## [How to add linker directories to cmake gtest\_discover\_tests](https://discourse.cmake.org/t/how-to-add-linker-directories-to-cmake-gtest-discover-tests/1704)

<div class="topic-metadata">

**Author:** [@gil.kalish](https://discourse.cmake.org/u/gil.kalish)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 3:15pm UTC](https://discourse.cmake.org/t/how-to-add-linker-directories-to-cmake-gtest-discover-tests/1704 "2021-01-04T15:15:27Z")

</div>

0 I’m using cmake and gtest for my project. My gtest executable is using the same name as the program executable. I know this is not ideal but I cannot change it. The compiler I’m using is installed in a different dire…

---

## [Export sets with targets in subdirectory](https://discourse.cmake.org/t/export-sets-with-targets-in-subdirectory/1694)

<div class="topic-metadata">

**Author:** [@tpb](https://discourse.cmake.org/u/tpb)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 3:13pm UTC](https://discourse.cmake.org/t/export-sets-with-targets-in-subdirectory/1694 "2021-01-04T15:13:30Z")

</div>

I am attempting to install my project foo which has a dependency bar which is included as a git submodule and consumed in my cmake project via add\_subdirectory(bar). bar is a library that is intended to be consumed via a…

---

## [The Zen of integrating 3rd party packages](https://discourse.cmake.org/t/the-zen-of-integrating-3rd-party-packages/1318)

<div class="topic-metadata">

**Author:** [@jwm](https://discourse.cmake.org/u/jwm)\
**Replies:** 2\
**Last updated:** [January 4, 2021, 3:06pm UTC](https://discourse.cmake.org/t/the-zen-of-integrating-3rd-party-packages/1318 "2021-01-04T15:06:57Z")

</div>

I’m updating my build chain (new compilers, updated 3rd party versions and such) and I want to clean up some of the cruft of our original naive implementations. I have at least 3 different ways external packages are int…

---

## [How to turn off warning flags for project added by FetchContent\_Declare?](https://discourse.cmake.org/t/how-to-turn-off-warning-flags-for-project-added-by-fetchcontent-declare/2461)

<div class="topic-metadata">

**Author:** [@Adam\_Badura](https://discourse.cmake.org/u/Adam_Badura)\
**Replies:** 1\
**Last updated:** [January 3, 2021, 11:49am UTC](https://discourse.cmake.org/t/how-to-turn-off-warning-flags-for-project-added-by-fetchcontent-declare/2461 "2021-01-03T11:49:47Z")

</div>

In our project, we have a global done at the root directory add\_compile\_options( -Wundef # (...) ) However, a problem appeared with FetchContent for Google Test. The build this creates “inherits” the -Wundef. H…

---

## [FetchContent with loose .cmake files](https://discourse.cmake.org/t/fetchcontent-with-loose-cmake-files/2451)

<div class="topic-metadata">

**Author:** [@tomhh](https://discourse.cmake.org/u/tomhh)\
**Replies:** 4\
**Last updated:** [January 2, 2021, 9:54am UTC](https://discourse.cmake.org/t/fetchcontent-with-loose-cmake-files/2451 "2021-01-02T09:54:59Z")

</div>

Calling @craig.scott :slight\_smile: I’ve been reading your excellent Professional CMake book and have got to the section about other uses for FetchContent (27.2.2). It talks about being able to pull down individual .cma…

---

## [How to get listing file when cross compile](https://discourse.cmake.org/t/how-to-get-listing-file-when-cross-compile/2297)

<div class="topic-metadata">

**Author:** [@Massimiliano\_Cialdi](https://discourse.cmake.org/u/Massimiliano_Cialdi)\
**Replies:** 15\
**Last updated:** [January 1, 2021, 8:52pm UTC](https://discourse.cmake.org/t/how-to-get-listing-file-when-cross-compile/2297 "2021-01-01T20:52:36Z")

</div>

I’m using cmake 3.16.3 on xubuntu 20.04 to cross-compile a bare metal project that will run on ARM cortex-m7 microcontroller. The project is structured in subdirectories, and for this I use the add\_subdirectory() comman…

---

## [Specify \<lib\>-prefix folder destination](https://discourse.cmake.org/t/specify-lib-prefix-folder-destination/2449)

<div class="topic-metadata">

**Author:** [@kerim](https://discourse.cmake.org/u/kerim)\
**Replies:** 2\
**Last updated:** [January 1, 2021, 1:14pm UTC](https://discourse.cmake.org/t/specify-lib-prefix-folder-destination/2449 "2021-01-01T13:14:18Z")

</div>

Happy New Year! Work less earn much :smiley: When I build external project using ExternalProject\_Add usually I can see three folders: \<lib\> (source folder) \<lib\>-build (build folder) \<lib\>-install (install …

---

## [Post-compilation step](https://discourse.cmake.org/t/post-compilation-step/1265)

<div class="topic-metadata">

**Author:** [@cola](https://discourse.cmake.org/u/cola)\
**Replies:** 1\
**Last updated:** [December 30, 2020, 7:50pm UTC](https://discourse.cmake.org/t/post-compilation-step/1265 "2020-12-30T19:50:30Z")

</div>

Hi! I have a project with several custom toolchains. When using one of the toolchains and building Release I have to do som post-compile processing of the object-files before linking, so currently I have a PRE\_LINK cust…

---

## [CMake Deprecation Warning](https://discourse.cmake.org/t/cmake-deprecation-warning/2406)

<div class="topic-metadata">

**Author:** [@Junior27](https://discourse.cmake.org/u/Junior27)\
**Replies:** 3\
**Last updated:** [December 30, 2020, 1:58am UTC](https://discourse.cmake.org/t/cmake-deprecation-warning/2406 "2020-12-30T01:58:23Z")

</div>

Hello Sorry for my poor English and if question has been already solve. I have never used cmake, I only want to turn a radiosonde to an amateur radio direction finding contests. For this I want to use this tutorial on …

---

## [ExternalProject\_Add project that depends on other external project](https://discourse.cmake.org/t/externalproject-add-project-that-depends-on-other-external-project/2437)

<div class="topic-metadata">

**Author:** [@kerim](https://discourse.cmake.org/u/kerim)\
**Replies:** 2\
**Last updated:** [December 29, 2020, 7:33am UTC](https://discourse.cmake.org/t/externalproject-add-project-that-depends-on-other-external-project/2437 "2020-12-29T07:33:05Z")

</div>

Hi, I can’t figure out the following situation: Let’ suppose that I have two external projects A and B that I build with ExternalProject\_Add so that B depends on A. In External\_B.cmake I write something like: Externa…

---

## [Looking for someone willing verify a minimal Xcode project on Apple Silicon](https://discourse.cmake.org/t/looking-for-someone-willing-verify-a-minimal-xcode-project-on-apple-silicon/2415)

<div class="topic-metadata">

**Author:** [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Replies:** 9\
**Last updated:** [December 24, 2020, 4:02pm UTC](https://discourse.cmake.org/t/looking-for-someone-willing-verify-a-minimal-xcode-project-on-apple-silicon/2415 "2020-12-24T16:02:47Z")

</div>

I’m trying to verify a minimal combination of settings that will allow an Xcode project to produce a universal binary on macOS. I don’t have access to an Apple Silicon machine, so I can only verify that it works on Intel…

---

## [Evaluating effective target setting via generator expression](https://discourse.cmake.org/t/evaluating-effective-target-setting-via-generator-expression/2389)

<div class="topic-metadata">

**Author:** [@hsattler](https://discourse.cmake.org/u/hsattler)\
**Replies:** 1\
**Last updated:** [December 24, 2020, 7:34am UTC](https://discourse.cmake.org/t/evaluating-effective-target-setting-via-generator-expression/2389 "2020-12-24T07:34:32Z")

</div>

Hi, I want to add a link flag when the target effectively used LTO optimization. So somwhere top-level I write: add\_link\_options ( $\<$\<BOOL:$\<TARGET\_PROPERTY:INTERPROCEDURAL\_OPTIMIZATION\>\>:-flto=8\> ) This works, if I …

---

## [Checking for target-less components existence in config files](https://discourse.cmake.org/t/checking-for-target-less-components-existence-in-config-files/2364)

<div class="topic-metadata">

**Author:** [@Artemis](https://discourse.cmake.org/u/Artemis)\
**Replies:** 5\
**Last updated:** [December 21, 2020, 11:17am UTC](https://discourse.cmake.org/t/checking-for-target-less-components-existence-in-config-files/2364 "2020-12-21T11:17:21Z")

</div>

Assuming a separated export file for every install component. In the book “Professional CMake” it’s suggested, as a recommended practice, that consumable projects should let users install runtime only components (binari…

---

## [unset all variables from find\_package()](https://discourse.cmake.org/t/unset-all-variables-from-find-package/2386)

<div class="topic-metadata">

**Author:** [@kerim](https://discourse.cmake.org/u/kerim)\
**Replies:** 6\
**Last updated:** [December 17, 2020, 4:26pm UTC](https://discourse.cmake.org/t/unset-all-variables-from-find-package/2386 "2020-12-17T16:26:46Z")

</div>

Hi, My task is to allow user to decide whether to use superbuild or manually specify \_DIR to a library. I’m interested in the situation when user uses CMake-GUI and at first he set USE\_SUPERBUILD = ON and specify path…

---

## [using \<packagename\>\_ROOT does not appear to be used by find\_program(\<packagename\>)](https://discourse.cmake.org/t/using-packagename-root-does-not-appear-to-be-used-by-find-program-packagename/2381)

<div class="topic-metadata">

**Author:** [@grimgort](https://discourse.cmake.org/u/grimgort)\
**Replies:** 5\
**Last updated:** [December 17, 2020, 12:56pm UTC](https://discourse.cmake.org/t/using-packagename-root-does-not-appear-to-be-used-by-find-program-packagename/2381 "2020-12-17T12:56:34Z")

</div>

Hello, the following lines of codes can’t find my sqlite3.exe. Is this normal? set(EXE\_SQLITE3\_ROOT D:/ftarroux/Documents/FRED/BaseGit/simbox\_externalProject/install/Windows-MSVC-1916-Win32/sqlite/bin/) find\_program(E…

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

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