# Usage

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

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

**Page:** 52

---

## [Convert pkg-config (.pc) file to relocatable CMake package](https://discourse.cmake.org/t/convert-pkg-config-pc-file-to-relocatable-cmake-package/7124)

<div class="topic-metadata">

**Author:** [@JRR](https://discourse.cmake.org/u/JRR)\
**Replies:** 1\
**Last updated:** [December 28, 2022, 12:35pm UTC](https://discourse.cmake.org/t/convert-pkg-config-pc-file-to-relocatable-cmake-package/7124 "2022-12-28T12:35:28Z")

</div>

Is there a way to convert a pkg-config .pc file into a relocatable CMake package file? Sometimes we need to move a 3rd party library that has a .pc, which isn’t relocatable. We’d like a reliable way to convert these .pc …

---

## [Using target\_sources with INTERFACE assembly sources does not generate absolute paths.](https://discourse.cmake.org/t/using-target-sources-with-interface-assembly-sources-does-not-generate-absolute-paths/7140)

<div class="topic-metadata">

**Author:** [@cookpate](https://discourse.cmake.org/u/cookpate)\
**Replies:** 7\
**Last updated:** [December 28, 2022, 1:52am UTC](https://discourse.cmake.org/t/using-target-sources-with-interface-assembly-sources-does-not-generate-absolute-paths/7140 "2022-12-28T01:52:51Z")

</div>

Was the ASM language simply left out of 3.13’s target\_sources relative path changes? I currently have to use CMAKE\_CURRENT\_SOURCE\_DIR when listing assembly files under INTERFACE sources. I have the following project tr…

---

## [Trying to compile shader with custom command](https://discourse.cmake.org/t/trying-to-compile-shader-with-custom-command/7132)

<div class="topic-metadata">

**Author:** [@RobN](https://discourse.cmake.org/u/RobN)\
**Replies:** 1\
**Last updated:** [December 27, 2022, 7:29pm UTC](https://discourse.cmake.org/t/trying-to-compile-shader-with-custom-command/7132 "2022-12-27T19:29:20Z")

</div>

I’ve got a simple program in one file (main.cc) that uses a Metal shader. I tried this CMakeLists.txt below, but when I edit the source file (Shaders.metal), it doesn’t rebuild. I’m trying to tell it to rebuild the Shad…

---

## [Sorry for repost - CPMAddPackage with ZLIB](https://discourse.cmake.org/t/sorry-for-repost-cpmaddpackage-with-zlib/7129)

<div class="topic-metadata">

**Author:** [@john](https://discourse.cmake.org/u/john)\
**Replies:** 1\
**Last updated:** [December 26, 2022, 2:34pm UTC](https://discourse.cmake.org/t/sorry-for-repost-cpmaddpackage-with-zlib/7129 "2022-12-26T14:34:24Z")

</div>

Hello all, I apologize for the repost, however I think this question is better placed in this sub-forum. I am fairly new to CMake but am interested in using the CMake Package Management (CPM) to add a local library/sou…

---

## [Linking on Windows requires versioned boost libraries](https://discourse.cmake.org/t/linking-on-windows-requires-versioned-boost-libraries/7119)

<div class="topic-metadata">

**Author:** [@Fabian188](https://discourse.cmake.org/u/Fabian188)\
**Replies:** 3\
**Last updated:** [December 23, 2022, 5:27pm UTC](https://discourse.cmake.org/t/linking-on-windows-requires-versioned-boost-libraries/7119 "2022-12-23T17:27:54Z")

</div>

For our CMake based C++ application we build boost ourselves as external project and add the libraries via target\_link\_libraries(). e.g. libboost\_filesystem.a for Linux and macOS. On Windows boost does by default not bu…

---

## [Running unit tests on iOS using CTest and GoogleTest](https://discourse.cmake.org/t/running-unit-tests-on-ios-using-ctest-and-googletest/7118)

<div class="topic-metadata">

**Author:** [@jviotti](https://discourse.cmake.org/u/jviotti)\
**Replies:** 1\
**Last updated:** [December 22, 2022, 5:30pm UTC](https://discourse.cmake.org/t/running-unit-tests-on-ios-using-ctest-and-googletest/7118 "2022-12-22T17:30:23Z")

</div>

Are there any resources out there for running iOS unit tests using CTest? Is it even possible to i.e. run a headless binary containing tests on the simulator? How do you people approach this?

---

## [How to set CMAKE variables in Visual Studio on Ubuntu side](https://discourse.cmake.org/t/how-to-set-cmake-variables-in-visual-studio-on-ubuntu-side/7095)

<div class="topic-metadata">

**Author:** [@Shrutia](https://discourse.cmake.org/u/Shrutia)\
**Replies:** 5\
**Last updated:** [December 21, 2022, 5:03am UTC](https://discourse.cmake.org/t/how-to-set-cmake-variables-in-visual-studio-on-ubuntu-side/7095 "2022-12-21T05:03:01Z")

</div>

I am building python files using CMAKE on Ubuntu side. My CmakeLists.txt looks as below. project(test) add\_executable(myhtml myhtml.py) execute\_process(COMMAND python myhtml.py WORKING\_DIRECTORY ${CMAKE\_CURRENT\_LIST…

---

## ['Could not find CMAKE\_ROOT' error from AppImage](https://discourse.cmake.org/t/could-not-find-cmake-root-error-from-appimage/4604)

<div class="topic-metadata">

**Author:** [@abuzila](https://discourse.cmake.org/u/abuzila)\
**Replies:** 9\
**Last updated:** [December 20, 2022, 2:34pm UTC](https://discourse.cmake.org/t/could-not-find-cmake-root-error-from-appimage/4604 "2022-12-20T14:34:21Z")

</div>

Hello, I’m building an application based on Eclipse Theia and packaging it with the electron-builder in an AppImage file, on linux. Calling cmake from a terminal opened in this product shows an error, like in the examp…

---

## [Using Generator Expressions with the STATIC\_LIBRARY\_OPTIONS property](https://discourse.cmake.org/t/using-generator-expressions-with-the-static-library-options-property/7089)

<div class="topic-metadata">

**Author:** [@JRR](https://discourse.cmake.org/u/JRR)\
**Replies:** 2\
**Last updated:** [December 19, 2022, 6:17pm UTC](https://discourse.cmake.org/t/using-generator-expressions-with-the-static-library-options-property/7089 "2022-12-19T18:17:49Z")

</div>

I’m having trouble adding a generator expression that wraps a list to the STATIC\_LIBRARY\_OPTIONS property for Windows Visual Studios 2017. I’m using cmake version 3.23.1 I’m not sure if I’m encountering some sort of q…

---

## [Prevent populated imported static library dependencies](https://discourse.cmake.org/t/prevent-populated-imported-static-library-dependencies/7086)

<div class="topic-metadata">

**Author:** [@daudrain](https://discourse.cmake.org/u/daudrain)\
**Replies:** 2\
**Last updated:** [December 16, 2022, 3:05pm UTC](https://discourse.cmake.org/t/prevent-populated-imported-static-library-dependencies/7086 "2022-12-16T15:05:07Z")

</div>

Hi, I am struggling with the current situation: An executable targets depends on external prebuilt DCMTK static libraries . These static DCMTK libraries have been built against crypto and openssl shared libraries, and t…

---

## [Organizing multiple CMake projects and dependencies, and what's wrong with linking libraries from CMake build dirs and never installing anything?](https://discourse.cmake.org/t/organizing-multiple-cmake-projects-and-dependencies-and-whats-wrong-with-linking-libraries-from-cmake-build-dirs-and-never-installing-anything/6952)

<div class="topic-metadata">

**Author:** [@Dennis\_Ferron](https://discourse.cmake.org/u/Dennis_Ferron)\
**Replies:** 9\
**Last updated:** [December 16, 2022, 6:09am UTC](https://discourse.cmake.org/t/organizing-multiple-cmake-projects-and-dependencies-and-whats-wrong-with-linking-libraries-from-cmake-build-dirs-and-never-installing-anything/6952 "2022-12-16T06:09:05Z")

</div>

First off, I know similar questions have already been answered, but it’s a complex topic, and I have different requirements. The last person to ask this question comprehensively was, if you read the fine print, authorin…

---

## [file(GENERATE ...) and Visual Studio 16 2019 generator](https://discourse.cmake.org/t/file-generate-and-visual-studio-16-2019-generator/7076)

<div class="topic-metadata">

**Author:** [@Mauro\_Ziliani](https://discourse.cmake.org/u/Mauro_Ziliani)\
**Replies:** 2\
**Last updated:** [December 15, 2022, 2:23pm UTC](https://discourse.cmake.org/t/file-generate-and-visual-studio-16-2019-generator/7076 "2022-12-15T14:23:48Z")

</div>

Goodmorning. I’m using file(GENERATE …) to test the espansion of generator expressions I get a list of libraries in MyTargetLibraries with get\_target\_property(MyTargetLibraries mytarget LINK\_LIBRARIES) Then I loop on…

---

## [No CMAKE\_LANGUAGE\_COMPILER could be found.](https://discourse.cmake.org/t/no-cmake-language-compiler-could-be-found/7067)

<div class="topic-metadata">

**Author:** [@Moran](https://discourse.cmake.org/u/Moran)\
**Replies:** 1\
**Last updated:** [December 15, 2022, 1:02pm UTC](https://discourse.cmake.org/t/no-cmake-language-compiler-could-be-found/7067 "2022-12-15T13:02:45Z")

</div>

I met some trouble when i try to create dir of build , i type cmake -B build, then error occur。 I google this mistake but cannot found . environment： Distributor ID: Ubuntu Description: Ubuntu 18.04.6 LTS Release:…

---

## [generating eclipse project with subprojects links the main project in the subprojects too](https://discourse.cmake.org/t/generating-eclipse-project-with-subprojects-links-the-main-project-in-the-subprojects-too/4374)

<div class="topic-metadata">

**Author:** [@bugblatterbeast](https://discourse.cmake.org/u/bugblatterbeast)\
**Replies:** 2\
**Last updated:** [December 14, 2022, 11:11am UTC](https://discourse.cmake.org/t/generating-eclipse-project-with-subprojects-links-the-main-project-in-the-subprojects-too/4374 "2022-12-14T11:11:31Z")

</div>

Hi, I use cmake to generate an eclipse project like this: cmake -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE\_ECLIPSE\_VERSION=4.18 -DCMAKE\_BUILD\_TYPE=Debug -DCMAKE\_ECLIPSE\_GENERATE\_SOURCE\_PROJECT=TRUE -DCMAKE\_ECLIPSE\_MAKE…

---

## [Using CMake to build the IMGUI Demo program](https://discourse.cmake.org/t/using-cmake-to-build-the-imgui-demo-program/7038)

<div class="topic-metadata">

**Author:** [@jochoalions](https://discourse.cmake.org/u/jochoalions)\
**Replies:** 1\
**Last updated:** [December 14, 2022, 10:09am UTC](https://discourse.cmake.org/t/using-cmake-to-build-the-imgui-demo-program/7038 "2022-12-14T10:09:59Z")

</div>

CMake newbie here. Learning how to use CMake to compile the Dear Imgui demo program. The Library libimgui.a seems to compile correctly without errors by running make in its own directory. But the imgui\_demo program does …

---

## [Namespaces for targets?](https://discourse.cmake.org/t/namespaces-for-targets/7057)

<div class="topic-metadata">

**Author:** [@RobN](https://discourse.cmake.org/u/RobN)\
**Replies:** 2\
**Last updated:** [December 14, 2022, 1:13am UTC](https://discourse.cmake.org/t/namespaces-for-targets/7057 "2022-12-14T01:13:17Z")

</div>

I’m experimenting with putting my projects into a monorepo. I have a root CMakeLists.txt with some global config and then a bunch of add\_subdirectory calls. An executable target somewhere in the tree builds in a similar …

---

## [add\_subdirectory(foo system) doesn't work for me](https://discourse.cmake.org/t/add-subdirectory-foo-system-doesnt-work-for-me/7063)

<div class="topic-metadata">

**Author:** [@gkodinov](https://discourse.cmake.org/u/gkodinov)\
**Replies:** 1\
**Last updated:** [December 13, 2022, 2:59pm UTC](https://discourse.cmake.org/t/add-subdirectory-foo-system-doesnt-work-for-me/7063 "2022-12-13T14:59:57Z")

</div>

I’m trying to add system subdirectories. my project is as follows: CMakeLists.txt cmake\_minimum\_required(VERSION 3.5.1) PROJECT(test VERSION 0.0.0.1) ADD\_SUBDIRECTORY(b1 SYSTEM) ADD\_SUBDIRECTORY(b2 SYSTEM) ADD\_EXEC…

---

## [parallel build with ctest](https://discourse.cmake.org/t/parallel-build-with-ctest/7045)

<div class="topic-metadata">

**Author:** [@Fabian188](https://discourse.cmake.org/u/Fabian188)\
**Replies:** 2\
**Last updated:** [December 13, 2022, 2:55pm UTC](https://discourse.cmake.org/t/parallel-build-with-ctest/7045 "2022-12-13T14:55:46Z")

</div>

We use for our build pipeline ctest (on Linux using make) ctest -D ExperimentalBuild --track $CDASH\_TRACK -V Is there a way to run it in parallel (make -j)? I only found this 15 years old answer and wonder if there is…

---

## [Forcing build for circular dependent dynamic libraries](https://discourse.cmake.org/t/forcing-build-for-circular-dependent-dynamic-libraries/7052)

<div class="topic-metadata">

**Author:** [@sda](https://discourse.cmake.org/u/sda)\
**Replies:** 1\
**Last updated:** [December 12, 2022, 7:13pm UTC](https://discourse.cmake.org/t/forcing-build-for-circular-dependent-dynamic-libraries/7052 "2022-12-12T19:13:56Z")

</div>

Hello, I have a circular dependency problem within libraries in a huge project. We are compiling for Linux so circular dependencies in dynamic libraries are not an issue. Is there a way to force cmake to ignore this cir…

---

## [Including a .cmake file](https://discourse.cmake.org/t/including-a-cmake-file/7034)

<div class="topic-metadata">

**Author:** [@willem](https://discourse.cmake.org/u/willem)\
**Replies:** 5\
**Last updated:** [December 9, 2022, 7:02am UTC](https://discourse.cmake.org/t/including-a-cmake-file/7034 "2022-12-09T07:02:07Z")

</div>

I have top-level cmakelists, with in subdirectory “cmake” a file “dependencies.cmake”. I cannot seem to include it following the approach in professional cmake book. See below? Can anybody explain what is going on? What …

---

## [add\_custom\_command with target dependency doesn't rebuild](https://discourse.cmake.org/t/add-custom-command-with-target-dependency-doesnt-rebuild/7029)

<div class="topic-metadata">

**Author:** [@Barry\_Revzin](https://discourse.cmake.org/u/Barry_Revzin)\
**Replies:** 9\
**Last updated:** [December 8, 2022, 1:19pm UTC](https://discourse.cmake.org/t/add-custom-command-with-target-dependency-doesnt-rebuild/7029 "2022-12-08T13:19:19Z")

</div>

Here’s a small reproduction: CMakeLists.txt: cmake\_minimum\_required(VERSION 3.21) project(cc) add\_custom\_command(OUTPUT inter.dat COMMAND cp ${CMAKE\_CURRENT\_LIST\_DIR}/num inter.dat DEPENDS ${CMAKE\_CURRENT\_LIST…

---

## [CMake does not set the compiler option -std to gnu17 or c++17 although I set the target\_compile\_features to cxx\_std\_17](https://discourse.cmake.org/t/cmake-does-not-set-the-compiler-option-std-to-gnu17-or-c-17-although-i-set-the-target-compile-features-to-cxx-std-17/3299)

<div class="topic-metadata">

**Author:** [@the\_shmoo](https://discourse.cmake.org/u/the_shmoo)\
**Replies:** 18\
**Last updated:** [December 7, 2022, 3:43pm UTC](https://discourse.cmake.org/t/cmake-does-not-set-the-compiler-option-std-to-gnu17-or-c-17-although-i-set-the-target-compile-features-to-cxx-std-17/3299 "2022-12-07T15:43:03Z")

</div>

I updated the versions of GCC and CMake. After the update CMake no longer sets the right command line option for the c++ standard. Here is how I set it: add\_library(project\_options INTERFACE) target\_compile\_features(pr…

---

## [Linking priority in cmake](https://discourse.cmake.org/t/linking-priority-in-cmake/7019)

<div class="topic-metadata">

**Author:** [@userE](https://discourse.cmake.org/u/userE)\
**Replies:** 6\
**Last updated:** [December 7, 2022, 2:25pm UTC](https://discourse.cmake.org/t/linking-priority-in-cmake/7019 "2022-12-07T14:25:29Z")

</div>

Is there any way i can set a priority at linking some libs/classes in cmake? I have a library BFciLib that i use in my class, and have added it in cmake like this target\_link\_libraries(Main PRIVATE BFciLib GL ${GTKMM…

---

## [How to set WarningLevel for CSharp targets](https://discourse.cmake.org/t/how-to-set-warninglevel-for-csharp-targets/7005)

<div class="topic-metadata">

**Author:** [@Knitschi](https://discourse.cmake.org/u/Knitschi)\
**Replies:** 2\
**Last updated:** [December 7, 2022, 6:35am UTC](https://discourse.cmake.org/t/how-to-set-warninglevel-for-csharp-targets/7005 "2022-12-07T06:35:58Z")

</div>

Hi everybody I am currently working on transforming our hard checked-in .csproj files into CMakeLists files. I ran into the problem that I do not know how to set the warning level in this case. This is done in the .csp…

---

## [configure-step dependencies](https://discourse.cmake.org/t/configure-step-dependencies/7020)

<div class="topic-metadata">

**Author:** [@Barry\_Revzin](https://discourse.cmake.org/u/Barry_Revzin)\
**Replies:** 7\
**Last updated:** [December 7, 2022, 12:48am UTC](https://discourse.cmake.org/t/configure-step-dependencies/7020 "2022-12-07T00:48:14Z")

</div>

Here is a reduced example: $ tree . ├── cmake │ └── foo.cmake ├── CMakeLists.txt ├── meow.py └── woof.py with the main CMakeLists.txt cmake\_minimum\_required(VERSION 3.21) project(execute) set(CMAKE\_RUNTIME\_OUTPUT\_D…

---

## [Help with find\_package with nested libs](https://discourse.cmake.org/t/help-with-find-package-with-nested-libs/7014)

<div class="topic-metadata">

**Author:** [@randaz81](https://discourse.cmake.org/u/randaz81)\
**Replies:** 1\
**Last updated:** [December 5, 2022, 10:08pm UTC](https://discourse.cmake.org/t/help-with-find-package-with-nested-libs/7014 "2022-12-05T22:08:35Z")

</div>

I am a CMake beginner and I’m a bit confused with the find\_package command when using nested libraries. In my project, I used the following command: find\_package(aaa COMPONENTS bbb REQUIRED) bbb is correctly found, bu…

---

## [verbose output with NMake Makefiles and msvc](https://discourse.cmake.org/t/verbose-output-with-nmake-makefiles-and-msvc/6974)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 3\
**Last updated:** [December 5, 2022, 4:59pm UTC](https://discourse.cmake.org/t/verbose-output-with-nmake-makefiles-and-msvc/6974 "2022-12-05T16:59:35Z")

</div>

How must I write my cmake files in order to see the actual command line with cl compiler and nmake makefile (I’d like to check the used compilation and link options, as with make and CMAKE\_VERBOSE\_MAKEFILE ON) Regards …

---

## [Find parent project in subprojects using find\_package](https://discourse.cmake.org/t/find-parent-project-in-subprojects-using-find-package/6988)

<div class="topic-metadata">

**Author:** [@fsimonis](https://discourse.cmake.org/u/fsimonis)\
**Replies:** 3\
**Last updated:** [December 5, 2022, 2:59pm UTC](https://discourse.cmake.org/t/find-parent-project-in-subprojects-using-find-package/6988 "2022-12-05T14:59:28Z")

</div>

My project consists of a library and example programs. The library generates a mylibrary-config.cmake in the binary directory using an export set. My example programs are individual CMake projects calling find\_package(…

---

## [Correct way to use third-party libraries in cmake project](https://discourse.cmake.org/t/correct-way-to-use-third-party-libraries-in-cmake-project/1368)

<div class="topic-metadata">

**Author:** [@jcfr](https://discourse.cmake.org/u/jcfr)\
**Replies:** 6\
**Last updated:** [December 5, 2022, 11:02am UTC](https://discourse.cmake.org/t/correct-way-to-use-third-party-libraries-in-cmake-project/1368 "2022-12-05T11:02:52Z")

</div>

A while back I answered this question on stackoverflow, since it is getting up voted regularly, I am also cross-posting here: It may also help answer questions in this thread: https://discourse.cmake.org/t/best-prac…

---

## [How to force NSIS installer to pack files from a debug configuration?](https://discourse.cmake.org/t/how-to-force-nsis-installer-to-pack-files-from-a-debug-configuration/6975)

<div class="topic-metadata">

**Author:** [@JuhaniX](https://discourse.cmake.org/u/JuhaniX)\
**Replies:** 2\
**Last updated:** [December 4, 2022, 3:36pm UTC](https://discourse.cmake.org/t/how-to-force-nsis-installer-to-pack-files-from-a-debug-configuration/6975 "2022-12-04T15:36:17Z")

</div>

I need to make an installer with NSIS that installs debug versions of files. It seems that CPack or NSIS does not care about cmake -D Release or cmake -D Debug. It is packing always release files to an installer. This …

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

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