fortran: make include scanning also work for CMake subprojects
also fixed PEP8
I originally implemented the "include" scanning,
but hadn't made a test for this case
@@ -1560,13 +1560,13 @@ int dummy;
self.get_target_dir(target))
else:
target_slashname_workaround_dir = self.get_target_dir(target)
- (rpath_args, target.rpath_dirs_to_remove) = \
+ rpath_args, target.rpath_dirs_to_remove = (
rustc.build_rpath_args(self.environment,
self.environment.get_build_dir(),
target_slashname_workaround_dir,
self.determine_rpath_dirs(target),
target.build_rpath,
- target.install_rpath)
+ target.install_rpath))
# ... but then add rustc's sysroot to account for rustup
# installations
for rpath_arg in rpath_args:
@@ -2777,13 +2777,13 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
self.get_target_dir(target))
else:
target_slashname_workaround_dir = self.get_target_dir(target)
- (rpath_args, target.rpath_dirs_to_remove) = \
+ (rpath_args, target.rpath_dirs_to_remove) = (
linker.build_rpath_args(self.environment,
self.environment.get_build_dir(),
target_slashname_workaround_dir,
self.determine_rpath_dirs(target),
target.build_rpath,
- target.install_rpath)
+ target.install_rpath))
commands += rpath_args
# Add libraries generated by custom targets
custom_target_libraries = self.get_custom_target_provided_libraries(target)
@@ -3041,7 +3041,9 @@ def _scan_fortran_file_deps(src: Path, srcdir: Path, dirname: Path, tdeps, compi
# included files
incmatch = incre.match(line)
if incmatch is not None:
- incfile = srcdir / incmatch.group(1)
+ incfile = src.parent / incmatch.group(1)
+ # NOTE: src.parent is most general, in particular for CMake subproject with Fortran file
+ # having an `include 'foo.f'` statement.
if incfile.suffix.lower()[1:] in compiler.file_suffixes:
mod_files.extend(_scan_fortran_file_deps(incfile, srcdir, dirname, tdeps, compiler))
# modules
