Open ivan-pi opened 3 years ago
Feel free to add more packages to the first post.
stdlib does provide a pc file and even some more or less transparent logic how it is generated: https://github.com/fortran-lang/stdlib/blob/3621b03c5748b309113316168eae7b6ddc973851/config/CMakeLists.txt#L3-L13
Related to FFTW and also discussion #447, the default installation of FFTW will place a set of source files containing the interfaces to the C routines in /usr/include
:
$ ls /usr/include/fftw* -l
-rw-r--r-- 1 root root 2447 Dez 9 2017 /usr/include/fftw3.f
-rw-r--r-- 1 root root 54596 Dez 9 2017 /usr/include/fftw3.f03
-rw-r--r-- 1 root root 31394 Dez 9 2017 /usr/include/fftw3.h
-rw-r--r-- 1 root root 26983 Dez 9 2017 /usr/include/fftw3l.f03
-rw-r--r-- 1 root root 25682 Dez 9 2017 /usr/include/fftw3q.f03
Now to bypass the whole issue of shipping Fortran modules, the FFTW manual recommends that users who want to import FFTW routines as a module, should define one themselves:
module FFTW3
use, intrinsic :: iso_c_binding
include 'fftw3.f03'
end module
However, since gfortran
doesn't search /usr/include/
, anyone who wants to use FFTW still needs to append the flag -I/usr/include
.
Also the system installed .pc
file is not geared towards Fortran users:
$ pkg-config --cflags fftw3
$ pkg-config --libs fftw3
-lfftw3
We would have to add --keep-system-cflags
in case we detect GFortran to work around this issue.
❯ pkg-config fftw3 --cflags --keep-system-cflags
-I/usr/include
It looks like you are using pkgconf
(see https://github.com/pkgconf/pkgconf/blob/2fdc5f0081dcf22fa476767877d13097eb81e255/cli/main.c#L849)
On my installation:
$ pkg-config --version
0.29.1
$ pkg-config fftw3 --cflags --keep-system-cflags
Unknown option --keep-system-cflags
So the different command line options of pkg-config
programs can potentially make a bigger mess.
This might also affect your reply to Milan in https://github.com/fortran-lang/fpm/issues/439#issuecomment-821781400
Arch Linux uses pkgconf (1.7.3) with symlinking it as pkg-config. This means we can't workaround this issue with GFortran by using pkg-config options because they won't be supported in all implementations.
Our alternatives for GFortran would be
-I
optionsAnother solution for FFTW3 with GFortran would be using the C preprocessor instead of the Fortran include
directive with:
module fftw3
use, intrinsic :: iso_c_binding
#include "fftw3.f03"
end module fftw3
That works, but the file needs to given the .F90
suffix in order to invoke the preprocessor automatically (for all compilers). In the long term, I would ultimately prefer the system fftw packages change their default install location (and suffix) of the interface files (unless we reach agreement that /usr/include/
is the right location for these).
Another option would be to offer an fftw3 module fpm package in a fortran-lang repository.
Should this be of use, sometime ago I wrote a module to read pkg-config files, including substitution of macros. See the attached file: pkgconfig.f90.txt
I've created this issue to keep track of some of the (scientific) packages which provide a pkg-config file and could be candidates for testing with fpm.
You can see a list of package files already installed on your system with the command
pkg-config --list-all
.