# \#gen:makefiles

**URL:** https://discourse.cmake.org/tag/gen-makefiles/7.md

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

---

## [Fortran\_PREPROCESS ignored on Linux](https://discourse.cmake.org/t/fortran-preprocess-ignored-on-linux/9105)

<div class="topic-metadata">

**Author:** [@Maarten\_Braakhekke](https://discourse.cmake.org/u/Maarten_Braakhekke)\
**Replies:** 5\
**Last updated:** [September 17, 2026, 3:54pm UTC](https://discourse.cmake.org/t/fortran-preprocess-ignored-on-linux/9105 "2026-09-17T15:54:19Z")

</div>

It seems that the Fortran\_PREPROCESS property is not functioning properly on Linux. The default behavior of CMake on Linux is that source files are not preprocssed and Fortran\_PREPROCESS doesn seem to affect this. I att…

---

## [Bad dependency management for custom commands with Unix Makefiles generator](https://discourse.cmake.org/t/bad-dependency-management-for-custom-commands-with-unix-makefiles-generator/15823)

<div class="topic-metadata">

**Author:** [@davide9](https://discourse.cmake.org/u/davide9)\
**Replies:** 1\
**Last updated:** [September 7, 2026, 12:37pm UTC](https://discourse.cmake.org/t/bad-dependency-management-for-custom-commands-with-unix-makefiles-generator/15823 "2026-09-07T12:37:27Z")

</div>

When using “Unix Makefile” generator combined with custom commands and custom targets to generate files, CMake make use of sub-make invocation which doesn’t propagate the dependency tree between custom targets. Give the…

---

## [presets: Omitting \`generator\` does not default to regular generator discovery procedure](https://discourse.cmake.org/t/presets-omitting-generator-does-not-default-to-regular-generator-discovery-procedure/7910)

<div class="topic-metadata">

**Author:** [@dabe](https://discourse.cmake.org/u/dabe)\
**Replies:** 2\
**Last updated:** [June 1, 2026, 12:38am UTC](https://discourse.cmake.org/t/presets-omitting-generator-does-not-default-to-regular-generator-discovery-procedure/7910 "2026-06-01T00:38:44Z")

</div>

I have a project that I’d like to use different generators for depending on the OS that is compiling it (specifically, Unix Makefiles for Linux and Visual Studio/Ninja for Windows). I’d like to just let the automatic ge…

---

## [generate .o files from compiler instead of .obj files](https://discourse.cmake.org/t/generate-o-files-from-compiler-instead-of-obj-files/2690)

<div class="topic-metadata">

**Author:** [@deepan](https://discourse.cmake.org/u/deepan)\
**Replies:** 14\
**Last updated:** [May 6, 2026, 3:45am UTC](https://discourse.cmake.org/t/generate-o-files-from-compiler-instead-of-obj-files/2690 "2026-05-06T03:45:09Z")

</div>

I am working in an embedded project. target : ppc compiler : windriver Host environment : windows 10 build generator : cmake, MinGW makefiles during compilation i see .c.obj getting generated. I want .o instead of .…

---

## [add\_custom\_command for OUTPUT that is updated only on change](https://discourse.cmake.org/t/add-custom-command-for-output-that-is-updated-only-on-change/15554)

<div class="topic-metadata">

**Author:** [@Lyubomir\_Filipov](https://discourse.cmake.org/u/Lyubomir_Filipov)\
**Replies:** 0\
**Last updated:** [March 11, 2026, 9:04pm UTC](https://discourse.cmake.org/t/add-custom-command-for-output-that-is-updated-only-on-change/15554 "2026-03-11T21:04:22Z")

</div>

I have the following CMake custom command: add\_custom\_command ( OUTPUT ${outCpp} ${outHpp} ${outBin} COMMAND ${layout-packer-app} -o ${outCpp} -O ${outHpp} -B ${ou…

---

## [CMake is working wierdly in terms of searching and adding libraries](https://discourse.cmake.org/t/cmake-is-working-wierdly-in-terms-of-searching-and-adding-libraries/15399)

<div class="topic-metadata">

**Author:** [@soumyadghosh](https://discourse.cmake.org/u/soumyadghosh)\
**Replies:** 2\
**Last updated:** [February 9, 2026, 5:18am UTC](https://discourse.cmake.org/t/cmake-is-working-wierdly-in-terms-of-searching-and-adding-libraries/15399 "2026-02-09T05:18:27Z")

</div>

I am building openboard from source, with an SDK for Qt libraries and building poppler from the latest release. Now, while compiling openboard it looks for poppler and finds the correct poppler==25.12 using pkg-configwhi…

---

## [Environment variable \<PackageName\>\_ROOT ignored with a cmake minimum required 3.22](https://discourse.cmake.org/t/environment-variable-packagename-root-ignored-with-a-cmake-minimum-required-3-22/13364)

<div class="topic-metadata">

**Author:** [@tpadioleau](https://discourse.cmake.org/u/tpadioleau)\
**Replies:** 1\
**Last updated:** [December 28, 2025, 7:04am UTC](https://discourse.cmake.org/t/environment-variable-packagename-root-ignored-with-a-cmake-minimum-required-3-22/13364 "2025-12-28T07:04:36Z")

</div>

Hello, I recently faced a curious situation. My project has the following structure: my CMakeLists.txt starts with a cmake\_minimum\_required(VERSION 3.22) then calls find\_package(Foo REQUIRED). The file FooConfig.cmake c…

---

## [Error: Instruction is too long.](https://discourse.cmake.org/t/error-instruction-is-too-long/15300)

<div class="topic-metadata">

**Author:** [@wild.boy](https://discourse.cmake.org/u/wild.boy)\
**Replies:** 1\
**Last updated:** [November 15, 2025, 6:48am UTC](https://discourse.cmake.org/t/error-instruction-is-too-long/15300 "2025-11-15T06:48:17Z")

</div>

In CMake, if the link command becomes excessively long due to the presence of too many executable files during the linking process, what methods can be used to solve this problem?

---

## [target\_sources() and target\_include\_directories() behaviour](https://discourse.cmake.org/t/target-sources-and-target-include-directories-behaviour/15297)

<div class="topic-metadata">

**Author:** [@moonsun\_interstell](https://discourse.cmake.org/u/moonsun_interstell)\
**Replies:** 3\
**Last updated:** [November 12, 2025, 3:17pm UTC](https://discourse.cmake.org/t/target-sources-and-target-include-directories-behaviour/15297 "2025-11-12T15:17:58Z")

</div>

i am not sure about how cmake retrieves header files. (see cmake code below) my expectation is that it looks only what is defined in target\_include\_directories(). According to the cmake text file and the directory stru…

---

## [CMAKE\_CXX\_CPPCHECK - scope leak](https://discourse.cmake.org/t/cmake-cxx-cppcheck-scope-leak/15114)

<div class="topic-metadata">

**Author:** [@Mathias\_B](https://discourse.cmake.org/u/Mathias_B)\
**Replies:** 0\
**Last updated:** [August 27, 2025, 7:31am UTC](https://discourse.cmake.org/t/cmake-cxx-cppcheck-scope-leak/15114 "2025-08-27T07:31:13Z")

</div>

Hello, I am using CMake 4.1.0 with the following generators : Unix Makefiles on Linux MSYS Makefiles on Windows These are used to build a C++ project. My filetree looks like this : Toplevel: - CMakeLists.txt …

---

## [MAKE\_TERMOUT environment variable causes a number of CMake generated variables to not be set correctly](https://discourse.cmake.org/t/make-termout-environment-variable-causes-a-number-of-cmake-generated-variables-to-not-be-set-correctly/15104)

<div class="topic-metadata">

**Author:** [@Amguls](https://discourse.cmake.org/u/Amguls)\
**Replies:** 4\
**Last updated:** [August 25, 2025, 3:28pm UTC](https://discourse.cmake.org/t/make-termout-environment-variable-causes-a-number-of-cmake-generated-variables-to-not-be-set-correctly/15104 "2025-08-25T15:28:56Z")

</div>

When using the Unix Makefiles generator, if the MAKE\_TERMOUT environment variable is set to a non-empty value at CMake generation time (for example, if invoking cmake from a Makefile recipe), many CMake variables are not…

---

## [Build with "RelWithDebInfo" flag is much bigger than "Debug"](https://discourse.cmake.org/t/build-with-relwithdebinfo-flag-is-much-bigger-than-debug/14461)

<div class="topic-metadata">

**Author:** [@zer0deck](https://discourse.cmake.org/u/zer0deck)\
**Replies:** 2\
**Last updated:** [July 30, 2025, 7:57am UTC](https://discourse.cmake.org/t/build-with-relwithdebinfo-flag-is-much-bigger-than-debug/14461 "2025-07-30T07:57:24Z")

</div>

I have a large project with three main dependencies: drogon, swredis and hiredis. All three dependencies are shared libraries. Project itself contains multiple static libs (tools, models, schemas, services, etc.) linkin…

---

## [cmake --install and passing -j arg](https://discourse.cmake.org/t/cmake-install-and-passing-j-arg/11310)

<div class="topic-metadata">

**Author:** [@jsykes15](https://discourse.cmake.org/u/jsykes15)\
**Replies:** 3\
**Last updated:** [July 22, 2025, 9:16am UTC](https://discourse.cmake.org/t/cmake-install-and-passing-j-arg/11310 "2025-07-22T09:16:23Z")

</div>

The following command works in 3.20: cmake --install . -prefix \<path\> -- -j8 but in 3.30 it results in: Unknown argument -- The documentation for the cmake --install command in both 3.20 and the latest 3.30 don’t say…

---

## [Manually simulating target namespaces for building multi-architecture repos](https://discourse.cmake.org/t/manually-simulating-target-namespaces-for-building-multi-architecture-repos/11397)

<div class="topic-metadata">

**Author:** [@buergi](https://discourse.cmake.org/u/buergi)\
**Replies:** 3\
**Last updated:** [July 20, 2025, 11:54pm UTC](https://discourse.cmake.org/t/manually-simulating-target-namespaces-for-building-multi-architecture-repos/11397 "2025-07-20T23:54:29Z")

</div>

This is an issue which I have since several years now and which always kept preventing me from transitioning to cmake for a larger STM32 project. I never found a reasonable solution so far, until I recently found a semi-…

---

## [The list of include directories is empty by default.](https://discourse.cmake.org/t/the-list-of-include-directories-is-empty-by-default/14360)

<div class="topic-metadata">

**Author:** [@gerogaga](https://discourse.cmake.org/u/gerogaga)\
**Replies:** 1\
**Last updated:** [July 14, 2025, 8:39pm UTC](https://discourse.cmake.org/t/the-list-of-include-directories-is-empty-by-default/14360 "2025-07-14T20:39:22Z")

</div>

I have a file with 2 target\_include\_directories() commands, but outside of the directories specified in them, nothing else gets searched for headers, including system directories, and printing the INCLUDE\_DIRECTORIES dir…

---

## [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…

---

## [Random bug when building makefile project by using ExternalProject\_Add()](https://discourse.cmake.org/t/random-bug-when-building-makefile-project-by-using-externalproject-add/13998)

<div class="topic-metadata">

**Author:** [@acraft](https://discourse.cmake.org/u/acraft)\
**Replies:** 1\
**Last updated:** [April 28, 2025, 1:43pm UTC](https://discourse.cmake.org/t/random-bug-when-building-makefile-project-by-using-externalproject-add/13998 "2025-04-28T13:43:11Z")

</div>

Hello, I use ExternalProject\_Add() to build Open MPI project which uses make file project. When I build the project from command line there is no issue. When I use ExternalProject\_Add(), it fails randomly. Sometime it b…

---

## [dependency file(\*.d) file generation in cmake](https://discourse.cmake.org/t/dependency-file-d-file-generation-in-cmake/2680)

<div class="topic-metadata">

**Author:** [@deepan](https://discourse.cmake.org/u/deepan)\
**Replies:** 8\
**Last updated:** [March 27, 2025, 4:08pm UTC](https://discourse.cmake.org/t/dependency-file-d-file-generation-in-cmake/2680 "2025-03-27T16:08:57Z")

</div>

I am using cmake version 3.18.5. I have a C project for embedded system in cmake. I want the build system to generate .d files while building. my project compilation is successful but i don’t see the .d files anywhere. H…

---

## [RSP files equivalent when using Unix Makefiles](https://discourse.cmake.org/t/rsp-files-equivalent-when-using-unix-makefiles/11039)

<div class="topic-metadata">

**Author:** [@AntoineN](https://discourse.cmake.org/u/AntoineN)\
**Replies:** 3\
**Last updated:** [March 14, 2025, 5:52pm UTC](https://discourse.cmake.org/t/rsp-files-equivalent-when-using-unix-makefiles/11039 "2025-03-14T17:52:05Z")

</div>

Hello, I’m working on a project with CMake, using Ninja generator. I have a post build command to “include” a CRC in the generated binary. It make a 2nd link including the CRC. The command use the .rsp file to have the …

---

## [how to only be windows or unix path in the \`Makefile\`?](https://discourse.cmake.org/t/how-to-only-be-windows-or-unix-path-in-the-makefile/10883)

<div class="topic-metadata">

**Author:** [@anlexN](https://discourse.cmake.org/u/anlexN)\
**Replies:** 1\
**Last updated:** [March 4, 2025, 9:26am UTC](https://discourse.cmake.org/t/how-to-only-be-windows-or-unix-path-in-the-makefile/10883 "2025-03-04T09:26:06Z")

</div>

\`MSYS2\_ARG\_CONV\_EXCL=$MY\_INSTALL\_DIR2 cmake -G"MinGW Makefiles"\\ -DgRPC\_INSTALL=ON \\ -DgRPC\_BUILD\_TESTS=OFF \\ -DCMAKE\_INSTALL\_PREFIX=$MY\_INSTALL\_DIR2 \\ ../..\` cmake generate “MinGW Makefiles” tha…

---

## [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…

---

## [How to build NVidia binaries using CMake's new HIP language?](https://discourse.cmake.org/t/how-to-build-nvidia-binaries-using-cmakes-new-hip-language/4208)

<div class="topic-metadata">

**Author:** [@krasznaa](https://discourse.cmake.org/u/krasznaa)\
**Replies:** 7\
**Last updated:** [February 3, 2025, 10:05am UTC](https://discourse.cmake.org/t/how-to-build-nvidia-binaries-using-cmakes-new-hip-language/4208 "2025-02-03T10:05:06Z")

</div>

I’ve updated my code recently to make use of the “HIP language”, introduced in 3.21. After some initial success on a host with an AMD card, I was now trying to build some code on a host that has an NVidia card. And had …

---

## [CMake Error : Cannot find source file -\> No SOURCES given to target](https://discourse.cmake.org/t/cmake-error-cannot-find-source-file-no-sources-given-to-target/9650)

<div class="topic-metadata">

**Author:** [@Raphy](https://discourse.cmake.org/u/Raphy)\
**Replies:** 7\
**Last updated:** [January 29, 2025, 3:53pm UTC](https://discourse.cmake.org/t/cmake-error-cannot-find-source-file-no-sources-given-to-target/9650 "2025-01-29T15:53:37Z")

</div>

With this CMakeLists.txt file: cmake\_minimum\_required(VERSION 3.24) project(my\_application LANGUAGES CXX) include(FetchContent) FetchContent\_Declare( WebKit2 #URL https://webkitgtk.org/releases/webkitgtk-2.42.3.tar…

---

## [How to mimic \`make check\` behavior](https://discourse.cmake.org/t/how-to-mimic-make-check-behavior/13462)

<div class="topic-metadata">

**Author:** [@vbsteph](https://discourse.cmake.org/u/vbsteph)\
**Replies:** 0\
**Last updated:** [January 22, 2025, 11:33pm UTC](https://discourse.cmake.org/t/how-to-mimic-make-check-behavior/13462 "2025-01-22T23:33:52Z")

</div>

I want to use CMake to mimic the behavior of a testing workflow that uses make check (as generated by Autotools). Let’s say I have two libraries, A and B, where B depends on A. If I run make check from the binary direct…

---

## [How can I use CMake with GreenHills compiler](https://discourse.cmake.org/t/how-can-i-use-cmake-with-greenhills-compiler/4388)

<div class="topic-metadata">

**Author:** [@AbdAllah.ElTamaly](https://discourse.cmake.org/u/AbdAllah.ElTamaly)\
**Replies:** 17\
**Last updated:** [January 22, 2025, 6:51am UTC](https://discourse.cmake.org/t/how-can-i-use-cmake-with-greenhills-compiler/4388 "2025-01-22T06:51:19Z")

</div>

Hello, I have been trying to use CMake to generate Makefiles for a C project compiling using GreenHills compiler. But I am getting these errors: – The C compiler identification is GHS – The CXX compiler identification…

---

## ["FLAGS" literal is being output in link.txt, causing error](https://discourse.cmake.org/t/flags-literal-is-being-output-in-link-txt-causing-error/13263)

<div class="topic-metadata">

**Author:** [@DavidRV00](https://discourse.cmake.org/u/DavidRV00)\
**Replies:** 3\
**Last updated:** [January 15, 2025, 11:40pm UTC](https://discourse.cmake.org/t/flags-literal-is-being-output-in-link-txt-causing-error/13263 "2025-01-15T23:40:51Z")

</div>

Hello, I’m seeing an odd behavior when trying to build a Shared CUDA library using clang++ with CMake. Here’s a simple reproducible example if you wanna try it out yourself: GitHub - DavidRV00/cmake-clang-cuda-bug-repro…

---

## [ExternalProject\_Add commands with wildcard](https://discourse.cmake.org/t/externalproject-add-commands-with-wildcard/13289)

<div class="topic-metadata">

**Author:** [@DKLind](https://discourse.cmake.org/u/DKLind)\
**Replies:** 5\
**Last updated:** [January 7, 2025, 2:32pm UTC](https://discourse.cmake.org/t/externalproject-add-commands-with-wildcard/13289 "2025-01-07T14:32:03Z")

</div>

I have a little problem with ExternalProject\_Add when I try to use a command with a wildcard ‘\*’. The command statement is generated with quotes around the wildcard statement which causes the command to fail. For exampl…

---

## [Generated Makefile build command gives errors as it has quotes in the build command](https://discourse.cmake.org/t/generated-makefile-build-command-gives-errors-as-it-has-quotes-in-the-build-command/13331)

<div class="topic-metadata">

**Author:** [@pj0585](https://discourse.cmake.org/u/pj0585)\
**Replies:** 9\
**Last updated:** [January 6, 2025, 8:50pm UTC](https://discourse.cmake.org/t/generated-makefile-build-command-gives-errors-as-it-has-quotes-in-the-build-command/13331 "2025-01-06T20:50:40Z")

</div>

Hi, I have created a CMakeLists.txt for cross compiling my C project. I have enabled many warning options and need many -D options as well. While adding these to target\_compile\_options() I have added quotes to make it l…

---

## [How to Enable CMake parallel compile](https://discourse.cmake.org/t/how-to-enable-cmake-parallel-compile/13265)

<div class="topic-metadata">

**Author:** [@ElbertZ](https://discourse.cmake.org/u/ElbertZ)\
**Replies:** 2\
**Last updated:** [December 30, 2024, 6:50am UTC](https://discourse.cmake.org/t/how-to-enable-cmake-parallel-compile/13265 "2024-12-30T06:50:49Z")

</div>

I try to parallel compile a c++ project with Visual Studio 2022. However It cost 4 minute in Visual Studio2022 or using command instead of 1minute in VSCode, VisualStudio2022 and using command will cost more time and le…

---

## [Method for allowing generate Makefiles to internally environment variables](https://discourse.cmake.org/t/method-for-allowing-generate-makefiles-to-internally-environment-variables/13248)

<div class="topic-metadata">

**Author:** [@leakec](https://discourse.cmake.org/u/leakec)\
**Replies:** 0\
**Last updated:** [December 21, 2024, 4:24pm UTC](https://discourse.cmake.org/t/method-for-allowing-generate-makefiles-to-internally-environment-variables/13248 "2024-12-21T16:24:06Z")

</div>

I use cmake to compile projects with many subdirectories that can be built independently. Sometimes, during debugging, I’d like to recompile just one of those subdirectories with a different optimization level for debugg…

[Next page](https://discourse.cmake.org/tag/gen-makefiles/7.md?match_all_tags=true&page=1&tags%5B%5D=gen%3Amakefiles)
