# Usage

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

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

**Page:** 82

---

## [Setting CMAKE\_\<LANG\>\_ARCHITECTURE\_ID/CMAKE\_CL\_SHOWINCLUDES\_PREFIX to get RC files working?](https://discourse.cmake.org/t/setting-cmake-lang-architecture-id-cmake-cl-showincludes-prefix-to-get-rc-files-working/2920)

<div class="topic-metadata">

**Author:** [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)\
**Replies:** 8\
**Last updated:** [March 11, 2021, 5:51pm UTC](https://discourse.cmake.org/t/setting-cmake-lang-architecture-id-cmake-cl-showincludes-prefix-to-get-rc-files-working/2920 "2021-03-11T17:51:52Z")

</div>

We have a custom MSVC toolchain. However, we were getting an issue related to RC files. That only manifested on Ninja dirty builds. # Here is the bug will manifest itself: # "ninja: error: FindFirstFileE…

---

## [Does FindVulkan provide version support?](https://discourse.cmake.org/t/does-findvulkan-provide-version-support/2939)

<div class="topic-metadata">

**Author:** [@anon45792294](https://discourse.cmake.org/u/anon45792294)\
**Replies:** 1\
**Last updated:** [March 11, 2021, 3:44pm UTC](https://discourse.cmake.org/t/does-findvulkan-provide-version-support/2939 "2021-03-11T15:44:31Z")

</div>

Does FindVulkan provide version support? IE is the below code legal? cmake\_minimum\_required(VERSION 3.19) project(EXAMPLE LANGUAGES CXX ) find\_package(Vulkan "1.2.170.0" EXACT REQUIRED) add\_executable(foobar) t…

---

## [Exported target list adds SHARED IMPORTED library with IMPORTED\_LOCATION property missing](https://discourse.cmake.org/t/exported-target-list-adds-shared-imported-library-with-imported-location-property-missing/2937)

<div class="topic-metadata">

**Author:** [@yisseamake](https://discourse.cmake.org/u/yisseamake)\
**Replies:** 3\
**Last updated:** [March 11, 2021, 3:40pm UTC](https://discourse.cmake.org/t/exported-target-list-adds-shared-imported-library-with-imported-location-property-missing/2937 "2021-03-11T15:40:25Z")

</div>

When cmake install(EXPORT…) command executed it creates myprojectTargets.cmake file which is being used by downstream consuming project issuing find\_package( myproject). cmake writes to myprojectTargets.cmake file comma…

---

## [CMake 3.19.6 does not set Boost\_LIBRARY\_DIR\_RELEASE](https://discourse.cmake.org/t/cmake-3-19-6-does-not-set-boost-library-dir-release/2927)

<div class="topic-metadata">

**Author:** [@nicolamori](https://discourse.cmake.org/u/nicolamori)\
**Replies:** 0\
**Last updated:** [March 10, 2021, 11:48am UTC](https://discourse.cmake.org/t/cmake-3-19-6-does-not-set-boost-library-dir-release/2927 "2021-03-10T11:48:45Z")

</div>

I’m using CMake 3.19.6 and Boost 1.71 on Ubuntu 20.04. I noticed that in this setup the FindBoost.cmake takes advantage of the CMake configuration files shipped by Boost to configure the Boost usage. Then the \_boost\_set\_…

---

## [Cannot find statement of Cmake documentation where module path is](https://discourse.cmake.org/t/cannot-find-statement-of-cmake-documentation-where-module-path-is/2914)

<div class="topic-metadata">

**Author:** [@abd](https://discourse.cmake.org/u/abd)\
**Replies:** 2\
**Last updated:** [March 10, 2021, 2:03am UTC](https://discourse.cmake.org/t/cannot-find-statement-of-cmake-documentation-where-module-path-is/2914 "2021-03-10T02:03:12Z")

</div>

Cannot find definite statement of Cmake documentation/manual that clearly state what the default of module if find\_package() is used, and just found CMAKE\_MODULE\_PATH is empty. But on investigating it looks like its on …

---

## [How let cmake know that dependencies must firstly be from a certain location](https://discourse.cmake.org/t/how-let-cmake-know-that-dependencies-must-firstly-be-from-a-certain-location/2875)

<div class="topic-metadata">

**Author:** [@abd](https://discourse.cmake.org/u/abd)\
**Replies:** 4\
**Last updated:** [March 9, 2021, 3:28am UTC](https://discourse.cmake.org/t/how-let-cmake-know-that-dependencies-must-firstly-be-from-a-certain-location/2875 "2021-03-09T03:28:36Z")

</div>

How can we force cmake to check that dependencies must firstly be looked up in a certain directory instead of default /usr/bin/, /usr/lib/, etc Linux dirs., then that default, in that order as its cmake firstly check …

---

## [enumerating and keeping up to date the list of sources](https://discourse.cmake.org/t/enumerating-and-keeping-up-to-date-the-list-of-sources/2900)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 2\
**Last updated:** [March 8, 2021, 11:10am UTC](https://discourse.cmake.org/t/enumerating-and-keeping-up-to-date-the-list-of-sources/2900 "2021-03-08T11:10:31Z")

</div>

Hi, It is common wisdom that file(glob) is not the proper way to collect and maintain the list of sources of a project as, when adding a new file, cmake will not detect the modification and will not regenerate. But I f…

---

## [CMake fails to add the include directories.](https://discourse.cmake.org/t/cmake-fails-to-add-the-include-directories/2902)

<div class="topic-metadata">

**Author:** [@mtm](https://discourse.cmake.org/u/mtm)\
**Replies:** 4\
**Last updated:** [March 7, 2021, 10:18pm UTC](https://discourse.cmake.org/t/cmake-fails-to-add-the-include-directories/2902 "2021-03-07T22:18:32Z")

</div>

Hi guys, In Linux I always write Makefiles by hand since it is way easier. I gave cmake it a try in Windows, and here is the result: I added add\_library(opencv\_world451d STATIC IMPORTED) set\_property(TARGET opencv\_w…

---

## [Difference and relation between CMAKE\_PREFIX\_PATH and CMAKE\_FIND\_ROOT\_PATH](https://discourse.cmake.org/t/difference-and-relation-between-cmake-prefix-path-and-cmake-find-root-path/2909)

<div class="topic-metadata">

**Author:** [@abd](https://discourse.cmake.org/u/abd)\
**Replies:** 1\
**Last updated:** [March 7, 2021, 10:11pm UTC](https://discourse.cmake.org/t/difference-and-relation-between-cmake-prefix-path-and-cmake-find-root-path/2909 "2021-03-07T22:11:56Z")

</div>

What’s the difference and relation between CMAKE\_PREFIX\_PATH and CMAKE\_FIND\_ROOT\_PATH (easier put: in a cmake script having find\_package command)? Thanks before.

---

## [Use of Visual C++ /WHOLEARCHIVE linker option](https://discourse.cmake.org/t/use-of-visual-c-wholearchive-linker-option/2905)

<div class="topic-metadata">

**Author:** [@johan556](https://discourse.cmake.org/u/johan556)\
**Replies:** 0\
**Last updated:** [March 6, 2021, 12:34pm UTC](https://discourse.cmake.org/t/use-of-visual-c-wholearchive-linker-option/2905 "2021-03-06T12:34:13Z")

</div>

We build ~30 DLL & EXE files with Visual C++. They use a number of static libraries in turn. I thought of temporarily using the linker option /WHOLEARCHIVE to get an extra check that all dependencies among CMake targets …

---

## [find\_package not searching a package in Config mode again after Module mode failure](https://discourse.cmake.org/t/find-package-not-searching-a-package-in-config-mode-again-after-module-mode-failure/2899)

<div class="topic-metadata">

**Author:** [@xw111luoye](https://discourse.cmake.org/u/xw111luoye)\
**Replies:** 3\
**Last updated:** [March 5, 2021, 4:44pm UTC](https://discourse.cmake.org/t/find-package-not-searching-a-package-in-config-mode-again-after-module-mode-failure/2899 "2021-03-05T16:44:21Z")

</div>

In an application, I’m using find\_package(Libxc 5.1.2 COMPONENTS Fortran) Based on find\_package documentaiton, it tries Module mode and found FindLibxc.cmake which is provided by the application . However, on one mac…

---

## [CCMake doesn't automatically found the Toolchain file where CMake does](https://discourse.cmake.org/t/ccmake-doesnt-automatically-found-the-toolchain-file-where-cmake-does/2887)

<div class="topic-metadata">

**Author:** [@Clement\_Peron](https://discourse.cmake.org/u/Clement_Peron)\
**Replies:** 4\
**Last updated:** [March 4, 2021, 8:59pm UTC](https://discourse.cmake.org/t/ccmake-doesnt-automatically-found-the-toolchain-file-where-cmake-does/2887 "2021-03-04T20:59:05Z")

</div>

Hi, I saw a strange behavior between cmake and ccmake. CMake detect the Toolchain file whereas CCMake doesn’t. Do you have any idea what’s the difference ? Thanks for your help :slight\_smile: When running CMake : c…

---

## [CMake RC Support (Ninja)?](https://discourse.cmake.org/t/cmake-rc-support-ninja/2883)

<div class="topic-metadata">

**Author:** [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)\
**Replies:** 6\
**Last updated:** [March 5, 2021, 12:35am UTC](https://discourse.cmake.org/t/cmake-rc-support-ninja/2883 "2021-03-05T00:35:58Z")

</div>

I’m unable to compile a simple project Ninja. I’ve made a SSCCE to demonstrate the issue. My command line is super basic: cmake -S . -B build -G "Ninja" -DCMAKE\_MAKE\_PROGRAM=D:\\foobar\\ninja.exe Here are the files con…

---

## [Dll by cmake with DllExport does not work in another application](https://discourse.cmake.org/t/dll-by-cmake-with-dllexport-does-not-work-in-another-application/2879)

<div class="topic-metadata">

**Author:** [@Bogdan029](https://discourse.cmake.org/u/Bogdan029)\
**Replies:** 3\
**Last updated:** [March 4, 2021, 1:48pm UTC](https://discourse.cmake.org/t/dll-by-cmake-with-dllexport-does-not-work-in-another-application/2879 "2021-03-04T13:48:55Z")

</div>

I want to create dll of my c# project with DllExport by cmake for use in another app(java), but I collided wit problem, app with the dll that I created by VS2019, works Ok, but with the dll that was created by cmake (usi…

---

## [How to install(EXPORT...) in subprojects with each having same dependencies](https://discourse.cmake.org/t/how-to-install-export-in-subprojects-with-each-having-same-dependencies/2076)

<div class="topic-metadata">

**Author:** [@yisseamake](https://discourse.cmake.org/u/yisseamake)\
**Replies:** 13\
**Last updated:** [March 3, 2021, 6:10pm UTC](https://discourse.cmake.org/t/how-to-install-export-in-subprojects-with-each-having-same-dependencies/2076 "2021-03-03T18:10:37Z")

</div>

I am getting ERROR CMake Error: install(EXPORT "mySubProjATargets" ...) includes target "mySubProjBshared" which requires target "logger" that is not in this export set, but in multiple other export sets: lib/cmake/myS…

---

## [Use external libraries using FetchContent.](https://discourse.cmake.org/t/use-external-libraries-using-fetchcontent/2710)

<div class="topic-metadata">

**Author:** [@Tyrreus](https://discourse.cmake.org/u/Tyrreus)\
**Replies:** 2\
**Last updated:** [March 3, 2021, 5:16pm UTC](https://discourse.cmake.org/t/use-external-libraries-using-fetchcontent/2710 "2021-03-03T17:16:53Z")

</div>

Problem description Hi everyone! I’m starting the new project and I would like to make it using CMake in a good way from the beginning. I’ve found the proposition of project structure at the modern CMake book and It loo…

---

## [Is unescaping of \\; in foreach() intentional or not?](https://discourse.cmake.org/t/is-unescaping-of-in-foreach-intentional-or-not/2876)

<div class="topic-metadata">

**Author:** [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Replies:** 5\
**Last updated:** [March 3, 2021, 12:52pm UTC](https://discourse.cmake.org/t/is-unescaping-of-in-foreach-intentional-or-not/2876 "2021-03-03T12:52:45Z")

</div>

I came across the following code extract today and was somewhat surprised by the way \\; is handled: cmake\_minimum\_required(VERSION 3.16) # Example of data to be processed set(output \[\[ firstLine;aaa;bbb secondLine;ccc;…

---

## [OSX: cmake finding older libpng library even though brew installs latest](https://discourse.cmake.org/t/osx-cmake-finding-older-libpng-library-even-though-brew-installs-latest/2870)

<div class="topic-metadata">

**Author:** [@boxerab](https://discourse.cmake.org/u/boxerab)\
**Replies:** 1\
**Last updated:** [March 2, 2021, 5:56pm UTC](https://discourse.cmake.org/t/osx-cmake-finding-older-libpng-library-even-though-brew-installs-latest/2870 "2021-03-02T17:56:08Z")

</div>

I have a Github workflow that requires version 1.16 of libpng. However, on osx, cmake Find finds an older version 1.14 of the library Run brew install libpng Warning: libpng 1.6.37 is already installed and up-to-date.…

---

## [Access export target name list variables](https://discourse.cmake.org/t/access-export-target-name-list-variables/2850)

<div class="topic-metadata">

**Author:** [@yisseamake](https://discourse.cmake.org/u/yisseamake)\
**Replies:** 10\
**Last updated:** [March 2, 2021, 4:59pm UTC](https://discourse.cmake.org/t/access-export-target-name-list-variables/2850 "2021-03-02T16:59:23Z")

</div>

When cmake generates file export\_target\_nameTargets.cmake (as a result of install(TARGETS myprojecttargets EXPORT export\_target\_name) install(EXPORT export\_target\_name …) ) it writes set(\_targetsDefined) set(\_targetsNo…

---

## [Do I need to set the CMAKE\_SYSTEM\_NAME when making a toolchain file?](https://discourse.cmake.org/t/do-i-need-to-set-the-cmake-system-name-when-making-a-toolchain-file/2861)

<div class="topic-metadata">

**Author:** [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)\
**Replies:** 3\
**Last updated:** [March 2, 2021, 2:43pm UTC](https://discourse.cmake.org/t/do-i-need-to-set-the-cmake-system-name-when-making-a-toolchain-file/2861 "2021-03-02T14:43:07Z")

</div>

We have a MSVC toolchain at work. In the toolchain we have the following code: # Define the target system and version set(CMAKE\_SYSTEM\_NAME "Windows" CACHE INTERNAL "") set(CMAKE\_SYSTEM\_VERSION "10.0.${…

---

## [execute cmake on command line not finding package](https://discourse.cmake.org/t/execute-cmake-on-command-line-not-finding-package/2852)

<div class="topic-metadata">

**Author:** [@kmilo9999](https://discourse.cmake.org/u/kmilo9999)\
**Replies:** 3\
**Last updated:** [March 2, 2021, 7:07am UTC](https://discourse.cmake.org/t/execute-cmake-on-command-line-not-finding-package/2852 "2021-03-02T07:07:44Z")

</div>

Hello, I cloned this repo, and inorder to build in requires another external library. I go to the folder and execute the command: cmake -S . -B build/ -G Ninja but it returns: CMake Error at C:/Program Files/CMake…

---

## [Correct usuage of target\_compile\_option MP for Visual Studio](https://discourse.cmake.org/t/correct-usuage-of-target-compile-option-mp-for-visual-studio/2825)

<div class="topic-metadata">

**Author:** [@Steven\_White](https://discourse.cmake.org/u/Steven_White)\
**Replies:** 3\
**Last updated:** [February 27, 2021, 3:48pm UTC](https://discourse.cmake.org/t/correct-usuage-of-target-compile-option-mp-for-visual-studio/2825 "2021-02-27T15:48:49Z")

</div>

According to the documents for MP in the MSVC website MP takes an optional digit to limit the number of parallel compilation units a single target will generate at a time. I wanted to always turn on MP for my users, bu…

---

## [How to install component libraries like boost?](https://discourse.cmake.org/t/how-to-install-component-libraries-like-boost/2854)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 1\
**Last updated:** [February 27, 2021, 10:44am UTC](https://discourse.cmake.org/t/how-to-install-component-libraries-like-boost/2854 "2021-02-27T10:44:38Z")

</div>

The are at least 2 ways to do it. 1) One is to set NO\_CHECK\_REQUIRED\_COMPONENTS\_MACRO It is recommended to set this option here https://cmake.org/cmake/help/latest/guide/importing-exporting/index.html?highlight=componen…

---

## [Creating Shared libraries and an executable](https://discourse.cmake.org/t/creating-shared-libraries-and-an-executable/2846)

<div class="topic-metadata">

**Author:** [@Q123](https://discourse.cmake.org/u/Q123)\
**Replies:** 11\
**Last updated:** [February 26, 2021, 7:55pm UTC](https://discourse.cmake.org/t/creating-shared-libraries-and-an-executable/2846 "2021-02-26T19:55:26Z")

</div>

I’m a cmake newbie and I’m converting a rather large existing project to cmake so the basic tutorials don’t seem to help that much, so after Google and the help files, here I am… The overall concept of the build is a sm…

---

## [Using cmake to make an executable in LAMMPS](https://discourse.cmake.org/t/using-cmake-to-make-an-executable-in-lammps/2836)

<div class="topic-metadata">

**Author:** [@ognjano3](https://discourse.cmake.org/u/ognjano3)\
**Replies:** 3\
**Last updated:** [February 26, 2021, 9:44am UTC](https://discourse.cmake.org/t/using-cmake-to-make-an-executable-in-lammps/2836 "2021-02-26T09:44:52Z")

</div>

I need to download this package in order to make an executable on lammps but I keep getting this error.

---

## [How to specify a target to be built only once](https://discourse.cmake.org/t/how-to-specify-a-target-to-be-built-only-once/2826)

<div class="topic-metadata">

**Author:** [@jwm](https://discourse.cmake.org/u/jwm)\
**Replies:** 6\
**Last updated:** [February 25, 2021, 7:26pm UTC](https://discourse.cmake.org/t/how-to-specify-a-target-to-be-built-only-once/2826 "2021-02-25T19:26:23Z")

</div>

As part of my larger project, I need to retrieve a file from an external SVN repo to be included in the final RPM build step. This repo is kind of slow… about 50% of the time the download times out, but it’s annoying whe…

---

## [Bypass block on installing IMPORTED libraries](https://discourse.cmake.org/t/bypass-block-on-installing-imported-libraries/2834)

<div class="topic-metadata">

**Author:** [@yisseamake](https://discourse.cmake.org/u/yisseamake)\
**Replies:** 4\
**Last updated:** [February 25, 2021, 9:39pm UTC](https://discourse.cmake.org/t/bypass-block-on-installing-imported-libraries/2834 "2021-02-25T21:39:59Z")

</div>

\[Unfortunately \] cmake doesn’t allow installation of IMPORTED libraries probably in assumption that if a project built and formed installation package, this package needs only newly built libraries and consumer of this …

---

## [How to enable language C and language Fortran when installing package from cmake in order to make executable](https://discourse.cmake.org/t/how-to-enable-language-c-and-language-fortran-when-installing-package-from-cmake-in-order-to-make-executable/2847)

<div class="topic-metadata">

**Author:** [@ognjano3](https://discourse.cmake.org/u/ognjano3)\
**Replies:** 2\
**Last updated:** [February 25, 2021, 7:27pm UTC](https://discourse.cmake.org/t/how-to-enable-language-c-and-language-fortran-when-installing-package-from-cmake-in-order-to-make-executable/2847 "2021-02-25T19:27:28Z")

</div>

I was trying to install this package from cmake shown in order to make an executable for lammps, but I got an error that my language C and language Fortran was not enabled. Any steps on what to do next would be appreciat…

---

## [I finished installing bootstrap now I get this error when I run make](https://discourse.cmake.org/t/i-finished-installing-bootstrap-now-i-get-this-error-when-i-run-make/2828)

<div class="topic-metadata">

**Author:** [@ognjano3](https://discourse.cmake.org/u/ognjano3)\
**Replies:** 3\
**Last updated:** [February 25, 2021, 7:17pm UTC](https://discourse.cmake.org/t/i-finished-installing-bootstrap-now-i-get-this-error-when-i-run-make/2828 "2021-02-25T19:17:33Z")

</div>

CMake Error: Cannot open file for write: /home/aleksa/cmake-3.17.3/Source/kwsys/CMakeFiles/cmsys\_c.dir/depend.make.tmp CMake Error: : System Error: Permission denied make\[2\]: \*\*\* \[Source/kwsys/CMakeFiles/cmsys\_c.dir/bu…

---

## [Failure to generate relocatable package with add\_jar GENERATE\_NATIVE\_HEADERS](https://discourse.cmake.org/t/failure-to-generate-relocatable-package-with-add-jar-generate-native-headers/2334)

<div class="topic-metadata">

**Author:** [@yisseamake](https://discourse.cmake.org/u/yisseamake)\
**Replies:** 8\
**Last updated:** [February 24, 2021, 5:16pm UTC](https://discourse.cmake.org/t/failure-to-generate-relocatable-package-with-add-jar-generate-native-headers/2334 "2021-02-24T17:16:44Z")

</div>

When using add\_jar for generating JNI headers , the option GENERATE\_NATIVE\_HEADERS DESTINATION rejects path prefixed into build directory and if absolute path specified writes it into INTERFACE\_INCLUDE\_DIRECTORIES which …

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

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