# Usage

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

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

**Page:** 91

---

## [Unable to include header files?](https://discourse.cmake.org/t/unable-to-include-header-files/1881)

<div class="topic-metadata">

**Author:** [@mbilyanov](https://discourse.cmake.org/u/mbilyanov)\
**Replies:** 1\
**Last updated:** [September 22, 2020, 9:31am UTC](https://discourse.cmake.org/t/unable-to-include-header-files/1881 "2020-09-22T09:31:12Z")

</div>

Hi, I’m trying to reproduce the following command, so that this works with CMake. /usr/bin/x86\_64-w64-mingw32-g++ -march=x86-64 -mtune=x86-64 -O2 -shared -static -static-libgcc -static-libstdc++ -s -fno-rtti -fno-excep…

---

## [Skip targets to be built in certain configuration](https://discourse.cmake.org/t/skip-targets-to-be-built-in-certain-configuration/1874)

<div class="topic-metadata">

**Author:** [@andriy](https://discourse.cmake.org/u/andriy)\
**Replies:** 0\
**Last updated:** [September 21, 2020, 6:03pm UTC](https://discourse.cmake.org/t/skip-targets-to-be-built-in-certain-configuration/1874 "2020-09-21T18:03:48Z")

</div>

Hello, I have next problem: I’m using cmake to configure and build my project for both Linux and Windows OSs. For Windows it uses multi-generator to configure the solution with different configs and for Linux I have se…

---

## [CMake doesn't link the actual object to the resulting dll](https://discourse.cmake.org/t/cmake-doesnt-link-the-actual-object-to-the-resulting-dll/1866)

<div class="topic-metadata">

**Author:** [@Coderx7](https://discourse.cmake.org/u/Coderx7)\
**Replies:** 2\
**Last updated:** [September 20, 2020, 6:38am UTC](https://discourse.cmake.org/t/cmake-doesnt-link-the-actual-object-to-the-resulting-dll/1866 "2020-09-20T06:38:33Z")

</div>

I created a C++ library in visual studio and all is fine. However, I’m trying to convert the projects to CMake so I can build them on linux as well. The library in question is implemented as pimple (dont know if it make…

---

## [/MP on all files but pre\_compiled\_header](https://discourse.cmake.org/t/mp-on-all-files-but-pre-compiled-header/1781)

<div class="topic-metadata">

**Author:** [@sandercox](https://discourse.cmake.org/u/sandercox)\
**Replies:** 1\
**Last updated:** [September 8, 2020, 3:59pm UTC](https://discourse.cmake.org/t/mp-on-all-files-but-pre-compiled-header/1781 "2020-09-08T15:59:16Z")

</div>

We have switched to using target\_precompile\_headers() and since we did this we’ve been getting the following warning in MSBuild based builds: cl : command line warning D9030: ‘/Yc’ is incompatible with multiprocessing;…

---

## [Using CMake with NVidia's CUDA](https://discourse.cmake.org/t/using-cmake-with-nvidias-cuda/1698)

<div class="topic-metadata">

**Author:** [@hungry-snorlax](https://discourse.cmake.org/u/hungry-snorlax)\
**Replies:** 3\
**Last updated:** [September 8, 2020, 1:32am UTC](https://discourse.cmake.org/t/using-cmake-with-nvidias-cuda/1698 "2020-09-08T01:32:51Z")

</div>

Hello, I have a cuda file (.cu) which does not have a main point of entry. I am able to compile it on the terminal using nvcc and a bunch of nvcc compile options to a .cubin (CUDA binary). Could someone please tell me h…

---

## [Generating files](https://discourse.cmake.org/t/generating-files/1788)

<div class="topic-metadata">

**Author:** [@AndrzejB](https://discourse.cmake.org/u/AndrzejB)\
**Replies:** 0\
**Last updated:** [September 7, 2020, 2:05pm UTC](https://discourse.cmake.org/t/generating-files/1788 "2020-09-07T14:05:41Z")

</div>

How to write Cmake file, where before building whole is build tblgen program. Next are generated files \*.inc (if not exists), next is build whole. I found https://crascit.com/2017/04/18/generated-sources-in-cmake-build…

---

## [Windows-Clang platform adds -fPIC for shared dlls](https://discourse.cmake.org/t/windows-clang-platform-adds-fpic-for-shared-dlls/1784)

<div class="topic-metadata">

**Author:** [@tgq](https://discourse.cmake.org/u/tgq)\
**Replies:** 5\
**Last updated:** [September 6, 2020, 5:48pm UTC](https://discourse.cmake.org/t/windows-clang-platform-adds-fpic-for-shared-dlls/1784 "2020-09-06T17:48:36Z")

</div>

Hello. I am compiling on linux host using clang-12 and CMAKE\_SYSTEM\_NAME Windows-Clang in my toolchain file. I have studied the Modules/Platform/Windows-Clang.cmake which makes a decission on choosing msvc/gnu variant ba…

---

## [Crosscompiling toolchain is functional but cmake does not want to cooperate](https://discourse.cmake.org/t/crosscompiling-toolchain-is-functional-but-cmake-does-not-want-to-cooperate/1766)

<div class="topic-metadata">

**Author:** [@tgq](https://discourse.cmake.org/u/tgq)\
**Replies:** 10\
**Last updated:** [September 4, 2020, 8:41pm UTC](https://discourse.cmake.org/t/crosscompiling-toolchain-is-functional-but-cmake-does-not-want-to-cooperate/1766 "2020-09-04T20:41:29Z")

</div>

Hello. I am long time CMake user but I can’t figure out how to crosscompile for windows using linux as a host using clang (version 12, built manually and placed in /opt and PATH if it matters). Without going into to much…

---

## [iOS support](https://discourse.cmake.org/t/ios-support/1776)

<div class="topic-metadata">

**Author:** [@thenewandy](https://discourse.cmake.org/u/thenewandy)\
**Replies:** 0\
**Last updated:** [September 3, 2020, 11:10am UTC](https://discourse.cmake.org/t/ios-support/1776 "2020-09-03T11:10:24Z")

</div>

Hello, I’m trying to understand what the state of iOS support is. I have a project which I can build for linux (cmake … && make) and macOS trivially (cmake -GXcode … && run xcode on generated files). However, when I try…

---

## [CMAKE\_STAGING\_PREFIX not being used by find\_\*](https://discourse.cmake.org/t/cmake-staging-prefix-not-being-used-by-find/1746)

<div class="topic-metadata">

**Author:** [@Daniel\_Stonier](https://discourse.cmake.org/u/Daniel_Stonier)\
**Replies:** 4\
**Last updated:** [August 28, 2020, 4:41am UTC](https://discourse.cmake.org/t/cmake-staging-prefix-not-being-used-by-find/1746 "2020-08-28T04:41:21Z")

</div>

CMAKE\_STAGING\_PREFIX would indicate that it’s used as one of the search paths for the find\_\*\*\* methods. However, I’m not finding that in practice - wondering if I’m missing some other configuration. Toolchain (for ubunt…

---

## [Trying to install CMake on windows and need to be admin](https://discourse.cmake.org/t/trying-to-install-cmake-on-windows-and-need-to-be-admin/1741)

<div class="topic-metadata">

**Author:** [@Jav\_Oper](https://discourse.cmake.org/u/Jav_Oper)\
**Replies:** 1\
**Last updated:** [August 26, 2020, 6:54pm UTC](https://discourse.cmake.org/t/trying-to-install-cmake-on-windows-and-need-to-be-admin/1741 "2020-08-26T18:54:14Z")

</div>

I am trying to install CMake 3.18.1 on Windows 10 through Msys. i have bootstraped i have run make but when i try make install i get the error when installation starts(after it has built everything), that it cant create …

---

## [rpm cpack debuginfo package generation getting warning "no source files were found!" and no debuginfo package](https://discourse.cmake.org/t/rpm-cpack-debuginfo-package-generation-getting-warning-no-source-files-were-found-and-no-debuginfo-package/1725)

<div class="topic-metadata">

**Author:** [@garybirnhak](https://discourse.cmake.org/u/garybirnhak)\
**Replies:** 2\
**Last updated:** [August 21, 2020, 7:33pm UTC](https://discourse.cmake.org/t/rpm-cpack-debuginfo-package-generation-getting-warning-no-source-files-were-found-and-no-debuginfo-package/1725 "2020-08-21T19:33:25Z")

</div>

I have a problem with cpackrpm and have been banging my head against the wall for several days. I am on Centos 7.6 and using cmake/cpack 3.18.1. I can create a binary rpm, however, I keep getting “CPackRPM:Warning: debug…

---

## [CPack archive file empty](https://discourse.cmake.org/t/cpack-archive-file-empty/1726)

<div class="topic-metadata">

**Author:** [@fry](https://discourse.cmake.org/u/fry)\
**Replies:** 7\
**Last updated:** [August 21, 2020, 4:26pm UTC](https://discourse.cmake.org/t/cpack-archive-file-empty/1726 "2020-08-21T16:26:41Z")

</div>

I have been trying to use CPack on my project (which builds vst plugins) and having a hard time making it work. So I created a smaller project to ask for help. The idea is that there are 2 components: a vst2 and a vst3 …

---

## [Skipping/selecting platform specific source files](https://discourse.cmake.org/t/skipping-selecting-platform-specific-source-files/1702)

<div class="topic-metadata">

**Author:** [@johan556](https://discourse.cmake.org/u/johan556)\
**Replies:** 1\
**Last updated:** [August 14, 2020, 5:21am UTC](https://discourse.cmake.org/t/skipping-selecting-platform-specific-source-files/1702 "2020-08-14T05:21:27Z")

</div>

I’m looking for a good way to select when platform specific source files should be included in the build. If I for example have “foo\_linux.cpp” and “foo\_windows.cpp”, I would like to select the appropriate version with a…

---

## [cmake part](https://discourse.cmake.org/t/cmake-part/1646)

<div class="topic-metadata">

**Author:** [@Tomasz](https://discourse.cmake.org/u/Tomasz)\
**Replies:** 2\
**Last updated:** [August 2, 2020, 6:00am UTC](https://discourse.cmake.org/t/cmake-part/1646 "2020-08-02T06:00:49Z")

</div>

Hi I have a part of CMake code ( to generate documentation in doxygen ) which I want to use in many not related each other projects. What is the best way to do this?

---

## [MSVC\_RUNTIME\_LIBRARY ignored on command line](https://discourse.cmake.org/t/msvc-runtime-library-ignored-on-command-line/1644)

<div class="topic-metadata">

**Author:** [@SpareSimian](https://discourse.cmake.org/u/SpareSimian)\
**Replies:** 3\
**Last updated:** [July 30, 2020, 3:37pm UTC](https://discourse.cmake.org/t/msvc-runtime-library-ignored-on-command-line/1644 "2020-07-30T15:37:56Z")

</div>

I’m trying to build libtiff on Win32 as a static library with static runtime linkage. I can’t seem to get the project to change the runtime library to static. Here’s my commands: cd g:\\devel\\libtiff\_out cmake.exe -G "Vi…

---

## [fetchcontent how to override dependency details](https://discourse.cmake.org/t/fetchcontent-how-to-override-dependency-details/1639)

<div class="topic-metadata">

**Author:** [@hex](https://discourse.cmake.org/u/hex)\
**Replies:** 1\
**Last updated:** [July 29, 2020, 3:00pm UTC](https://discourse.cmake.org/t/fetchcontent-how-to-override-dependency-details/1639 "2020-07-29T15:00:36Z")

</div>

When using FetchContent: I need to override dependency details for an already populated content. How do I do this? More specifically, I need to change the tag used for checkout on a git repository.

---

## [CPack / CPACK\_COMPONENTS\_ALL](https://discourse.cmake.org/t/cpack-cpack-components-all/1631)

<div class="topic-metadata">

**Author:** [@John\_Eivind\_Helset](https://discourse.cmake.org/u/John_Eivind_Helset)\
**Replies:** 1\
**Last updated:** [July 28, 2020, 10:58pm UTC](https://discourse.cmake.org/t/cpack-cpack-components-all/1631 "2020-07-28T22:58:55Z")

</div>

CPack clears out CPACK\_COMPONENTS\_ALL if there is only one component in it, event though the component was explicitly specified in the install commands, and CPACK\_EXTERNAL\_COMPONENT\_INSTALL was set to 1 (I was using an e…

---

## [Compatibility with gcc 4.9.2](https://discourse.cmake.org/t/compatibility-with-gcc-4-9-2/1637)

<div class="topic-metadata">

**Author:** [@Tamir\_Shmilovich](https://discourse.cmake.org/u/Tamir_Shmilovich)\
**Replies:** 1\
**Last updated:** [July 28, 2020, 8:16pm UTC](https://discourse.cmake.org/t/compatibility-with-gcc-4-9-2/1637 "2020-07-28T20:16:49Z")

</div>

Which versions of cmake are compatible with Gcc 4.9.2?

---

## [Why is not accessible the library built on top level directory under the test subdirectory?](https://discourse.cmake.org/t/why-is-not-accessible-the-library-built-on-top-level-directory-under-the-test-subdirectory/1614)

<div class="topic-metadata">

**Author:** [@tiborkiss](https://discourse.cmake.org/u/tiborkiss)\
**Replies:** 4\
**Last updated:** [July 28, 2020, 12:15pm UTC](https://discourse.cmake.org/t/why-is-not-accessible-the-library-built-on-top-level-directory-under-the-test-subdirectory/1614 "2020-07-28T12:15:08Z")

</div>

I have a library module which has some tests under test subdirectory. The test binaries are built and linked to the library from the top level, but when the tests are executed, does not find the shared object. The share…

---

## [FindMPI error: Failed with exit code 1](https://discourse.cmake.org/t/findmpi-error-failed-with-exit-code-1/1616)

<div class="topic-metadata">

**Author:** [@danlipsa](https://discourse.cmake.org/u/danlipsa)\
**Replies:** 1\
**Last updated:** [July 24, 2020, 11:27pm UTC](https://discourse.cmake.org/t/findmpi-error-failed-with-exit-code-1/1616 "2020-07-24T23:27:37Z")

</div>

This is the full error: \[ 96%\] Performing configure step for 'paraview' Not searching for unused variables given on the command line. -- Could not use git to determine source version, using version 5.8.1-RC2 -- Could NO…

---

## [CPack: distributing both shared and static libraries](https://discourse.cmake.org/t/cpack-distributing-both-shared-and-static-libraries/1225)

<div class="topic-metadata">

**Author:** [@alex](https://discourse.cmake.org/u/alex)\
**Replies:** 9\
**Last updated:** [July 23, 2020, 11:49pm UTC](https://discourse.cmake.org/t/cpack-distributing-both-shared-and-static-libraries/1225 "2020-07-23T23:49:00Z")

</div>

Before switching to CMake we were able to distribute tarballs containing our library as both a static library and a shared library (at least on Linux and macOS). What is the preferred way to do this with CMake 3.16+?

---

## [CTest slower than Test Explorer or command line](https://discourse.cmake.org/t/ctest-slower-than-test-explorer-or-command-line/1600)

<div class="topic-metadata">

**Author:** [@EosPengwern](https://discourse.cmake.org/u/EosPengwern)\
**Replies:** 2\
**Last updated:** [July 21, 2020, 12:03pm UTC](https://discourse.cmake.org/t/ctest-slower-than-test-explorer-or-command-line/1600 "2020-07-21T12:03:42Z")

</div>

Is there a reason why I should expect CTest to run tests from within a Google Test executable much more slowly than the command line or Visual Studio Test Explorer? Give an test suite with 744 tests inside a single exec…

---

## [Using asset catalogs for macOS/iOS projects](https://discourse.cmake.org/t/using-asset-catalogs-for-macos-ios-projects/1588)

<div class="topic-metadata">

**Author:** [@kaworu1986](https://discourse.cmake.org/u/kaworu1986)\
**Replies:** 3\
**Last updated:** [July 21, 2020, 11:14am UTC](https://discourse.cmake.org/t/using-asset-catalogs-for-macos-ios-projects/1588 "2020-07-21T11:14:02Z")

</div>

Is it possible to get CMake to generate a macOS/iOS Xcode project that uses asset catalogs to set the application icon? I’ve been trying to get it to work for days now without success, and I currently have the below cod…

---

## [Finding a writable directory location for installing Python modules](https://discourse.cmake.org/t/finding-a-writable-directory-location-for-installing-python-modules/1590)

<div class="topic-metadata">

**Author:** [@EosPengwern](https://discourse.cmake.org/u/EosPengwern)\
**Replies:** 2\
**Last updated:** [July 20, 2020, 3:13pm UTC](https://discourse.cmake.org/t/finding-a-writable-directory-location-for-installing-python-modules/1590 "2020-07-20T15:13:28Z")

</div>

Does CMake / CPack provide a generic way of identifying the %APPDATA% library on a user’s machine during installation? I ask because I’m trying to install a large scriptable application which provides various standard P…

---

## [CTest Dynamic Analysis](https://discourse.cmake.org/t/ctest-dynamic-analysis/1560)

<div class="topic-metadata">

**Author:** [@Leon0402](https://discourse.cmake.org/u/Leon0402)\
**Replies:** 9\
**Last updated:** [July 19, 2020, 5:18pm UTC](https://discourse.cmake.org/t/ctest-dynamic-analysis/1560 "2020-07-19T17:18:38Z")

</div>

Hi everyone, I currently explore the possibilities of cmake scripting to run sanitizers and tests. But it seems to be not working. # This file is supposed to run in ctest script mode: # ctest -S \<path-to-this-file\>/CTe…

---

## [Including resources with add\_jar](https://discourse.cmake.org/t/including-resources-with-add-jar/1583)

<div class="topic-metadata">

**Author:** [@Jacob\_Varghese](https://discourse.cmake.org/u/Jacob_Varghese)\
**Replies:** 1\
**Last updated:** [July 18, 2020, 9:00am UTC](https://discourse.cmake.org/t/including-resources-with-add-jar/1583 "2020-07-18T09:00:41Z")

</div>

Hi I’m trying to include some resources (jni library files) inside my jar but I’m facing issues to get exactly what I want. I use add\_jar(target SOURCES ${javasources} OUTPUT\_DIR ${BUILD\_ROOT}/jar) to generate the Jar a…

---

## ["CheckIPOSupported" inside subdirectory says that it's not supported](https://discourse.cmake.org/t/checkiposupported-inside-subdirectory-says-that-its-not-supported/1581)

<div class="topic-metadata">

**Author:** [@Foot](https://discourse.cmake.org/u/Foot)\
**Replies:** 2\
**Last updated:** [July 18, 2020, 2:08am UTC](https://discourse.cmake.org/t/checkiposupported-inside-subdirectory-says-that-its-not-supported/1581 "2020-07-18T02:08:56Z")

</div>

Hi there, I’m having some problems when I try to check/enable IPO only for my application! This is the project structure: project CMakeLists.txt \<-- works for all modules including the externals - external CMa…

---

## [How to disable '-pedantic' compiler option for a specific library?](https://discourse.cmake.org/t/how-to-disable-pedantic-compiler-option-for-a-specific-library/1575)

<div class="topic-metadata">

**Author:** [@DavidA](https://discourse.cmake.org/u/DavidA)\
**Replies:** 5\
**Last updated:** [July 17, 2020, 3:04pm UTC](https://discourse.cmake.org/t/how-to-disable-pedantic-compiler-option-for-a-specific-library/1575 "2020-07-17T15:04:51Z")

</div>

For my gcc C++ project, my top-level CMakeLists.txt contains: add\_compile\_options(-Wall -pedantic) and it builds multiple libraries using add\_subdirectory() calls. How can I disable the ‘-pedantic’ flag for one of tho…

---

## [How to assign a list of values to a variable in ctest's --build-options from within an add\_test() command](https://discourse.cmake.org/t/how-to-assign-a-list-of-values-to-a-variable-in-ctests-build-options-from-within-an-add-test-command/1552)

<div class="topic-metadata">

**Author:** [@alcroito](https://discourse.cmake.org/u/alcroito)\
**Replies:** 3\
**Last updated:** [July 15, 2020, 8:24am UTC](https://discourse.cmake.org/t/how-to-assign-a-list-of-values-to-a-variable-in-ctests-build-options-from-within-an-add-test-command/1552 "2020-07-15T08:24:58Z")

</div>

Sample project with what I’ve tried cmake\_minimum\_required(VERSION 3.14) project(ctest\_multiple\_prefixes CXX) file(WRITE "${CMAKE\_CURRENT\_BINARY\_DIR}/subdir/lib.cpp" "void func(){}") file(WRITE "${CMAKE\_CURRENT\_BINARY\_…

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

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