# \#lang:fortran

**URL:** https://discourse.cmake.org/tag/lang-fortran/40.md

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

---

## [problem using gfortran with MSVC 18](https://discourse.cmake.org/t/problem-using-gfortran-with-msvc-18/15608)

<div class="topic-metadata">

**Author:** [@BillG](https://discourse.cmake.org/u/BillG)\
**Replies:** 0\
**Last updated:** [April 19, 2026, 7:59pm UTC](https://discourse.cmake.org/t/problem-using-gfortran-with-msvc-18/15608 "2026-04-19T19:59:38Z")

</div>

I am trying to use cmake 4.3.0 to build a project with -G “Visual Studio 18 2026” and gfortran. My CMakeLists.txt file includes: set(CMake\_ARCHIVE\_OUTPUT\_DIRECTORY ./my\_fortran\_lib) set(CMake\_RUNTIME\_OUTPUT\_DIRECTOR…

---

## [Problems with fortran an Xcode generator](https://discourse.cmake.org/t/problems-with-fortran-an-xcode-generator/11112)

<div class="topic-metadata">

**Author:** [@Fabian188](https://discourse.cmake.org/u/Fabian188)\
**Replies:** 2\
**Last updated:** [July 17, 2025, 4:06pm UTC](https://discourse.cmake.org/t/problems-with-fortran-an-xcode-generator/11112 "2025-07-17T16:06:28Z")

</div>

I don’t know if this a bug, principally not possible or if I’m doing something wrong. I have a C,C++,Fortran cmake project which builds nicely with Apple clang and gfortran from brew on macOS. Usually I use Eclipse wit…

---

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

---

## [CMake, Ninja, Fortran, and inconsistent \`Cannot open module file\` errors](https://discourse.cmake.org/t/cmake-ninja-fortran-and-inconsistent-cannot-open-module-file-errors/9276)

<div class="topic-metadata">

**Author:** [@golmschenk](https://discourse.cmake.org/u/golmschenk)\
**Replies:** 10\
**Last updated:** [December 9, 2023, 10:47pm UTC](https://discourse.cmake.org/t/cmake-ninja-fortran-and-inconsistent-cannot-open-module-file-errors/9276 "2023-12-09T22:47:37Z")

</div>

Hello! I’m running into an issue where, for some system configurations, I encounter a Cannot open module file (for a Fortran module file) during the build. From what I can tell, this is occurring because the way I’ve set…

---

## [Multiple Build Invocations Required to Compile?](https://discourse.cmake.org/t/multiple-build-invocations-required-to-compile/9301)

<div class="topic-metadata">

**Author:** [@KTRR](https://discourse.cmake.org/u/KTRR)\
**Replies:** 1\
**Last updated:** [October 29, 2023, 12:17pm UTC](https://discourse.cmake.org/t/multiple-build-invocations-required-to-compile/9301 "2023-10-29T12:17:05Z")

</div>

I’m running into an issue where multiple build invocations are required to complete compilation (because modules are not being compiled in the correct order). I’m using CMake 3.27.7 and Ninja 1.11.1 on Windows with the l…

---

## [How to prevent CMake usage of an outdated fortran module](https://discourse.cmake.org/t/how-to-prevent-cmake-usage-of-an-outdated-fortran-module/8710)

<div class="topic-metadata">

**Author:** [@uranix](https://discourse.cmake.org/u/uranix)\
**Replies:** 6\
**Last updated:** [August 10, 2023, 6:18pm UTC](https://discourse.cmake.org/t/how-to-prevent-cmake-usage-of-an-outdated-fortran-module/8710 "2023-08-10T18:18:01Z")

</div>

I’m using CMake to build a moderate-sized Fortran project. I noticed that sometimes when I refactor modules I ran into weird compilation errors that are gone after clean rebuild in a fresh build directory. I’ve managed …

---

## [RPATH incorrect when clang links a library compiled with gfortran](https://discourse.cmake.org/t/rpath-incorrect-when-clang-links-a-library-compiled-with-gfortran/6720)

<div class="topic-metadata">

**Author:** [@cianciosa](https://discourse.cmake.org/u/cianciosa)\
**Replies:** 1\
**Last updated:** [October 25, 2022, 9:54pm UTC](https://discourse.cmake.org/t/rpath-incorrect-when-clang-links-a-library-compiled-with-gfortran/6720 "2022-10-25T21:54:35Z")

</div>

I’m running into a runtime problem that I have never had before. I have a bunch of projects spread out across multiple GitHub repositories. A parent repository collects coordinates all this using a bunch of FetchContent …

---

## [VCTargetsPath error while using VS 10 2010 generator](https://discourse.cmake.org/t/vctargetspath-error-while-using-vs-10-2010-generator/6063)

<div class="topic-metadata">

**Author:** [@lsoranco](https://discourse.cmake.org/u/lsoranco)\
**Replies:** 9\
**Last updated:** [July 26, 2022, 4:48pm UTC](https://discourse.cmake.org/t/vctargetspath-error-while-using-vs-10-2010-generator/6063 "2022-07-26T16:48:33Z")

</div>

Hello! I am absolutely new to CMake (in fact I am still figuring out its purpose, not usually to languages that are complex to compile, programmed most of my stuff on Python and Rust), so please bear with me if the ques…

---

## [How to set up compilation with Intel Fortran compiler on Windows correctly?](https://discourse.cmake.org/t/how-to-set-up-compilation-with-intel-fortran-compiler-on-windows-correctly/532)

<div class="topic-metadata">

**Author:** [@MartinBeseda](https://discourse.cmake.org/u/MartinBeseda)\
**Replies:** 11\
**Last updated:** [May 10, 2022, 6:01pm UTC](https://discourse.cmake.org/t/how-to-set-up-compilation-with-intel-fortran-compiler-on-windows-correctly/532 "2022-05-10T18:01:13Z")

</div>

Hello, I’m trying to build my C/C++/Fortran project both on Ubuntu and Windows10. The compilation on Linux posses no problems, but Intel Fortran compiler on Windows seems to cause great complications for CMake. I’ve tr…

---

## [Possible regression with c564a3e3 in CMake 3.21](https://discourse.cmake.org/t/possible-regression-with-c564a3e3-in-cmake-3-21/4167)

<div class="topic-metadata">

**Author:** [@akleber](https://discourse.cmake.org/u/akleber)\
**Replies:** 2\
**Last updated:** [September 30, 2021, 6:18am UTC](https://discourse.cmake.org/t/possible-regression-with-c564a3e3-in-cmake-3-21/4167 "2021-09-30T06:18:56Z")

</div>

My use case is building a Fortran project with CMake, Ninja, Intel Fortran Compiler through Conan on Windows. Commit c564a3e3 “Ninja: Always compile sources using absolute paths” included in CMake 3.21 had the followin…

---

## [No CMAKE\_Fortran\_COMPILER could be found.](https://discourse.cmake.org/t/no-cmake-fortran-compiler-could-be-found/3720)

<div class="topic-metadata">

**Author:** [@roslyn.parker](https://discourse.cmake.org/u/roslyn.parker)\
**Replies:** 2\
**Last updated:** [July 9, 2021, 8:07pm UTC](https://discourse.cmake.org/t/no-cmake-fortran-compiler-could-be-found/3720 "2021-07-09T20:07:24Z")

</div>

I have been getting this error from my cmake-gui window when compiling my C++/Fortran based project. The Fortran compiler identification is unknown CMake Error at Lib/Fast\_Table/CMakeLists.txt:2 (project): No CMAKE\_Fo…

---

## [Generated sources and dependencies in Visual Studio](https://discourse.cmake.org/t/generated-sources-and-dependencies-in-visual-studio/3289)

<div class="topic-metadata">

**Author:** [@Maarten\_Braakhekke](https://discourse.cmake.org/u/Maarten_Braakhekke)\
**Replies:** 4\
**Last updated:** [May 11, 2021, 6:28am UTC](https://discourse.cmake.org/t/generated-sources-and-dependencies-in-visual-studio/3289 "2021-05-11T06:28:34Z")

</div>

I have a Fortran project which I’m porting to Intel Visual Fortran (parallel studio) on Windows. CMake (in my case) generates the Visual Studio solution and project files. A number of the source files are generated in p…

---

## [Preserving options with spaces in add\_compile\_options](https://discourse.cmake.org/t/preserving-options-with-spaces-in-add-compile-options/1551)

<div class="topic-metadata">

**Author:** [@kvrigor](https://discourse.cmake.org/u/kvrigor)\
**Replies:** 9\
**Last updated:** [March 24, 2021, 9:17pm UTC](https://discourse.cmake.org/t/preserving-options-with-spaces-in-add-compile-options/1551 "2021-03-24T21:17:09Z")

</div>

Hello, I have a CMake project with several targets and I wish to set global compile options through add\_compile\_options . These are the flags that I need to set: ifort icc -qno-opt-dynamic-align -qno-opt-dynami…

---

## [Debug symbols in Fortran with Ninja and Intel compiler on Windows](https://discourse.cmake.org/t/debug-symbols-in-fortran-with-ninja-and-intel-compiler-on-windows/2762)

<div class="topic-metadata">

**Author:** [@ascmagma](https://discourse.cmake.org/u/ascmagma)\
**Replies:** 2\
**Last updated:** [February 15, 2021, 3:51pm UTC](https://discourse.cmake.org/t/debug-symbols-in-fortran-with-ninja-and-intel-compiler-on-windows/2762 "2021-02-15T15:51:16Z")

</div>

Hi guys, we have a problem with debugging Fortran code, because the source code reference in the object file is not set correctly. Find below a minimal example to reproduce the problem. Apparently, during preprocessing…

---

## [Building MPICH as an external project results in an odd fortran error - FCMODOUTFLAG not detected.](https://discourse.cmake.org/t/building-mpich-as-an-external-project-results-in-an-odd-fortran-error-fcmodoutflag-not-detected/927)

<div class="topic-metadata">

**Author:** [@KBentley57](https://discourse.cmake.org/u/KBentley57)\
**Replies:** 1\
**Last updated:** [April 6, 2020, 3:29pm UTC](https://discourse.cmake.org/t/building-mpich-as-an-external-project-results-in-an-odd-fortran-error-fcmodoutflag-not-detected/927 "2020-04-06T15:29:58Z")

</div>

I’m building several packages of scientific software, for use in my program, and for the life of me, I can’t figure out the behavior I’m seeing. I am unsure that it’s a bug, per se, but something is awry, and I’m not su…
