# Fortran\_MODULE\_DIRECTORY

**URL:** https://discourse.cmake.org/t/fortran-module-directory/4462
**Category:** Development
**Created:** [November 10, 2021, 7:09pm UTC](https://discourse.cmake.org/t/fortran-module-directory/4462 "2021-11-10T19:09:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lguez](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lguez/32/2115_2.png) [@lguez](https://discourse.cmake.org/u/lguez)
#### Post date: [November 10, 2021, 7:09pm UTC](https://discourse.cmake.org/t/fortran-module-directory/4462/1 "2021-11-10T19:09:29Z")

</div>

Hello. The default location for Fortran compiler-generated .mod files  
is ${CMAKE\_CURRENT\_BINARY\_DIR}. I think this is really a problem.

Suppose a given source file belongs to several targets, in the same source directory. Then CMake will re-compile this source file for each target it belongs to. But it will each time generate the corresponding .mod files in the same directory. This can crash the compilation if the compilation is parallel. It can even produce silent nasty errors if the source file is compiled with different compiler options of preprocessor definitions for different targets.

Note the same problem does not occur for object files because CMake wisely puts object files in directories specific to each target.

I think the default location of compiler-generated .mod files should be the same as the location of the corresponding object files.

What do you think?

Regards,

---

<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: [November 10, 2021, 9:55pm UTC](https://discourse.cmake.org/t/fortran-module-directory/4462/2 "2021-11-10T21:55:23Z")

</div>

I agree, but it would need to be a policy (because the current location can be assumed by existing code, the default cannot just be moved). Please file [an issue](https://gitlab.kitware.com/cmake/cmake/-/issues) to track this.

---

<div class="post-metadata">

### Author: ![lguez](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lguez/32/2115_2.png) [@lguez](https://discourse.cmake.org/u/lguez)
#### Post date: [November 11, 2021, 10:26am UTC](https://discourse.cmake.org/t/fortran-module-directory/4462/3 "2021-11-11T10:26:11Z")

</div>

Hello. It is done: [issue 22898](https://gitlab.kitware.com/cmake/cmake/-/issues/22898).
