Skip to content

Commit ece1971

Browse files
committed
Write a more verbose introduction to building stdlib
- explicitly spell out the requirements on compilers, build system and preprocessor - add a short paragraph on how to install the build dependencies using pip or conda - explain the CMake build step by step - list all important CMake configuration options in the README - add the CMake install command to the build instructions - move the paragraph about the max array rank into the build instructions
1 parent 0c50e78 commit ece1971

File tree

1 file changed

+65
-18
lines changed

1 file changed

+65
-18
lines changed

README.md

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,54 +40,101 @@ git clone https://github.com/fortran-lang/stdlib
4040
cd stdlib
4141
```
4242

43+
4344
### Requirements
4445

45-
The preprocessor ```fypp``` (https://github.com/aradi/fypp) is needed because metaprogramming is used.
46-
It can be installed using the command line installer ```pip```.
46+
To build the Fortran standard library you need
47+
48+
- a Fortran 2008 compliant compiler, better a Fortran 2018 compliant compiler
49+
(GCC Fortran or Intel Fortran compilers are known to work for stdlib)
50+
- CMake version 3.14 or newer (alternatively make can be used)
51+
- a build backend for CMake, like make or ninja (the latter is recommended on Windows)
52+
- the [``fypp``](https://github.com/aradi/fypp) preprocessor (used as meta-programming tool)
53+
54+
If your system package manager does not provide the required build tools, all build dependencies can be installed with the Python command line installer ``pip``:
55+
4756
```sh
48-
pip install fypp
57+
pip install fypp cmake ninja
4958
```
5059

60+
Alternatively, you can install the build tools from the conda-forge channel with the conda package manager:
61+
62+
```sh
63+
conda config --add channels conda-forge
64+
conda create -n stdlib-tools fypp cmake ninja
65+
conda activate stdlib-tools
66+
```
67+
68+
You can install conda from using the [miniforge installer](https://github.com/conda-forge/miniforge/releases).
69+
Also, you can install a Fortran compiler from conda-forge by installing the ``fortran-compiler`` package, which installs ``gfortran``.
70+
71+
5172
### Build with CMake
5273

74+
Configure the build with
75+
5376
```sh
5477
cmake -B build
78+
```
79+
80+
you can pass additional options to CMake to customize the build.
81+
Important options are
82+
83+
- `-G Ninja` to use the ninja backend instead of the default make backend, other build backends are available with a similar syntax
84+
- `-DCMAKE_INSTALL_PREFIX` is used to provide the install location for the library.
85+
- `-DCMAKE_MAXIMUM_RANK` the maximum array rank procedures should be generated for.
86+
The default is 15 for Fortran 2003 compliant compilers, otherwise 7 for compilers not supporting Fortran 2003 completely yet.
87+
The minimum required rank to compile this project is 4.
88+
Compiling with maximum rank 15 can be resource intensive and requires at least 16 GB of memory to allow parallel compilation or 4 GB memory for sequential compilation.
89+
- `-DBUILD_SHARED_LIBS` set to `on` in case you want link your application dynamically against the standard library (default: `off`).
90+
91+
For example, to configure a build using the ninja backend and generating procedures up to rank 7, which is installed to your home directory use
92+
93+
```sh
94+
cmake -B build -G Ninja -DCMAKE_MAXIMUM_RANK=7 -DCMAKE_INSTALL_PREFIX=$HOME/.local
95+
```
5596

97+
To build the standard library run
98+
99+
```sh
56100
cmake --build build
101+
```
57102

103+
To test your build setup run the projects testsuite after the build has finished with
104+
105+
```sh
58106
cmake --build build --target test
59107
```
60108

61-
### Build with make
109+
Please report failing tests on our [issue tracker](https://github.com/fortran-lang/stdlib/issues/new/choose) including details on the compiler used, the operating system and platform architecture.
62110

63-
Alternatively, you can build using provided Makefiles:
111+
To install the project to the declared prefix run
64112

113+
```sh
114+
cmake --install build
65115
```
66-
make -f Makefile.manual
67-
```
68116

69-
## Limiting the maximum rank of generated procedures
117+
Now you have a working version of stdlib you can use for your project.
118+
70119

71-
Stdlib's preprocessor (fypp) by default generates specific procedures for arrays of all ranks, up to rank 15.
72-
This can result in long compilation times and, on some computers, exceeding available memory.
73-
If you know that you won't need all 15 ranks, you can specify the maximum rank for which the specific procedures will be generated.
74-
For example, with CMake:
120+
### Build with make
121+
122+
Alternatively, you can build using provided Makefiles:
75123

76124
```sh
77-
cmake -B build -DCMAKE_MAXIMUM_RANK=4
78-
cmake --build build
79-
cmake --build build --target test
125+
make -f Makefile.manual
80126
```
81-
or as follows with `make`:
127+
128+
You can limit the maximum rank by setting ``-DMAXRANK=<num>`` in the ``FYPPFLAGS`` environment variable:
82129

83130
```sh
84131
make -f Makefile.manual FYPPFLAGS=-DMAXRANK=4
85132
```
86-
Note that currently the minimum value for maximum rank is 4.
133+
87134

88135
## Documentation
89136

90-
Documentation is a work in progress (see issue #4) but is currently available at https://stdlib.fortran-lang.org.
137+
Documentation is a work in progress (see issue [#4](https://github.com/fortran-lang/stdlib/issues/4)) but alrealy available at https://stdlib.fortran-lang.org.
91138
This includes API documentation automatically generated from static analysis and markup comments in the source files
92139
using the [FORD](https://github.com/Fortran-FOSS-programmers/ford/wiki) tool,
93140
as well as a specification document or ["spec"](https://stdlib.fortran-lang.org/page/specs/index.html) for each proposed feature.

0 commit comments

Comments
 (0)