# Usage

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

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

**Page:** 15

---

## [Using a compiler cache on Windows with MSVC?](https://discourse.cmake.org/t/using-a-compiler-cache-on-windows-with-msvc/13694)

<div class="topic-metadata">

**Author:** [@exoosh](https://discourse.cmake.org/u/exoosh)\
**Replies:** 2\
**Last updated:** [March 7, 2025, 2:24pm UTC](https://discourse.cmake.org/t/using-a-compiler-cache-on-windows-with-msvc/13694 "2025-03-07T14:24:07Z")

</div>

Hi, the documentation of \<LANG\>\_COMPILER\_LAUNCHER suggests — although not in very explicit terms — that only Unix Makefiles and Ninja are supported for this property: Specify a semicolon-separated list containing a co…

---

## [How to run script AFTER \*.pbxproj is generated?](https://discourse.cmake.org/t/how-to-run-script-after-pbxproj-is-generated/13675)

<div class="topic-metadata">

**Author:** [@shokarta](https://discourse.cmake.org/u/shokarta)\
**Replies:** 4\
**Last updated:** [March 6, 2025, 4:32pm UTC](https://discourse.cmake.org/t/how-to-run-script-after-pbxproj-is-generated/13675 "2025-03-06T16:32:05Z")

</div>

0 basicaly I made a shell script which I need to run always when cmake finish configuration and its after generation phase (so when pbxproj is generated). so far i tried add\_custom\_command() which does not do anything,…

---

## [How to see what steps are run by cmake --workflow xxx?](https://discourse.cmake.org/t/how-to-see-what-steps-are-run-by-cmake-workflow-xxx/13684)

<div class="topic-metadata">

**Author:** [@Gary\_Oberbrunner](https://discourse.cmake.org/u/Gary_Oberbrunner)\
**Replies:** 1\
**Last updated:** [March 6, 2025, 7:44am UTC](https://discourse.cmake.org/t/how-to-see-what-steps-are-run-by-cmake-workflow-xxx/13684 "2025-03-06T07:44:02Z")

</div>

I understand you can’t pass additional args like --trace when using cmake --workflow foo. But I really would like to see what actual cmake commands the workflow is issuing, since my workflow results differ when I just us…

---

## [variables for cross-platform code?](https://discourse.cmake.org/t/variables-for-cross-platform-code/10115)

<div class="topic-metadata">

**Author:** [@dabrahams](https://discourse.cmake.org/u/dabrahams)\
**Replies:** 17\
**Last updated:** [March 5, 2025, 5:09pm UTC](https://discourse.cmake.org/t/variables-for-cross-platform-code/10115 "2025-03-05T17:09:54Z")

</div>

I find myself writing this kind of thing repeatedly. if(CMAKE\_HOST\_SYSTEM\_NAME STREQUAL "Windows") set(path\_separator ";") else() set(path\_separator ":") endif() if(CMAKE\_HOST\_SYSTEM\_NAME ST…

---

## [Forcing CMake to output link.txt for executable?](https://discourse.cmake.org/t/forcing-cmake-to-output-link-txt-for-executable/13669)

<div class="topic-metadata">

**Author:** [@sdbbs](https://discourse.cmake.org/u/sdbbs)\
**Replies:** 2\
**Last updated:** [March 5, 2025, 12:25pm UTC](https://discourse.cmake.org/t/forcing-cmake-to-output-link-txt-for-executable/13669 "2025-03-05T12:25:34Z")

</div>

I was developing a project of mine on Ubuntu 22, with: $ cmake --version | head -1 cmake version 3.22.1 I noticed there, that there is a link.txt for both of my executables from the project, as well as for many other l…

---

## [TARGET\_RUNTIME\_DLLS for Linux?](https://discourse.cmake.org/t/target-runtime-dlls-for-linux/13673)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 0\
**Last updated:** [March 5, 2025, 8:31am UTC](https://discourse.cmake.org/t/target-runtime-dlls-for-linux/13673 "2025-03-05T08:31:01Z")

</div>

Hi there, There is $\<TARGET\_RUNTIME\_DLLS:tgt\> and $\<TARGET\_RUNTIME\_DLL\_DIRS:tgt\> which is useful when executing you own built binary and need to make the dlls it needs available in PATH. I am wondering, why these thing…

---

## [Listing available targets with cmake ?](https://discourse.cmake.org/t/listing-available-targets-with-cmake/10855)

<div class="topic-metadata">

**Author:** [@neundorf](https://discourse.cmake.org/u/neundorf)\
**Replies:** 3\
**Last updated:** [March 4, 2025, 9:18am UTC](https://discourse.cmake.org/t/listing-available-targets-with-cmake/10855 "2025-03-04T09:18:45Z")

</div>

Hi, I can use cmake from the command line to configure a project, to build it and to install it. But is there a way to list all buildable targets ? When using makefiles, I can do “make help”, with ninja I can do “ninj…

---

## [Adding gtest test to a CONFIGURATION](https://discourse.cmake.org/t/adding-gtest-test-to-a-configuration/10511)

<div class="topic-metadata">

**Author:** [@KUGA2](https://discourse.cmake.org/u/KUGA2)\
**Replies:** 1\
**Last updated:** [March 4, 2025, 9:02am UTC](https://discourse.cmake.org/t/adding-gtest-test-to-a-configuration/10511 "2025-03-04T09:02:23Z")

</div>

Am I right, that you cannot add gtest testcase to a test configuration using gtest\_add\_tests()? It does not have any argument for CONFIGURATION and CONFIGURATION is not a test property I can manually add.

---

## [Compiler program installed in Windows cannot recognize file path generated by Cmake in Cygwin.](https://discourse.cmake.org/t/compiler-program-installed-in-windows-cannot-recognize-file-path-generated-by-cmake-in-cygwin/8369)

<div class="topic-metadata">

**Author:** [@focusfeel](https://discourse.cmake.org/u/focusfeel)\
**Replies:** 2\
**Last updated:** [February 28, 2025, 5:53pm UTC](https://discourse.cmake.org/t/compiler-program-installed-in-windows-cannot-recognize-file-path-generated-by-cmake-in-cygwin/8369 "2025-02-28T17:53:18Z")

</div>

Environment description: Cmake and Ninja installed in Cygwin Compiler program (like mingw-gcc) installed in Windows When I use cmake in cygwin to build a project, it will go error when running try-compile project for …

---

## [Using optimization flags with \`CC\` (PrgEnv-gnu)](https://discourse.cmake.org/t/using-optimization-flags-with-cc-prgenv-gnu/13642)

<div class="topic-metadata">

**Author:** [@wme7](https://discourse.cmake.org/u/wme7)\
**Replies:** 0\
**Last updated:** [February 26, 2025, 9:25pm UTC](https://discourse.cmake.org/t/using-optimization-flags-with-cc-prgenv-gnu/13642 "2025-02-26T21:25:52Z")

</div>

Nob questions here: I recall during my HPE training that Cray Compilers Wrappers automatically pass architecture-specific flags to the underlying (gcc, clang or intel) compilers. But I came cross some examples with CMa…

---

## [CMake target\_include\_directories doesn't export to compile\_commands.json when using CUDA](https://discourse.cmake.org/t/cmake-target-include-directories-doesnt-export-to-compile-commands-json-when-using-cuda/10072)

<div class="topic-metadata">

**Author:** [@SidYaj](https://discourse.cmake.org/u/SidYaj)\
**Replies:** 11\
**Last updated:** [February 27, 2025, 7:07am UTC](https://discourse.cmake.org/t/cmake-target-include-directories-doesnt-export-to-compile-commands-json-when-using-cuda/10072 "2025-02-27T07:07:34Z")

</div>

I am trying to use CMake to build a CUDA project. However, when I use add\_library followed by target\_include\_directories, the relevant commands are not updated in the compile\_commands.json file. The structure of the p…

---

## [cmake offline build - how to pre-populate source dependencies in the build tree](https://discourse.cmake.org/t/cmake-offline-build-how-to-pre-populate-source-dependencies-in-the-build-tree/13173)

<div class="topic-metadata">

**Author:** [@s837jhc](https://discourse.cmake.org/u/s837jhc)\
**Replies:** 2\
**Last updated:** [February 24, 2025, 4:51pm UTC](https://discourse.cmake.org/t/cmake-offline-build-how-to-pre-populate-source-dependencies-in-the-build-tree/13173 "2025-02-24T16:51:01Z")

</div>

I am trying to build a project while offline. The project is sol2, but the question is more general. Using that project as an example to talk to in a response here is fine, but I am more interested in the general “cmake…

---

## [using Catch2 test detection when test binary is output outside the build tree](https://discourse.cmake.org/t/using-catch2-test-detection-when-test-binary-is-output-outside-the-build-tree/13340)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 4\
**Last updated:** [February 22, 2025, 2:54am UTC](https://discourse.cmake.org/t/using-catch2-test-detection-when-test-binary-is-output-outside-the-build-tree/13340 "2025-02-22T02:54:35Z")

</div>

Hi, I’m using the devel branch of Catch2 and can run simple tests using Catch2 directly. Now I tried to configure CTest for my project, using Catch2 automation: include(CTest) include(Catch) catch\_discover\_tests(${TAR…

---

## [correctly setting symbol visibility for shared libraries](https://discourse.cmake.org/t/correctly-setting-symbol-visibility-for-shared-libraries/13604)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 3\
**Last updated:** [February 19, 2025, 1:44pm UTC](https://discourse.cmake.org/t/correctly-setting-symbol-visibility-for-shared-libraries/13604 "2025-02-19T13:44:24Z")

</div>

I’m currently using include(GenerateExportHeader) generate\_export\_header(${THALIA\_TARGET\_NAME}) in order to generate \<MyTarget\>\_EXPORT macro for managing my library symbols visibility. By default, it resolve by defaul…

---

## [How to add a third party lib to a lib built by cmake and get a new lib as output?](https://discourse.cmake.org/t/how-to-add-a-third-party-lib-to-a-lib-built-by-cmake-and-get-a-new-lib-as-output/13605)

<div class="topic-metadata">

**Author:** [@leso](https://discourse.cmake.org/u/leso)\
**Replies:** 0\
**Last updated:** [February 19, 2025, 1:46pm UTC](https://discourse.cmake.org/t/how-to-add-a-third-party-lib-to-a-lib-built-by-cmake-and-get-a-new-lib-as-output/13605 "2025-02-19T13:46:25Z")

</div>

When I search online for this matter I only see how to link libs together with the target\_link\_libraries() function. My understanding is that this will link the libs and produce an executable as output. I want to to have…

---

## [Identifying the CMakeConfig.h File](https://discourse.cmake.org/t/identifying-the-cmakeconfig-h-file/13591)

<div class="topic-metadata">

**Author:** [@Lisa\_Schaefer\_Fujits](https://discourse.cmake.org/u/Lisa_Schaefer_Fujits)\
**Replies:** 3\
**Last updated:** [February 19, 2025, 4:05am UTC](https://discourse.cmake.org/t/identifying-the-cmakeconfig-h-file/13591 "2025-02-19T04:05:39Z")

</div>

I am trying to identify the CMakeConfig.h.in file in every GitHub project dynamically. This file is sometimes also named something like projectName-config.h.cmake. The only method I know so far to identify such a file i…

---

## [Test errors on CMake 3.27.9 and Linux Mint 21.3](https://discourse.cmake.org/t/test-errors-on-cmake-3-27-9-and-linux-mint-21-3/13594)

<div class="topic-metadata">

**Author:** [@nestor](https://discourse.cmake.org/u/nestor)\
**Replies:** 0\
**Last updated:** [February 17, 2025, 2:59pm UTC](https://discourse.cmake.org/t/test-errors-on-cmake-3-27-9-and-linux-mint-21-3/13594 "2025-02-17T14:59:00Z")

</div>

I am building cmake 3.27.9 for Linux Mint 21.3 (Ubuntu Jammy), but I find some errors when executing the tests with ctest. I attach the log file for ../../ctest --output-on-failure \> ~/ctest\_log2.txt 2\>&1 (ctest version …

---

## [Creating a library split into multiple sub-modules](https://discourse.cmake.org/t/creating-a-library-split-into-multiple-sub-modules/13569)

<div class="topic-metadata">

**Author:** [@Tapiwa\_Zimunhu](https://discourse.cmake.org/u/Tapiwa_Zimunhu)\
**Replies:** 1\
**Last updated:** [February 17, 2025, 11:21am UTC](https://discourse.cmake.org/t/creating-a-library-split-into-multiple-sub-modules/13569 "2025-02-17T11:21:05Z")

</div>

I’m trying to create a huge library and have decided to modularize that project by developing it component by component so that I can easily test and develop each component separately. But in the end all these component…

---

## [pkg\_check\_modules problem finding libsc as dependency for p4est](https://discourse.cmake.org/t/pkg-check-modules-problem-finding-libsc-as-dependency-for-p4est/13580)

<div class="topic-metadata">

**Author:** [@dom](https://discourse.cmake.org/u/dom)\
**Replies:** 0\
**Last updated:** [February 14, 2025, 6:31pm UTC](https://discourse.cmake.org/t/pkg-check-modules-problem-finding-libsc-as-dependency-for-p4est/13580 "2025-02-14T18:31:56Z")

</div>

Hi, I installed p4est, which creates the following pkg-config files: cat /home/dom/prod/spack-stack-20250128/envs/ne-gcc-13.3.1/install/gcc/13.3.1/p4est-2.8-buexbce/lib/pkgconfig/p4est-2.8.pc prefix=/home/dom/prod/sp…

---

## [precompilation macros from CSV file](https://discourse.cmake.org/t/precompilation-macros-from-csv-file/13367)

<div class="topic-metadata">

**Author:** [@CarlosDelfino](https://discourse.cmake.org/u/CarlosDelfino)\
**Replies:** 4\
**Last updated:** [February 13, 2025, 3:17am UTC](https://discourse.cmake.org/t/precompilation-macros-from-csv-file/13367 "2025-02-13T03:17:15Z")

</div>

I’m starting out in the professional world of firmware, and I’m having my first contact with CMake and Ninja. I need to read a CSV file, which is composed of information in the following format: Serial, Module A, Modul…

---

## [How to suppress the preprocessor define CMAKE\_INTDIR?](https://discourse.cmake.org/t/how-to-suppress-the-preprocessor-define-cmake-intdir/13551)

<div class="topic-metadata">

**Author:** [@exoosh](https://discourse.cmake.org/u/exoosh)\
**Replies:** 0\
**Last updated:** [February 7, 2025, 3:54pm UTC](https://discourse.cmake.org/t/how-to-suppress-the-preprocessor-define-cmake-intdir/13551 "2025-02-07T15:54:47Z")

</div>

Hi, how can I suppress the preprocessor define CMAKE\_INTDIR? I understand it appears in multi-config builds, I can appreciate the thoughts behind it (CMAKE\_CFG\_INTDIR). I don’t want it. It serves no purpose in my build…

---

## [Looking for clarity on using find\_package with a dylib and xcframework in same directory.](https://discourse.cmake.org/t/looking-for-clarity-on-using-find-package-with-a-dylib-and-xcframework-in-same-directory/13545)

<div class="topic-metadata">

**Author:** [@externl](https://discourse.cmake.org/u/externl)\
**Replies:** 2\
**Last updated:** [February 7, 2025, 3:04pm UTC](https://discourse.cmake.org/t/looking-for-clarity-on-using-find-package-with-a-dylib-and-xcframework-in-same-directory/13545 "2025-02-07T15:04:21Z")

</div>

Hello, Sorry if this should be obvious but I’m relatively new to cmake and haven’t been able to find a clean solution to my issue. I’m trying to create some imported targets for an installation of a library on my syste…

---

## [Linux DSO-\>Static-\>DSO link impasse](https://discourse.cmake.org/t/linux-dso-static-dso-link-impasse/13543)

<div class="topic-metadata">

**Author:** [@wdezell](https://discourse.cmake.org/u/wdezell)\
**Replies:** 0\
**Last updated:** [February 5, 2025, 7:26pm UTC](https://discourse.cmake.org/t/linux-dso-static-dso-link-impasse/13543 "2025-02-05T19:26:19Z")

</div>

BG We have a product in the late stages of development, the architecture of which implements hardware/functionality support as plugins loaded at startup (impl via Boost::DLL). Hardware support vendor drivers are typica…

---

## [Should you use install components from a FetchContent subproject?](https://discourse.cmake.org/t/should-you-use-install-components-from-a-fetchcontent-subproject/13542)

<div class="topic-metadata">

**Author:** [@SamCoutteauHybrid](https://discourse.cmake.org/u/SamCoutteauHybrid)\
**Replies:** 0\
**Last updated:** [February 5, 2025, 3:49pm UTC](https://discourse.cmake.org/t/should-you-use-install-components-from-a-fetchcontent-subproject/13542 "2025-02-05T15:49:37Z")

</div>

In general is it a good idea to use install components defined inside a project consumed via FetchContent?, should that project even define those components when it isn’t the top level project? (Context: All libraries a…

---

## [Cmake preset, configure condition on specific compiler found?](https://discourse.cmake.org/t/cmake-preset-configure-condition-on-specific-compiler-found/13541)

<div class="topic-metadata">

**Author:** [@MickeJ](https://discourse.cmake.org/u/MickeJ)\
**Replies:** 0\
**Last updated:** [February 5, 2025, 2:57pm UTC](https://discourse.cmake.org/t/cmake-preset-configure-condition-on-specific-compiler-found/13541 "2025-02-05T14:57:12Z")

</div>

Hi, I have a project that requires g++ compiler but provides additional features if/when using Clang and Oneapi DPC compilers. Because only gcc compiler is required I want to hide clang and oneapi configure alternatives…

---

## [FindOpenSSL slow and not cached on Windows ?](https://discourse.cmake.org/t/findopenssl-slow-and-not-cached-on-windows/13532)

<div class="topic-metadata">

**Author:** [@pcorbineau](https://discourse.cmake.org/u/pcorbineau)\
**Replies:** 2\
**Last updated:** [February 5, 2025, 8:09am UTC](https://discourse.cmake.org/t/findopenssl-slow-and-not-cached-on-windows/13532 "2025-02-05T08:09:53Z")

</div>

Hi, I’m investing why our CMake configuration takes really much longer time on Windows than macOS and Linux. I’m already aware that Windows filesystem and Windows defender is one of the culprit. However, I profile the …

---

## [Unclarity around the usage of install and CPack in specific scenario](https://discourse.cmake.org/t/unclarity-around-the-usage-of-install-and-cpack-in-specific-scenario/13533)

<div class="topic-metadata">

**Author:** [@SamCoutteauHybrid](https://discourse.cmake.org/u/SamCoutteauHybrid)\
**Replies:** 0\
**Last updated:** [February 4, 2025, 4:18pm UTC](https://discourse.cmake.org/t/unclarity-around-the-usage-of-install-and-cpack-in-specific-scenario/13533 "2025-02-04T16:18:28Z")

</div>

I’m in the process of splitting up a large and quite dated, monorepo into smaller more isolated chunks. But I’m left uncertain on how the install and CPack functionality is ment to be used here, specificly when it comes …

---

## [How to handle transitive dependencies of a header-only library target?](https://discourse.cmake.org/t/how-to-handle-transitive-dependencies-of-a-header-only-library-target/13517)

<div class="topic-metadata">

**Author:** [@tonh](https://discourse.cmake.org/u/tonh)\
**Replies:** 1\
**Last updated:** [January 30, 2025, 2:10pm UTC](https://discourse.cmake.org/t/how-to-handle-transitive-dependencies-of-a-header-only-library-target/13517 "2025-01-30T14:10:28Z")

</div>

I have some header-only library dependency Foo::foo which I do not want to end up in the exported targets of my library. To prevent that from happening, the library is linked as follows: target\_link\_libraries(my\_library…

---

## [Problem with RPATH](https://discourse.cmake.org/t/problem-with-rpath/13484)

<div class="topic-metadata">

**Author:** [@perdrix](https://discourse.cmake.org/u/perdrix)\
**Replies:** 1\
**Last updated:** [January 28, 2025, 3:23pm UTC](https://discourse.cmake.org/t/problem-with-rpath/13484 "2025-01-28T15:23:51Z")

</div>

Given a top level file: cmake\_minimum\_required(VERSION 3.16) project(SmtpMime VERSION 2.0 LANGUAGES C CXX) option(BUILD\_TESTS "builds tests" ON) option(BUILD\_DEMOS "builds demos" ON) set(CMAKE\_CXX\_STANDARD 17) s…

---

## [Xcode does not showing live issues for CMake generated project](https://discourse.cmake.org/t/xcode-does-not-showing-live-issues-for-cmake-generated-project/13500)

<div class="topic-metadata">

**Author:** [@Denni1986](https://discourse.cmake.org/u/Denni1986)\
**Replies:** 0\
**Last updated:** [January 28, 2025, 8:32am UTC](https://discourse.cmake.org/t/xcode-does-not-showing-live-issues-for-cmake-generated-project/13500 "2025-01-28T08:32:08Z")

</div>

Hello everyone! I made a minimum CMake project for testing purpose: cmake\_minimum\_required(VERSION 3.31) project(Test-project) add\_executable(Test-project main.cpp) After generating an Xcode project I was able to buil…

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

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