# LFortran now recognized by CMake

**URL:** <https://fortran-lang.discourse.group/t/lfortran-now-recognized-by-cmake/9144>\
**Category:** LFortran\
**Created:** [January 29, 2025, 9:50pm UTC](https://fortran-lang.discourse.group/t/lfortran-now-recognized-by-cmake/9144 "2025-01-29T21:50:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jorgeg](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jorgeg/32/6835_2.png) [@jorgeg](https://fortran-lang.discourse.group/u/jorgeg)\
**Post date:** [January 29, 2025, 9:50pm UTC](https://fortran-lang.discourse.group/t/lfortran-now-recognized-by-cmake/9144/1 "2025-01-29T21:50:31Z")

</div>

I don’t think this has been mentioned elsewhere, see the [release notes](https://cmake.org/cmake/help/latest/release/3.31.html#compilers) for CMake 3.31 Lfortran is now supported in CMake! 😃

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [January 29, 2025, 10:28pm UTC](https://fortran-lang.discourse.group/t/lfortran-now-recognized-by-cmake/9144/2 "2025-01-29T22:28:06Z")

</div>

Yes. Please report all bugs. This is a new feature and some things might break.

---

<div class="post-metadata">

**Author:** ![tyranids](https://avatars.discourse-cdn.com/v4/letter/t/3e96dc/32.png) [@tyranids](https://fortran-lang.discourse.group/u/tyranids)\
**Post date:** [January 30, 2025, 4:15pm UTC](https://fortran-lang.discourse.group/t/lfortran-now-recognized-by-cmake/9144/3 "2025-01-30T16:15:00Z")

</div>

This is great to hear, fantastic!

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [May 6, 2026, 12:37am UTC](https://fortran-lang.discourse.group/t/lfortran-now-recognized-by-cmake/9144/4 "2026-05-06T00:37:44Z")

</div>

How to use it?

I tried lfortran-0.63.0\examples\project1 on Win 10 with cmake 4.3.2.

The readme.md says:

```auto
To compile with LFortran:

    FC=lfortran cmake .

```

Have to changed to:

```auto
cmake FC=lfortran .

```

The error is:

```auto
D:\00masterLib\lfortran-0.63.0\examples\project1>cmake FC=lfortran .
-- Selecting Windows SDK version 10.0.26100.0 to target Windows 10.0.19045.
-- The Fortran compiler identification is IntelLLVM 2025.1.0 with MSVC-like command-line
CMake Error at CMakeLists.txt:3 (project):
  The CMAKE_Fortran_COMPILER:

    lfortran

  is not a full path and was not found in the PATH. Perhaps the extension is
  missing?

```

I have Intel Fortran on my pc. It found IntelLLVM first, then says lfortran not found. In that folder, I do can start lfortran. My lfortran.exe is at D:\00masterLib\lfortran-0.63.0\inst\bin\lfortran.exe and it is in the PATH.

Thanks for help

Cean

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [May 6, 2026, 1:49am UTC](https://fortran-lang.discourse.group/t/lfortran-now-recognized-by-cmake/9144/5 "2026-05-06T01:49:53Z")

</div>

I don’t know how to fix it. I don’t have time right now to debug it myself, but if somebody can help with setting up cmake+lfortran on Windows, that would be highly appreciated. It works on linux/macOS.

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [May 6, 2026, 2:17am UTC](https://fortran-lang.discourse.group/t/lfortran-now-recognized-by-cmake/9144/6 "2026-05-06T02:17:22Z")

</div>

I uploaded my lfortran\_0.63.0.exe to my google drive. 20.54MB

[https://drive.google.com/file/d/11GRJIIPredV8lLlsPljtQHL0FDObDxM6/view?usp=drivesdk](https://drive.google.com/file/d/11GRJIIPredV8lLlsPljtQHL0FDObDxM6/view?usp=drivesdk)

After unzip, all under an inst folder. Need to set the inst/bin into Windows 10’s PATH.

If lfortran asks some Dlls to run, upzip these into the bin folder. 9.49MB.

[https://drive.google.com/file/d/1NWAF8EqfsKtw8uyMTnPC2eQMtaeyPrE8/view?usp=drivesdk](https://drive.google.com/file/d/1NWAF8EqfsKtw8uyMTnPC2eQMtaeyPrE8/view?usp=drivesdk)

Because lfortran needs VS’s link to generate exe file, you must have VS installed and run lfortran inside the X64 native terminal.

Hope that will help.

---

<div class="post-metadata">

**Author:** ![jorgeg](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jorgeg/32/6835_2.png) [@jorgeg](https://fortran-lang.discourse.group/u/jorgeg)\
**Post date:** [May 6, 2026, 3:45am UTC](https://fortran-lang.discourse.group/t/lfortran-now-recognized-by-cmake/9144/7 "2026-05-06T03:45:50Z")

</div>

it might be a CMake for windows thing? Can you use the WSL?

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [May 6, 2026, 4:06am UTC](https://fortran-lang.discourse.group/t/lfortran-now-recognized-by-cmake/9144/8 "2026-05-06T04:06:47Z")

</div>

Not really want to use wsl.

What file and where cmake look for lFortran? Never tried to figure out how the find package works.

---

<div class="post-metadata">

**Author:** ![jorgeg](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jorgeg/32/6835_2.png) [@jorgeg](https://fortran-lang.discourse.group/u/jorgeg)\
**Post date:** [May 6, 2026, 4:10am UTC](https://fortran-lang.discourse.group/t/lfortran-now-recognized-by-cmake/9144/9 "2026-05-06T04:10:16Z")

</div>

you can use `cmake --debug-find ../` to see what it is looking for

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [May 6, 2026, 5:19am UTC](https://fortran-lang.discourse.group/t/lfortran-now-recognized-by-cmake/9144/10 "2026-05-06T05:19:09Z")

</div>

Put full path worked.

```auto
cmake -DCMAKE_Fortran_COMPILER="D:/bjbin/lfortran/bin/lfortran.exe" .

```

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [May 7, 2026, 12:54am UTC](https://fortran-lang.discourse.group/t/lfortran-now-recognized-by-cmake/9144/11 "2026-05-07T00:54:32Z")

</div>

This generates sln file. When loaded in VS, it is actually build by Intel Fortran on my computer.

I should add the -G “Unix Makefiles”. Then it generates makefile file and then can be build by lfortran.

Disable my Intel Fortran first, then no need for full path of lfortran.
