# Code

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

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

**Page:** 66

---

## [How can Cmake be configured to ignore such 'ADD\_SUBDIRECTORY is not an existing directory' errors?](https://discourse.cmake.org/t/how-can-cmake-be-configured-to-ignore-such-add-subdirectory-is-not-an-existing-directory-errors/2250)

<div class="topic-metadata">

**Author:** [@mirro187](https://discourse.cmake.org/u/mirro187)\
**Replies:** 1\
**Last updated:** [November 27, 2020, 6:06am UTC](https://discourse.cmake.org/t/how-can-cmake-be-configured-to-ignore-such-add-subdirectory-is-not-an-existing-directory-errors/2250 "2020-11-27T06:06:02Z")

</div>

---

## [compile ASM using armasm with MSYS2 in windows10](https://discourse.cmake.org/t/compile-asm-using-armasm-with-msys2-in-windows10/2243)

<div class="topic-metadata">

**Author:** [@dalianduzhi](https://discourse.cmake.org/u/dalianduzhi)\
**Replies:** 1\
**Last updated:** [November 26, 2020, 1:59pm UTC](https://discourse.cmake.org/t/compile-asm-using-armasm-with-msys2-in-windows10/2243 "2020-11-26T13:59:55Z")

</div>

I used the cmake + ninja and got the rule for compiling ASM file command = \\armasm.exe @$RSP\_FILE -o $out $in description = Building ASM object $out rspfile = $RSP\_FILE rspfile\_content = $DEFINES $INCLUDES $FLAGS b…

---

## [How add .so lib on Qt for Android using CMake](https://discourse.cmake.org/t/how-add-so-lib-on-qt-for-android-using-cmake/2224)

<div class="topic-metadata">

**Author:** [@software.dev992](https://discourse.cmake.org/u/software.dev992)\
**Replies:** 2\
**Last updated:** [November 25, 2020, 5:37pm UTC](https://discourse.cmake.org/t/how-add-so-lib-on-qt-for-android-using-cmake/2224 "2020-11-25T17:37:26Z")

</div>

Hi, I have a project that I build for android using Qt 5.12.9. This project uses CMake 3.16.2 and of course androiddeployqt. I don’t see any gradle script in my project tree so I think that is all automated by androidde…

---

## [Expressing runtime dependencies in CMake](https://discourse.cmake.org/t/expressing-runtime-dependencies-in-cmake/2235)

<div class="topic-metadata">

**Author:** [@Joachim\_Priesner](https://discourse.cmake.org/u/Joachim_Priesner)\
**Replies:** 1\
**Last updated:** [November 25, 2020, 5:33pm UTC](https://discourse.cmake.org/t/expressing-runtime-dependencies-in-cmake/2235 "2020-11-25T17:33:01Z")

</div>

Hi all, I am working on a project making excessive use of run-time library loading, i.e. dlopen()/LoadLibrary(). This means that if target B uses library A, it needs: at compile time: the include directories of A at …

---

## [Compiling C as C++ in CMake 3.18](https://discourse.cmake.org/t/compiling-c-as-c-in-cmake-3-18/2172)

<div class="topic-metadata">

**Author:** [@Scott\_Michel](https://discourse.cmake.org/u/Scott_Michel)\
**Replies:** 3\
**Last updated:** [November 25, 2020, 5:27pm UTC](https://discourse.cmake.org/t/compiling-c-as-c-in-cmake-3-18/2172 "2020-11-25T17:27:20Z")

</div>

I’m (semi-)maintaining a private copy of pthreads4w, which is one of those libraries which uses one “.c” file and different definitions to output several variants of the library. One variant uses C++ exceptions to clean …

---

## [What targets/files does a specific component install?](https://discourse.cmake.org/t/what-targets-files-does-a-specific-component-install/2125)

<div class="topic-metadata">

**Author:** [@dbahadir](https://discourse.cmake.org/u/dbahadir)\
**Replies:** 1\
**Last updated:** [November 25, 2020, 4:42pm UTC](https://discourse.cmake.org/t/what-targets-files-does-a-specific-component-install/2125 "2020-11-25T16:42:45Z")

</div>

Background and question In my CMake project I am installing some built libraries and other files, all associated with several components (using the install(... COMPONENT ...) syntax). I then want to create (Debian) pack…

---

## [How to determine whether the generation of the project build system is being run in trace mode?](https://discourse.cmake.org/t/how-to-determine-whether-the-generation-of-the-project-build-system-is-being-run-in-trace-mode/2100)

<div class="topic-metadata">

**Author:** [@Shane\_Dev](https://discourse.cmake.org/u/Shane_Dev)\
**Replies:** 1\
**Last updated:** [November 25, 2020, 4:35pm UTC](https://discourse.cmake.org/t/how-to-determine-whether-the-generation-of-the-project-build-system-is-being-run-in-trace-mode/2100 "2020-11-25T16:35:26Z")

</div>

Hello, Is possible to determine whether the generation of the project build system is being run in trace mode (from within the called script)? For example, can the script determine which command line options were passe…

---

## [CMAKE\_SYSTEM\_INCLUDE\_PATH - has just one path, for X11?](https://discourse.cmake.org/t/cmake-system-include-path-has-just-one-path-for-x11/2060)

<div class="topic-metadata">

**Author:** [@tomoreilly](https://discourse.cmake.org/u/tomoreilly)\
**Replies:** 2\
**Last updated:** [November 25, 2020, 12:24pm UTC](https://discourse.cmake.org/t/cmake-system-include-path-has-just-one-path-for-x11/2060 "2020-11-25T12:24:09Z")

</div>

Running on Ubuntu 18.04, cmake version 3.18.0-rc2. From documentation I expect CMAKE\_SYSTEM\_INCLUDE\_PATH to hold a list of directories including /usr/include, /usr/local/include, etc. : Semicolon-separated list of direc…

---

## [Building Lib file from asm - cmake bug?](https://discourse.cmake.org/t/building-lib-file-from-asm-cmake-bug/1959)

<div class="topic-metadata">

**Author:** [@anrose00](https://discourse.cmake.org/u/anrose00)\
**Replies:** 3\
**Last updated:** [November 25, 2020, 12:03pm UTC](https://discourse.cmake.org/t/building-lib-file-from-asm-cmake-bug/1959 "2020-11-25T12:03:39Z")

</div>

Hello! I’m trying to convert a larger project to cmake. It consists or various C and ASM files. I was trying to create a static library containing the functions provided by the ASM files and then linking this static li…

---

## [find\_file() not resolving relative paths correctly (?)](https://discourse.cmake.org/t/find-file-not-resolving-relative-paths-correctly/1984)

<div class="topic-metadata">

**Author:** [@DaveR](https://discourse.cmake.org/u/DaveR)\
**Replies:** 5\
**Last updated:** [November 25, 2020, 11:44am UTC](https://discourse.cmake.org/t/find-file-not-resolving-relative-paths-correctly/1984 "2020-11-25T11:44:47Z")

</div>

Hi, I’m using find\_file to try to locate where builtin compiler library (in this case tsan.so) is located. I’m doing this by first parsing the output of try\_compile(... -print-search-dirs) to extract the list of paths, …

---

## [Incorrect CUDA Architecture detection](https://discourse.cmake.org/t/incorrect-cuda-architecture-detection/2018)

<div class="topic-metadata">

**Author:** [@Microno95](https://discourse.cmake.org/u/Microno95)\
**Replies:** 3\
**Last updated:** [November 25, 2020, 12:22am UTC](https://discourse.cmake.org/t/incorrect-cuda-architecture-detection/2018 "2020-11-25T00:22:11Z")

</div>

So I’ve been trying to generate the cmake project for Mitsuba 2 on Windows 10 (build: 19041.572) using the Visual Studio 16 2019 generator and x64 toolchain. This is a project that requires CUDA and thus for the archite…

---

## [How to collect and export usage-requirements of dependencies?](https://discourse.cmake.org/t/how-to-collect-and-export-usage-requirements-of-dependencies/1973)

<div class="topic-metadata">

**Author:** [@dbahadir](https://discourse.cmake.org/u/dbahadir)\
**Replies:** 1\
**Last updated:** [November 24, 2020, 11:55pm UTC](https://discourse.cmake.org/t/how-to-collect-and-export-usage-requirements-of-dependencies/1973 "2020-11-24T23:55:14Z")

</div>

Hi everyone, I am currently writing a CMakeLists.txt and am trying to export a single target from it that shall carry all its usage-requirements, even the indirectly inherited ones, without the need to also export its (…

---

## [Debugging Targets Added](https://discourse.cmake.org/t/debugging-targets-added/1843)

<div class="topic-metadata">

**Author:** [@Some\_Guy](https://discourse.cmake.org/u/Some_Guy)\
**Replies:** 1\
**Last updated:** [November 24, 2020, 11:24pm UTC](https://discourse.cmake.org/t/debugging-targets-added/1843 "2020-11-24T23:24:52Z")

</div>

I am new to CMAKE and I have added a third party library, glfw. It compiles using ExternalProject\_Add. This ExternalProject\_Add apparently calls the CMake code for glfw and adds a new target to which I can link, but I on…

---

## [Link libraries with armcc/armlink](https://discourse.cmake.org/t/link-libraries-with-armcc-armlink/1928)

<div class="topic-metadata">

**Author:** [@SadE](https://discourse.cmake.org/u/SadE)\
**Replies:** 2\
**Last updated:** [November 23, 2020, 1:12pm UTC](https://discourse.cmake.org/t/link-libraries-with-armcc-armlink/1928 "2020-11-23T13:12:11Z")

</div>

Hi I’m trying to have a setup for the armcc compiler from Keil/ARM . The compiler is supported well but I get some problem linking libraries. The correct way of using the linker with test.c and sample.lib is armlink.e…

---

## [CTest: CMake fixtures and background service - no failed test](https://discourse.cmake.org/t/ctest-cmake-fixtures-and-background-service-no-failed-test/1869)

<div class="topic-metadata">

**Author:** [@Acki](https://discourse.cmake.org/u/Acki)\
**Replies:** 2\
**Last updated:** [November 22, 2020, 8:43pm UTC](https://discourse.cmake.org/t/ctest-cmake-fixtures-and-background-service-no-failed-test/1869 "2020-11-22T20:43:35Z")

</div>

I use CTest fixtures. In my FIXTURES\_SETUP I call a bash script, wich is starting a service in the background via: "$@" \> ${SERVICE\_LOG\_FILE} 2\>&1 & RESULT=$? You see how I store the log output via a text file Then …

---

## [Linking VL53L0X Api](https://discourse.cmake.org/t/linking-vl53l0x-api/1938)

<div class="topic-metadata">

**Author:** [@hack-mike](https://discourse.cmake.org/u/hack-mike)\
**Replies:** 1\
**Last updated:** [November 22, 2020, 7:51pm UTC](https://discourse.cmake.org/t/linking-vl53l0x-api/1938 "2020-11-22T19:51:54Z")

</div>

Hi everybody, I’m new in CMake and I have some difficult to import VL53L0X Api to my ESP-IDF project. I created inside Api folder this CMake.txt then in main/Cmake.txt I called add\_subdirectory(/Users/michelemocelli…

---

## [CMake or VS issue: In Debug mode libcmt is linked together with libcmtd?](https://discourse.cmake.org/t/cmake-or-vs-issue-in-debug-mode-libcmt-is-linked-together-with-libcmtd/1911)

<div class="topic-metadata">

**Author:** [@ProTur1](https://discourse.cmake.org/u/ProTur1)\
**Replies:** 1\
**Last updated:** [November 22, 2020, 7:45pm UTC](https://discourse.cmake.org/t/cmake-or-vs-issue-in-debug-mode-libcmt-is-linked-together-with-libcmtd/1911 "2020-11-22T19:45:02Z")

</div>

CMake or VS issue? In Debug mode libcmt is linked together with libcmtd? Although I set for a release build /MT and for a debug build /MTd, in the debug mode the libcmt is still being linked, together with the libcmtd. …

---

## [add\_library(ALIAS) and target\_include\_directories](https://discourse.cmake.org/t/add-library-alias-and-target-include-directories/1877)

<div class="topic-metadata">

**Author:** [@davemilter](https://discourse.cmake.org/u/davemilter)\
**Replies:** 1\
**Last updated:** [November 22, 2020, 7:20pm UTC](https://discourse.cmake.org/t/add-library-alias-and-target-include-directories/1877 "2020-11-22T19:20:51Z")

</div>

For linux I use find\_package(ICU 57.1 COMPONENTS uc i18n data REQUIRED) all works fine. But for other platforms I want build icu package included as submodule. Again all works fine: target\_include\_directories(icuuc P…

---

## [How to stop CMake from appending shared libraries on a Cray?](https://discourse.cmake.org/t/how-to-stop-cmake-from-appending-shared-libraries-on-a-cray/1826)

<div class="topic-metadata">

**Author:** [@jrobcary](https://discourse.cmake.org/u/jrobcary)\
**Replies:** 2\
**Last updated:** [November 19, 2020, 3:39pm UTC](https://discourse.cmake.org/t/how-to-stop-cmake-from-appending-shared-libraries-on-a-cray/1826 "2020-11-19T15:39:22Z")

</div>

3.18.2 The end of my link line has -lz -ldl -lrt /global/project/projectdirs/txsupp/vp11usrs/cori/contrib-gcc8.3/muparser-2.2.6.1-ser/lib64/libmuparser.a /global/project/projectdirs/txsupp/vp11usrs/cori/contrib-gcc8.…

---

## [How to create ALIAS targets for all of my libs in one command?](https://discourse.cmake.org/t/how-to-create-alias-targets-for-all-of-my-libs-in-one-command/2200)

<div class="topic-metadata">

**Author:** [@oliver](https://discourse.cmake.org/u/oliver)\
**Replies:** 1\
**Last updated:** [November 19, 2020, 2:58pm UTC](https://discourse.cmake.org/t/how-to-create-alias-targets-for-all-of-my-libs-in-one-command/2200 "2020-11-19T14:58:51Z")

</div>

I’m in the process of porting my project from GNU Make to CMake, and am now creating the exported CMake file. I want to add all of my exported libraries into a namespace, since that appears to be good practice. However, …

---

## [Override system include directories on MacOS](https://discourse.cmake.org/t/override-system-include-directories-on-macos/1850)

<div class="topic-metadata">

**Author:** [@MathiasMagnus](https://discourse.cmake.org/u/MathiasMagnus)\
**Replies:** 1\
**Last updated:** [November 19, 2020, 1:29pm UTC](https://discourse.cmake.org/t/override-system-include-directories-on-macos/1850 "2020-11-19T13:29:42Z")

</div>

I’m trying to create imported targets to consume OpenCL components. Previously the project relied on include\_directories() to specify non-system include directories. However, once I moved to installing components as prop…

---

## [Set CPACK\_DEBIAN\_PACKAGE\_DEPENDS from subproject library](https://discourse.cmake.org/t/set-cpack-debian-package-depends-from-subproject-library/1803)

<div class="topic-metadata">

**Author:** [@DKLind](https://discourse.cmake.org/u/DKLind)\
**Replies:** 1\
**Last updated:** [November 19, 2020, 1:17pm UTC](https://discourse.cmake.org/t/set-cpack-debian-package-depends-from-subproject-library/1803 "2020-11-19T13:17:51Z")

</div>

I have a very large CMake project with lots of binary and library subprojects. I am using CPACK\_DEBIAN\_PACKAGE\_GENERATE\_SHLIBS to automatically set CPACK\_DEBIAN\_PACKAGE\_DEPENDS from external libraries for a target. Is t…

---

## [README not packaged in tar.gz or .pkg file in CPack\_install\_scripts](https://discourse.cmake.org/t/readme-not-packaged-in-tar-gz-or-pkg-file-in-cpack-install-scripts/2192)

<div class="topic-metadata">

**Author:** [@reikdas](https://discourse.cmake.org/u/reikdas)\
**Replies:** 5\
**Last updated:** [November 18, 2020, 6:29am UTC](https://discourse.cmake.org/t/readme-not-packaged-in-tar-gz-or-pkg-file-in-cpack-install-scripts/2192 "2020-11-18T06:29:17Z")

</div>

Somewhat related to - https://discourse.cmake.org/t/cpack-script-not-recognizing-cmake-binary-dir/2191 These are some steps in my CPack configuration file - .... configure\_file(README.md README.md COPYONLY) set(CPACK\_P…

---

## [CPack script not recognizing CMAKE\_BINARY\_DIR](https://discourse.cmake.org/t/cpack-script-not-recognizing-cmake-binary-dir/2191)

<div class="topic-metadata">

**Author:** [@reikdas](https://discourse.cmake.org/u/reikdas)\
**Replies:** 1\
**Last updated:** [November 17, 2020, 4:27pm UTC](https://discourse.cmake.org/t/cpack-script-not-recognizing-cmake-binary-dir/2191 "2020-11-17T16:27:01Z")

</div>

For my CPack configuration, I have a step where I do - set(CPACK\_INSTALL\_SCRIPTS ${CMAKE\_SOURCE\_DIR}/cmake/CPackfoo.cmake) Inside CPackfoo.cmake , I am using a command - execute\_process(COMMAND textutil -convert html …

---

## [Copy dll's to runtime\_output\_directory via Imported\_Location property?](https://discourse.cmake.org/t/copy-dlls-to-runtime-output-directory-via-imported-location-property/1544)

<div class="topic-metadata">

**Author:** [@craffael](https://discourse.cmake.org/u/craffael)\
**Replies:** 5\
**Last updated:** [November 16, 2020, 3:54pm UTC](https://discourse.cmake.org/t/copy-dlls-to-runtime-output-directory-via-imported-location-property/1544 "2020-11-16T15:54:21Z")

</div>

Lets say I have two shared Libraries A, B and an Executable E. E depends on B and B depends on A: E -\> B -\> A Now assume that A and B are imported shared library targets that have their IMPORTED\_LOCATION properly set. …

---

## [Best practice for a library with multiple language bindings: target definitions with compile\_features](https://discourse.cmake.org/t/best-practice-for-a-library-with-multiple-language-bindings-target-definitions-with-compile-features/2168)

<div class="topic-metadata">

**Author:** [@relliott](https://discourse.cmake.org/u/relliott)\
**Replies:** 2\
**Last updated:** [November 13, 2020, 7:23pm UTC](https://discourse.cmake.org/t/best-practice-for-a-library-with-multiple-language-bindings-target-definitions-with-compile-features/2168 "2020-11-13T19:23:30Z")

</div>

I develop a library with language bindings for c, c++, and Fortran. The library c++ bindings require cxx\_std\_17 features. If I create the shared library target and use target\_compile\_features(XYZ PUBLIC cxx\_std\_17) and…

---

## [Setting CMAKE\_C\_FLAGS breaks transitive include folders?](https://discourse.cmake.org/t/setting-cmake-c-flags-breaks-transitive-include-folders/2165)

<div class="topic-metadata">

**Author:** [@ndevenish](https://discourse.cmake.org/u/ndevenish)\
**Replies:** 2\
**Last updated:** [November 13, 2020, 1:05pm UTC](https://discourse.cmake.org/t/setting-cmake-c-flags-breaks-transitive-include-folders/2165 "2020-11-13T13:05:14Z")

</div>

I’m trying to understand a failing behaviour where linking to an imported target isn’t properly using the include directory. The target has a proper INTERFACE\_INCLUDE\_DIRECTORIES set but it isn’t propagated to the compil…

---

## [Windows 32bit and ASM error when bumping cmake\_minimum\_required](https://discourse.cmake.org/t/windows-32bit-and-asm-error-when-bumping-cmake-minimum-required/1066)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 4\
**Last updated:** [November 13, 2020, 1:00pm UTC](https://discourse.cmake.org/t/windows-32bit-and-asm-error-when-bumping-cmake-minimum-required/1066 "2020-11-13T13:00:59Z")

</div>

I had a CMakeLists with minimum required 3.3 and realised I should make that 3.15 as I used a feature from there under certain conditions. I was surprised to see that this broke a Windows 32 bit build (not using the 3.1…

---

## [Need Help](https://discourse.cmake.org/t/need-help/1648)

<div class="topic-metadata">

**Author:** [@pig13pi](https://discourse.cmake.org/u/pig13pi)\
**Replies:** 2\
**Last updated:** [November 12, 2020, 1:16pm UTC](https://discourse.cmake.org/t/need-help/1648 "2020-11-12T13:16:52Z")

</div>

CMake Error at CMakeLists.txt:50 (project): Generator Visual Studio 15 2017 Win64 could not find any instance of Visual Studio. I have Visual Studio 15 2017 loaded…

---

## [Access properties via generator expressions](https://discourse.cmake.org/t/access-properties-via-generator-expressions/2152)

<div class="topic-metadata">

**Author:** [@DreamCaptain](https://discourse.cmake.org/u/DreamCaptain)\
**Replies:** 3\
**Last updated:** [November 12, 2020, 7:39am UTC](https://discourse.cmake.org/t/access-properties-via-generator-expressions/2152 "2020-11-12T07:39:57Z")

</div>

Hi, I need a way to conditionally mark some include directories as PRIVATE or PUBLIC depending on global property. here’s the code i use now that explicitly applies target property if global property is set: if(GLOBAL…

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

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