# Usage

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

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

**Page:** 79

---

## [How to handle duplicate targets (add\_subdirectory only)](https://discourse.cmake.org/t/how-to-handle-duplicate-targets-add-subdirectory-only/3362)

<div class="topic-metadata">

**Author:** [@YMba9g8j9CJp0wLoQf5y](https://discourse.cmake.org/u/YMba9g8j9CJp0wLoQf5y)\
**Replies:** 5\
**Last updated:** [May 20, 2021, 3:16pm UTC](https://discourse.cmake.org/t/how-to-handle-duplicate-targets-add-subdirectory-only/3362 "2021-05-20T15:16:42Z")

</div>

Here is the situation. We have library p which depends on a We have library d which depends on a And finally library p depends on library d p -\> d -\> a \\ \> a Our company is basically only using add\_subdirector…

---

## [FindDoxygen: Path handling in MSYS2](https://discourse.cmake.org/t/finddoxygen-path-handling-in-msys2/3373)

<div class="topic-metadata">

**Author:** [@senr80](https://discourse.cmake.org/u/senr80)\
**Replies:** 2\
**Last updated:** [May 20, 2021, 11:19am UTC](https://discourse.cmake.org/t/finddoxygen-path-handling-in-msys2/3373 "2021-05-20T11:19:05Z")

</div>

I’m trying to add a target to generate API doc with Doxygen to my CMake project by find\_package(Doxygen ...) and doxygen\_add\_docs() . I’m in a MSYS2 environment on Windows 10 usig CMake 3.19.3. For some reason CMake and …

---

## [cpack and third-party libs on mac os](https://discourse.cmake.org/t/cpack-and-third-party-libs-on-mac-os/3366)

<div class="topic-metadata">

**Author:** [@manang](https://discourse.cmake.org/u/manang)\
**Replies:** 5\
**Last updated:** [May 19, 2021, 4:07pm UTC](https://discourse.cmake.org/t/cpack-and-third-party-libs-on-mac-os/3366 "2021-05-19T16:07:06Z")

</div>

Hi, I’m trying to create an installer on Mac Os of a little project that uses openssl as dependency. I need to create an installer that includes libssl and libcrypto in my destination foder. How can I change the rpath…

---

## [Regenerate/recompile at install time](https://discourse.cmake.org/t/regenerate-recompile-at-install-time/3287)

<div class="topic-metadata">

**Author:** [@cerna](https://discourse.cmake.org/u/cerna)\
**Replies:** 4\
**Last updated:** [May 18, 2021, 6:34pm UTC](https://discourse.cmake.org/t/regenerate-recompile-at-install-time/3287 "2021-05-18T18:34:01Z")

</div>

Hello, I am writing a build system for an old project currently using hand-written Make files. In the sourcefiles, there are numerous hard-coded paths to files in the absolute form. (Mostly to the configuration files an…

---

## [Linking a C++/CLR shared library to another C++/CLR shared library](https://discourse.cmake.org/t/linking-a-c-clr-shared-library-to-another-c-clr-shared-library/3354)

<div class="topic-metadata">

**Author:** [@ian.gralinski.inv](https://discourse.cmake.org/u/ian.gralinski.inv)\
**Replies:** 0\
**Last updated:** [May 18, 2021, 2:25am UTC](https://discourse.cmake.org/t/linking-a-c-clr-shared-library-to-another-c-clr-shared-library/3354 "2021-05-18T02:25:13Z")

</div>

I have two C++/CLR shared libraries where one depends on the other. I have set the VS\_DOTNET\_REFERENCE to point to the DLL as follows set\_target\_properties(clr1 PROPERTIES COMMON\_LANGUAGE\_RUNTIME "" VS\_DOTNET\_REFERENCES…

---

## [risk of using cmake\_policy(VERSION ...) instead of setting policies individually](https://discourse.cmake.org/t/risk-of-using-cmake-policy-version-instead-of-setting-policies-individually/3350)

<div class="topic-metadata">

**Author:** [@maarten](https://discourse.cmake.org/u/maarten)\
**Replies:** 1\
**Last updated:** [May 17, 2021, 9:46pm UTC](https://discourse.cmake.org/t/risk-of-using-cmake-policy-version-instead-of-setting-policies-individually/3350 "2021-05-17T21:46:53Z")

</div>

Hi, The cmake documentation recommends the use of cmake\_policy(VERSION \[…\]) instead of setting policies individually with cmake\_policy(SET CMP… NEW|OLD): “While setting policies individually is supported, we encourage …

---

## [add\_custom\_target dependencies](https://discourse.cmake.org/t/add-custom-target-dependencies/3342)

<div class="topic-metadata">

**Author:** [@kmosk](https://discourse.cmake.org/u/kmosk)\
**Replies:** 3\
**Last updated:** [May 17, 2021, 2:56pm UTC](https://discourse.cmake.org/t/add-custom-target-dependencies/3342 "2021-05-17T14:56:18Z")

</div>

my CMakeLists.txt: # wxFormBuilder generation set(FORM\_BUILDER\_PROJECT ${PROJECT\_SOURCE\_DIR}/source/view/gen.fbp) set(GENERATED\_VIEW\_DIR ${PROJECT\_SOURCE\_DIR}/source/view/generated) set(GENERATED\_VIEW\_FILE\_CPP ${GENERAT…

---

## [C++ language wrongly propagated through dependency chain](https://discourse.cmake.org/t/c-language-wrongly-propagated-through-dependency-chain/3315)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 7\
**Last updated:** [May 17, 2021, 1:54pm UTC](https://discourse.cmake.org/t/c-language-wrongly-propagated-through-dependency-chain/3315 "2021-05-17T13:54:08Z")

</div>

I have a library L (either a static lib or a headers only library) and an client application A. I set the required language level for L with : target\_compile\_features(L PUBLIC cxx\_std\_14) on a recent CMake target\_comp…

---

## [proper way to wrap an imported target around a third-party target](https://discourse.cmake.org/t/proper-way-to-wrap-an-imported-target-around-a-third-party-target/2757)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 7\
**Last updated:** [May 17, 2021, 8:47am UTC](https://discourse.cmake.org/t/proper-way-to-wrap-an-imported-target-around-a-third-party-target/2757 "2021-05-17T08:47:57Z")

</div>

Hi, I’m trying to enforce namespace usage for imported libraries. For third-party libraries that can be imported through find\_package but the don’t provide a namespace, I tried to wrap them in a namespace (see attached…

---

## [how to refer to the package file in external projects?](https://discourse.cmake.org/t/how-to-refer-to-the-package-file-in-external-projects/3338)

<div class="topic-metadata">

**Author:** [@hex](https://discourse.cmake.org/u/hex)\
**Replies:** 1\
**Last updated:** [May 16, 2021, 12:36pm UTC](https://discourse.cmake.org/t/how-to-refer-to-the-package-file-in-external-projects/3338 "2021-05-16T12:36:54Z")

</div>

how to i refer to the downloaded package with ExternalProject? It is not in \<SOURCE\_DIR\> nor \<BINARY\_DIR\>: ExternalProject\_Add(ext URL ${url} DOWNLOAD\_NO\_EXTRACT TRUE CONFIGURE\_COMMAND "... ?" ) i en…

---

## [CMake uses the wrong Visual Studio version](https://discourse.cmake.org/t/cmake-uses-the-wrong-visual-studio-version/3333)

<div class="topic-metadata">

**Author:** [@nitawa](https://discourse.cmake.org/u/nitawa)\
**Replies:** 1\
**Last updated:** [May 15, 2021, 12:55pm UTC](https://discourse.cmake.org/t/cmake-uses-the-wrong-visual-studio-version/3333 "2021-05-15T12:55:17Z")

</div>

Hi, I do have Visual Studio 2017 and Visual Studio 2019 installed side by side on my workstation. To compile a third product used in my application, I used to do: call "C:\\Program Files (x86)\\Microsoft Visual Studio\\2…

---

## [CMAKE\_SYSTEM\_PREFIX\_PATH under macOS](https://discourse.cmake.org/t/cmake-system-prefix-path-under-macos/3311)

<div class="topic-metadata">

**Author:** [@nicolamori](https://discourse.cmake.org/u/nicolamori)\
**Replies:** 3\
**Last updated:** [May 13, 2021, 9:16am UTC](https://discourse.cmake.org/t/cmake-system-prefix-path-under-macos/3311 "2021-05-13T09:16:52Z")

</div>

I don’t understand how the CMAKE\_SYSTEM\_PREFIX\_PATH is set under macOS. On my system (Catalina) the currently selected SDK is: $ xcrun --show-sdk-path /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk but printi…

---

## [compile CMake (32 bit) with Visual Studio 2019](https://discourse.cmake.org/t/compile-cmake-32-bit-with-visual-studio-2019/3307)

<div class="topic-metadata">

**Author:** [@nitawa](https://discourse.cmake.org/u/nitawa)\
**Replies:** 2\
**Last updated:** [May 12, 2021, 9:31pm UTC](https://discourse.cmake.org/t/compile-cmake-32-bit-with-visual-studio-2019/3307 "2021-05-12T21:31:33Z")

</div>

dear experts, I installed both Visual Studio 2017 and Visual Studio 2019 on my Microsoft Windows 10 workstation. I tried to compile cmake as a 32 bit application and did not manage to get it compile with Visual Studio …

---

## [CTest --show-only interaction with CTEST\_CUSTOM\_POST\_TEST](https://discourse.cmake.org/t/ctest-show-only-interaction-with-ctest-custom-post-test/3309)

<div class="topic-metadata">

**Author:** [@rleigh](https://discourse.cmake.org/u/rleigh)\
**Replies:** 0\
**Last updated:** [May 12, 2021, 7:09pm UTC](https://discourse.cmake.org/t/ctest-show-only-interaction-with-ctest-custom-post-test/3309 "2021-05-12T19:09:08Z")

</div>

Hi folks, I’ve had failures running ctest within CLion. It turns out this is due to an interaction between “–show-only=json-v1” and “CTEST\_CUSTOM\_POST\_TEST”: ctest --show-only=json-v1: "version" : { "major" :…

---

## [Preserving build settings for CMake GUI](https://discourse.cmake.org/t/preserving-build-settings-for-cmake-gui/3297)

<div class="topic-metadata">

**Author:** [@pauljurczak](https://discourse.cmake.org/u/pauljurczak)\
**Replies:** 3\
**Last updated:** [May 12, 2021, 12:46pm UTC](https://discourse.cmake.org/t/preserving-build-settings-for-cmake-gui/3297 "2021-05-12T12:46:44Z")

</div>

I’m using CMake GUI to build large projects like OpenCV. There is over 20 settings I have to change from defaults while experimenting with different build scenarios. What is the way to preserve these settings when I eras…

---

## [CMAKE\_FIND\_ROOT\_PATH and toolchain files](https://discourse.cmake.org/t/cmake-find-root-path-and-toolchain-files/3294)

<div class="topic-metadata">

**Author:** [@RedDwarf](https://discourse.cmake.org/u/RedDwarf)\
**Replies:** 4\
**Last updated:** [May 12, 2021, 12:43pm UTC](https://discourse.cmake.org/t/cmake-find-root-path-and-toolchain-files/3294 "2021-05-12T12:43:33Z")

</div>

After taking a look at the docs and the 8th edition of Professional CMake I am not sure what’s the intended usage, if any, of CMAKE\_FIND\_ROOT\_PATH inside a toolchain file. For the simple case you can argue “just use CMA…

---

## [How to specify different compile options for C and C++?](https://discourse.cmake.org/t/how-to-specify-different-compile-options-for-c-and-c/583)

<div class="topic-metadata">

**Author:** [@DavidA](https://discourse.cmake.org/u/DavidA)\
**Replies:** 9\
**Last updated:** [May 10, 2021, 10:57am UTC](https://discourse.cmake.org/t/how-to-specify-different-compile-options-for-c-and-c/583 "2021-05-10T10:57:24Z")

</div>

My CMake project builds an executable consisting of C and C++ source files: add\_executable(myAP main.cpp DpdkSock.c \<snip\> ) I want to specify different compile options for the .cpp and .c files. (For examp…

---

## [How to install CMAKE on Mac M1 (ARM)](https://discourse.cmake.org/t/how-to-install-cmake-on-mac-m1-arm/3280)

<div class="topic-metadata">

**Author:** [@fester225](https://discourse.cmake.org/u/fester225)\
**Replies:** 1\
**Last updated:** [May 9, 2021, 3:17pm UTC](https://discourse.cmake.org/t/how-to-install-cmake-on-mac-m1-arm/3280 "2021-05-09T15:17:34Z")

</div>

How do I install CMAKE on a Mac M1?

---

## [Performing C SOURCE FILE Test CMAKE\_HAVE\_LIBC\_PTHREAD failed with the following output:](https://discourse.cmake.org/t/performing-c-source-file-test-cmake-have-libc-pthread-failed-with-the-following-output/3253)

<div class="topic-metadata">

**Author:** [@Yifan\_Liu](https://discourse.cmake.org/u/Yifan_Liu)\
**Replies:** 4\
**Last updated:** [May 7, 2021, 9:42am UTC](https://discourse.cmake.org/t/performing-c-source-file-test-cmake-have-libc-pthread-failed-with-the-following-output/3253 "2021-05-07T09:42:41Z")

</div>

Hi, I am trying to create a c++ project from existing source, but I am stuck with an error during the pre-build process and I can’t figure out what leads to it. The first one is a CMakeError, which is shown below: Perf…

---

## [Relationship between presets cmakeMinimumRequired and cmake\_minimum\_required](https://discourse.cmake.org/t/relationship-between-presets-cmakeminimumrequired-and-cmake-minimum-required/3262)

<div class="topic-metadata">

**Author:** [@David\_Hunter](https://discourse.cmake.org/u/David_Hunter)\
**Replies:** 5\
**Last updated:** [May 6, 2021, 11:15pm UTC](https://discourse.cmake.org/t/relationship-between-presets-cmakeminimumrequired-and-cmake-minimum-required/3262 "2021-05-06T23:15:58Z")

</div>

So I have an existing root CmakeLists.txt with cmake\_minimum\_required(VERSION 3.19) I started using presets and have a cmakeMinimumRequired set to 3.20 So is there any relationship between these two settings. When I r…

---

## [CMakePresets.json and graphviz](https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256)

<div class="topic-metadata">

**Author:** [@David\_Hunter](https://discourse.cmake.org/u/David_Hunter)\
**Replies:** 9\
**Last updated:** [May 6, 2021, 1:54pm UTC](https://discourse.cmake.org/t/cmakepresets-json-and-graphviz/3256 "2021-05-06T13:54:04Z")

</div>

Does anyone know if, and how, you can set the equivalent of a “–graphviz=graphviz.dot” command line option in a CMakePresets.json preset?

---

## [CUDA 11.2 SDK Incorrect Detection Under Windows](https://discourse.cmake.org/t/cuda-11-2-sdk-incorrect-detection-under-windows/3149)

<div class="topic-metadata">

**Author:** [@Andrea\_Borsic](https://discourse.cmake.org/u/Andrea_Borsic)\
**Replies:** 8\
**Last updated:** [May 5, 2021, 8:33pm UTC](https://discourse.cmake.org/t/cuda-11-2-sdk-incorrect-detection-under-windows/3149 "2021-05-05T20:33:05Z")

</div>

Hi All, I am experiencing a problem configuring a C++/CUDA project under Windows 10 / VS 2019 / CMake 3.20.1 (and a bunch of previous versions) The PC has installed CUDA 11.2 and no trace of CUDA 10.2 (not under Progra…

---

## [C'ant compile aseprite with Cmake and ninja and skia](https://discourse.cmake.org/t/cant-compile-aseprite-with-cmake-and-ninja-and-skia/3264)

<div class="topic-metadata">

**Author:** [@Rogue\_taleteller](https://discourse.cmake.org/u/Rogue_taleteller)\
**Replies:** 11\
**Last updated:** [May 5, 2021, 7:56pm UTC](https://discourse.cmake.org/t/cant-compile-aseprite-with-cmake-and-ninja-and-skia/3264 "2021-05-05T19:56:54Z")

</div>

Compiling the C compiler identification source file “CMakeCCompilerId.c” failed. Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe Build flags: Id…

---

## [Hello i need help to start a calculator programm with cmake](https://discourse.cmake.org/t/hello-i-need-help-to-start-a-calculator-programm-with-cmake/3273)

<div class="topic-metadata">

**Author:** [@Unknown](https://discourse.cmake.org/u/Unknown)\
**Replies:** 1\
**Last updated:** [May 5, 2021, 6:03pm UTC](https://discourse.cmake.org/t/hello-i-need-help-to-start-a-calculator-programm-with-cmake/3273 "2021-05-05T18:03:56Z")

</div>

Hello what must i do to give me a output with main.cpp main.h and CMakeLists? i write the programm i only need the commands

---

## [How to put a result file to any subdirectory](https://discourse.cmake.org/t/how-to-put-a-result-file-to-any-subdirectory/3266)

<div class="topic-metadata">

**Author:** [@polarisru](https://discourse.cmake.org/u/polarisru)\
**Replies:** 3\
**Last updated:** [May 5, 2021, 6:02pm UTC](https://discourse.cmake.org/t/how-to-put-a-result-file-to-any-subdirectory/3266 "2021-05-05T18:02:23Z")

</div>

I try to compile my Cortex-M0 project with CMake and arm-none-eabi-gcc (mingw32-make as make). Everything is Ok, I get my hex and binary as result, but I want to have them not in the main directory with CMakeLists.txt, …

---

## [cmake 3.20 build error when copying iOS frameworks - signing on build machine not supported](https://discourse.cmake.org/t/cmake-3-20-build-error-when-copying-ios-frameworks-signing-on-build-machine-not-supported/3258)

<div class="topic-metadata">

**Author:** [@buggy](https://discourse.cmake.org/u/buggy)\
**Replies:** 5\
**Last updated:** [May 4, 2021, 2:21pm UTC](https://discourse.cmake.org/t/cmake-3-20-build-error-when-copying-ios-frameworks-signing-on-build-machine-not-supported/3258 "2021-05-04T14:21:41Z")

</div>

Hi everybody, I run into an error when building an iOS app linking a framework on a machine without Apple dev certificates installed: \_lib\_shared\_it\_copy\_lib.build/Script-827DD60D11E805EA4271AEE0.sh: line 5: unexpected…

---

## [Error while loading shared libraries](https://discourse.cmake.org/t/error-while-loading-shared-libraries/3239)

<div class="topic-metadata">

**Author:** [@JoeAB](https://discourse.cmake.org/u/JoeAB)\
**Replies:** 3\
**Last updated:** [April 30, 2021, 7:53pm UTC](https://discourse.cmake.org/t/error-while-loading-shared-libraries/3239 "2021-04-30T19:53:46Z")

</div>

The product is a full embedded Linux operating system. I am trying to add a module to a layer provided by a component provider. For development I am using VS-Code on Ubuntu 18.04. The project is in /home/me/develop/sourc…

---

## [Ignoring CMake's delivered Find\<Package\>.cmake to favor external Library's Config.cmake](https://discourse.cmake.org/t/ignoring-cmakes-delivered-find-package-cmake-to-favor-external-librarys-config-cmake/3236)

<div class="topic-metadata">

**Author:** [@brentd](https://discourse.cmake.org/u/brentd)\
**Replies:** 4\
**Last updated:** [April 30, 2021, 5:58pm UTC](https://discourse.cmake.org/t/ignoring-cmakes-delivered-find-package-cmake-to-favor-external-librarys-config-cmake/3236 "2021-04-30T17:58:08Z")

</div>

I am trying to use an external library that has recently started providing Config.cmake files for itself. Before this, cmake was providing a Find.cmake module for this library. The library provides an imported target t…

---

## [How to use add\_custom\_command right?](https://discourse.cmake.org/t/how-to-use-add-custom-command-right/3229)

<div class="topic-metadata">

**Author:** [@serge](https://discourse.cmake.org/u/serge)\
**Replies:** 2\
**Last updated:** [April 30, 2021, 12:06pm UTC](https://discourse.cmake.org/t/how-to-use-add-custom-command-right/3229 "2021-04-30T12:06:04Z")

</div>

Hi there, I am quite new to CMake and can see some weird benaviors. Also I could see similar issues of people to this kind of problem but could not see a good solution. Hopefully, someone can help. Suppose I use add\_c…

---

## [Evaluate $\<JOIN:\> with another generator expression as the glue](https://discourse.cmake.org/t/evaluate-join-with-another-generator-expression-as-the-glue/3231)

<div class="topic-metadata">

**Author:** [@alcroito](https://discourse.cmake.org/u/alcroito)\
**Replies:** 7\
**Last updated:** [April 29, 2021, 10:05am UTC](https://discourse.cmake.org/t/evaluate-join-with-another-generator-expression-as-the-glue/3231 "2021-04-29T10:05:33Z")

</div>

Consider the following project which tries to create a JOIN genex which uses $\<TARGET\_PROPERTY\> as glue cmake\_minimum\_required(VERSION 3.16) project(proj LANGUAGES CXX) set(source "${CMAKE\_CURRENT\_BINARY\_DIR}/source.c…

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

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