From 5c0e8cbd49db69357dc8812fd177bda038b41a0a Mon Sep 17 00:00:00 2001 From: Pauli Virtanen <pauli.t.virtanen@jyu.fi> Date: Mon, 19 Jun 2023 15:00:34 +0300 Subject: [PATCH] meson: add fallback options for eigen/cppad --- meson.build | 26 ++++++++++++++++++++++++-- meson_options.txt | 6 ++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 meson_options.txt diff --git a/meson.build b/meson.build index 5c43a98..ddd2aef 100644 --- a/meson.build +++ b/meson.build @@ -3,15 +3,37 @@ project('usadelndsoc', ['cpp', 'fortran'], meson_version: '>= 0.55.0', default_options : ['cpp_std=c++17', 'build.cpp_std=c++17']) +cpp = meson.get_compiler('cpp') + cppad_dep = dependency('cppad') eigen3_dep = dependency('eigen3') +if not cppad_dep.found() + cppad_dep = cpp.find_library('libcppad_lib', + dirs : [get_option('cppad_lib')], + has_headers : ['cppad/cppad.h'], + header_include_directories : [get_option('cppad_inc')]) + if not cppad_dep.found() + cppad_dep = cpp.find_library('cppad_lib', + dirs : [get_option('cppad_lib')], + has_headers : ['cppad/cppad.h'], + header_include_directories : [get_option('cppad_inc')], + required : true) + endif +endif + +if not eigen3_dep.found() + if cpp.has_header('Eigen/Core', include_directories : [get_option('eigen_lib')]) + eigen3_dep = declare_dependency(include_directories : [get_option('eigen_lib')]) + else + error('Eigen/Core header not found') + endif +endif + py_mod = import('python') py3 = py_mod.find_installation('python3') py3_dep = py3.dependency() -cpp = meson.get_compiler('cpp') - incdir_numpy = run_command(py3, [ '-c', diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..7352112 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,6 @@ +option('cppad_inc', + type: 'string') +option('cppad_lib', + type: 'string') +option('eigen_inc', + type: 'string') -- GitLab