# Usage

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

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

**Page:** 49

---

## [CPack not installing package contents?](https://discourse.cmake.org/t/cpack-not-installing-package-contents/7411)

<div class="topic-metadata">

**Author:** [@benthevining](https://discourse.cmake.org/u/benthevining)\
**Replies:** 4\
**Last updated:** [February 28, 2023, 3:57am UTC](https://discourse.cmake.org/t/cpack-not-installing-package-contents/7411 "2023-02-28T03:57:16Z")

</div>

I’ve got a mono-repo building several audio plugins. I want to keep them all in the same build tree / CMake project, but use CPack to generate separate installers for each individual plugin. I’ve got this function to cr…

---

## [CMAKE\_SKIP\_INSTALL\_RULES can only be set in CMAKE\_SOURCE\_DIR](https://discourse.cmake.org/t/cmake-skip-install-rules-can-only-be-set-in-cmake-source-dir/7556)

<div class="topic-metadata">

**Author:** [@fdk17](https://discourse.cmake.org/u/fdk17)\
**Replies:** 2\
**Last updated:** [February 27, 2023, 5:34pm UTC](https://discourse.cmake.org/t/cmake-skip-install-rules-can-only-be-set-in-cmake-source-dir/7556 "2023-02-27T17:34:36Z")

</div>

I was trying to control generation of install rules at a sub-directory level. But it appears that setting CMAKE\_SKIP\_INSTALL\_RULES only works when setting in the scope of the top-level CMake file. This was being done b…

---

## [FindPkgConfig: How to use IMPORTED\_TARGET to create a static library target?](https://discourse.cmake.org/t/findpkgconfig-how-to-use-imported-target-to-create-a-static-library-target/7555)

<div class="topic-metadata">

**Author:** [@BLumia](https://discourse.cmake.org/u/BLumia)\
**Replies:** 1\
**Last updated:** [February 27, 2023, 3:44pm UTC](https://discourse.cmake.org/t/findpkgconfig-how-to-use-imported-target-to-create-a-static-library-target/7555 "2023-02-27T15:44:11Z")

</div>

Currently, we can use pkg\_check\_modules with IMPORTED\_TARGET to create a PkgConfig::prefix target which is nice and clean. Something like: find\_package(PkgConfig REQUIRED) pkg\_check\_modules(rsvg REQUIRED librsvg-2.0 IMP…

---

## [Add Property for a specific config](https://discourse.cmake.org/t/add-property-for-a-specific-config/7549)

<div class="topic-metadata">

**Author:** [@Julian\_LALU](https://discourse.cmake.org/u/Julian_LALU)\
**Replies:** 1\
**Last updated:** [February 27, 2023, 2:35pm UTC](https://discourse.cmake.org/t/add-property-for-a-specific-config/7549 "2023-02-27T14:35:27Z")

</div>

Hello, I try to find a way to enable VS\_NO\_COMPILE\_BATCHING property only for a specific build type. I have set\_property(TARGET test\_target PROPERTY VS\_NO\_COMPILE\_BATCHING ON And I try to do something like this : set…

---

## [CPack produce multiple RPMs](https://discourse.cmake.org/t/cpack-produce-multiple-rpms/7542)

<div class="topic-metadata">

**Author:** [@MM77](https://discourse.cmake.org/u/MM77)\
**Replies:** 1\
**Last updated:** [February 26, 2023, 8:26pm UTC](https://discourse.cmake.org/t/cpack-produce-multiple-rpms/7542 "2023-02-26T20:26:22Z")

</div>

I have 1 CMake project. It produces a number of .so files. Those are then used by Python scripts and by C++ executables. I’m interested in generated 4 RPMs and perhaps a 5th RPM that is common. While reading the doc a…

---

## [How do I only add a compile definition only on debug builds?](https://discourse.cmake.org/t/how-do-i-only-add-a-compile-definition-only-on-debug-builds/7541)

<div class="topic-metadata">

**Author:** [@dundargoc](https://discourse.cmake.org/u/dundargoc)\
**Replies:** 1\
**Last updated:** [February 26, 2023, 6:55pm UTC](https://discourse.cmake.org/t/how-do-i-only-add-a-compile-definition-only-on-debug-builds/7541 "2023-02-26T18:55:03Z")

</div>

So I want to add a -DMIN\_LOG\_DEBUG when building on debug build type. I tried the following target\_compile\_definitions(main\_lib INTERFACE $\<$\<CONFIG:Debug\>:MIN\_LOG\_DEBUG\>) which works fine in debug builds but on any ot…

---

## [makefiles without references to cmakelists or cmake](https://discourse.cmake.org/t/makefiles-without-references-to-cmakelists-or-cmake/7545)

<div class="topic-metadata">

**Author:** [@cp38](https://discourse.cmake.org/u/cp38)\
**Replies:** 1\
**Last updated:** [February 26, 2023, 3:52pm UTC](https://discourse.cmake.org/t/makefiles-without-references-to-cmakelists-or-cmake/7545 "2023-02-26T15:52:45Z")

</div>

hello, I’m new with cmake. Is it possible to generate makefiles (windows, linux…) in which there are no references to cmakelists.txt or to cmake. In other words, can we generate, with cmake, makefiles allowing the user…

---

## [Define x86 preset on Windows x64 host using Ninja generator](https://discourse.cmake.org/t/define-x86-preset-on-windows-x64-host-using-ninja-generator/7526)

<div class="topic-metadata">

**Author:** [@wulfgarpro](https://discourse.cmake.org/u/wulfgarpro)\
**Replies:** 4\
**Last updated:** [February 26, 2023, 12:11am UTC](https://discourse.cmake.org/t/define-x86-preset-on-windows-x64-host-using-ninja-generator/7526 "2023-02-26T00:11:01Z")

</div>

I have a basic CMakePresets.json as follows: { "version": 3, "configurePresets": \[ { "name": "windows-base", "hidden": true, "generator": "Ninja", "binaryD…

---

## [Building cmake from source on linux Fedora 37](https://discourse.cmake.org/t/building-cmake-from-source-on-linux-fedora-37/7519)

<div class="topic-metadata">

**Author:** [@Salvatore\_Filippone](https://discourse.cmake.org/u/Salvatore_Filippone)\
**Replies:** 5\
**Last updated:** [February 24, 2023, 8:48pm UTC](https://discourse.cmake.org/t/building-cmake-from-source-on-linux-fedora-37/7519 "2023-02-24T20:48:02Z")

</div>

Hi there, I need to have multiple versions of gnu/cuda toolchain on a machine, handled through environment-modules, and I have run into two issues. ------ Issue 1 ------------- When building the GNU compilers I had to…

---

## [Using a fetched cross-compiler toolchain](https://discourse.cmake.org/t/using-a-fetched-cross-compiler-toolchain/1895)

<div class="topic-metadata">

**Author:** [@laurence](https://discourse.cmake.org/u/laurence)\
**Replies:** 13\
**Last updated:** [February 24, 2023, 6:23am UTC](https://discourse.cmake.org/t/using-a-fetched-cross-compiler-toolchain/1895 "2023-02-24T06:23:23Z")

</div>

Hi, I have inherited a system on short notice in the midst of being cmakeified. For $reasons not a lot of explanation came with it, so I’m left to puzzle it out and finish it. My first issue is this: we have an embedded…

---

## [Config preset in CMakeUserPresets.json doesn't inherit cacheVariables from parent in CMakePresets.json](https://discourse.cmake.org/t/config-preset-in-cmakeuserpresets-json-doesnt-inherit-cachevariables-from-parent-in-cmakepresets-json/7497)

<div class="topic-metadata">

**Author:** [@wulfgarpro](https://discourse.cmake.org/u/wulfgarpro)\
**Replies:** 2\
**Last updated:** [February 20, 2023, 8:57pm UTC](https://discourse.cmake.org/t/config-preset-in-cmakeuserpresets-json-doesnt-inherit-cachevariables-from-parent-in-cmakepresets-json/7497 "2023-02-20T20:57:24Z")

</div>

My CMakePresets.json: { "version": 3, "configurePresets": \[ { "name": "base", "hidden": true, "generator": "Ninja", "cacheVariables": { "CM…

---

## [A CMake way to embed a library in another?](https://discourse.cmake.org/t/a-cmake-way-to-embed-a-library-in-another/7534)

<div class="topic-metadata">

**Author:** [@JRR](https://discourse.cmake.org/u/JRR)\
**Replies:** 1\
**Last updated:** [February 23, 2023, 7:57pm UTC](https://discourse.cmake.org/t/a-cmake-way-to-embed-a-library-in-another/7534 "2023-02-23T19:57:41Z")

</div>

We have a product that creates a few libraries that are in turn combined with more code to make a super library. For example, we have static libraries lib-A and lib-B that are combined with even more source code to make…

---

## [How to create findable imported libraries](https://discourse.cmake.org/t/how-to-create-findable-imported-libraries/7533)

<div class="topic-metadata">

**Author:** [@patsv](https://discourse.cmake.org/u/patsv)\
**Replies:** 1\
**Last updated:** [February 23, 2023, 4:53pm UTC](https://discourse.cmake.org/t/how-to-create-findable-imported-libraries/7533 "2023-02-23T16:53:08Z")

</div>

Hi, I am working in a project where we have some autogenerated libraries that are created outside of cmake. I want to make them available within CMake , with some cmake find for the rest of the project. I also want the…

---

## [Cmake build project in VS Code (Windows)](https://discourse.cmake.org/t/cmake-build-project-in-vs-code-windows/7525)

<div class="topic-metadata">

**Author:** [@suri371994](https://discourse.cmake.org/u/suri371994)\
**Replies:** 0\
**Last updated:** [February 23, 2023, 5:37am UTC](https://discourse.cmake.org/t/cmake-build-project-in-vs-code-windows/7525 "2023-02-23T05:37:16Z")

</div>

Hello, I am new to build Cmake project in VS Code. please follow below mentioned steps: Create a New project in VS Code IDE.PI PICO Arduino based in VS Code. Downloaded Ethernet Directory Clone from Github and Includ…

---

## [Does CMake store the generation command used anywhere?](https://discourse.cmake.org/t/does-cmake-store-the-generation-command-used-anywhere/7511)

<div class="topic-metadata">

**Author:** [@Rich\_von\_Lehe](https://discourse.cmake.org/u/Rich_von_Lehe)\
**Replies:** 4\
**Last updated:** [February 22, 2023, 2:49am UTC](https://discourse.cmake.org/t/does-cmake-store-the-generation-command-used-anywhere/7511 "2023-02-22T02:49:48Z")

</div>

Is there some place CMake stores away the command used when generating? Or is there a way to get it to do this? My situation is I’ve started working on a project where Conan is used and the folks that wrote the Conan fi…

---

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

<div class="topic-metadata">

**Author:** [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)\
**Replies:** 8\
**Last updated:** [February 21, 2023, 10:10pm UTC](https://discourse.cmake.org/t/fetchcontent-cmake-make-program-issue/2522 "2023-02-21T22:10:56Z")

</div>

I’ve created a GitHub repo to show a minimal reproducible example as requested by @craig.scott in the other thread: Basically the intent is to have a way to be in control of the version of Ninja my developers on my te…

---

## [CMake selecting incorrect assembler](https://discourse.cmake.org/t/cmake-selecting-incorrect-assembler/7501)

<div class="topic-metadata">

**Author:** [@armandyam](https://discourse.cmake.org/u/armandyam)\
**Replies:** 7\
**Last updated:** [February 21, 2023, 9:40pm UTC](https://discourse.cmake.org/t/cmake-selecting-incorrect-assembler/7501 "2023-02-21T21:40:45Z")

</div>

Hello everyone, I am relatively new to CMake and I encountered an issue with CMake filing to compile the test program when trying to setup a simple “hello world” CMake script on a (new) Redhat 8 machine. I want to use …

---

## [FetchContent\_Declare() via a remote ssh git command](https://discourse.cmake.org/t/fetchcontent-declare-via-a-remote-ssh-git-command/7504)

<div class="topic-metadata">

**Author:** [@jmoellm](https://discourse.cmake.org/u/jmoellm)\
**Replies:** 2\
**Last updated:** [February 21, 2023, 9:30pm UTC](https://discourse.cmake.org/t/fetchcontent-declare-via-a-remote-ssh-git-command/7504 "2023-02-21T21:30:49Z")

</div>

We have a backend service node which cannot access the internet, but a CMake script which uses FetchContent\_Declare() to grab submodules from GitHub. I tried to run git on a front-end server which does have access: #!/b…

---

## [regex doesn't work in source\_group](https://discourse.cmake.org/t/regex-doesnt-work-in-source-group/7506)

<div class="topic-metadata">

**Author:** [@pavel\_krupets](https://discourse.cmake.org/u/pavel_krupets)\
**Replies:** 3\
**Last updated:** [February 21, 2023, 12:35am UTC](https://discourse.cmake.org/t/regex-doesnt-work-in-source-group/7506 "2023-02-21T00:35:11Z")

</div>

cmake 3.24 add\_executable( ${PROJECT\_NAME} ${SOURCES\_MCU\_STARTUP} ${SOURCES} ${SOURCES\_SHARED} ${SOURCES\_MCU\_DUAL\_CPU\_BOOT} ) ... set\_target\_linker(${PROJECT\_NAME} ${SOURCES\_MCU\_LOADER}) ... source\_g…

---

## [CMake is not using toolchain includes](https://discourse.cmake.org/t/cmake-is-not-using-toolchain-includes/7495)

<div class="topic-metadata">

**Author:** [@Jeremy\_Ardley](https://discourse.cmake.org/u/Jeremy_Ardley)\
**Replies:** 0\
**Last updated:** [February 20, 2023, 1:48am UTC](https://discourse.cmake.org/t/cmake-is-not-using-toolchain-includes/7495 "2023-02-20T01:48:37Z")

</div>

I am cross-compiling from intel to ARM. My problem is the ninja generated files seem to refer to the host system includes rather than the cross-compile includes cat ../../toolchain-armv7l.cmake # Define the toolchain f…

---

## [why do GLEW and GLFW have inconsistent usage?](https://discourse.cmake.org/t/why-do-glew-and-glfw-have-inconsistent-usage/7490)

<div class="topic-metadata">

**Author:** [@Craig\_Reynolds](https://discourse.cmake.org/u/Craig_Reynolds)\
**Replies:** 2\
**Last updated:** [February 18, 2023, 1:57am UTC](https://discourse.cmake.org/t/why-do-glew-and-glfw-have-inconsistent-usage/7490 "2023-02-18T01:57:15Z")

</div>

(I’ve used CMake before, this is my first time writing a CMakeLists.txt. Sorry for any cluelessness.) I wanted to build some code using the OpenGL library, which in modern times is provided through two libraries: GLEW a…

---

## [ctest for embedded](https://discourse.cmake.org/t/ctest-for-embedded/7415)

<div class="topic-metadata">

**Author:** [@pavel\_krupets](https://discourse.cmake.org/u/pavel_krupets)\
**Replies:** 4\
**Last updated:** [February 17, 2023, 7:11am UTC](https://discourse.cmake.org/t/ctest-for-embedded/7415 "2023-02-17T07:11:04Z")

</div>

is it possible to program microchip, then connect and run tests (collect results over uart, usb, bluetooth, etc.)? are there points I can hook into to make it work? i have a bunch of projects and most have libraries, w…

---

## [Extra /usr in path in PackagConfig](https://discourse.cmake.org/t/extra-usr-in-path-in-packagconfig/7472)

<div class="topic-metadata">

**Author:** [@jshanab](https://discourse.cmake.org/u/jshanab)\
**Replies:** 5\
**Last updated:** [February 16, 2023, 11:05pm UTC](https://discourse.cmake.org/t/extra-usr-in-path-in-packagconfig/7472 "2023-02-16T23:05:33Z")

</div>

Our build server (jenkins) is building gtest via cmake and it creates a package config. We install it into a staging area to tar it up for upload to artifactory. That gets installed to /opt/gtest/{version}/x64/{lib,inc…

---

## [Visual Studio closes non-project files when reloading ?](https://discourse.cmake.org/t/visual-studio-closes-non-project-files-when-reloading/7438)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 5\
**Last updated:** [February 15, 2023, 5:38pm UTC](https://discourse.cmake.org/t/visual-studio-closes-non-project-files-when-reloading/7438 "2023-02-15T17:38:02Z")

</div>

Hi, using Visual Studio 2017 I noticed today that when Visual Studio reloads the cmake-generated project (because cmake was rerun when building one of the targets), it closes the open files which are not part of the pro…

---

## [define\_property on target has no effect?](https://discourse.cmake.org/t/define-property-on-target-has-no-effect/7425)

<div class="topic-metadata">

**Author:** [@kfsone](https://discourse.cmake.org/u/kfsone)\
**Replies:** 5\
**Last updated:** [February 15, 2023, 3:57am UTC](https://discourse.cmake.org/t/define-property-on-target-has-no-effect/7425 "2023-02-15T03:57:30Z")

</div>

kfsone/cmake-defprop: Cmake “define-property” validation (github.com) Am I misusing/misunderstanding define\_property? CMake documentation suggests that using define\_property will cause get\_target\_property to return no …

---

## [How to add dependencies to an object library \[for ninja generator\]?](https://discourse.cmake.org/t/how-to-add-dependencies-to-an-object-library-for-ninja-generator/7462)

<div class="topic-metadata">

**Author:** [@LittleFall](https://discourse.cmake.org/u/LittleFall)\
**Replies:** 3\
**Last updated:** [February 14, 2023, 4:00pm UTC](https://discourse.cmake.org/t/how-to-add-dependencies-to-an-object-library-for-ninja-generator/7462 "2023-02-14T16:00:25Z")

</div>

The full source and cmake files can be found in this issue. Ninja: Cannot create dependency of an object library (#24411) · Issues · CMake / CMake · GitLab (kitware.com) add\_library(main OBJECT main.cpp) target\_link\_li…

---

## [Howto check for existence of test in sub directory?](https://discourse.cmake.org/t/howto-check-for-existence-of-test-in-sub-directory/7416)

<div class="topic-metadata">

**Author:** [@georg](https://discourse.cmake.org/u/georg)\
**Replies:** 3\
**Last updated:** [February 13, 2023, 4:09pm UTC](https://discourse.cmake.org/t/howto-check-for-existence-of-test-in-sub-directory/7416 "2023-02-13T16:09:30Z")

</div>

Hi all, I need to check if a test with a certain name already exists. The obvious way is the following: add\_test(NAME my\_test COMMAND /bin/true) if(TEST my\_test) message(STATUS "yes") else() message(STATUS "no…

---

## [How to use a cached variable in a toolchain file?](https://discourse.cmake.org/t/how-to-use-a-cached-variable-in-a-toolchain-file/7444)

<div class="topic-metadata">

**Author:** [@DavidA](https://discourse.cmake.org/u/DavidA)\
**Replies:** 3\
**Last updated:** [February 13, 2023, 3:31pm UTC](https://discourse.cmake.org/t/how-to-use-a-cached-variable-in-a-toolchain-file/7444 "2023-02-13T15:31:29Z")

</div>

Hi, I am using a toolchain file for an Arm toolchain. It works fine. However, it specifies a certain compiler path which is true for developers, but incorrect for our CI system. Perhaps I should specify a second toolchai…

---

## [How do I disable "Perfoming Test CXX\_HAS..."](https://discourse.cmake.org/t/how-do-i-disable-perfoming-test-cxx-has/7439)

<div class="topic-metadata">

**Author:** [@Russell\_Schultz](https://discourse.cmake.org/u/Russell_Schultz)\
**Replies:** 1\
**Last updated:** [February 12, 2023, 1:06am UTC](https://discourse.cmake.org/t/how-do-i-disable-perfoming-test-cxx-has/7439 "2023-02-12T01:06:57Z")

</div>

We’re in a controlled build environment (our tools are fixed and do not change) and these tests really slow down the configure phase. (especially when we’re very far away from our FlexLM server since each one fires off …

---

## [I added tests to my project but ctest says "No tests were found!!!"](https://discourse.cmake.org/t/i-added-tests-to-my-project-but-ctest-says-no-tests-were-found/7430)

<div class="topic-metadata">

**Author:** [@pavel\_krupets](https://discourse.cmake.org/u/pavel_krupets)\
**Replies:** 2\
**Last updated:** [February 9, 2023, 9:29pm UTC](https://discourse.cmake.org/t/i-added-tests-to-my-project-but-ctest-says-no-tests-were-found/7430 "2023-02-09T21:29:22Z")

</div>

project build and produces all files I expect (bin, hex, elf) but when I run: \\\> ctest CMakeLists.txt Test project D:/projects/mazelbot/libs/lib\_utils/test No tests were found!!! here is my CMakeLists.txt cmake\_minim…

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

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