# Usage

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

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

**Page:** 10

---

## [ExternalData and local paths](https://discourse.cmake.org/t/externaldata-and-local-paths/11086)

<div class="topic-metadata">

**Author:** [@benthevining](https://discourse.cmake.org/u/benthevining)\
**Replies:** 2\
**Last updated:** [July 17, 2025, 3:50pm UTC](https://discourse.cmake.org/t/externaldata-and-local-paths/11086 "2025-07-17T15:50:13Z")

</div>

I’m trying to add a local path to ExternalData\_URL\_TEMPLATES like so: set (ExternalData\_URL\_TEMPLATES "file:///Users/benvining/Documents/MTM/audio-samples/%(algo)/%(hash)") and my build keeps failing with: -- Fetching…

---

## [Applying a pre-processor macro to a single source with cmake](https://discourse.cmake.org/t/applying-a-pre-processor-macro-to-a-single-source-with-cmake/11080)

<div class="topic-metadata">

**Author:** [@pmarguinaud](https://discourse.cmake.org/u/pmarguinaud)\
**Replies:** 1\
**Last updated:** [July 17, 2025, 3:42pm UTC](https://discourse.cmake.org/t/applying-a-pre-processor-macro-to-a-single-source-with-cmake/11080 "2025-07-17T15:42:00Z")

</div>

Hello, I am using cmake to build my Fortran project, and I am trying to set a pre-processor macro on a single file, using set\_source\_files\_properties. It works (the cpp flag is there when I compile the code), but cmake …

---

## [AUTOMOC is applied to SQLite3 sources when added as dependency resulting in compile error](https://discourse.cmake.org/t/automoc-is-applied-to-sqlite3-sources-when-added-as-dependency-resulting-in-compile-error/14371)

<div class="topic-metadata">

**Author:** [@snoriman](https://discourse.cmake.org/u/snoriman)\
**Replies:** 1\
**Last updated:** [July 15, 2025, 9:12pm UTC](https://discourse.cmake.org/t/automoc-is-applied-to-sqlite3-sources-when-added-as-dependency-resulting-in-compile-error/14371 "2025-07-15T21:12:19Z")

</div>

This is kind of a silly one. Whenever I add SQLite via FetchContent and I’m building a Qt project I run into the following error: sqlite\\version(1,1): error C2059: syntax error: 'constant' It seems that automoc is appl…

---

## [ExternalProject/FetchContent\_Add with unresolveable URL hangs forever on Windows, how to fix/prevent.](https://discourse.cmake.org/t/externalproject-fetchcontent-add-with-unresolveable-url-hangs-forever-on-windows-how-to-fix-prevent/14358)

<div class="topic-metadata">

**Author:** [@snoriman](https://discourse.cmake.org/u/snoriman)\
**Replies:** 2\
**Last updated:** [July 15, 2025, 7:50am UTC](https://discourse.cmake.org/t/externalproject-fetchcontent-add-with-unresolveable-url-hangs-forever-on-windows-how-to-fix-prevent/14358 "2025-07-15T07:50:45Z")

</div>

I’m using FetchContent\_ and had a typo in the URL which made CMake (4.0.3) hang forever. I tried adding TIMEOUT and INACTIVITY\_TIMEOUT which didn’t do anything. Is this a bug or should I use another solution to at least…

---

## [How to prevent CMake to add an empty /Fd flag](https://discourse.cmake.org/t/how-to-prevent-cmake-to-add-an-empty-fd-flag/14357)

<div class="topic-metadata">

**Author:** [@ElBorak3](https://discourse.cmake.org/u/ElBorak3)\
**Replies:** 0\
**Last updated:** [July 14, 2025, 2:30pm UTC](https://discourse.cmake.org/t/how-to-prevent-cmake-to-add-an-empty-fd-flag/14357 "2025-07-14T14:30:48Z")

</div>

In CMake, while using the ninja generator, when I try to build my fortran project, an empty /Fd flag (the flag used to specify the path name of the generated .pdb) is always set at the end of the command passed to the if…

---

## [How to add library with only module interface unit in msvc?](https://discourse.cmake.org/t/how-to-add-library-with-only-module-interface-unit-in-msvc/14355)

<div class="topic-metadata">

**Author:** [@paperchalice](https://discourse.cmake.org/u/paperchalice)\
**Replies:** 2\
**Last updated:** [July 14, 2025, 1:33pm UTC](https://discourse.cmake.org/t/how-to-add-library-with-only-module-interface-unit-in-msvc/14355 "2025-07-14T13:33:57Z")

</div>

Show case: // test.ixx export module foo; // No member is declared with dllexport, this is the simplest case. // test.cpp import foo; int main() {} CMakeLists.txt: cmake\_minimum\_required(VERSION 4.1) project(test) …

---

## [No GHS toolsets found in GHS\_TOOLSET\_ROOT ‘e:/ Renesas\_greenhills/’](https://discourse.cmake.org/t/no-ghs-toolsets-found-in-ghs-toolset-root-e-renesas-greenhills/14220)

<div class="topic-metadata">

**Author:** [@Sakura](https://discourse.cmake.org/u/Sakura)\
**Replies:** 1\
**Last updated:** [July 13, 2025, 1:57am UTC](https://discourse.cmake.org/t/no-ghs-toolsets-found-in-ghs-toolset-root-e-renesas-greenhills/14220 "2025-07-13T01:57:00Z")

</div>

I got it because the installation of greenhills didn’t follow the default folder, my installation is as follows:E:\\Renesas\_greenhills\\greenhills,E:\\Renesas\_greenhills\\Renesas\_RH840\_Architecter,now When I run CMake for se…

---

## [\`\`import std\`\` doesn't work on windows](https://discourse.cmake.org/t/import-std-doesnt-work-on-windows/14268)

<div class="topic-metadata">

**Author:** [@mccakit](https://discourse.cmake.org/u/mccakit)\
**Replies:** 34\
**Last updated:** [July 10, 2025, 5:59pm UTC](https://discourse.cmake.org/t/import-std-doesnt-work-on-windows/14268 "2025-07-10T17:59:30Z")

</div>

Currently, import std doesn’t work on Windows. It fails both in a pure Visual Studio environment (using the CMake and Clang provided by Visual Studio) and with the latest versions of LLVM and CMake built from source. I’v…

---

## [Is there any command line option to force static build?](https://discourse.cmake.org/t/is-there-any-command-line-option-to-force-static-build/14336)

<div class="topic-metadata">

**Author:** [@leo9800](https://discourse.cmake.org/u/leo9800)\
**Replies:** 0\
**Last updated:** [July 9, 2025, 5:56pm UTC](https://discourse.cmake.org/t/is-there-any-command-line-option-to-force-static-build/14336 "2025-07-09T17:56:49Z")

</div>

Hi, folks I am currently trying to build static binary of a C++ & CMake based project, qbittorrent-enhanced-edition to be specific. My goal would be producing a ELF which is completely static, i.e. ldd shows statically…

---

## [INTERFACE\_INCLUDE\_DIRECTORIES do not work as documented](https://discourse.cmake.org/t/interface-include-directories-do-not-work-as-documented/14332)

<div class="topic-metadata">

**Author:** [@Adam\_BZH](https://discourse.cmake.org/u/Adam_BZH)\
**Replies:** 4\
**Last updated:** [July 9, 2025, 4:09am UTC](https://discourse.cmake.org/t/interface-include-directories-do-not-work-as-documented/14332 "2025-07-09T04:09:51Z")

</div>

Using version 3.28, Linux Ubuntu 24.04 As title suggests, having issue with a simple library and consumer use case. library’s INTERFACE\_INCLUDE\_DIRECTORIES is populated, but when I use add\_subdirectory(library) to inclu…

---

## [Building Go/Golang Android app using Gradle and Cmake](https://discourse.cmake.org/t/building-go-golang-android-app-using-gradle-and-cmake/14306)

<div class="topic-metadata">

**Author:** [@ziik](https://discourse.cmake.org/u/ziik)\
**Replies:** 1\
**Last updated:** [July 8, 2025, 9:03pm UTC](https://discourse.cmake.org/t/building-go-golang-android-app-using-gradle-and-cmake/14306 "2025-07-08T21:03:47Z")

</div>

Hi, I am trying to build the Golang Android native application using Gradle and CMake. And I would like to ask for help with the CMake configuration. I uploaded the project I’m testing on to GitHub GitHub - tomas-mraz/s…

---

## [Accidental escape sequence included install directory on Windows platforms](https://discourse.cmake.org/t/accidental-escape-sequence-included-install-directory-on-windows-platforms/14331)

<div class="topic-metadata">

**Author:** [@adembudak](https://discourse.cmake.org/u/adembudak)\
**Replies:** 0\
**Last updated:** [July 8, 2025, 3:46pm UTC](https://discourse.cmake.org/t/accidental-escape-sequence-included-install-directory-on-windows-platforms/14331 "2025-07-08T15:46:35Z")

</div>

Hello everyone, I’m trying to setup GitHub workflow for the project I worked on CMakeForImGui, which adds CMake support for ImGui… anyway. The workflow file configures, builds and installs on different platforms, but hav…

---

## [CDash Server Displays Empty Submission When Uploading a Single Subproject](https://discourse.cmake.org/t/cdash-server-displays-empty-submission-when-uploading-a-single-subproject/14245)

<div class="topic-metadata">

**Author:** [@yus](https://discourse.cmake.org/u/yus)\
**Replies:** 1\
**Last updated:** [July 7, 2025, 4:08pm UTC](https://discourse.cmake.org/t/cdash-server-displays-empty-submission-when-uploading-a-single-subproject/14245 "2025-07-07T16:08:11Z")

</div>

Hello. I am trying to submit a new subproject to an existing project from a different site at a different time. This encounters some unusual behavior on the my.cdash.org server. The panel listing different sites does sho…

---

## [Advice on Combining CHAI3D and OpenSim with CMake](https://discourse.cmake.org/t/advice-on-combining-chai3d-and-opensim-with-cmake/14325)

<div class="topic-metadata">

**Author:** [@AHMADREZA\_RAVANGARD](https://discourse.cmake.org/u/AHMADREZA_RAVANGARD)\
**Replies:** 1\
**Last updated:** [July 7, 2025, 1:45pm UTC](https://discourse.cmake.org/t/advice-on-combining-chai3d-and-opensim-with-cmake/14325 "2025-07-07T13:45:08Z")

</div>

Hi, I’m working on a C++ project where I need to use both CHAI3D (for haptics) and OpenSim (for simulation). Each library has its own CMake setup, and I’m trying to combine them into a single CMake project on Windows 11 …

---

## [How to specify C++-module-implementation file in CMakeLists.txt?](https://discourse.cmake.org/t/how-to-specify-c-module-implementation-file-in-cmakelists-txt/14317)

<div class="topic-metadata">

**Author:** [@markus.parker](https://discourse.cmake.org/u/markus.parker)\
**Replies:** 1\
**Last updated:** [July 5, 2025, 5:18am UTC](https://discourse.cmake.org/t/how-to-specify-c-module-implementation-file-in-cmakelists-txt/14317 "2025-07-05T05:18:16Z")

</div>

Hello, I posted the following at https://stackoverflow.com/q/79687866/5525302, but got no answer, that is why I try it here. I want to create a c+±20-module without partitions but where the interface is in a different …

---

## [CXX\_MODULES: FAILED: CMakeFiles/Algo.dir/algo-impl.cpp.o.ddi](https://discourse.cmake.org/t/cxx-modules-failed-cmakefiles-algo-dir-algo-impl-cpp-o-ddi/14262)

<div class="topic-metadata">

**Author:** [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Replies:** 4\
**Last updated:** [July 4, 2025, 8:03pm UTC](https://discourse.cmake.org/t/cxx-modules-failed-cmakefiles-algo-dir-algo-impl-cpp-o-ddi/14262 "2025-07-04T20:03:44Z")

</div>

I have an import std; example based on C++20 Modules, CMake, And Shared Libraries It builds on CI windows (MS cl), ubuntu (gcc-15, gcc-16), but not with clang-20/21! @ben.boeckel But on my local iMac i368 (OSX) it bui…

---

## [CMake with CI pipelines - Basics?](https://discourse.cmake.org/t/cmake-with-ci-pipelines-basics/14313)

<div class="topic-metadata">

**Author:** [@franki](https://discourse.cmake.org/u/franki)\
**Replies:** 1\
**Last updated:** [July 3, 2025, 7:56pm UTC](https://discourse.cmake.org/t/cmake-with-ci-pipelines-basics/14313 "2025-07-03T19:56:28Z")

</div>

The simplest quick start is to add cmake -G and cmake --build to the build stage of the pipeline file, but this means that cmake’s generate/configure is redone every time! That’s wasteful especially if pulling in many d…

---

## [Does anyone have experience compiling for HPE OSS?](https://discourse.cmake.org/t/does-anyone-have-experience-compiling-for-hpe-oss/14308)

<div class="topic-metadata">

**Author:** [@manray](https://discourse.cmake.org/u/manray)\
**Replies:** 0\
**Last updated:** [July 2, 2025, 1:48pm UTC](https://discourse.cmake.org/t/does-anyone-have-experience-compiling-for-hpe-oss/14308 "2025-07-02T13:48:37Z")

</div>

I am switching build systems from Meson/Ninja to CMake/Ninja for a large C/C++ project that targets many operating systems. AIX, Solaris, Linux, Windows, etc seem well supported by CMake, but I am worried about HPE OSS a…

---

## [CMake Link.txt generated during CMake configuration does not contain any link flags or source files when using riscv toolchain](https://discourse.cmake.org/t/cmake-link-txt-generated-during-cmake-configuration-does-not-contain-any-link-flags-or-source-files-when-using-riscv-toolchain/14304)

<div class="topic-metadata">

**Author:** [@Atul\_Joshi](https://discourse.cmake.org/u/Atul_Joshi)\
**Replies:** 4\
**Last updated:** [July 2, 2025, 10:29am UTC](https://discourse.cmake.org/t/cmake-link-txt-generated-during-cmake-configuration-does-not-contain-any-link-flags-or-source-files-when-using-riscv-toolchain/14304 "2025-07-02T10:29:58Z")

</div>

I have 2 source files, one is C (cstart.c) and another is assembly (startup.S) using which i am trying to make an riscv executable. Here is how my CMakeLists.txt Looks Like =============================================…

---

## [Directly building in the install directory](https://discourse.cmake.org/t/directly-building-in-the-install-directory/14238)

<div class="topic-metadata">

**Author:** [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Replies:** 2\
**Last updated:** [July 1, 2025, 7:09am UTC](https://discourse.cmake.org/t/directly-building-in-the-install-directory/14238 "2025-07-01T07:09:46Z")

</div>

What are the disadvantages of generating binaries (exe, lib) directly in their installation directory (using \<TARGET\_TYPE\>\_OUTPUT\_DIRECTORY) rather than in the build directory and then copying them (in post-build or via …

---

## [fetchcontent not prompting for ssh password on powershell](https://discourse.cmake.org/t/fetchcontent-not-prompting-for-ssh-password-on-powershell/14296)

<div class="topic-metadata">

**Author:** [@ChipsUndCola](https://discourse.cmake.org/u/ChipsUndCola)\
**Replies:** 1\
**Last updated:** [June 30, 2025, 10:21pm UTC](https://discourse.cmake.org/t/fetchcontent-not-prompting-for-ssh-password-on-powershell/14296 "2025-06-30T22:21:28Z")

</div>

Hi, I use cpmaddpackage() to add a protected git repo to my project. I use a password protected ssh key to access the git repo. Cpmaddpackage is a wrapper for fetchcontent. When I run cmake --preset mypreset on Git …

---

## [Cross-compiling with ninja multi-config](https://discourse.cmake.org/t/cross-compiling-with-ninja-multi-config/14291)

<div class="topic-metadata">

**Author:** [@galax](https://discourse.cmake.org/u/galax)\
**Replies:** 3\
**Last updated:** [June 30, 2025, 1:52pm UTC](https://discourse.cmake.org/t/cross-compiling-with-ninja-multi-config/14291 "2025-06-30T13:52:34Z")

</div>

Hi All, I managed to cross compile with the ccrx v3.06 using ninja and cmake v4.0.2. I would like to go multi-config BUT a define (CMAKE\_INTDIR) is added under the hood. The problem is that the ccrx accepts defines as…

---

## [Fortran compiler is not found](https://discourse.cmake.org/t/fortran-compiler-is-not-found/14298)

<div class="topic-metadata">

**Author:** [@Tudor.Istrate](https://discourse.cmake.org/u/Tudor.Istrate)\
**Replies:** 0\
**Last updated:** [June 30, 2025, 1:17pm UTC](https://discourse.cmake.org/t/fortran-compiler-is-not-found/14298 "2025-06-30T13:17:08Z")

</div>

Hello! I am trying to use CMake for OpenFAST. I am using the following command: cmake .. -G “Visual Studio 17 2022” -A x64 -DCMAKE\_BUILD\_TYPE=Debug -DBUILD\_SHARED\_LIBS=ON However, I get the following error: CMake …

---

## [Main use cases for COMPAT\_VERSION of project() (in new CMake 4.1)](https://discourse.cmake.org/t/main-use-cases-for-compat-version-of-project-in-new-cmake-4-1/14289)

<div class="topic-metadata">

**Author:** [@leha-bot](https://discourse.cmake.org/u/leha-bot)\
**Replies:** 2\
**Last updated:** [June 28, 2025, 4:03pm UTC](https://discourse.cmake.org/t/main-use-cases-for-compat-version-of-project-in-new-cmake-4-1/14289 "2025-06-28T16:03:48Z")

</div>

It’s unclear the main usage of this feature and potential use-cases. The most similar things I thought, was write\_basic\_package\_version\_file and their COMPATIBILITY ( AnyNewerVersion, SameMinor, SameMajor, ExactVersion)

---

## [Strange executable name when setting SUFFIX and VERSION](https://discourse.cmake.org/t/strange-executable-name-when-setting-suffix-and-version/14292)

<div class="topic-metadata">

**Author:** [@JonTheBurger](https://discourse.cmake.org/u/JonTheBurger)\
**Replies:** 0\
**Last updated:** [June 27, 2025, 12:37pm UTC](https://discourse.cmake.org/t/strange-executable-name-when-setting-suffix-and-version/14292 "2025-06-27T12:37:27Z")

</div>

On Windows, the following snippet creates a main-1.2.3.elf (with both GCC and MSVC). However on Linux, it creates main.elf-1.2.3. I tried to also set OUTPUT\_NAME main-1.2.3 to override the version string it added, but th…

---

## [Does it make sense to set cmakeMinimimRequired in CMakePresets.json?](https://discourse.cmake.org/t/does-it-make-sense-to-set-cmakeminimimrequired-in-cmakepresets-json/14285)

<div class="topic-metadata">

**Author:** [@georg](https://discourse.cmake.org/u/georg)\
**Replies:** 2\
**Last updated:** [June 26, 2025, 7:30pm UTC](https://discourse.cmake.org/t/does-it-make-sense-to-set-cmakeminimimrequired-in-cmakepresets-json/14285 "2025-06-26T19:30:19Z")

</div>

Hi all, I am wondering if it makes sense to set the option field cmakeMinimumRequired in CMakePresets.json in addition to cmake\_minimum\_required() in the top-level CMakeLists.txt. I made some experiments and it turned …

---

## [Combine static libraries](https://discourse.cmake.org/t/combine-static-libraries/14172)

<div class="topic-metadata">

**Author:** [@ramcdona](https://discourse.cmake.org/u/ramcdona)\
**Replies:** 7\
**Last updated:** [June 20, 2025, 2:42pm UTC](https://discourse.cmake.org/t/combine-static-libraries/14172 "2025-06-20T14:42:02Z")

</div>

I’ve seen a bunch of related questions here and across the internet. However, most are pretty old and/or have different circumstances. So apologies for the potential repeat. I have a project that organizes its files i…

---

## [How to test for CXX module availability](https://discourse.cmake.org/t/how-to-test-for-cxx-module-availability/14266)

<div class="topic-metadata">

**Author:** [@kfsone](https://discourse.cmake.org/u/kfsone)\
**Replies:** 5\
**Last updated:** [June 20, 2025, 11:16am UTC](https://discourse.cmake.org/t/how-to-test-for-cxx-module-availability/14266 "2025-06-20T11:16:03Z")

</div>

I’ve been trying to find some way to detect if the current generators and/or compiler supports c++ modules. Right now, I just have a giant set of "if"s, but given that cmake will bark at me that Visual Studio 2019 genera…

---

## [cmake progress loosed](https://discourse.cmake.org/t/cmake-progress-loosed/14250)

<div class="topic-metadata">

**Author:** [@cmpeter](https://discourse.cmake.org/u/cmpeter)\
**Replies:** 1\
**Last updated:** [June 20, 2025, 11:05am UTC](https://discourse.cmake.org/t/cmake-progress-loosed/14250 "2025-06-20T11:05:04Z")

</div>

Hello I have cmake build tree containing three git submodules built with add\_subdirectory(). First of them contains add\_custom\_command() and the command contains shell script running cpack and some shell commands and i…

---

## [How to mark GMock as a required component](https://discourse.cmake.org/t/how-to-mark-gmock-as-a-required-component/10106)

<div class="topic-metadata">

**Author:** [@Ryanf55](https://discourse.cmake.org/u/Ryanf55)\
**Replies:** 5\
**Last updated:** [June 19, 2025, 8:38pm UTC](https://discourse.cmake.org/t/how-to-mark-gmock-as-a-required-component/10106 "2025-06-19T20:38:59Z")

</div>

I’m using CMake 3.27 and use both GTest and GMock in a package. There are a few options I’ve seen to pull this in: With the FindGTest module include(FindGTest) Directly with find\_package find\_package(GTest CONFIG …

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

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