@@ -3,15 +3,17 @@ project('sleef', version: '3.8')
3
3
cmake = find_program (' cmake' )
4
4
ninja = find_program (' ninja' , ' make' , required : false )
5
5
6
+ # Use relative paths from build directory
6
7
sleef_build_dir = ' sleef_build'
7
8
sleef_install_dir = ' sleef_install'
8
9
9
- # This can be done manually from user side, but lets handle it here as well
10
+ # Dynamically set libdir based on platform conventions
10
11
libdir = ' lib'
11
12
if host_machine .system() == ' linux' and host_machine .cpu_family() == ' x86_64'
12
13
libdir = ' lib64'
13
14
endif
14
15
16
+ # Configure SLEEF at configuration time
15
17
sleef_configure = run_command ([
16
18
cmake,
17
19
' -S' , meson .current_source_dir(),
@@ -29,6 +31,7 @@ if sleef_configure.returncode() != 0
29
31
error (' SLEEF CMake configuration failed: ' + sleef_configure.stderr())
30
32
endif
31
33
34
+ # Build target for SLEEF libraries - create a dummy output file
32
35
sleef_build_target = custom_target (' sleef_build' ,
33
36
command : [cmake, ' --build' , meson .current_build_dir() / sleef_build_dir, ' --target' , ' install' , ' --parallel' ],
34
37
output : ' sleef_built.stamp' , # Dummy stamp file
@@ -37,17 +40,28 @@ sleef_build_target = custom_target('sleef_build',
37
40
build_by_default : true
38
41
)
39
42
43
+ # Path variables
40
44
sleef_include_path = meson .current_build_dir() / sleef_install_dir / ' include'
41
45
sleef_lib_path = meson .current_build_dir() / sleef_install_dir / libdir
42
46
47
+ # Create a dependency that ensures the build happens but doesn't link the dummy file
43
48
sleef_build_dep = declare_dependency (sources : [sleef_build_target])
49
+
50
+ # Platform-specific define for static linking on Windows
51
+ sleef_static_define = ''
52
+ if host_machine .system() == ' windows'
53
+ sleef_static_define = ' -DSLEEF_STATIC_LIBS'
54
+ endif
55
+
56
+ # Create the actual linking dependencies
44
57
sleef_dep = declare_dependency (
45
- dependencies : [sleef_build_dep],
46
- compile_args : [' -I' + sleef_include_path],
58
+ dependencies : [sleef_build_dep], # Ensures build happens first
59
+ compile_args : [' -I' + sleef_include_path, sleef_static_define ],
47
60
link_args : [' -L' + sleef_lib_path, ' -lsleef' ]
48
61
)
62
+
49
63
sleefquad_dep = declare_dependency (
50
- dependencies : [sleef_build_dep],
51
- compile_args : [' -I' + sleef_include_path],
64
+ dependencies : [sleef_build_dep], # Ensures build happens first
65
+ compile_args : [' -I' + sleef_include_path, sleef_static_define ],
52
66
link_args : [' -L' + sleef_lib_path, ' -lsleefquad' ]
53
67
)
0 commit comments