-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to install Fortran .mod files? #5374
Comments
#4708 is the same issue i believe. This might not be in Meson yet. A workaround would be to call a Python script that copies them over. |
See also: |
In my gtk-fortran project, I am using the following workaround: install_subdir(meson.build_root()/'src'/'25a6634@'/gtk_V_fortran+'@sha',
install_dir: 'include'/gtk_V_fortran,
strip_directory: true,
exclude_files: ['src_atk-auto.f90.o', 'src_gdk-pixbuf-auto.f90.o', 'src_gtk.f90.o'...]) The problem is that these So, I tried to write something like: install_subdir(shared_lib.private_dir_include(),...` but I obtained the message Is it possible to obtain a string from |
That's a good thought I had also tried private_dir. It seems possible an internal modification to Meson might be able to do it. |
Is there a way forward for this long-standing issue? |
The easiest way to install module files seems to be with an install script meson.add_install_script(
find_program(files('install-mod.py')),
get_option('includedir') / meson.project_name(),
) To find and copy all module from the target's private directories in the build root directories or in the complete build tree this script worked for me: #!/usr/bin/env python
# SPDX-Identifier: CC0-1.0
from os import environ, listdir, makedirs, walk
from os.path import join, isdir, exists
from sys import argv
from shutil import copy
all_modules = True
build_dir = environ["MESON_BUILD_ROOT"]
if "MESON_INSTALL_DESTDIR_PREFIX" in environ:
install_dir = environ["MESON_INSTALL_DESTDIR_PREFIX"]
else:
install_dir = environ["MESON_INSTALL_PREFIX"]
include_dir = argv[1] if len(argv) > 1 else "include"
module_dir = join(install_dir, include_dir)
modules = []
if all_modules:
# finds $build_dir/**/*.mod
for root, dirs, files in walk(build_dir):
modules += [join(root, f) for f in files if f.endswith(".mod")]
else:
# finds $build_dir/*/*.mod
for d in listdir(build_dir):
bd = join(build_dir, d)
if isdir(bd):
modules += [join(bd, f) for f in listdir(bd) if f.endswith(".mod")]
if not exists(module_dir):
makedirs(module_dir)
for mod in modules:
print("Installing", mod, "to", module_dir)
copy(mod, module_dir) |
I can't seem to figure out how to install the Fortran module files that are generated during the build.
Not sure if it matters, but I am building a library that is made up from C, C++ and Fortran code, all of which works fine, the Fortran unit tests compilation also has no problem finding the .mod files.
Any thoughts? Apologies if this has been covered elsewhere already...
The text was updated successfully, but these errors were encountered: