# Usage

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

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

**Page:** 44

---

## [Inclusion of CMAKE\_CUDA\_IMPLICIT\_LINK\_DIRECTORIES](https://discourse.cmake.org/t/inclusion-of-cmake-cuda-implicit-link-directories/8357)

<div class="topic-metadata">

**Author:** [@jnc](https://discourse.cmake.org/u/jnc)\
**Replies:** 2\
**Last updated:** [June 20, 2023, 3:30pm UTC](https://discourse.cmake.org/t/inclusion-of-cmake-cuda-implicit-link-directories/8357 "2023-06-20T15:30:28Z")

</div>

Hi, I have a simple project relaying on some cuda libraries, using a slightly older cmake (3.25). I have found that the inclusion of the CMAKE\_CUDA\_IMPLICIT\_LINK\_DIRECTORIES in the linker command is only done by CMake w…

---

## [setting fortran language standard](https://discourse.cmake.org/t/setting-fortran-language-standard/8351)

<div class="topic-metadata">

**Author:** [@wolfman21](https://discourse.cmake.org/u/wolfman21)\
**Replies:** 2\
**Last updated:** [June 19, 2023, 3:35pm UTC](https://discourse.cmake.org/t/setting-fortran-language-standard/8351 "2023-06-19T15:35:13Z")

</div>

Hello, GFortran supports passing the Fortran standard via -std=\[f95|f2003|f2008|...\] Is there a correct way to do this in CMake? It appears that Fortran isn’t supported as a language in: https://cmake.org/cmake/help…

---

## [using Visual Studio 2022 Generator's install target](https://discourse.cmake.org/t/using-visual-studio-2022-generators-install-target/8335)

<div class="topic-metadata">

**Author:** [@jrb](https://discourse.cmake.org/u/jrb)\
**Replies:** 2\
**Last updated:** [June 18, 2023, 12:02am UTC](https://discourse.cmake.org/t/using-visual-studio-2022-generators-install-target/8335 "2023-06-18T00:02:39Z")

</div>

Hi, I just used the VS 2022 generator for the first time (3.26.4 and the vs bundled 3.64.0-msvc3) and I see the targets have a new layout when I open the solution. I have used cmake for many years. I see that I no longe…

---

## [Best practice to manage collection of projects](https://discourse.cmake.org/t/best-practice-to-manage-collection-of-projects/8330)

<div class="topic-metadata">

**Author:** [@menno](https://discourse.cmake.org/u/menno)\
**Replies:** 2\
**Last updated:** [June 17, 2023, 10:49pm UTC](https://discourse.cmake.org/t/best-practice-to-manage-collection-of-projects/8330 "2023-06-17T22:49:35Z")

</div>

We have a number of different CMake projects, each representing a set of tests for our code. Each project uses the same build target names (preprocess, compute, postprocess and others) to perform said steps of the set of…

---

## [Can a CMake target name ever be an actual file?](https://discourse.cmake.org/t/can-a-cmake-target-name-ever-be-an-actual-file/8323)

<div class="topic-metadata">

**Author:** [@dtgriscom](https://discourse.cmake.org/u/dtgriscom)\
**Replies:** 1\
**Last updated:** [June 17, 2023, 9:26pm UTC](https://discourse.cmake.org/t/can-a-cmake-target-name-ever-be-an-actual-file/8323 "2023-06-17T21:26:10Z")

</div>

I teethed on Makefiles, where by default a target name is an actual file (although you can have a .PHONY target that is independent of any like-named file). I’m writing a custom CMake function which processes some input…

---

## [CMAKE\_WINDOWS\_EXPORT\_ALL\_SYMBOLS exports "=="](https://discourse.cmake.org/t/cmake-windows-export-all-symbols-exports/8314)

<div class="topic-metadata">

**Author:** [@Ohjurot](https://discourse.cmake.org/u/Ohjurot)\
**Replies:** 3\
**Last updated:** [June 17, 2023, 8:58pm UTC](https://discourse.cmake.org/t/cmake-windows-export-all-symbols-exports/8314 "2023-06-17T20:58:06Z")

</div>

Hello, I’m currently migrating an Open Source lib into a package manager using CMake. During my testing, I found that CMake exports “==” to “exports.def” when using CMAKE\_WINDOWS\_EXPORT\_ALL\_SYMBOLS (Required in the cur…

---

## [\[CTest\] best practice for running tests on a cluster](https://discourse.cmake.org/t/ctest-best-practice-for-running-tests-on-a-cluster/7202)

<div class="topic-metadata">

**Author:** [@menno](https://discourse.cmake.org/u/menno)\
**Replies:** 3\
**Last updated:** [June 16, 2023, 1:05pm UTC](https://discourse.cmake.org/t/ctest-best-practice-for-running-tests-on-a-cluster/7202 "2023-06-16T13:05:22Z")

</div>

I’m wondering what the best way to run tests on a cluster would be when I use CTest. The objective is to run a number of tests on the compute nodes of a cluster that has the SLURM resource aanager. Any tips are welcome …

---

## [How to get the packaging directory in a CPACK\_PRE\_BUILD\_SCRIPTS ?](https://discourse.cmake.org/t/how-to-get-the-packaging-directory-in-a-cpack-pre-build-scripts/8339)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 4\
**Last updated:** [June 15, 2023, 9:57pm UTC](https://discourse.cmake.org/t/how-to-get-the-packaging-directory-in-a-cpack-pre-build-scripts/8339 "2023-06-15T21:57:26Z")

</div>

Hi, when creating a package, I’d like to run some commands on the installed, but not yet packaged executables. in the scripts in CPACK\_INSTALL\_SCRIPTS there is the variable CMAKE\_INSTALL\_PREFIX set to the directory whe…

---

## [Running tests for a library tries and fails to run tests for dependencies](https://discourse.cmake.org/t/running-tests-for-a-library-tries-and-fails-to-run-tests-for-dependencies/8332)

<div class="topic-metadata">

**Author:** [@rbartling](https://discourse.cmake.org/u/rbartling)\
**Replies:** 2\
**Last updated:** [June 15, 2023, 6:32pm UTC](https://discourse.cmake.org/t/running-tests-for-a-library-tries-and-fails-to-run-tests-for-dependencies/8332 "2023-06-15T18:32:23Z")

</div>

My preference would be that if A depends upon B, then running the tests in A would not try to run the tests in B. Here’s the CMakeList. THe one for the dependency lib is basically the same. cmake\_minimum\_required(VERS…

---

## [CMakeLists - AddExternalProject cmake is not run correctly](https://discourse.cmake.org/t/cmakelists-addexternalproject-cmake-is-not-run-correctly/8307)

<div class="topic-metadata">

**Author:** [@FlorianBrueck](https://discourse.cmake.org/u/FlorianBrueck)\
**Replies:** 3\
**Last updated:** [June 12, 2023, 9:39pm UTC](https://discourse.cmake.org/t/cmakelists-addexternalproject-cmake-is-not-run-correctly/8307 "2023-06-12T21:39:36Z")

</div>

Hi! I am currently trying to add an external library to my project using AddExternalProject, but it does not seem to run cmake for the external project correctly (I don’t see cmake being run when I use CMAKE\_VERBOSE\_MAK…

---

## [Newest CMake not available from apt.kitware.com for Ubuntu 18.04](https://discourse.cmake.org/t/newest-cmake-not-available-from-apt-kitware-com-for-ubuntu-18-04/8272)

<div class="topic-metadata">

**Author:** [@jnc](https://discourse.cmake.org/u/jnc)\
**Replies:** 4\
**Last updated:** [June 8, 2023, 4:03pm UTC](https://discourse.cmake.org/t/newest-cmake-not-available-from-apt-kitware-com-for-ubuntu-18-04/8272 "2023-06-08T16:03:47Z")

</div>

Hi, I use the deb packages distributed via apt.kitware.com to get the latest CMake versions in Ubuntu LTS (18.04, 20.04 and 22.04). For Ubuntu 2x0.4, the latest is available, but not for 18.04 which only has up to 3.25.…

---

## [How to create different types of packages with CPack?](https://discourse.cmake.org/t/how-to-create-different-types-of-packages-with-cpack/8282)

<div class="topic-metadata">

**Author:** [@mojca](https://discourse.cmake.org/u/mojca)\
**Replies:** 1\
**Last updated:** [June 8, 2023, 11:48am UTC](https://discourse.cmake.org/t/how-to-create-different-types-of-packages-with-cpack/8282 "2023-06-08T11:48:05Z")

</div>

I like the way CPack works. If I want to create Debian and NSIS packages, I just tell it which components to include. What I didn’t yet manage to figure out is whether I could create multiple different kinds of packages…

---

## [Generator expression not evaluated](https://discourse.cmake.org/t/generator-expression-not-evaluated/8264)

<div class="topic-metadata">

**Author:** [@Panu](https://discourse.cmake.org/u/Panu)\
**Replies:** 4\
**Last updated:** [June 8, 2023, 8:32am UTC](https://discourse.cmake.org/t/generator-expression-not-evaluated/8264 "2023-06-08T08:32:42Z")

</div>

Is this supposed to work: cmake\_minimum\_required(VERSION 3.25) project(TEST) add\_executable(test\_ext dummy.cpp) add\_library(lib\_a STATIC dummy.cpp) add\_library(lib\_b STATIC dummy.cpp) target\_link\_libraries(lib\_a …

---

## [CMake precompile header issue](https://discourse.cmake.org/t/cmake-precompile-header-issue/8243)

<div class="topic-metadata">

**Author:** [@magisu](https://discourse.cmake.org/u/magisu)\
**Replies:** 4\
**Last updated:** [June 7, 2023, 8:40pm UTC](https://discourse.cmake.org/t/cmake-precompile-header-issue/8243 "2023-06-07T20:40:12Z")

</div>

I have the following header files h1.h #ifndef \_\_HEADER1\_\_ #define \_\_HEADER1\_\_ #include \<iostream\> #include \<string\> class Coupler { private: const std::string file; const int line; public: Coupler(const std::stri…

---

## [Concurrency issue during configuration step ? (\`No CMAKE\_OBJCXX\_COMPILER could be found.\`)](https://discourse.cmake.org/t/concurrency-issue-during-configuration-step-no-cmake-objcxx-compiler-could-be-found/8245)

<div class="topic-metadata">

**Author:** [@tonygo](https://discourse.cmake.org/u/tonygo)\
**Replies:** 5\
**Last updated:** [June 7, 2023, 12:32pm UTC](https://discourse.cmake.org/t/concurrency-issue-during-configuration-step-no-cmake-objcxx-compiler-could-be-found/8245 "2023-06-07T12:32:07Z")

</div>

Hi people :wave: My current challenge is to enable parallelization for an e2e tests suite. The fun part is that what we test is also based on CMake. So each test will run the cmake configure command. Before paralleliz…

---

## [CMAKE\_MFC\_FLAG for individual targets?](https://discourse.cmake.org/t/cmake-mfc-flag-for-individual-targets/8262)

<div class="topic-metadata">

**Author:** [@johan556](https://discourse.cmake.org/u/johan556)\
**Replies:** 1\
**Last updated:** [June 7, 2023, 12:07pm UTC](https://discourse.cmake.org/t/cmake-mfc-flag-for-individual-targets/8262 "2023-06-07T12:07:48Z")

</div>

There is a CMake variable CMAKE\_MFC\_FLAG that affects how an EXE/DLL links with Microsoft Foundation Class library (e.g. dynamic / static). Unlike many other variables, there seem to be no corresponding target property …

---

## [Portable way to set filepaths in presets](https://discourse.cmake.org/t/portable-way-to-set-filepaths-in-presets/7892)

<div class="topic-metadata">

**Author:** [@abdelmaged](https://discourse.cmake.org/u/abdelmaged)\
**Replies:** 2\
**Last updated:** [June 6, 2023, 1:05pm UTC](https://discourse.cmake.org/t/portable-way-to-set-filepaths-in-presets/7892 "2023-06-06T13:05:06Z")

</div>

Is there a portable way to set filepath variables in presets ? Intention is to have one preset common between Linux & Windows platforms with the same name, the only difference is in some of the specified file paths, i.e…

---

## [What is the correct way to write a find module?](https://discourse.cmake.org/t/what-is-the-correct-way-to-write-a-find-module/8168)

<div class="topic-metadata">

**Author:** [@Barry\_Revzin](https://discourse.cmake.org/u/Barry_Revzin)\
**Replies:** 12\
**Last updated:** [May 31, 2023, 6:00pm UTC](https://discourse.cmake.org/t/what-is-the-correct-way-to-write-a-find-module/8168 "2023-05-31T18:00:36Z")

</div>

I can’t seem to find any information on how to do this. Here’s a concrete example I have in mind. I would like to build {fmt}, from source, in my project, with some specific flags (specifically with -fPIC). I’m currentl…

---

## [Can we compile Azure IoT C SDK for ArmV4I platform?](https://discourse.cmake.org/t/can-we-compile-azure-iot-c-sdk-for-armv4i-platform/8217)

<div class="topic-metadata">

**Author:** [@edwin](https://discourse.cmake.org/u/edwin)\
**Replies:** 3\
**Last updated:** [May 30, 2023, 12:35pm UTC](https://discourse.cmake.org/t/can-we-compile-azure-iot-c-sdk-for-armv4i-platform/8217 "2023-05-30T12:35:09Z")

</div>

I’m currently trying to compile the Azure IoT C SDK in ArmV4I. My system can’t be modified or upgraded and the different solutions on internet to compile only Arm (ArmV7) doesn’t match with my machine. Machine specs : C…

---

## [How to get final list of linked static libraries ?](https://discourse.cmake.org/t/how-to-get-final-list-of-linked-static-libraries/8222)

<div class="topic-metadata">

**Author:** [@abdelmaged](https://discourse.cmake.org/u/abdelmaged)\
**Replies:** 2\
**Last updated:** [May 29, 2023, 6:16pm UTC](https://discourse.cmake.org/t/how-to-get-final-list-of-linked-static-libraries/8222 "2023-05-29T18:16:04Z")

</div>

I’d like to get final list of linked static libraries for a shared library target, and do some extra processing on this list. How can I achieve this ? I’ve already done some search, but didn’t found concrete answer: …

---

## [CMake -Werror flag removal logic may break ABI detection](https://discourse.cmake.org/t/cmake-werror-flag-removal-logic-may-break-abi-detection/8230)

<div class="topic-metadata">

**Author:** [@nowitshistory](https://discourse.cmake.org/u/nowitshistory)\
**Replies:** 2\
**Last updated:** [May 29, 2023, 2:29pm UTC](https://discourse.cmake.org/t/cmake-werror-flag-removal-logic-may-break-abi-detection/8230 "2023-05-29T14:29:23Z")

</div>

CMake compiles a temporary C program to detect values for CMAKE\_SIZEOF\_VOID\_P and other variables. I have a toolchain file that defined the linker flag -pie for executable targets and for the temporary program to compil…

---

## [add\_custom\_command rebuilds every time](https://discourse.cmake.org/t/add-custom-command-rebuilds-every-time/8213)

<div class="topic-metadata">

**Author:** [@Pospelove](https://discourse.cmake.org/u/Pospelove)\
**Replies:** 2\
**Last updated:** [May 29, 2023, 1:09pm UTC](https://discourse.cmake.org/t/add-custom-command-rebuilds-every-time/8213 "2023-05-29T13:09:53Z")

</div>

Dear CMake forums folks, I run into issues with add\_custom\_command. I’d kindly appreciate if you give me a direction. The issue is that the target rebuilds every time, regardless of dependencies. Expected behavior, th…

---

## [gmake error](https://discourse.cmake.org/t/gmake-error/8042)

<div class="topic-metadata">

**Author:** [@luis.mendez.ctr](https://discourse.cmake.org/u/luis.mendez.ctr)\
**Replies:** 20\
**Last updated:** [May 24, 2023, 11:08pm UTC](https://discourse.cmake.org/t/gmake-error/8042 "2023-05-24T23:08:10Z")

</div>

I am currently in the middle of installing CMake and after doing so, I have to run the “gmake” command. When I do that, here is where it stops and I don’t know what to do now. \[90%\] Linking CXX executable ../bin/cte…

---

## [How to conditionally call either \`find\_pacakge()\` or \`find\_dependency()\`?](https://discourse.cmake.org/t/how-to-conditionally-call-either-find-pacakge-or-find-dependency/8175)

<div class="topic-metadata">

**Author:** [@ton](https://discourse.cmake.org/u/ton)\
**Replies:** 2\
**Last updated:** [May 22, 2023, 12:43pm UTC](https://discourse.cmake.org/t/how-to-conditionally-call-either-find-pacakge-or-find-dependency/8175 "2023-05-22T12:43:36Z")

</div>

We have a library that depends on various third-party libraries. These dependencies are generally found using find\_package in the project’s main CMake file. To avoid having to write these dependencies twice, in the main…

---

## [Creating a minimal CMake template for C(++), running into issues as I learn CMake](https://discourse.cmake.org/t/creating-a-minimal-cmake-template-for-c-running-into-issues-as-i-learn-cmake/8157)

<div class="topic-metadata">

**Author:** [@rbartling](https://discourse.cmake.org/u/rbartling)\
**Replies:** 0\
**Last updated:** [May 18, 2023, 5:07pm UTC](https://discourse.cmake.org/t/creating-a-minimal-cmake-template-for-c-running-into-issues-as-i-learn-cmake/8157 "2023-05-18T17:07:30Z")

</div>

I work with a few electrical engineers and am looking for ways to make it easier for them to write tests for the code they write, so I’m trying to create a template that covers a few basics with minimal setup on Windows.…

---

## [Unable to set compiler using windows](https://discourse.cmake.org/t/unable-to-set-compiler-using-windows/8137)

<div class="topic-metadata">

**Author:** [@rbartling](https://discourse.cmake.org/u/rbartling)\
**Replies:** 3\
**Last updated:** [May 18, 2023, 4:40pm UTC](https://discourse.cmake.org/t/unable-to-set-compiler-using-windows/8137 "2023-05-18T16:40:31Z")

</div>

I have CC and CXX set to clang and clang++, however CMAKE is using MSVC instead. I’ve scoured stack overflow and other places and can’t seem to find anyone else running into this problem. ///c\_template on  master …

---

## [CMake Authenticated Download From Artifactory](https://discourse.cmake.org/t/cmake-authenticated-download-from-artifactory/8148)

<div class="topic-metadata">

**Author:** [@cmacd122](https://discourse.cmake.org/u/cmacd122)\
**Replies:** 3\
**Last updated:** [May 18, 2023, 12:16pm UTC](https://discourse.cmake.org/t/cmake-authenticated-download-from-artifactory/8148 "2023-05-18T12:16:49Z")

</div>

I have been trying to perform an authenticated download using the ‘file’ command. I have tried setting up the HTTPHEADER option several ways: First with a token: set(ART\_HEADER “"Authorization: Bearer mytoken"”) and …

---

## [Error when I open CMake as a new project in Visual Studio](https://discourse.cmake.org/t/error-when-i-open-cmake-as-a-new-project-in-visual-studio/8141)

<div class="topic-metadata">

**Author:** [@Robert180](https://discourse.cmake.org/u/Robert180)\
**Replies:** 4\
**Last updated:** [May 18, 2023, 12:05pm UTC](https://discourse.cmake.org/t/error-when-i-open-cmake-as-a-new-project-in-visual-studio/8141 "2023-05-18T12:05:57Z")

</div>

When I open CMake in Visual Studio 2022 , I got this error: CMake Error at C: /VisualStudio/Common7 / IDE / CommonExtensions / Microsoft / CMake / CMake / share / cmake - 3.25 / Modules / CMakeTestCCompiler.cmake: 70(me…

---

## [Visual Studio natvis files in ITK](https://discourse.cmake.org/t/visual-studio-natvis-files-in-itk/8145)

<div class="topic-metadata">

**Author:** [@dzenanz](https://discourse.cmake.org/u/dzenanz)\
**Replies:** 5\
**Last updated:** [May 18, 2023, 12:04pm UTC](https://discourse.cmake.org/t/visual-studio-natvis-files-in-itk/8145 "2023-05-18T12:04:49Z")

</div>

I am trying to embed ITK’s natvis file in to the debug database, as per /NATVIS linker option and Add a .natvis file to a C++ project. My branch with a very small commit is here. As far as I can tell, it is not working, …

---

## [checking if installation script is launch in a terminal](https://discourse.cmake.org/t/checking-if-installation-script-is-launch-in-a-terminal/8134)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 3\
**Last updated:** [May 17, 2023, 11:44am UTC](https://discourse.cmake.org/t/checking-if-installation-script-is-launch-in-a-terminal/8134 "2023-05-17T11:44:49Z")

</div>

Hi, on installing a target, I launch a cmake script (set with install(SCRIPT...) which, in turn launch shell scripts (with execute\_process) in order to prompt the user for some “last minute” input. Yet if my installatio…

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

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