# Usage

**URL:** https://discourse.cmake.org/c/usage/12.md?page=92

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

**Page:** 93

---

## [CMake generating invalid Ninja build rules for asm](https://discourse.cmake.org/t/cmake-generating-invalid-ninja-build-rules-for-asm/1389)

<div class="topic-metadata">

**Author:** [@tbrearley](https://discourse.cmake.org/u/tbrearley)\
**Replies:** 3\
**Last updated:** [June 15, 2020, 4:11pm UTC](https://discourse.cmake.org/t/cmake-generating-invalid-ninja-build-rules-for-asm/1389 "2020-06-15T16:11:58Z")

</div>

I am attempting to use CMake with the Ninja generator to cross compile a project for ARM. Part of this project consists of .asm files that are passed to arm-none-eabi-as during the build process. However, when I attempt…

---

## [CMake Generator Error for Unix Makefiles - Would like a Solution.](https://discourse.cmake.org/t/cmake-generator-error-for-unix-makefiles-would-like-a-solution/1385)

<div class="topic-metadata">

**Author:** [@Garry\_Anderson1](https://discourse.cmake.org/u/Garry_Anderson1)\
**Replies:** 9\
**Last updated:** [June 14, 2020, 10:10am UTC](https://discourse.cmake.org/t/cmake-generator-error-for-unix-makefiles-would-like-a-solution/1385 "2020-06-14T10:10:39Z")

</div>

Hi CMake Discourse Gurus” When the CMake Generator (cmake -G “Eclipse CDT4 - Unix Makefiles”) process the following command line found in CMakeLists.txt: include\_directories($(MACRO\_UTILS\_INC\_FOLDER)) a Generated rea…

---

## [add\_test in CTestTestfile.cmake to contain relative paths.](https://discourse.cmake.org/t/add-test-in-ctesttestfile-cmake-to-contain-relative-paths/1340)

<div class="topic-metadata">

**Author:** [@Jacob\_Varghese](https://discourse.cmake.org/u/Jacob_Varghese)\
**Replies:** 18\
**Last updated:** [June 14, 2020, 1:15am UTC](https://discourse.cmake.org/t/add-test-in-ctesttestfile-cmake-to-contain-relative-paths/1340 "2020-06-14T01:15:05Z")

</div>

Can CTestTestfile.cmake hold relative paths instead of absolute ? I’m trying to move my build and test folders and executables to another VM and test it there where the folder structure is obviously different. I need to…

---

## [Set default toolchain system-wide](https://discourse.cmake.org/t/set-default-toolchain-system-wide/1373)

<div class="topic-metadata">

**Author:** [@Achpile](https://discourse.cmake.org/u/Achpile)\
**Replies:** 2\
**Last updated:** [June 12, 2020, 7:14am UTC](https://discourse.cmake.org/t/set-default-toolchain-system-wide/1373 "2020-06-12T07:14:10Z")

</div>

Good day. I use cmake on linux for cross-compilation. For both 32 and 64 systems i have separate “chroots”. Now I also want to add one for windows as well to compile with mingw. So the question is - can I set up mingw to…

---

## [Can I create a global variable to use for future projects?](https://discourse.cmake.org/t/can-i-create-a-global-variable-to-use-for-future-projects/1359)

<div class="topic-metadata">

**Author:** [@johnratius](https://discourse.cmake.org/u/johnratius)\
**Replies:** 5\
**Last updated:** [June 12, 2020, 1:55am UTC](https://discourse.cmake.org/t/can-i-create-a-global-variable-to-use-for-future-projects/1359 "2020-06-12T01:55:29Z")

</div>

I am wondering if there is a way to set a “global” variable, except it can be used with other projects that don’t initially declare it. Let me explain: I have a folder on my system that contains many useful include fold…

---

## [Feature Request: Give me a way to specify the MSVC Toolset when using "-G Ninja"](https://discourse.cmake.org/t/feature-request-give-me-a-way-to-specify-the-msvc-toolset-when-using-g-ninja/1332)

<div class="topic-metadata">

**Author:** [@steven-johnson](https://discourse.cmake.org/u/steven-johnson)\
**Replies:** 8\
**Last updated:** [June 10, 2020, 11:24pm UTC](https://discourse.cmake.org/t/feature-request-give-me-a-way-to-specify-the-msvc-toolset-when-using-g-ninja/1332 "2020-06-10T23:24:35Z")

</div>

TL;DR: I wish CMake had an optional arg that meant “run vcvarsall x64|x86|etc before doing anything else”. More backstory: I have a buildbot worker script running in a git-for-windows bash shell (basically, msys2) The…

---

## [PRIVATE target\_link\_libraries on header only imported library results in linkage requirement](https://discourse.cmake.org/t/private-target-link-libraries-on-header-only-imported-library-results-in-linkage-requirement/1350)

<div class="topic-metadata">

**Author:** [@Kerstin\_Keller](https://discourse.cmake.org/u/Kerstin_Keller)\
**Replies:** 3\
**Last updated:** [June 9, 2020, 2:56pm UTC](https://discourse.cmake.org/t/private-target-link-libraries-on-header-only-imported-library-results-in-linkage-requirement/1350 "2020-06-09T14:56:40Z")

</div>

Let’s assume I have a library that links privately to an imported, header only library: FindAsio.cmake (unfortunately does not export itself) add\_library(asio::asio INTERFACE IMPORTED) set\_target\_properties(asio::asio …

---

## [Building cmake from source for Android](https://discourse.cmake.org/t/building-cmake-from-source-for-android/1341)

<div class="topic-metadata">

**Author:** [@Jacob\_Varghese](https://discourse.cmake.org/u/Jacob_Varghese)\
**Replies:** 2\
**Last updated:** [June 9, 2020, 5:23am UTC](https://discourse.cmake.org/t/building-cmake-from-source-for-android/1341 "2020-06-09T05:23:50Z")

</div>

Has anyone tried building cmake for Android? Any issues? I would like to run ctest from within an emulator.

---

## [General pattern for making libraries available to other projects?](https://discourse.cmake.org/t/general-pattern-for-making-libraries-available-to-other-projects/1264)

<div class="topic-metadata">

**Author:** [@thomthom](https://discourse.cmake.org/u/thomthom)\
**Replies:** 6\
**Last updated:** [June 8, 2020, 8:13am UTC](https://discourse.cmake.org/t/general-pattern-for-making-libraries-available-to-other-projects/1264 "2020-06-08T08:13:32Z")

</div>

So far my projects have been rather small and simple. Haven’t had much use of reusing parts nor have I shared my libraries. However, my projects have grown and there are some I’m considering making available for general…

---

## [undefind symbol in Swig python build](https://discourse.cmake.org/t/undefind-symbol-in-swig-python-build/1331)

<div class="topic-metadata">

**Author:** [@poseid](https://discourse.cmake.org/u/poseid)\
**Replies:** 0\
**Last updated:** [June 4, 2020, 8:28pm UTC](https://discourse.cmake.org/t/undefind-symbol-in-swig-python-build/1331 "2020-06-04T20:28:35Z")

</div>

Hello, I am trying to build an example swig module for Python3. The build works fine but the resulting module is not working. The symbol can not be found. CMakeLists.txt cmake\_minimum\_required(VERSION 3.12) project(s…

---

## [Is it safe to delete CMakeCache.txt before each incremental build?](https://discourse.cmake.org/t/is-it-safe-to-delete-cmakecache-txt-before-each-incremental-build/1279)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 1\
**Last updated:** [May 28, 2020, 10:54am UTC](https://discourse.cmake.org/t/is-it-safe-to-delete-cmakecache-txt-before-each-incremental-build/1279 "2020-05-28T10:54:53Z")

</div>

My incremental CI builds frequently get: ##\[error\]CMake Error: Target xxx has dependency information when it shouldn't. ##\[error\]Your cache is probably stale. Please remove the entry xxx\_LIB\_DEPENDS from the cache. Is …

---

## [CMake promotes Fortran reals to 8 bytes](https://discourse.cmake.org/t/cmake-promotes-fortran-reals-to-8-bytes/1302)

<div class="topic-metadata">

**Author:** [@RedKnight7](https://discourse.cmake.org/u/RedKnight7)\
**Replies:** 4\
**Last updated:** [June 2, 2020, 5:26pm UTC](https://discourse.cmake.org/t/cmake-promotes-fortran-reals-to-8-bytes/1302 "2020-06-02T17:26:13Z")

</div>

We are using gfortran to build our code. When we build with our legacy configure system, default reals are 4 bytes with 24 digits of precision. When we build with cmake 3.16.5 , default reals are 8-bytes with 53 digits …

---

## [Build failure with Ninja Multi-Config](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290)

<div class="topic-metadata">

**Author:** [@alex](https://discourse.cmake.org/u/alex)\
**Replies:** 23\
**Last updated:** [June 1, 2020, 2:41pm UTC](https://discourse.cmake.org/t/build-failure-with-ninja-multi-config/1290 "2020-06-01T14:41:49Z")

</div>

Hi all, I just tried testing out Ninja Multi-Config for the first time on Windows. My project has worked with both the Ninja and Visual Studio 19 generators before without issue. I try running in a developer command pro…

---

## [Generator for Eclipse CDT4 Unix Makefiles - Error](https://discourse.cmake.org/t/generator-for-eclipse-cdt4-unix-makefiles-error/966)

<div class="topic-metadata">

**Author:** [@Garry\_Anderson](https://discourse.cmake.org/u/Garry_Anderson)\
**Replies:** 9\
**Last updated:** [May 29, 2020, 10:26pm UTC](https://discourse.cmake.org/t/generator-for-eclipse-cdt4-unix-makefiles-error/966 "2020-05-29T22:26:37Z")

</div>

CMake Commuinity & Guru Support Group: I am using command line for cmake -G “Eclipse CDT4 - Unix Makefiles” to generate makefiles (from CMake tree) to be imported into Eclipse environment, but it looks like your Cmake G…

---

## [CMake for (wx)python project(s)](https://discourse.cmake.org/t/cmake-for-wx-python-project-s/1261)

<div class="topic-metadata">

**Author:** [@gour](https://discourse.cmake.org/u/gour)\
**Replies:** 4\
**Last updated:** [May 29, 2020, 7:56am UTC](https://discourse.cmake.org/t/cmake-for-wx-python-project-s/1261 "2020-05-29T07:56:48Z")

</div>

Hello, I’m about to start working on open-source desktop app using (wx)python. I need to bind 3rd party C library using cffi/cython, possibly use Nuitka python compiler, would like to to provide manual in html/epub/pdf …

---

## [target\_link\_libraries for lpthread, ldl, and lutils](https://discourse.cmake.org/t/target-link-libraries-for-lpthread-ldl-and-lutils/1235)

<div class="topic-metadata">

**Author:** [@albertchristianto](https://discourse.cmake.org/u/albertchristianto)\
**Replies:** 4\
**Last updated:** [May 28, 2020, 3:45am UTC](https://discourse.cmake.org/t/target-link-libraries-for-lpthread-ldl-and-lutils/1235 "2020-05-28T03:45:31Z")

</div>

Hello, i am new at using cmake for compiling and building c++ code. here is my CMakeLists.txt cmake\_minimum\_required(VERSION 3.0) project(example) add\_subdirectory(pybind11) find\_package( Threads REQUIRED ) #find\_pack…

---

## [Clang-tidy passing incorrect arguments on windows?](https://discourse.cmake.org/t/clang-tidy-passing-incorrect-arguments-on-windows/1123)

<div class="topic-metadata">

**Author:** [@anon45792294](https://discourse.cmake.org/u/anon45792294)\
**Replies:** 3\
**Last updated:** [May 23, 2020, 8:40pm UTC](https://discourse.cmake.org/t/clang-tidy-passing-incorrect-arguments-on-windows/1123 "2020-05-23T20:40:12Z")

</div>

I’m trying to use clang-tidy on windows using clang-cl. But I’m getting this error while trying to run clang-tidy: \>------ Build All started: Project: PitoEngine, Configuration: Debug\_x64 ------ \[1/14\] Building CXX o…

---

## [submit to CDash with excluding lines from coverage using GCOV\_EXCL\_LINE](https://discourse.cmake.org/t/submit-to-cdash-with-excluding-lines-from-coverage-using-gcov-excl-line/1259)

<div class="topic-metadata">

**Author:** [@Nikhil\_Reddy\_Ramolla](https://discourse.cmake.org/u/Nikhil_Reddy_Ramolla)\
**Replies:** 0\
**Last updated:** [May 23, 2020, 9:05am UTC](https://discourse.cmake.org/t/submit-to-cdash-with-excluding-lines-from-coverage-using-gcov-excl-line/1259 "2020-05-23T09:05:26Z")

</div>

Hello all, I am learning CMake by making a sample C++ project, and I have succesfully integrated it with CDash, with both tests (using boost unit test) and coverage (using --coverage and gcov). I am using this CTest Sc…

---

## [how to find Qt for iOS?](https://discourse.cmake.org/t/how-to-find-qt-for-ios/1061)

<div class="topic-metadata">

**Author:** [@davemilter](https://discourse.cmake.org/u/davemilter)\
**Replies:** 1\
**Last updated:** [May 20, 2020, 8:35am UTC](https://discourse.cmake.org/t/how-to-find-qt-for-ios/1061 "2020-05-20T08:35:33Z")

</div>

I want to compile project (which uses Qt) for iOS on Mac OS . But cmake can not find Qt for iOS (the project compiled just fine for iOS on the same machine with qmake). Here is my CMakeLists.txt: cmake\_minimum\_requir…

---

## [Include PRIVATE generated headers dir under build tree in test execution from a source dir](https://discourse.cmake.org/t/include-private-generated-headers-dir-under-build-tree-in-test-execution-from-a-source-dir/1231)

<div class="topic-metadata">

**Author:** [@yisseamake](https://discourse.cmake.org/u/yisseamake)\
**Replies:** 1\
**Last updated:** [May 19, 2020, 1:45pm UTC](https://discourse.cmake.org/t/include-private-generated-headers-dir-under-build-tree-in-test-execution-from-a-source-dir/1231 "2020-05-19T13:45:55Z")

</div>

Could you please advise on the proper way to support test execution when test program includes generated file from the build tree without exposing generated file as PUBLIC. When library is built header files are generat…

---

## [How to force install into custom dir under project](https://discourse.cmake.org/t/how-to-force-install-into-custom-dir-under-project/1209)

<div class="topic-metadata">

**Author:** [@yisseamake](https://discourse.cmake.org/u/yisseamake)\
**Replies:** 2\
**Last updated:** [May 18, 2020, 6:39pm UTC](https://discourse.cmake.org/t/how-to-force-install-into-custom-dir-under-project/1209 "2020-05-18T18:39:46Z")

</div>

I have project structure with custom install dir under the project dir (build dir is at the same level as install dir) which I’d like to install to my librray (with library and public include objects). However I am getti…

---

## [Drive Letter Inconsistency on Windows between find\_path and IMPLICIT\_INCLUDE\_DIRECTORIES](https://discourse.cmake.org/t/drive-letter-inconsistency-on-windows-between-find-path-and-implicit-include-directories/1221)

<div class="topic-metadata">

**Author:** [@cgudrian](https://discourse.cmake.org/u/cgudrian)\
**Replies:** 4\
**Last updated:** [May 18, 2020, 12:06pm UTC](https://discourse.cmake.org/t/drive-letter-inconsistency-on-windows-between-find-path-and-implicit-include-directories/1221 "2020-05-18T12:06:27Z")

</div>

Hello! On Windows find\_path returns a path with a lowercase drive letter (e.g. “c:/cross-sdk/sysroots/target/usr/include”). The CMAKE\_\<LANG\>\_IMPLICIT\_INCLUDE\_DIRECTORIES variables however contain upper case drive letter…

---

## [Is CMAKE\_PREFIX\_PATH recursively searched?](https://discourse.cmake.org/t/is-cmake-prefix-path-recursively-searched/817)

<div class="topic-metadata">

**Author:** [@MathiasMagnus](https://discourse.cmake.org/u/MathiasMagnus)\
**Replies:** 9\
**Last updated:** [May 18, 2020, 8:13am UTC](https://discourse.cmake.org/t/is-cmake-prefix-path-recursively-searched/817 "2020-05-18T08:13:59Z")

</div>

Hi! I have a build where a system package config file is picked up even though it should not be. Having read the docs on what the config file search logic is, it could only possible find it if the search of \<prefix\> is …

---

## [How to specify different variable value for different build type for visual studio ?](https://discourse.cmake.org/t/how-to-specify-different-variable-value-for-different-build-type-for-visual-studio/1216)

<div class="topic-metadata">

**Author:** [@davied9](https://discourse.cmake.org/u/davied9)\
**Replies:** 6\
**Last updated:** [May 18, 2020, 6:57am UTC](https://discourse.cmake.org/t/how-to-specify-different-variable-value-for-different-build-type-for-visual-studio/1216 "2020-05-18T06:57:06Z")

</div>

I’m trying to generate a simple c++ project with cmake for visual studio. CMakeLists.txt cmake\_minimum\_required(VERSION 3.5.1) project(simple) get\_filename\_component(LIB\_PATH\_RELEASE ../release/lib ABSOLUTE) get\_filen…

---

## [when to use include on core functions?](https://discourse.cmake.org/t/when-to-use-include-on-core-functions/1224)

<div class="topic-metadata">

**Author:** [@hex](https://discourse.cmake.org/u/hex)\
**Replies:** 1\
**Last updated:** [May 15, 2020, 10:33am UTC](https://discourse.cmake.org/t/when-to-use-include-on-core-functions/1224 "2020-05-15T10:33:05Z")

</div>

CMake offers some functions to use without any includes: project add\_executable … some other functions require an include before being used: add\_file\_dependencies. cmake\_print\_properties … is there any indication …

---

## [MKL 64lp versus 64ilp difficulties](https://discourse.cmake.org/t/mkl-64lp-versus-64ilp-difficulties/1223)

<div class="topic-metadata">

**Author:** [@spinicist](https://discourse.cmake.org/u/spinicist)\
**Replies:** 0\
**Last updated:** [May 15, 2020, 10:01am UTC](https://discourse.cmake.org/t/mkl-64lp-versus-64ilp-difficulties/1223 "2020-05-15T10:01:47Z")

</div>

Hello, I’ve been having difficulty with using Eigen and the Intel MKL backend in my project. My CMake version is 3.15.2. For the full details, see here: https://gitlab.com/libeigen/eigen/-/issues/1890 The summary versi…

---

## [Making set(CMAKE\_C\_COMPILER) understand alt sysroot path](https://discourse.cmake.org/t/making-set-cmake-c-compiler-understand-alt-sysroot-path/1219)

<div class="topic-metadata">

**Author:** [@eriols](https://discourse.cmake.org/u/eriols)\
**Replies:** 0\
**Last updated:** [May 14, 2020, 8:23pm UTC](https://discourse.cmake.org/t/making-set-cmake-c-compiler-understand-alt-sysroot-path/1219 "2020-05-14T20:23:08Z")

</div>

Just setting the above fails in my case as it can’t find things like crti.o, which in this particular cross-compilation case are in an unorthodox location. I’m setting the --sysroot path as a manually added flag for the …

---

## [Unknown CMake command "SWIG\_ADD\_LIBRARY"](https://discourse.cmake.org/t/unknown-cmake-command-swig-add-library/1208)

<div class="topic-metadata">

**Author:** [@pmchozas](https://discourse.cmake.org/u/pmchozas)\
**Replies:** 2\
**Last updated:** [May 13, 2020, 2:47pm UTC](https://discourse.cmake.org/t/unknown-cmake-command-swig-add-library/1208 "2020-05-13T14:47:31Z")

</div>

Hi, I’m trying to install a python3 library with cmake 3.17 and I get this error all the time. CMake Error at CMakeLists.txt:12 (SWIG\_ADD\_LIBRARY): Unknown CMake command “SWIG\_ADD\_LIBRARY”. I’ve seen that was a common…

---

## [CMake not find some QT5 packages](https://discourse.cmake.org/t/cmake-not-find-some-qt5-packages/1167)

<div class="topic-metadata">

**Author:** [@FredMontteiro](https://discourse.cmake.org/u/FredMontteiro)\
**Replies:** 8\
**Last updated:** [May 13, 2020, 11:20am UTC](https://discourse.cmake.org/t/cmake-not-find-some-qt5-packages/1167 "2020-05-13T11:20:38Z")

</div>

Hi friends, I’m using the translator, my English is medium. I am trying to install the Otter browser on Lubuntu via CMake / QT5. I have QT5 installed on /opt/Qt5.14.2 and CMake installed on /home/“user”/cmake-3.17.2-Li…

---

## [CMake Duplicating Debug Library and not including normal library](https://discourse.cmake.org/t/cmake-duplicating-debug-library-and-not-including-normal-library/1174)

<div class="topic-metadata">

**Author:** [@jasperswallen](https://discourse.cmake.org/u/jasperswallen)\
**Replies:** 7\
**Last updated:** [May 11, 2020, 4:41pm UTC](https://discourse.cmake.org/t/cmake-duplicating-debug-library-and-not-including-normal-library/1174 "2020-05-11T16:41:48Z")

</div>

Hi! I’m experiencing some strange behavior with CMake’s Visual Studio makefile generator. I have a project that includes Python3’s libraries through the normal methods, and it successfully finds both the debug and norma…

[Previous page](https://discourse.cmake.org/c/usage/12.md?page=91)

[Next page](https://discourse.cmake.org/c/usage/12.md?page=93)
