better handle variable HDF5 setups, update Fortran compiler def
This commit is contained in:
parent
e1a83793ae
commit
8821c0aadc
|
@ -267,8 +267,8 @@ class FortranCompiler(Compiler):
|
||||||
return CCompiler._get_trials_from_pattern(pattern, directory, libname)
|
return CCompiler._get_trials_from_pattern(pattern, directory, libname)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_file_from_list(files) -> List[str]:
|
def _get_file_from_list(env, files: List[str]) -> str:
|
||||||
return CCompiler._get_file_from_list(files)
|
return CCompiler._get_file_from_list(env, files)
|
||||||
|
|
||||||
class GnuFortranCompiler(GnuCompiler, FortranCompiler):
|
class GnuFortranCompiler(GnuCompiler, FortranCompiler):
|
||||||
def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, defines=None, **kwargs):
|
def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, defines=None, **kwargs):
|
||||||
|
|
|
@ -19,7 +19,6 @@ import copy
|
||||||
import functools
|
import functools
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import stat
|
|
||||||
import json
|
import json
|
||||||
import shlex
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
|
|
|
@ -52,23 +52,25 @@ class HDF5Dependency(ExternalDependency):
|
||||||
if pkgdep.found():
|
if pkgdep.found():
|
||||||
self.compile_args = pkgdep.get_compile_args()
|
self.compile_args = pkgdep.get_compile_args()
|
||||||
# derive needed libraries by language
|
# derive needed libraries by language
|
||||||
link_args = pkgdep.get_link_args()
|
pd_link_args = pkgdep.get_link_args()
|
||||||
lang_link_args = []
|
link_args = []
|
||||||
for larg in link_args:
|
for larg in pd_link_args:
|
||||||
lpath = Path(larg)
|
lpath = Path(larg)
|
||||||
if lpath.is_file():
|
if lpath.is_file():
|
||||||
if language == 'cpp':
|
if language == 'cpp':
|
||||||
lang_link_args.append(str(lpath.parent / (lpath.stem + '_hl_cpp' + lpath.suffix)))
|
link_args.append(str(lpath.parent / (lpath.stem + '_hl_cpp' + lpath.suffix)))
|
||||||
lang_link_args.append(str(lpath.parent / (lpath.stem + '_cpp' + lpath.suffix)))
|
link_args.append(str(lpath.parent / (lpath.stem + '_cpp' + lpath.suffix)))
|
||||||
elif language == 'fortran':
|
elif language == 'fortran':
|
||||||
lang_link_args.append(str(lpath.parent / (lpath.stem + 'hl_fortran' + lpath.suffix)))
|
link_args.append(str(lpath.parent / (lpath.stem + 'hl_fortran' + lpath.suffix)))
|
||||||
lang_link_args.append(str(lpath.parent / (lpath.stem + '_fortran' + lpath.suffix)))
|
link_args.append(str(lpath.parent / (lpath.stem + '_fortran' + lpath.suffix)))
|
||||||
|
|
||||||
# C is used by other languages
|
# HDF5 C libs are required by other HDF5 languages
|
||||||
lang_link_args.append(str(lpath.parent / (lpath.stem + '_hl' + lpath.suffix)))
|
link_args.append(str(lpath.parent / (lpath.stem + '_hl' + lpath.suffix)))
|
||||||
lang_link_args.append(larg)
|
link_args.append(larg)
|
||||||
|
else:
|
||||||
|
link_args.append(larg)
|
||||||
|
|
||||||
self.link_args = lang_link_args
|
self.link_args = link_args
|
||||||
self.version = pkgdep.get_version()
|
self.version = pkgdep.get_version()
|
||||||
self.is_found = True
|
self.is_found = True
|
||||||
self.pcdep = pkgdep
|
self.pcdep = pkgdep
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
# This file contains the detection logic for external dependencies that are
|
# This file contains the detection logic for external dependencies that are
|
||||||
# platform-specific (generally speaking).
|
# platform-specific (generally speaking).
|
||||||
|
|
||||||
from .. import mesonlib
|
|
||||||
|
|
||||||
from .base import ExternalDependency, DependencyException
|
from .base import ExternalDependency, DependencyException
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ unsigned maj, min, rel;
|
||||||
|
|
||||||
ier = H5open();
|
ier = H5open();
|
||||||
if (ier) {
|
if (ier) {
|
||||||
std::cerr << "Unable to initialize HDF5: %d" << ier << std::endl;
|
std::cerr << "Unable to initialize HDF5: " << ier << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,11 +18,11 @@ if (ier) {
|
||||||
std::cerr << "HDF5 did not initialize!" << std::endl;
|
std::cerr << "HDF5 did not initialize!" << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
printf("C++ HDF5 version %d.%d.%d\n", maj, min, rel);
|
std::cout << "C++ HDF5 version " << maj << "." << min << "." << rel << std::endl;
|
||||||
|
|
||||||
ier = H5close();
|
ier = H5close();
|
||||||
if (ier) {
|
if (ier) {
|
||||||
std::cerr << "Unable to close HDF5: %d" << ier << std::endl;
|
std::cerr << "Unable to close HDF5: " << ier << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
@ -12,31 +12,30 @@ endif
|
||||||
# --- C tests
|
# --- C tests
|
||||||
h5c = dependency('hdf5', language : 'c', required : false)
|
h5c = dependency('hdf5', language : 'c', required : false)
|
||||||
if not h5c.found()
|
if not h5c.found()
|
||||||
error('MESON_SKIP_TEST: HDF5 not found, skipping.')
|
error('MESON_SKIP_TEST: HDF5 C library not found, skipping HDF5 framework tests.')
|
||||||
endif
|
endif
|
||||||
exec = executable('exec', 'main.c',
|
exec = executable('exec', 'main.c', dependencies : h5c)
|
||||||
dependencies : h5c)
|
|
||||||
|
|
||||||
test('HDF5 C', exec)
|
test('HDF5 C', exec)
|
||||||
|
|
||||||
# --- C++ tests
|
# --- C++ tests
|
||||||
h5cpp = dependency('hdf5', language : 'cpp')
|
h5cpp = dependency('hdf5', language : 'cpp', required : false)
|
||||||
execpp = executable('execpp', 'main.cpp',
|
if h5cpp.found()
|
||||||
dependencies : h5cpp)
|
execpp = executable('execpp', 'main.cpp', dependencies : h5cpp)
|
||||||
|
|
||||||
test('HDF5 C++', execpp)
|
test('HDF5 C++', execpp)
|
||||||
|
endif
|
||||||
|
|
||||||
# --- Fortran tests
|
# --- Fortran tests
|
||||||
if build_machine.system() != 'windows'
|
if build_machine.system() != 'windows'
|
||||||
add_languages('fortran')
|
add_languages('fortran')
|
||||||
|
|
||||||
h5f = dependency('hdf5', language : 'fortran')
|
h5f = dependency('hdf5', language : 'fortran', required : false)
|
||||||
exef = executable('exef', 'main.f90',
|
if h5f.found()
|
||||||
dependencies : h5f)
|
exef = executable('exef', 'main.f90', dependencies : h5f)
|
||||||
|
|
||||||
test('HDF5 Fortran', exef)
|
test('HDF5 Fortran', exef)
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
# Check we can apply a version constraint
|
# Check we can apply a version constraint
|
||||||
if h5c.version() != 'unknown'
|
if h5c.version() != 'unknown'
|
||||||
|
|
Loading…
Reference in New Issue