@@ -37,6 +37,12 @@ Choose a build tool you are comfortable working with, it should not get in your
37
37
way while developing. Spending more time on working against your build tools
38
38
than doing actual development work can quickly become frustrating.
39
39
40
+ In recent years, the [ Fortran Package Manager] ( https://fpm.fortran-lang.org/ ) tool
41
+ has been in development. The FPM is a package manager and build system for Fortran
42
+ applications. The user interface for the FPM is inspired by Rust's cargo. The main
43
+ goal of the FPM is to nurture and grow the ecosystem of modern Fortran applications
44
+ and libraries.
45
+
40
46
Also, consider the accessibility of your build tools.
41
47
If it is restricted to a specific integrated development environment, can all
42
48
developers on your project access it?
@@ -48,6 +54,61 @@ learn a complex programming language first to add a new source file.
48
54
Finally, consider what other project are using, those you are depending on and
49
55
those that use (or will use) your project as dependency.
50
56
57
+ ## Using the FPM as a build tool
58
+
59
+ First, we have to install the FPM to our system. Click [ here] ( https://fpm.fortran-lang.org/install/index.html )
60
+ for detailed instructions. For simplicity, on Linux (or WSL2)
61
+
62
+ ```
63
+ git clone https://github.com/fortran-lang/fpm
64
+ cd fpm
65
+ ./install.sh
66
+ ```
67
+
68
+ FPM will be installed in ~ /.local/bin/fpm. We will start by creating a simple project using the FPM itself
69
+ by doing ` fpm new first_steps ` . This will create a project with a fpm.toml file that will look like this:
70
+
71
+ ```
72
+ name = "first_steps"
73
+ version = "0.1.0"
74
+ license = "license"
75
+ author = "T. Rex."
76
+
77
+ copyright = "Copyright 2021, T. Rex."
78
+ [build]
79
+ auto-executables = true
80
+ auto-tests = true
81
+ auto-examples = true
82
+ [install]
83
+ library = false
84
+ ```
85
+
86
+ The ` fpm.toml ` file is our main control for how our application will be built, also known as our "package manifest".
87
+ Our sample project looks like this:
88
+
89
+ ```
90
+ ├── README.md
91
+ ├── app
92
+ │ └── main.f90
93
+ ├── fpm.toml
94
+ ├── src
95
+ │ └── first_steps.f90
96
+ └── test
97
+ └── check.f90
98
+ ```
99
+
100
+ The FPM allows us to easily add tests and gracefully separate our main subroutines from the main program by creating
101
+ the ` app/main.f90 ` directory and file. It is a good practice to separate this since your ` main.f90 ` file should be a
102
+ simple fail that is mostly in charged of launching the program. This is a good practice in case your project grows
103
+ to become quite large! You will see that the ` first_steps.f90 ` file contains a module and a subroutine to basically
104
+ say "hello!" from your Fortan program. _ Grosso modo_ :
105
+
106
+ - How to build ` fpm build `
107
+ - To run ` fpm run `
108
+ - To install ` fpm install ` the default install location is ` ~/local/bin `
109
+ - To install the executable to a custom location ` fpm install --prefix /a/path/to/custom/location `
110
+
111
+
51
112
## Using make as build tool
52
113
53
114
The most well-known and commonly used build system is called ` make ` .
0 commit comments