# Usage

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

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

**Page:** 85

---

## [Can't crosscompile CMake itself](https://discourse.cmake.org/t/cant-crosscompile-cmake-itself/2558)

<div class="topic-metadata">

**Author:** [@tgq](https://discourse.cmake.org/u/tgq)\
**Replies:** 3\
**Last updated:** [January 16, 2021, 12:31pm UTC](https://discourse.cmake.org/t/cant-crosscompile-cmake-itself/2558 "2021-01-16T12:31:31Z")

</div>

Hello. I am using clang as a crosscompiler. My toolchain is functional, i can build programs for arm with it. But when i want to bootstrap CMake itself it fails with error: $ cmake .. -DCMAKE\_CROSSCOMPILING=True -DCMAKE…

---

## [\[Visual Studio\] Error: Unable to deploy local file 'C:\\....\\x64\\Release\\ZERO\_CHECK'](https://discourse.cmake.org/t/visual-studio-error-unable-to-deploy-local-file-c-x64-release-zero-check/2072)

<div class="topic-metadata">

**Author:** [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)\
**Replies:** 2\
**Last updated:** [January 15, 2021, 5:42pm UTC](https://discourse.cmake.org/t/visual-studio-error-unable-to-deploy-local-file-c-x64-release-zero-check/2072 "2021-01-15T17:42:34Z")

</div>

I’m trying to deploy my code onto my testing machine. Here is a windows guide on how to do this: However I’m running into a really annoying issue with the workflow. The visual studio solution tries to deploy zer…

---

## [Unable to understand the difference in 3.19 and 3.5.2](https://discourse.cmake.org/t/unable-to-understand-the-difference-in-3-19-and-3-5-2/2553)

<div class="topic-metadata">

**Author:** [@davas](https://discourse.cmake.org/u/davas)\
**Replies:** 2\
**Last updated:** [January 15, 2021, 12:54pm UTC](https://discourse.cmake.org/t/unable-to-understand-the-difference-in-3-19-and-3-5-2/2553 "2021-01-15T12:54:00Z")

</div>

Hi, I am new to cmake and I have just started learning. So please excuse if the question is naive. The book I am following says to use version \>= 3.5.2 and I am able to find such version here https://github.com/Kitware…

---

## [File API and imported targets](https://discourse.cmake.org/t/file-api-and-imported-targets/242)

<div class="topic-metadata">

**Author:** [@Pablo\_Le\_Henaff](https://discourse.cmake.org/u/Pablo_Le_Henaff)\
**Replies:** 6\
**Last updated:** [January 15, 2021, 6:23am UTC](https://discourse.cmake.org/t/file-api-and-imported-targets/242 "2021-01-15T06:23:04Z")

</div>

Hi everyone, I would like to automatically list the dependencies of all of my project’s targets, including external dependencies. Is there a way to get the file API to list IMPORTED targets? Thank you, Pablo

---

## [Passing build variables using command line](https://discourse.cmake.org/t/passing-build-variables-using-command-line/2530)

<div class="topic-metadata">

**Author:** [@toothache](https://discourse.cmake.org/u/toothache)\
**Replies:** 4\
**Last updated:** [January 15, 2021, 1:30am UTC](https://discourse.cmake.org/t/passing-build-variables-using-command-line/2530 "2021-01-15T01:30:07Z")

</div>

I’d like to override the cmake cached variable using the command line. But if a variable is repeatedly provided, does the last value take effect? # what is the value of FOO? \> cmake -DFOO=123 -DFOO=321 Update: Test r…

---

## [win command within add\_test() never returns and blocks test suite execution](https://discourse.cmake.org/t/win-command-within-add-test-never-returns-and-blocks-test-suite-execution/2545)

<div class="topic-metadata">

**Author:** [@agouaillard](https://discourse.cmake.org/u/agouaillard)\
**Replies:** 0\
**Last updated:** [January 14, 2021, 4:02pm UTC](https://discourse.cmake.org/t/win-command-within-add-test-never-returns-and-blocks-test-suite-execution/2545 "2021-01-14T16:02:36Z")

</div>

I have a simple command on windows that starts an appium server on a separate windows and return: start appium when I try to add the corresponding test, even going through the indirection of a script, the script works …

---

## [How about let compiler executes the preprocessor step.](https://discourse.cmake.org/t/how-about-let-compiler-executes-the-preprocessor-step/2533)

<div class="topic-metadata">

**Author:** [@dalianduzhi](https://discourse.cmake.org/u/dalianduzhi)\
**Replies:** 6\
**Last updated:** [January 14, 2021, 1:31pm UTC](https://discourse.cmake.org/t/how-about-let-compiler-executes-the-preprocessor-step/2533 "2021-01-14T13:31:09Z")

</div>

Hi I want to let the compiler executes the preprocessor and get the output. Can CMake do this without using the add\_custcom\_command? thanks

---

## ["get\_property could not find TARGET clang-resource-headers" during -DCMAKE\_CXX\_FLAGS=-stdlib=libc++ '-DLLVM\_ENABLE\_RUNTIMES=compiler-rt;libcxx'](https://discourse.cmake.org/t/get-property-could-not-find-target-clang-resource-headers-during-dcmake-cxx-flags-stdlib-libc-dllvm-enable-runtimes-compiler-rt-libcxx/1624)

<div class="topic-metadata">

**Author:** [@Ivan\_Serdyuk](https://discourse.cmake.org/u/Ivan_Serdyuk)\
**Replies:** 3\
**Last updated:** [January 13, 2021, 8:25pm UTC](https://discourse.cmake.org/t/get-property-could-not-find-target-clang-resource-headers-during-dcmake-cxx-flags-stdlib-libc-dllvm-enable-runtimes-compiler-rt-libcxx/1624 "2021-01-13T20:25:31Z")

</div>

Kind a hi. I was trying to compile https://go.googlesource.com/gollvm/ using Clang’s C++ compiler and libc++ (instead of GCC and libstdc++ - this project is pretty much LLVM related, which itself means that it could rel…

---

## [Problems with compiling gollvm project (CMake version 3.18.0)](https://discourse.cmake.org/t/problems-with-compiling-gollvm-project-cmake-version-3-18-0/1576)

<div class="topic-metadata">

**Author:** [@Ivan\_Serdyuk](https://discourse.cmake.org/u/Ivan_Serdyuk)\
**Replies:** 2\
**Last updated:** [January 13, 2021, 8:24pm UTC](https://discourse.cmake.org/t/problems-with-compiling-gollvm-project-cmake-version-3-18-0/1576 "2021-01-13T20:24:23Z")

</div>

Hi. I am experiencing some issues, related to https://go.googlesource.com/gollvm/. C:\\Users\\Worker\\gollvm\\build-debug\>cmake -DCMAKE\_BUILD\_TYPE=Debug -DLLVM\_USE\_LINKER=gold -G Ninja …/llvm-project/llvm – The C compiler…

---

## [Run clang-tidy only?](https://discourse.cmake.org/t/run-clang-tidy-only/2537)

<div class="topic-metadata">

**Author:** [@RedDwarf](https://discourse.cmake.org/u/RedDwarf)\
**Replies:** 2\
**Last updated:** [January 13, 2021, 5:38pm UTC](https://discourse.cmake.org/t/run-clang-tidy-only/2537 "2021-01-13T17:38:04Z")

</div>

I have Jenkins running cmake with -DCMAKE\_C\_CLANG\_TIDY=clang-tidy -DCMAKE\_CXX\_CLANG\_TIDY=clang-tidy but, since the warnings format of clang-tidy is basically the same than the one from gcc/clang, the Jenkins Warnings NG …

---

## [Cmake compiler tool](https://discourse.cmake.org/t/cmake-compiler-tool/2496)

<div class="topic-metadata">

**Author:** [@Khalid\_Al-kuwity](https://discourse.cmake.org/u/Khalid_Al-kuwity)\
**Replies:** 11\
**Last updated:** [January 13, 2021, 4:10pm UTC](https://discourse.cmake.org/t/cmake-compiler-tool/2496 "2021-01-13T16:10:41Z")

</div>

I tried to confirm the cmake confirmation on iOS 11.1, but I get incomplete error because ((CMake Error at CMakeLists.txt:3 (project): The CMAKE\_CXX\_COMPILER: /Library/Developer/CommandLineTools/usr/bin/c++ is not a f…

---

## [Enumerate all transitive dependencies of target?](https://discourse.cmake.org/t/enumerate-all-transitive-dependencies-of-target/2523)

<div class="topic-metadata">

**Author:** [@target.san](https://discourse.cmake.org/u/target.san)\
**Replies:** 2\
**Last updated:** [January 13, 2021, 6:41am UTC](https://discourse.cmake.org/t/enumerate-all-transitive-dependencies-of-target/2523 "2021-01-13T06:41:24Z")

</div>

Hello! Like some other developers, I need to copy external dependency DLLs to executable’s directory. I’ve checked this topic. Unfortunately, suggested solution doesn’t fit that well First of all, it lists all depende…

---

## [CMAKE\_MAKE\_PROGRAM 3.19 issue?](https://discourse.cmake.org/t/cmake-make-program-3-19-issue/2213)

<div class="topic-metadata">

**Author:** [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)\
**Replies:** 16\
**Last updated:** [January 12, 2021, 8:54pm UTC](https://discourse.cmake.org/t/cmake-make-program-3-19-issue/2213 "2021-01-12T20:54:14Z")

</div>

In my cmake toolchain I set the CMAKE\_MAKE\_PROGRAM. To clarify I was setting my ninja executable like this: if (CMAKE\_GENERATOR MATCHES "Ninja") # Force update the program to allow updating the ninja version …

---

## [Adding standard libraries to use for every link target](https://discourse.cmake.org/t/adding-standard-libraries-to-use-for-every-link-target/2519)

<div class="topic-metadata">

**Author:** [@Stephan268](https://discourse.cmake.org/u/Stephan268)\
**Replies:** 9\
**Last updated:** [January 12, 2021, 8:31pm UTC](https://discourse.cmake.org/t/adding-standard-libraries-to-use-for-every-link-target/2519 "2021-01-12T20:31:44Z")

</div>

I am attempting to build for Windows XP using VS 2015 on Windows 10. Several parts of the code require us to link against Microsofts psapi.lib in this “cross compilation” case. I have attempted to set (CMAKE\_C\_STANDARD…

---

## [How to find/manage Ninja?](https://discourse.cmake.org/t/how-to-find-manage-ninja/2518)

<div class="topic-metadata">

**Author:** [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)\
**Replies:** 5\
**Last updated:** [January 12, 2021, 6:50pm UTC](https://discourse.cmake.org/t/how-to-find-manage-ninja/2518 "2021-01-12T18:50:21Z")

</div>

I’m confused how I should find/manage Ninja. The easiest solution I have found is to simply add Ninja to my PATH. What are the alternatives to simply adding Ninja to my PATH? I don’t really like the idea of developers…

---

## [How to deal with ld error: 'can not be used when making a PIE object; recompile with -fPIC'?](https://discourse.cmake.org/t/how-to-deal-with-ld-error-can-not-be-used-when-making-a-pie-object-recompile-with-fpic/2509)

<div class="topic-metadata">

**Author:** [@DavidA](https://discourse.cmake.org/u/DavidA)\
**Replies:** 3\
**Last updated:** [January 12, 2021, 4:04pm UTC](https://discourse.cmake.org/t/how-to-deal-with-ld-error-can-not-be-used-when-making-a-pie-object-recompile-with-fpic/2509 "2021-01-12T16:04:02Z")

</div>

Hi, I have built the 3rd party Accellera SystemC library using CMake on Centos 7 with devtoolset-7. I can successfully link my C++ application to that library, on the same platform. I also need to link my application …

---

## [ctest 3.16 - tests don't timeout if there are remaining subprocesses](https://discourse.cmake.org/t/ctest-3-16-tests-dont-timeout-if-there-are-remaining-subprocesses/2493)

<div class="topic-metadata">

**Author:** [@Marc\_Legendre](https://discourse.cmake.org/u/Marc_Legendre)\
**Replies:** 3\
**Last updated:** [January 8, 2021, 10:38am UTC](https://discourse.cmake.org/t/ctest-3-16-tests-dont-timeout-if-there-are-remaining-subprocesses/2493 "2021-01-08T10:38:54Z")

</div>

Hi there, I noticed that ctest 3.16 fails to timeout tests if their main process has terminated, but there are still subprocesses running. (NB : Ubuntu 20.04 ships cmake 3.16.3) For example, here is a test script that …

---

## [Xcode workspace VS project built product issue](https://discourse.cmake.org/t/xcode-workspace-vs-project-built-product-issue/2479)

<div class="topic-metadata">

**Author:** [@m\_g](https://discourse.cmake.org/u/m_g)\
**Replies:** 8\
**Last updated:** [January 6, 2021, 4:51pm UTC](https://discourse.cmake.org/t/xcode-workspace-vs-project-built-product-issue/2479 "2021-01-06T16:51:49Z")

</div>

Hi everyone! I currently moved my macOS/iOS app (mainly C++ / Objective-C++) to CMake. So far, so good! I can properly generate each Xcode project, one targeting the macOS platform, and the other one for iOS. Before m…

---

## [CMake build failure - Clang vs GCC?](https://discourse.cmake.org/t/cmake-build-failure-clang-vs-gcc/2473)

<div class="topic-metadata">

**Author:** [@Adam\_Haber](https://discourse.cmake.org/u/Adam_Haber)\
**Replies:** 4\
**Last updated:** [January 5, 2021, 10:12pm UTC](https://discourse.cmake.org/t/cmake-build-failure-clang-vs-gcc/2473 "2021-01-05T22:12:50Z")

</div>

Hi, Not sure if this is the right place to ask this question, but I’ve already tried every SO solution I could find, and thought maybe someone from the CMake community might help. I’m learning Cpp using exercism, and t…

---

## [CMake 3.19 / Xcode 12 fails when cross-compiling for iOS unless -T buildsystem=1 is specified](https://discourse.cmake.org/t/cmake-3-19-xcode-12-fails-when-cross-compiling-for-ios-unless-t-buildsystem-1-is-specified/2463)

<div class="topic-metadata">

**Author:** [@herzbube](https://discourse.cmake.org/u/herzbube)\
**Replies:** 4\
**Last updated:** [January 5, 2021, 7:34pm UTC](https://discourse.cmake.org/t/cmake-3-19-xcode-12-fails-when-cross-compiling-for-ios-unless-t-buildsystem-1-is-specified/2463 "2021-01-05T19:34:15Z")

</div>

From the CMake 3.19 release notes: The Xcode generator now uses the Xcode “new build system” when generating for Xcode 12.0 or higher. See the CMAKE\_XCODE\_BUILD\_SYSTEM variable. One may use -T buildsystem=1 to switch t…

---

## [How to detect Linux distro type?](https://discourse.cmake.org/t/how-to-detect-linux-distro-type/2476)

<div class="topic-metadata">

**Author:** [@DavidA](https://discourse.cmake.org/u/DavidA)\
**Replies:** 4\
**Last updated:** [January 5, 2021, 2:03pm UTC](https://discourse.cmake.org/t/how-to-detect-linux-distro-type/2476 "2021-01-05T14:03:16Z")

</div>

My CMake project targets Ubuntu and Centos distros and I need to link to separate libraries for each. How can I detect the distro type and conditionally call target\_link\_libraries accordingly? There are some suggestion…

---

## [difference between Xxx\_VERSION\_Yy and Xxx\_VERSION\_MAJOR](https://discourse.cmake.org/t/difference-between-xxx-version-yy-and-xxx-version-major/2430)

<div class="topic-metadata">

**Author:** [@hex](https://discourse.cmake.org/u/hex)\
**Replies:** 3\
**Last updated:** [January 5, 2021, 1:42pm UTC](https://discourse.cmake.org/t/difference-between-xxx-version-yy-and-xxx-version-major/2430 "2021-01-05T13:42:20Z")

</div>

the documentation about CMake modules lists both Xxx\_VERSION\_Yy and Xxx\_VERSION\_MAJOR et all as recommended variables: Xxx\_VERSION\_Yy: Expect Version Yy if true. Make sure at most one of these is ever true Xxx\_VERSION\_…

---

## [find\_package() link path on target for pre-built cross compiled libraries](https://discourse.cmake.org/t/find-package-link-path-on-target-for-pre-built-cross-compiled-libraries/2212)

<div class="topic-metadata">

**Author:** [@shannon](https://discourse.cmake.org/u/shannon)\
**Replies:** 4\
**Last updated:** [January 5, 2021, 1:41pm UTC](https://discourse.cmake.org/t/find-package-link-path-on-target-for-pre-built-cross-compiled-libraries/2212 "2021-01-05T13:41:10Z")

</div>

Hi there, I am working on converting a embedded project which cross compiles for two different targets, and am trying to convert it to CMake (and also getting x86 host system builds working). I have got this (somewhat)…

---

## [FetchContent / CMAKE\_MAKE\_PROGRAM error](https://discourse.cmake.org/t/fetchcontent-cmake-make-program-error/2468)

<div class="topic-metadata">

**Author:** [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)\
**Replies:** 9\
**Last updated:** [January 4, 2021, 10:02pm UTC](https://discourse.cmake.org/t/fetchcontent-cmake-make-program-error/2468 "2021-01-04T22:02:58Z")

</div>

I’m having an issue with Ninja and FetchContent. I’m trying to create a shared cmake code repository at my company. And I would like to use FetchContent to grab this shared cmake code. So I have the following FetchC…

---

## [CPack Dependencies Shared Library](https://discourse.cmake.org/t/cpack-dependencies-shared-library/1687)

<div class="topic-metadata">

**Author:** [@arturoar3nas](https://discourse.cmake.org/u/arturoar3nas)\
**Replies:** 4\
**Last updated:** [January 4, 2021, 9:36pm UTC](https://discourse.cmake.org/t/cpack-dependencies-shared-library/1687 "2021-01-04T21:36:53Z")

</div>

Hello, I’m trying to package my shared library with dependencies and I’m using the below code: # # CPack Properties # set(CPACK\_PACKAGE\_VERSION\_MAJOR "1") set(CPACK\_PACKAGE\_VERSION\_MINOR "1") set(CPACK\_PACKAGE\_VERSION\_…

---

## [cmake add\_custom\_command introduces false dependency unless add\_custom\_target also used](https://discourse.cmake.org/t/cmake-add-custom-command-introduces-false-dependency-unless-add-custom-target-also-used/2467)

<div class="topic-metadata">

**Author:** [@rhbroberg](https://discourse.cmake.org/u/rhbroberg)\
**Replies:** 3\
**Last updated:** [January 4, 2021, 8:38pm UTC](https://discourse.cmake.org/t/cmake-add-custom-command-introduces-false-dependency-unless-add-custom-target-also-used/2467 "2021-01-04T20:38:21Z")

</div>

I’m building some libraries, all of which generate some of their files. I’ve created the generated files using add\_custom\_command(), but I’ve discovered something which seems like a false dependency. If a downstream li…

---

## [generate or copy .dll of 3rd-party to executable folder](https://discourse.cmake.org/t/generate-or-copy-dll-of-3rd-party-to-executable-folder/2436)

<div class="topic-metadata">

**Author:** [@aopaw](https://discourse.cmake.org/u/aopaw)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 7:02pm UTC](https://discourse.cmake.org/t/generate-or-copy-dll-of-3rd-party-to-executable-folder/2436 "2021-01-04T19:02:12Z")

</div>

Hello, First time at here. I am using CMakeLists.txt to configure my project, a test project only. Suppose that the project depends on serveral 3rd-party libraries. Every of the libraries is in different directory and …

---

## [How to control \_IMPORT\_PREFIX in exported Targets.cmake list file generated by cmake](https://discourse.cmake.org/t/how-to-control-import-prefix-in-exported-targets-cmake-list-file-generated-by-cmake/2291)

<div class="topic-metadata">

**Author:** [@yisseamake](https://discourse.cmake.org/u/yisseamake)\
**Replies:** 2\
**Last updated:** [January 4, 2021, 6:47pm UTC](https://discourse.cmake.org/t/how-to-control-import-prefix-in-exported-targets-cmake-list-file-generated-by-cmake/2291 "2021-01-04T18:47:48Z")

</div>

The Target.cmake target list file generated by install(EXPORT…) has line that set \_IMPORT\_PREFIX to absolute path of the project that generates this file. Therefore the consuming project is not able to find files in imp…

---

## [Failure to install(EXPORT due to linked target already exported with another export set](https://discourse.cmake.org/t/failure-to-install-export-due-to-linked-target-already-exported-with-another-export-set/2040)

<div class="topic-metadata">

**Author:** [@yisseamake](https://discourse.cmake.org/u/yisseamake)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 6:33pm UTC](https://discourse.cmake.org/t/failure-to-install-export-due-to-linked-target-already-exported-with-another-export-set/2040 "2021-01-04T18:33:29Z")

</div>

I am getting error with cmake\_minimum\_required(VERSION 3.17). CMake Error: install(EXPORT "mypSubroj2Targets" ...) includes target "mypSubroj2shared" which requires target "mylogger" that is not in this export set, but …

---

## [link MKL libraries in Windows / Clion /Cmake](https://discourse.cmake.org/t/link-mkl-libraries-in-windows-clion-cmake/2046)

<div class="topic-metadata">

**Author:** [@ragnarokas](https://discourse.cmake.org/u/ragnarokas)\
**Replies:** 1\
**Last updated:** [January 4, 2021, 6:32pm UTC](https://discourse.cmake.org/t/link-mkl-libraries-in-windows-clion-cmake/2046 "2021-01-04T18:32:36Z")

</div>

0 I am very new in CMake and I am trying to include MKL libraries in my project done in Clion. Compiler is MVS 2019 as required. Using MKL tool https://software.intel.com/content/www/us/en/develop/articles/intel-mkl-li…

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

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