You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The stdlib project exports CMake package files and pkg-config files to make stdlib usable for other projects.
221
-
The package files are located in the library directory in the installation prefix.
244
+
After the library has been built, it can be included in a regular Makefile.
245
+
The recommended way to do this is using the [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) tool, for which an example is shown below.
246
+
```make
247
+
# Necessary if the installation directory is not in PKG_CONFIG_PATH
# Example definition of Fortran compiler and flags
255
+
FC := gfortran
256
+
FFLAGS := -O2 -Wall -g
257
+
258
+
# Definition of targets etc.
227
259
...
228
-
target_link_libraries(
229
-
${PROJECT_NAME}
230
-
PRIVATE
231
-
fortran_stdlib::fortran_stdlib
232
-
)
260
+
261
+
# Example rule to compile object files from .f90 files
262
+
%.o: %.f90
263
+
$(FC) -c -o $@ $< $(FFLAGS) $(STDLIB_CFLAGS)
264
+
265
+
# Example rule to link an executable from object files
266
+
%: %.o
267
+
$(FC) -o $@ $^ $(FFLAGS) $(STDLIB_LIBS)
268
+
233
269
```
234
270
235
-
To make the installed stdlib project discoverable add the stdlib directory to the ``CMAKE_PREFIX_PATH``.
236
-
The usual install location of the package files is ``$PREFIX/lib/cmake/fortran_stdlib``.
271
+
The same can also be achieved without pkg-config.
272
+
If the library has been installed in a directory inside the compiler's search path,
273
+
only a flag `-lfortran_stdlib` is required.
274
+
If the installation directory is not in the compiler's search path, one can add for example
275
+
```make
276
+
install_dir := path/to/install_dir
277
+
libdir := $(install_dir)/lib
278
+
moduledir := $(install_dir)/include/fortran_stdlib/<compiler name and version>
279
+
```
280
+
The linker should then look for libraries in `libdir` (using e.g.`-L$(libdir)`) and the compiler should look for module files in `moduledir` (using e.g. `-I$(moduledir)`).
281
+
Alternatively, the library can also be included from a build directory without installation with
0 commit comments