Skip to content

Commit

Permalink
Allow finding libraries with C compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
awvwgk committed Nov 24, 2024
1 parent 2a3d675 commit abb5948
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
22 changes: 11 additions & 11 deletions config/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

os = host_machine.system()
fc = meson.get_compiler('fortran')
cc = fc
if has_cc
cc = meson.get_compiler('c')
endif
fc_id = fc.get_id()

# Treat Intel LLVM compiler as standard Intel compiler for compatibility
Expand Down Expand Up @@ -63,10 +67,6 @@ endif

if lapack_vendor == 'mkl'
mkl_dep = []
cc = fc
if add_languages('c', required: false, native: false)
cc = meson.get_compiler('c')
endif
if fc_id == 'intel'
mkl_dep += cc.find_library(ilp64 ? 'mkl_intel_ilp64' : 'mkl_intel_lp64')
if get_option('openmp')
Expand All @@ -87,19 +87,19 @@ if lapack_vendor == 'mkl'
lib_deps += mkl_dep

elif lapack_vendor == 'mkl-rt'
mkl_dep = fc.find_library('mkl_rt')
mkl_dep = cc.find_library('mkl_rt')
lib_deps += mkl_dep

elif lapack_vendor == 'openblas'
openblas_dep = dependency(ilp64 ? 'openblas64' : 'openblas', required: false)
if not openblas_dep.found()
openblas_dep = fc.find_library(ilp64 ? 'openblas64' : 'openblas')
openblas_dep = cc.find_library(ilp64 ? 'openblas64' : 'openblas')
endif
lib_deps += openblas_dep
if not fc.links('external dsytrs; call dsytrs(); end', dependencies: openblas_dep)
lapack_dep = dependency(ilp64 ? 'lapack64' : 'lapack', required: false)
if not lapack_dep.found()
lapack_dep = fc.find_library(ilp64 ? 'lapack64' : 'lapack')
lapack_dep = cc.find_library(ilp64 ? 'lapack64' : 'lapack')
endif
lib_deps += lapack_dep
endif
Expand All @@ -110,12 +110,12 @@ elif lapack_vendor == 'custom'
if libs[0].startswith('-L')
foreach lib: libs
if lib != libs[0]
custom_deps += fc.find_library(lib, dirs: libs[0].substring(2))
custom_deps += cc.find_library(lib, dirs: libs[0].substring(2))
endif
endforeach
else
foreach lib: libs
custom_deps += fc.find_library(lib)
custom_deps += cc.find_library(lib)
endforeach
endif
if (not fc.links('external dsytrs; call dsytrs(); end', dependencies: [custom_deps,omp_dep]))
Expand All @@ -129,12 +129,12 @@ elif lapack_vendor == 'custom'
else
lapack_dep = dependency(ilp64 ? 'lapack64' : 'lapack', required: false)
if not lapack_dep.found()
lapack_dep = fc.find_library(ilp64 ? 'lapack64' : 'lapack')
lapack_dep = cc.find_library(ilp64 ? 'lapack64' : 'lapack')
endif
lib_deps += lapack_dep
blas_dep = dependency(ilp64 ? 'blas64' : 'blas', required: false)
if not blas_dep.found()
blas_dep = fc.find_library(ilp64 ? 'blas64' : 'blas')
blas_dep = cc.find_library(ilp64 ? 'blas64' : 'blas')
endif
lib_deps += blas_dep
endif
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ project(
],
)
install = not (meson.is_subproject() and get_option('default_library') == 'static')
has_cc = add_languages('c', required: false, native: false)

# General configuration information
inc_dirs = []
Expand Down

0 comments on commit abb5948

Please sign in to comment.