# A couple of newbie FPM questions

**URL:** <https://fortran-lang.discourse.group/t/a-couple-of-newbie-fpm-questions/8485>\
**Category:** fpm\
**Created:** [August 15, 2024, 10:57pm UTC](https://fortran-lang.discourse.group/t/a-couple-of-newbie-fpm-questions/8485 "2024-08-15T22:57:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rwmsu](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@rwmsu](https://fortran-lang.discourse.group/u/rwmsu)\
**Post date:** [August 15, 2024, 10:57pm UTC](https://fortran-lang.discourse.group/t/a-couple-of-newbie-fpm-questions/8485/1 "2024-08-15T22:57:14Z")

</div>

I’m trying to set up an FPM build for something I’m been working on for a couple of months. I’m currently using Makefiles and they are mostly bullet proof. However there are a couple of things I’ve encountered with FPM that I have questions about.

1 - Is there a way to define an alternate directory to hold module files instead of include. If not why isn’t there. All Fortran compilers have an option to define a path where modules are both written to and read from (usually a -module /path/to/modules). I know I’m in the minority but I only like to put things in include that are actual include type files. Besides an include directory is just SO C/C++ 😄 Something I try desperately to avoid

2 - Is there a way to stop FPM from trying to run tests and just make the executables for the tests

Here is what my FPM manifest looks like. I’m compiling with gfortran-13

```auto
name = "myProject"
version = "0.1"
author = "me"
maintainer = "me"
copyright = "Copyright (c) 2024, me"
license = "BSD-3"
description = "Testing fpm build"

[library]
source-dir = "src"

[install]
library = true

[build]
auto-tests = true

[[test]]
name = "test1"
source-dir = "test"
main = "test1.F90"

[[test]]
name = "test2"
source-dir = "test"
main = test2.F90

[[test]]
name = "test3"
source-dir = "test"
main = "test3.F90"

[[test]]
name = "test4"
source-dir = "test"
main = "test4.F90"

[[test]]
name = "test5"
source-dir = "test"
main = "test5.F90"

[[test]]
name = "test6"
source-dir = "test"
main = "test6.F90"

```

---

<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:** [August 16, 2024, 12:10am UTC](https://fortran-lang.discourse.group/t/a-couple-of-newbie-fpm-questions/8485/2 "2024-08-16T00:10:36Z")

</div>

```bash
fpm build --tests

```

you can specify multiple include directories via the manifest file fpm.toml

```plaintext

   Projects which use the Fortran include statement or C preprocessor
   #include statement, can use the include-dir key to specify search
   directories for the included files. include-dir can contain one or more
   directories, where multiple directories are specified using a list of
   strings. Include directories from all project dependencies are passed
   to the compiler using the appropriate compiler flag.

   Example:
[library]
include-dir = ["include", "third_party/include"]

```

files are also searched for in the src directories and can also be specified using options on the fpm command or using FPM-specific environment variables but also via compiler-specific methods as well.

The command options are available via “fpm manual \>manual.txt” , the manifest file is available  
on-line. If you have commands like lynx, links, or w3m or any other terminal-based browsers an easy way to convert it to text is something like

```bash
lynx -dump https://fpm.fortran-lang.org/spec/manifest.html manifest.txt >manifest.txt

```

or go to that URL to see the section on include directories.

So the fpm.toml file can be used to list any directories in the project you want to search for include files… For directories outside of the project (unless you want to create links to them) I generally use one of the other options or response files. The pathnames to other URLs of interest are in the output of the help commands or the text file generated via “fpm manual” as described above. If you have grep you  
want to visit most of the sites listed by entering “fpm manual|grep -i http”. at some point or another and read the associated documents.

---

<div class="post-metadata">

**Author:** ![rwmsu](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@rwmsu](https://fortran-lang.discourse.group/u/rwmsu)\
**Post date:** [August 16, 2024, 12:55am UTC](https://fortran-lang.discourse.group/t/a-couple-of-newbie-fpm-questions/8485/3 "2024-08-16T00:55:57Z")

</div>

Thanks but I don’t think the include-dir is a solution to my problem. Mainly, I don’t want any .mod files wrtten to include. I want them written to a modules directory in the project root directory. That is unless

include-dir = [“./modules”, “include”]

will cause FPM to search modules first and write things there before include. I can force the compile to write to a module directory by adding a -module ./modules to FPM\_FFLAGS. But I’m not sure how FPM will handle .mod files that are not in include.

Also, another question. On Linux why is FPM writing stuff to my home dir hidden .local file. I don’t want anything written there without at least some warning. Can that be turned off.

---

<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:** [August 16, 2024, 1:33am UTC](https://fortran-lang.discourse.group/t/a-couple-of-newbie-fpm-questions/8485/4 "2024-08-16T01:33:18Z")

</div>

Of no use if you do not have Unix or GNU/Linux but if you do this is a bash shell script that will create a test fpm project and edit it to create an example project that uses multiple include directores

> **inc\_test.sh**
>
> #!/bin/bash  
> (  
> set -v -x  
> exec 2\>&1  
> fpm manual \>manual.txt  
> : fpm manual is on manual.txt  
> command -v lynx && lynx -dump [Manifest reference — Fortran Package Manager](https://fpm.fortran-lang.org/spec/manifest.html) manifest.txt \>manifest.txt  
> : if lynx is installed text version of manifest document is on manifest.txt  
> fpm new inc\_test  
> : create test project  
> cd inc\_test  
> : add lines to include from many directories to fpm.toml  
> : create include directories with minimal include files  
> : change application program to have INCLUDE directives  
> echo ‘[library]’ \>\>fpm.toml  
> printf ‘include-dir=[’ \>\>fpm.toml  
> for NAME in add amalgamate assemble blend combine couple embed enfold   
> fuse incorporate integrate interfuse join meld unite weld  
> do  
> mkdir -p $NAME  
> cat \>$NAME/$NAME.inc \<\<EOF  
> write(_,_)‘hello from $NAME!’  
> EOF  
> sed -i -e ‘/say\_hello()/iinclude "’$NAME’.inc"’ app/main.f90  
> printf ‘“%s”, ’ NAME \>\>fpm.toml done sed -i -e 's/, //’ fpm.toml  
> echo ‘]’ \>\>fpm.toml  
> : show file structure created if tree is installed  
> command -v tree && tree  
> : show changed fpm.toml manifest  
> cat fpm.toml  
> : show changed default project program  
> cat app/main.f90  
> : run it and show included files from many directories  
> fpm run  
> )|tee record-$(uuidgen).log  
> exit

---

<div class="post-metadata">

**Author:** ![rwmsu](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@rwmsu](https://fortran-lang.discourse.group/u/rwmsu)\
**Post date:** [August 16, 2024, 1:49am UTC](https://fortran-lang.discourse.group/t/a-couple-of-newbie-fpm-questions/8485/5 "2024-08-16T01:49:42Z")

</div>

I figured out two of my problems. FPM was putting stuff into .local when I didn’t specify a prefix on fpm install. Also, trying to force FPM to copy .mod files over to a modules subdirectory at compile time won’t work. IE adding -J./modules to FPM\_FFLAGS causes gfortran to gripe about -J being defined more than once so I guess FPM is also setting this option. However, the next best thing is to use the --includedir options when installing. ie

fpm install --prefix=./ --includedir=./modules

will end up with what I want.
