# As of vwersion 3.19.8 I get -MD and -MT flags in my gcc makefile

**URL:** https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326
**Category:** Usage
**Created:** [March 8, 2024, 8:12am UTC](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326 "2024-03-08T08:12:13Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![BertEzendam](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@BertEzendam](https://discourse.cmake.org/u/BertEzendam)
#### Post date: [March 8, 2024, 8:12am UTC](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326/1 "2024-03-08T08:12:13Z")

</div>

As of from version 3.19.8 I get makefiles which introduce the -MD and -MT flags in my makefile. It then wants to find a file .d which might exsist, but is not supposed to be used by our (very old) gcc compiler.

The compiler does not understand these flags.

What caused Cmake to introduce these flags in my output?

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [March 8, 2024, 9:20am UTC](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326/2 "2024-03-08T09:20:19Z")

</div>

These flags are used to compute effective dependencies of source files.  
You can disable this behavior by setting variable [CMAKE\_DEPENDS\_USE\_COMPILER](https://cmake.org/cmake/help/latest/variable/CMAKE_DEPENDS_USE_COMPILER.html) with value `FALSE`.

Can you specify which compiler you are using and on which platform?

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [March 11, 2024, 11:00pm UTC](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326/3 "2024-03-11T23:00:42Z")

</div>

CMake v3.20 introduced depfiles in Makefile generators.  
In previous versions it’s only used for Ninja generator.

I guess you have used a newer CMake version. Otherwise you need to bisect to pin down the responsible CMake version or commit that causes you the problem.  
Or you say “makefile” but mean “ninja build files”.

---

<div class="post-metadata">

### Author: ![BertEzendam](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@BertEzendam](https://discourse.cmake.org/u/BertEzendam)
#### Post date: [March 12, 2024, 2:27pm UTC](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326/4 "2024-03-12T14:27:10Z")

</div>

Hello Josef,

Thank you for the reply. I then indeed have a problem with the introduction (version 3.20) of the depfiles. The options for the depfiles are not (properly) supported by our pretty old gcc compiler. Is there a way to prevent the generation of these depency files and generate makefiles like V3.19.8 did?

---

<div class="post-metadata">

### Author: ![BertEzendam](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@BertEzendam](https://discourse.cmake.org/u/BertEzendam)
#### Post date: [March 12, 2024, 2:29pm UTC](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326/5 "2024-03-12T14:29:06Z")

</div>

I now see that Marc already provides the answer. I will try.

---

<div class="post-metadata">

### Author: ![BertEzendam](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/b38774/32.png) [@BertEzendam](https://discourse.cmake.org/u/BertEzendam)
#### Post date: [March 14, 2024, 4:34pm UTC](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326/6 "2024-03-14T16:34:35Z")

</div>

Thanks, This [CMAKE\_DEPENDS\_USE\_COMPILER](https://cmake.org/cmake/help/latest/variable/CMAKE_DEPENDS_USE_COMPILER.html) with value `FALSE` indeed solved my issue.  
I am still wondering why this option hasn’t been implemented the other way around: Default no change, set to True to have a change. That would have kept it backward compatible.

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [March 14, 2024, 5:53pm UTC](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326/7 "2024-03-14T17:53:15Z")

</div>

My guess:

- it’s faster
- it’s more accurate
- it’s proven, as it’s used for Ninja for a long time
- it’s supported by gcc for [23 years](https://gcc.gnu.org/news/dependencies.html)

I don’t know if a policy was forgotten, or such old gcc versions were simply not considered.

Probably this flag can be set to false automatically for gcc \< 3 in CMake’s compiler modules.  
This would make it compatible, without sacrifying the benefits for newer versions.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 10, 2024, 9:39pm UTC](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326/8 "2024-04-10T21:39:30Z")

</div>

Can an issue be filed about this so that it can be tracked?

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [April 10, 2024, 11:13pm UTC](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326/9 "2024-04-10T23:13:58Z")

</div>

Is it reasonable to fill an issue for the support of a compiler which is older than **23** years?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [April 11, 2024, 12:02am UTC](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326/10 "2024-04-11T00:02:38Z")

</div>

If it’s still in use…yes. (That’s why I ask others to file the issue; if that is too much burden, then it’s obviously not _that_ big of a problem. It also ensures that someone with a stake in the problem is in any discussion of the issue right from the start.)

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [April 11, 2024, 10:02am UTC](https://discourse.cmake.org/t/as-of-vwersion-3-19-8-i-get-md-and-mt-flags-in-my-gcc-makefile/10326/11 "2024-04-11T10:02:44Z")

</div>

Try something like this:

```cmake
option(CMAKE_DEPENDS_IN_PROJECT_ONLY "do not use system header files" YES)
if(CMAKE_DEPENDS_IN_PROJECT_ONLY)
  set(CMAKE_DEPFILE_FLAGS_C "-MMD" CACHE STRING "dependency flag" FORCE)
  set(CMAKE_DEPFILE_FLAGS_CXX "-MMD" CACHE STRING "dependency flag" FORCE)
else()
  set(CMAKE_DEPFILE_FLAGS_C "-MD" CACHE STRING "dependency flag" FORCE)
  set(CMAKE_DEPFILE_FLAGS_CXX "-MD" CACHE STRING "dependency flag" FORCE)
endif()

```

### But be warned, CMAKE\_DEPFILE\_FLAGS\_ are manipulated from many cmake modules!
