# Specifying the default compiler for fpm

**URL:** <https://fortran-lang.discourse.group/t/specifying-the-default-compiler-for-fpm/10686>\
**Category:** Help\
**Created:** [February 2, 2026, 3:05pm UTC](https://fortran-lang.discourse.group/t/specifying-the-default-compiler-for-fpm/10686 "2026-02-02T15:05:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![simong](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@simong](https://fortran-lang.discourse.group/u/simong)\
**Post date:** [February 2, 2026, 3:05pm UTC](https://fortran-lang.discourse.group/t/specifying-the-default-compiler-for-fpm/10686/1 "2026-02-02T15:05:16Z")

</div>

I’ve just started using fpm 0.12.0.  
I’d like to specify the default compiler to use with a particular project since my code builds okay with ifx but not gfortran (the default default). I can use the environment variable FPM\_FC to specify ifx or use the --compiler option (both work). What I’d like to do is specify it in a configuration e.g. fpm.toml but I can’t find any information in the docs on-line on how to do this.  
Many thanks  
Simon

---

<div class="post-metadata">

**Author:** ![urbanjost](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@urbanjost](https://fortran-lang.discourse.group/u/urbanjost)\
**Post date:** [February 2, 2026, 11:26pm UTC](https://fortran-lang.discourse.group/t/specifying-the-default-compiler-for-fpm/10686/2 "2026-02-02T23:26:58Z")

</div>

fpm does not currently read a configuration file other than the fpm.toml file, which someday will hopefully allow specifying custom profiles and perhaps a default compiler. In addition to the methods you mention, choices include:

1. an fpm.rsp response file
2. a shell alias command
3. a plug-in command
4. a wrapper script that sets up an environment and starts a subshell.

[GitHub - urbanjost/M\_CLI2: Fortran commandline-interface using a simple prototype command](https://github.com/urbanjost/M_CLI2) has a description on how to write an fpm.rsp response file, which I think is the easiest solution. You can create a default file, but an easy way to start is to create something like

```plaintext
@run
option run --compiler ifx --flag "-O3 " --profile debug --verbose

@build
option build --compiler ifx --flag "-O3 " --profile debug --verbose

@test
option test --compiler ifx --flag "-O3 " --profile debug --verbose

```

in the top directory of your project and call it “fpm.rsp”, and then you can use fpm like

```bash
fpm @test
fpm @build

```

Edit: corrected URL

---

<div class="post-metadata">

**Author:** ![simong](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@simong](https://fortran-lang.discourse.group/u/simong)\
**Post date:** [February 3, 2026, 10:51am UTC](https://fortran-lang.discourse.group/t/specifying-the-default-compiler-for-fpm/10686/3 "2026-02-03T10:51:10Z")

</div>

Thank you. I will look into this but the link above just gives a 404 error.

---

<div class="post-metadata">

**Author:** ![moriglia](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@moriglia](https://fortran-lang.discourse.group/u/moriglia)\
**Post date:** [February 3, 2026, 11:16am UTC](https://fortran-lang.discourse.group/t/specifying-the-default-compiler-for-fpm/10686/4 "2026-02-03T11:16:45Z")

</div>

Maybe it was the wrong user handle:

> **[GitHub - urbanjost/M\_CLI2: Fortran commandline-interface using a simple...](https://github.com/urbanjost/M_CLI2)**
>
> Fortran commandline-interface using a simple prototype command

---

<div class="post-metadata">

**Author:** ![simong](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@simong](https://fortran-lang.discourse.group/u/simong)\
**Post date:** [February 3, 2026, 6:08pm UTC](https://fortran-lang.discourse.group/t/specifying-the-default-compiler-for-fpm/10686/5 "2026-02-03T18:08:34Z")

</div>

Yes that works thanks.

---

<div class="post-metadata">

**Author:** ![BFelsher](https://avatars.discourse-cdn.com/v4/letter/b/71c47a/32.png) [@BFelsher](https://fortran-lang.discourse.group/u/BFelsher)\
**Post date:** [February 3, 2026, 7:55pm UTC](https://fortran-lang.discourse.group/t/specifying-the-default-compiler-for-fpm/10686/6 "2026-02-03T19:55:53Z")

</div>

Looking forward to this implementation. It will be a lot nicer than my current method of setting bash aliases to set compiler flags before calling fpm build, test, etc…Fortunately, I am only working on one single project at the moment.
