@@ -3,15 +3,17 @@ project('sleef', version: '3.8')
33cmake = find_program (' cmake' )
44ninja = find_program (' ninja' , ' make' , required : false )
55
6+ # Use relative paths from build directory
67sleef_build_dir = ' sleef_build'
78sleef_install_dir = ' sleef_install'
89
9- # This can be done manually from user side, but lets handle it here as well
10+ # Dynamically set libdir based on platform conventions
1011libdir = ' lib'
1112if host_machine .system() == ' linux' and host_machine .cpu_family() == ' x86_64'
1213 libdir = ' lib64'
1314endif
1415
16+ # Configure SLEEF at configuration time
1517sleef_configure = run_command ([
1618 cmake,
1719 ' -S' , meson .current_source_dir(),
@@ -29,6 +31,7 @@ if sleef_configure.returncode() != 0
2931 error (' SLEEF CMake configuration failed: ' + sleef_configure.stderr())
3032endif
3133
34+ # Build target for SLEEF libraries - create a dummy output file
3235sleef_build_target = custom_target (' sleef_build' ,
3336 command : [cmake, ' --build' , meson .current_build_dir() / sleef_build_dir, ' --target' , ' install' , ' --parallel' ],
3437 output : ' sleef_built.stamp' , # Dummy stamp file
@@ -37,17 +40,28 @@ sleef_build_target = custom_target('sleef_build',
3740 build_by_default : true
3841)
3942
43+ # Path variables
4044sleef_include_path = meson .current_build_dir() / sleef_install_dir / ' include'
4145sleef_lib_path = meson .current_build_dir() / sleef_install_dir / libdir
4246
47+ # Create a dependency that ensures the build happens but doesn't link the dummy file
4348sleef_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
4457sleef_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 ],
4760 link_args : [' -L' + sleef_lib_path, ' -lsleef' ]
4861)
62+
4963sleefquad_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 ],
5266 link_args : [' -L' + sleef_lib_path, ' -lsleefquad' ]
5367)
0 commit comments