Skip to content

Commit 556988c

Browse files
committed
hmm sleef package works
1 parent 43a7c84 commit 556988c

File tree

4 files changed

+70
-6
lines changed

4 files changed

+70
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,5 @@ compile_commands.json
140140

141141
# quddtype
142142
/quaddtype/subprojects/qblas/
143+
/quaddtype/subprojects/sleef/
143144
.wraplock

quaddtype/meson.build

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ if is_windows
1313
add_project_arguments('-DWIN32', '-D_WINDOWS', language : ['c', 'cpp'])
1414
endif
1515

16-
sleef_dep = [
17-
c.find_library('sleef', required : true),
18-
c.find_library('sleefquad', required : true)
19-
]
16+
sleef_subproj = subproject('sleef', required: true)
17+
sleef_dep = sleef_subproj.get_variable('sleef_dep')
18+
sleefquad_dep = sleef_subproj.get_variable('sleefquad_dep')
2019

2120
incdir_numpy = run_command(py,
2221
['-c', 'import numpy; print(numpy.get_include())'],
@@ -26,7 +25,7 @@ incdir_numpy = run_command(py,
2625
# OpenMP dependency (optional, for threading)
2726
openmp_dep = dependency('openmp', required: false)
2827
qblas_dep = dependency('qblas', fallback: ['qblas', 'qblas_dep'])
29-
dependencies = [sleef_dep, py_dep, qblas_dep]
28+
dependencies = [py_dep, qblas_dep, sleef_dep, sleefquad_dep]
3029
if openmp_dep.found()
3130
dependencies += openmp_dep
3231
endif
@@ -126,7 +125,7 @@ py.install_sources(
126125

127126
py.extension_module('_quaddtype_main',
128127
srcs,
129-
link_args: is_windows ? ['/DEFAULTLIB:sleef', '/DEFAULTLIB:sleefquad'] : ['-lsleef', '-lsleefquad'],
128+
# link_args: is_windows ? ['/DEFAULTLIB:sleef', '/DEFAULTLIB:sleefquad'] : ['-lsleef', '-lsleefquad'],
130129
link_language: 'cpp',
131130
dependencies: dependencies,
132131
install: true,
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
project('sleef', version: '3.8')
2+
3+
cmake = find_program('cmake')
4+
ninja = find_program('ninja', 'make', required: false)
5+
6+
# Use relative paths from build directory
7+
sleef_build_dir = 'sleef_build'
8+
sleef_install_dir = 'sleef_install'
9+
10+
# Configure SLEEF at configuration time
11+
sleef_configure = run_command([
12+
cmake,
13+
'-S', meson.current_source_dir(),
14+
'-B', meson.current_build_dir() / sleef_build_dir,
15+
'-DCMAKE_BUILD_TYPE=Release',
16+
'-DSLEEF_BUILD_QUAD=ON',
17+
'-DSLEEF_BUILD_SHARED_LIBS=ON',
18+
'-DSLEEF_BUILD_TESTS=OFF',
19+
'-DSLEEF_BUILD_INLINE_HEADERS=OFF',
20+
'-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
21+
'-DCMAKE_INSTALL_PREFIX=' + meson.current_build_dir() / sleef_install_dir
22+
], check: false, capture: true)
23+
24+
if sleef_configure.returncode() != 0
25+
error('SLEEF CMake configuration failed: ' + sleef_configure.stderr())
26+
endif
27+
28+
# Build target for SLEEF libraries - create a dummy output file
29+
sleef_build_target = custom_target('sleef_build',
30+
command: [cmake, '--build', meson.current_build_dir() / sleef_build_dir, '--target', 'install', '--parallel'],
31+
output: 'sleef_built.stamp', # Dummy stamp file
32+
console: true,
33+
build_always_stale: true,
34+
build_by_default: true
35+
)
36+
37+
# Path variables
38+
sleef_include_path = meson.current_build_dir() / sleef_install_dir / 'include'
39+
sleef_lib_path = meson.current_build_dir() / sleef_install_dir / 'lib'
40+
41+
# Create a dependency that ensures the build happens but doesn't link the dummy file
42+
sleef_build_dep = declare_dependency(sources: [sleef_build_target])
43+
44+
# Create the actual linking dependencies
45+
sleef_dep = declare_dependency(
46+
dependencies: [sleef_build_dep], # Ensures build happens first
47+
compile_args: ['-I' + sleef_include_path],
48+
link_args: ['-L' + sleef_lib_path, '-lsleef', '-Wl,-rpath,' + sleef_lib_path]
49+
)
50+
51+
sleefquad_dep = declare_dependency(
52+
dependencies: [sleef_build_dep], # Ensures build happens first
53+
compile_args: ['-I' + sleef_include_path],
54+
link_args: ['-L' + sleef_lib_path, '-lsleefquad', '-Wl,-rpath,' + sleef_lib_path]
55+
)

quaddtype/subprojects/sleef.wrap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[wrap-git]
2+
directory=sleef
3+
url=https://github.com/shibatch/sleef.git
4+
revision=3.8
5+
patch_directory=sleef
6+
7+
[provide]
8+
sleef = sleef_dep
9+
sleefquad = sleefquad_dep

0 commit comments

Comments
 (0)