# Code

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

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

**Page:** 50

---

## [\`target\_link\_libraries\` not propagating include paths to dependent targets](https://discourse.cmake.org/t/target-link-libraries-not-propagating-include-paths-to-dependent-targets/5162)

<div class="topic-metadata">

**Author:** [@theonemcdonald](https://discourse.cmake.org/u/theonemcdonald)\
**Replies:** 2\
**Last updated:** [March 4, 2022, 8:58pm UTC](https://discourse.cmake.org/t/target-link-libraries-not-propagating-include-paths-to-dependent-targets/5162 "2022-03-04T20:58:36Z")

</div>

Hi, I’m new to CMake. I’ve been listening to and watching lots of CMake talks, learning about “modern” cmake, etc. I understand that I should be thinking in terms of targets. Got it. Maybe I’m misunderstanding somethin…

---

## [add\_compile\_options and propagation to CMAKE\_C\_FLAGS and toolchain files etc.](https://discourse.cmake.org/t/add-compile-options-and-propagation-to-cmake-c-flags-and-toolchain-files-etc/5088)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 5\
**Last updated:** [March 2, 2022, 2:35pm UTC](https://discourse.cmake.org/t/add-compile-options-and-propagation-to-cmake-c-flags-and-toolchain-files-etc/5088 "2022-03-02T14:35:27Z")

</div>

How should an invocation of add\_compile\_options be propagated to CMAKE\_C\_FLAGS? Should that be handled by cmake internals? Similarly what is the suggested way to propagate compile options to an external project built wit…

---

## [Install header only targets?](https://discourse.cmake.org/t/install-header-only-targets/5147)

<div class="topic-metadata">

**Author:** [@cmak](https://discourse.cmake.org/u/cmak)\
**Replies:** 1\
**Last updated:** [March 2, 2022, 2:34pm UTC](https://discourse.cmake.org/t/install-header-only-targets/5147 "2022-03-02T14:34:40Z")

</div>

What is the correct way to install header only targets? Currently I’m doing something like this; install( DIRECTORY include/my\_header\_interface DESTINATION ${CMAKE\_INSTALL\_INCLUDEDIR} ) Trying to do install(TAR…

---

## [install(FILES ...) to ignore install of files when file at DESTINATION is newer/has been modified](https://discourse.cmake.org/t/install-files-to-ignore-install-of-files-when-file-at-destination-is-newer-has-been-modified/5140)

<div class="topic-metadata">

**Author:** [@Caointean](https://discourse.cmake.org/u/Caointean)\
**Replies:** 4\
**Last updated:** [March 1, 2022, 5:44pm UTC](https://discourse.cmake.org/t/install-files-to-ignore-install-of-files-when-file-at-destination-is-newer-has-been-modified/5140 "2022-03-01T17:44:39Z")

</div>

Hello ! I’m looking for a way to prevent the install(FILES \<myfile\> DESTINATION \<myfolder\>) to re-install \<myfile\> when the file at destination \<folder\>/\<myfile\> is newer than the source. To put things into context: W…

---

## [How to selectively include source files according to universal binary architecture?](https://discourse.cmake.org/t/how-to-selectively-include-source-files-according-to-universal-binary-architecture/5138)

<div class="topic-metadata">

**Author:** [@yangxi](https://discourse.cmake.org/u/yangxi)\
**Replies:** 1\
**Last updated:** [March 1, 2022, 1:23pm UTC](https://discourse.cmake.org/t/how-to-selectively-include-source-files-according-to-universal-binary-architecture/5138 "2022-03-01T13:23:47Z")

</div>

I’m trying to compile my project into Mac universal binaries. However, some of the SDK source code I used only works for x86. How can I make these files only being compiled in x86 part? If there’s no way to do so, I have…

---

## [Problem with duplicate library names under MS-Windows](https://discourse.cmake.org/t/problem-with-duplicate-library-names-under-ms-windows/5120)

<div class="topic-metadata">

**Author:** [@SepandMeenu](https://discourse.cmake.org/u/SepandMeenu)\
**Replies:** 2\
**Last updated:** [February 26, 2022, 1:24pm UTC](https://discourse.cmake.org/t/problem-with-duplicate-library-names-under-ms-windows/5120 "2022-02-26T13:24:00Z")

</div>

Under MS-Windows, if two different shared libraries have the same name, their produced binaries will be the same, even if their output directories differ. A minimal example: cmake\_minimum\_required(VERSION 3.14 FATAL\_ER…

---

## [compile C++20 modules with cmake](https://discourse.cmake.org/t/compile-c-20-modules-with-cmake/5116)

<div class="topic-metadata">

**Author:** [@raj](https://discourse.cmake.org/u/raj)\
**Replies:** 1\
**Last updated:** [February 25, 2022, 5:49pm UTC](https://discourse.cmake.org/t/compile-c-20-modules-with-cmake/5116 "2022-02-25T17:49:59Z")

</div>

Hi I have two files main.cpp and module1.cpp (simple hello\_world example) I want to build them with cmake. following is cmake code (not working) cmake\_minimum\_required(VERSION 3.21) project(cpp\_concurrency\_mastercla…

---

## [How to install a specific target for multiple projects by \`add\_subdirectory\`?](https://discourse.cmake.org/t/how-to-install-a-specific-target-for-multiple-projects-by-add-subdirectory/5099)

<div class="topic-metadata">

**Author:** [@Ronald](https://discourse.cmake.org/u/Ronald)\
**Replies:** 1\
**Last updated:** [February 23, 2022, 3:38pm UTC](https://discourse.cmake.org/t/how-to-install-a-specific-target-for-multiple-projects-by-add-subdirectory/5099 "2022-02-23T15:38:44Z")

</div>

CMakeLists.txt add\_subdirectory(App1) add\_subdirectory(App2) Can the user choose to install only App1 and how?

---

## [Calling target\_link\_libraries with an interface library doesn't add include compiler flags on Windows](https://discourse.cmake.org/t/calling-target-link-libraries-with-an-interface-library-doesnt-add-include-compiler-flags-on-windows/5083)

<div class="topic-metadata">

**Author:** [@josiest](https://discourse.cmake.org/u/josiest)\
**Replies:** 3\
**Last updated:** [February 22, 2022, 9:56pm UTC](https://discourse.cmake.org/t/calling-target-link-libraries-with-an-interface-library-doesnt-add-include-compiler-flags-on-windows/5083 "2022-02-22T21:56:32Z")

</div>

Consider two cmake projects bar/ CMakeLists.txt bar-config.cmake.in src/bar/bar.hpp foo/ CMakeLists.txt src/foo.cpp source code (click the arrow to expand): bar/CMakeLists.txt: cmake\_minimum\_required(VERSIO…

---

## [Building application using ExternalProject\_Add on M1 CPU](https://discourse.cmake.org/t/building-application-using-externalproject-add-on-m1-cpu/4931)

<div class="topic-metadata">

**Author:** [@tomhh](https://discourse.cmake.org/u/tomhh)\
**Replies:** 8\
**Last updated:** [February 22, 2022, 8:18pm UTC](https://discourse.cmake.org/t/building-application-using-externalproject-add-on-m1-cpu/4931 "2022-02-22T20:18:54Z")

</div>

Hello there, I encountered a problem recently where I get a series of link errors while attempting to build an application on an M1 (ARM) CPU (this is on a 2021 MacBook) when linking against libraries built using Extern…

---

## [How to use the same name for a target and a library](https://discourse.cmake.org/t/how-to-use-the-same-name-for-a-target-and-a-library/5044)

<div class="topic-metadata">

**Author:** [@JRR](https://discourse.cmake.org/u/JRR)\
**Replies:** 2\
**Last updated:** [February 17, 2022, 5:39pm UTC](https://discourse.cmake.org/t/how-to-use-the-same-name-for-a-target-and-a-library/5044 "2022-02-17T17:39:28Z")

</div>

We have a project that creates both a library and an executable. Moreover, we want the exec and library to have the same name. For example: What Windows Linux executable foobar.exe foobar static library fooba…

---

## [Is there a best practices/correct way of code signing the installer via CPACK?](https://discourse.cmake.org/t/is-there-a-best-practices-correct-way-of-code-signing-the-installer-via-cpack/5043)

<div class="topic-metadata">

**Author:** [@scottaronbloom](https://discourse.cmake.org/u/scottaronbloom)\
**Replies:** 0\
**Last updated:** [February 17, 2022, 4:21pm UTC](https://discourse.cmake.org/t/is-there-a-best-practices-correct-way-of-code-signing-the-installer-via-cpack/5043 "2022-02-17T16:21:48Z")

</div>

Using the NSIS/CPack package modules, is there a variable (I cant find one) to set to point the installer to a code signing certificate? If so What formats are supported? If not, what settings need to get setup to sign…

---

## [Start menu and desktop shortcuts with Wix](https://discourse.cmake.org/t/start-menu-and-desktop-shortcuts-with-wix/4988)

<div class="topic-metadata">

**Author:** [@ocroquette](https://discourse.cmake.org/u/ocroquette)\
**Replies:** 4\
**Last updated:** [February 16, 2022, 11:01am UTC](https://discourse.cmake.org/t/start-menu-and-desktop-shortcuts-with-wix/4988 "2022-02-16T11:01:56Z")

</div>

Hi, I needed to add desktop and start menu shortcuts to an installer using CPack and Wix and realized that the documentation is pretty bad. So I checked out CPack source code and found out the solution is easy: Also,…

---

## [When using the XCODE Generator is there a way to set the scheme attribute "enableGPUFrameCaptureMode"](https://discourse.cmake.org/t/when-using-the-xcode-generator-is-there-a-way-to-set-the-scheme-attribute-enablegpuframecapturemode/4091)

<div class="topic-metadata">

**Author:** [@Zorro666](https://discourse.cmake.org/u/Zorro666)\
**Replies:** 2\
**Last updated:** [February 16, 2022, 5:31am UTC](https://discourse.cmake.org/t/when-using-the-xcode-generator-is-there-a-way-to-set-the-scheme-attribute-enablegpuframecapturemode/4091 "2022-02-16T05:31:21Z")

</div>

By default I would like to set the Xcode scheme Option GPU Frame Capture to disabled when generating an Xcode project using CMake. In the Xcode .xcscheme file the attribute is called enableGPUFrameCaptureMode and the va…

---

## [How to detect misspelled variable names on command line](https://discourse.cmake.org/t/how-to-detect-misspelled-variable-names-on-command-line/5016)

<div class="topic-metadata">

**Author:** [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)\
**Replies:** 1\
**Last updated:** [February 16, 2022, 1:30am UTC](https://discourse.cmake.org/t/how-to-detect-misspelled-variable-names-on-command-line/5016 "2022-02-16T01:30:48Z")

</div>

My CMakeLists.txt can take variables and values specified on the command line in the usual form -Dname=value. E.g. % cmake -DmyVariable=someValue .. How can CMakeLists.txt detect variables that aren’t actually relevant…

---

## [Is there a way to disable start menu shortcuts when using the CPack NSIS generator?](https://discourse.cmake.org/t/is-there-a-way-to-disable-start-menu-shortcuts-when-using-the-cpack-nsis-generator/5006)

<div class="topic-metadata">

**Author:** [@Username404-59](https://discourse.cmake.org/u/Username404-59)\
**Replies:** 0\
**Last updated:** [February 14, 2022, 8:55pm UTC](https://discourse.cmake.org/t/is-there-a-way-to-disable-start-menu-shortcuts-when-using-the-cpack-nsis-generator/5006 "2022-02-14T20:55:25Z")

</div>

The description of CPACK\_PACKAGE\_EXECUTABLES says: Lists each of the executables and associated text label to be used to create Start Menu shortcuts. For example, setting this to the list ccmake;CMake will create a sho…

---

## [Bad Address error during compilation](https://discourse.cmake.org/t/bad-address-error-during-compilation/3917)

<div class="topic-metadata">

**Author:** [@Santosh](https://discourse.cmake.org/u/Santosh)\
**Replies:** 5\
**Last updated:** [February 9, 2022, 7:09am UTC](https://discourse.cmake.org/t/bad-address-error-during-compilation/3917 "2022-02-09T07:09:07Z")

</div>

Hello Team Facing bad address error in CMAKE during compilation. Cmake path , version, set up and environment varaibles are proper. could you please let me know any information…

---

## [Precedence in compound conditions](https://discourse.cmake.org/t/precedence-in-compound-conditions/4979)

<div class="topic-metadata">

**Author:** [@vmilea](https://discourse.cmake.org/u/vmilea)\
**Replies:** 1\
**Last updated:** [February 9, 2022, 6:44pm UTC](https://discourse.cmake.org/t/precedence-in-compound-conditions/4979 "2022-02-09T18:44:45Z")

</div>

The documentation states: Compound conditions are evaluated in the following order of precedence: \[…\] Then the boolean operators in the order NOT, AND, and finally OR. But the following prints “FALSE”: cmake\_minimum…

---

## [find\_package( ... NO\_MODULE ) not working properly](https://discourse.cmake.org/t/find-package-no-module-not-working-properly/4934)

<div class="topic-metadata">

**Author:** [@Gonzalo\_Garramuno](https://discourse.cmake.org/u/Gonzalo_Garramuno)\
**Replies:** 18\
**Last updated:** [February 4, 2022, 6:25pm UTC](https://discourse.cmake.org/t/find-package-no-module-not-working-properly/4934 "2022-02-04T18:25:15Z")

</div>

For FLTK. If I set FLTK\_DIR to a build directory in the CMakeLists.txt file and then run find\_package( FLTK REQUIRED NO\_MODULE ), I get an error message: CMake Error at mrViewer/src/CMakeLists.txt:53 (FIND\_PACKAGE): …

---

## [minimum working example for CMakePresets.json](https://discourse.cmake.org/t/minimum-working-example-for-cmakepresets-json/3419)

<div class="topic-metadata">

**Author:** [@hex](https://discourse.cmake.org/u/hex)\
**Replies:** 3\
**Last updated:** [February 4, 2022, 1:01pm UTC](https://discourse.cmake.org/t/minimum-working-example-for-cmakepresets-json/3419 "2022-02-04T13:01:44Z")

</div>

i am struggling to get CMakePresets.json to work. consider the following CMakePresets.json: { "version": 2, } the version field is required. When i ran with cmake -S . --preset=default i received: CMake Error: Coul…

---

## [Copying created shared libraries](https://discourse.cmake.org/t/copying-created-shared-libraries/4936)

<div class="topic-metadata">

**Author:** [@scottaronbloom](https://discourse.cmake.org/u/scottaronbloom)\
**Replies:** 17\
**Last updated:** [February 3, 2022, 7:46pm UTC](https://discourse.cmake.org/t/copying-created-shared-libraries/4936 "2022-02-03T19:46:58Z")

</div>

My project has 3 shared libraries, and 2 executables. During the Install phase, everything is copied to the correct location. However when debugging, the shared libraries must be copied into the directory where the exe…

---

## [Missing Separator error](https://discourse.cmake.org/t/missing-separator-error/4947)

<div class="topic-metadata">

**Author:** [@fenixD](https://discourse.cmake.org/u/fenixD)\
**Replies:** 5\
**Last updated:** [February 2, 2022, 6:24pm UTC](https://discourse.cmake.org/t/missing-separator-error/4947 "2022-02-02T18:24:27Z")

</div>

Hello everyone :slight\_smile: I get a missing separator error, when I change PRIVATE to PUBLIC specificator in target\_include\_directories statement. I have 3 shared libraries and I change the specificator only in one (l…

---

## [Cross-compile OpenAL using MinGW in CMake?](https://discourse.cmake.org/t/cross-compile-openal-using-mingw-in-cmake/4942)

<div class="topic-metadata">

**Author:** [@Fruit](https://discourse.cmake.org/u/Fruit)\
**Replies:** 0\
**Last updated:** [February 1, 2022, 5:54pm UTC](https://discourse.cmake.org/t/cross-compile-openal-using-mingw-in-cmake/4942 "2022-02-01T17:54:07Z")

</div>

Hello I am quite novice to CMake. I am trying to cross compile a project which uses OpenAL, using MinGW in my CMake file. However I am struggling to find a way to add the OpenAL headers and DLL for the target platform. …

---

## [IMPORTED\_LINK\_INTERFACE\_LANGUAGES property is ignored?](https://discourse.cmake.org/t/imported-link-interface-languages-property-is-ignored/4909)

<div class="topic-metadata">

**Author:** [@pcercuei](https://discourse.cmake.org/u/pcercuei)\
**Replies:** 7\
**Last updated:** [January 31, 2022, 4:49pm UTC](https://discourse.cmake.org/t/imported-link-interface-languages-property-is-ignored/4909 "2022-01-31T16:49:12Z")

</div>

Hi, A possible bug related to the IMPORTED\_LINK\_INTERFACE\_LANGUAGES property. I created a very simple CMake script to show my issue, available here: The test.c file referenced in the script is a dead simple example …

---

## [File GLOB\_RECURSE incorrectly filters directories](https://discourse.cmake.org/t/file-glob-recurse-incorrectly-filters-directories/4930)

<div class="topic-metadata">

**Author:** [@ixsci](https://discourse.cmake.org/u/ixsci)\
**Replies:** 0\
**Last updated:** [January 29, 2022, 7:56am UTC](https://discourse.cmake.org/t/file-glob-recurse-incorrectly-filters-directories/4930 "2022-01-29T07:56:49Z")

</div>

I have the following dir \[sub\]structure: ├── src │ ├── Mistery │ │ ├── IntegrationTests │ │ └── mistery.txt │ ├── SomeFolder │ │ └── AnotherFolder │ └── UnitTests And I try to find all directories whi…

---

## [add\_custom\_command behaviour different with make & ninja](https://discourse.cmake.org/t/add-custom-command-behaviour-different-with-make-ninja/4867)

<div class="topic-metadata">

**Author:** [@pmqs](https://discourse.cmake.org/u/pmqs)\
**Replies:** 6\
**Last updated:** [January 27, 2022, 9:10pm UTC](https://discourse.cmake.org/t/add-custom-command-behaviour-different-with-make-ninja/4867 "2022-01-27T21:10:26Z")

</div>

Consider this cmake file that uses a custom command to update the file /tmp/fred.out. The updating of this files has a DEPENDS on /tmp/fred.in cmake\_minimum\_required(VERSION 3.17) project(Hello\_world VERSION 1.0) set(…

---

## [How to Install shared library from add\_subdirectory, but not header includes?](https://discourse.cmake.org/t/how-to-install-shared-library-from-add-subdirectory-but-not-header-includes/4919)

<div class="topic-metadata">

**Author:** [@thehans](https://discourse.cmake.org/u/thehans)\
**Replies:** 3\
**Last updated:** [January 27, 2022, 5:59pm UTC](https://discourse.cmake.org/t/how-to-install-shared-library-from-add-subdirectory-but-not-header-includes/4919 "2022-01-27T17:59:43Z")

</div>

I have an application which depends on a library, which uses add\_subdirectory() to include in our CMakeLists. This subdirectory is 3rd party code, and placed there as a git submodule, so I can’t easily modify CMakeLists…

---

## [Help getting CMake to install a library created by custom command](https://discourse.cmake.org/t/help-getting-cmake-to-install-a-library-created-by-custom-command/4898)

<div class="topic-metadata">

**Author:** [@mathomp4](https://discourse.cmake.org/u/mathomp4)\
**Replies:** 1\
**Last updated:** [January 24, 2022, 9:21pm UTC](https://discourse.cmake.org/t/help-getting-cmake-to-install-a-library-created-by-custom-command/4898 "2022-01-24T21:21:26Z")

</div>

I have an odd situation that I’m struggling with the CMake for. I work on a big Fortran source code that now has a need to build a shared object library and include file where they are created by Python and not by Fortra…

---

## [Custom command results in MSB8065 warnings in Visual Studio 2019](https://discourse.cmake.org/t/custom-command-results-in-msb8065-warnings-in-visual-studio-2019/4893)

<div class="topic-metadata">

**Author:** [@bjornblissing](https://discourse.cmake.org/u/bjornblissing)\
**Replies:** 1\
**Last updated:** [January 24, 2022, 3:34pm UTC](https://discourse.cmake.org/t/custom-command-results-in-msb8065-warnings-in-visual-studio-2019/4893 "2022-01-24T15:34:54Z")

</div>

When I migrated some old source I got MSB8065 warnings from Visual Studio 2019. I have managed to reproduce this behavior in a simple example: cmake\_minimum\_required(VERSION 3.22) # set the project name project(Test) …

---

## [cmake project data structure type (public lib)?](https://discourse.cmake.org/t/cmake-project-data-structure-type-public-lib/4879)

<div class="topic-metadata">

**Author:** [@ElDesalmado](https://discourse.cmake.org/u/ElDesalmado)\
**Replies:** 2\
**Last updated:** [January 21, 2022, 7:22am UTC](https://discourse.cmake.org/t/cmake-project-data-structure-type-public-lib/4879 "2022-01-21T07:22:04Z")

</div>

This is rather a question. There are a lot of legacy projects that use Visual Studio or MakeFile or whatever. I myself have an old legacy project that I’d be very glad to migrate to CMake using some automation. The thi…

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

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