From 881764a0a25970c7b9709ad0741a59aeeb7c80ef Mon Sep 17 00:00:00 2001 From: Joshua Torrence Date: Sun, 20 Apr 2025 14:55:56 -0500 Subject: [PATCH 1/2] Add Meson dependency declaration for use as a subproject Signed-off-by: Joshua Torrence --- meson.build | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/meson.build b/meson.build index 3a9f68a..13366cc 100644 --- a/meson.build +++ b/meson.build @@ -61,6 +61,11 @@ else ) endif +x86simdsortcpp_dep = declare_dependency( + include_directories: include_directories('lib'), + link_with: libsimdsort, +) + pkg_mod = import('pkgconfig') pkg_mod.generate(libraries : libsimdsort, version : '4.0', From 951958c15d0713a24bbf30bb6974f71b6f5a2f26 Mon Sep 17 00:00:00 2001 From: Raghuveer Devulapalli Date: Tue, 22 Apr 2025 12:41:38 -0700 Subject: [PATCH 2/2] Add a section in README on how to use this as a Meson subproject --- README.md | 13 +++++++++++++ meson.build | 17 ++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3124a81..6c1e8c4 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,19 @@ benchmark](https://github.com/google/benchmark) frameworks respectively. You can configure meson to build them both by using `-Dbuild_tests=true` and `-Dbuild_benchmarks=true`. +## Using x86-simd-sort as a Meson subproject + +If you would like to use this as a Meson subproject, then create `subprojects` +directory and copy `x86-simd-sort` into it. Add these two lines +in your meson.build. +``` +xss = subproject('x86-simd-sort') +xss_dep = xss.get_variable('x86simdsortcpp_dep') +``` + +For more detailed instructions please refer to Meson +[documentation](https://mesonbuild.com/Subprojects.html#using-a-subproject). + ## Example usage #### Sort an array of floats diff --git a/meson.build b/meson.build index 13366cc..c796a0a 100644 --- a/meson.build +++ b/meson.build @@ -61,11 +61,6 @@ else ) endif -x86simdsortcpp_dep = declare_dependency( - include_directories: include_directories('lib'), - link_with: libsimdsort, -) - pkg_mod = import('pkgconfig') pkg_mod.generate(libraries : libsimdsort, version : '4.0', @@ -73,15 +68,20 @@ pkg_mod.generate(libraries : libsimdsort, filebase : 'x86simdsortcpp', description : 'C++ template library for high performance SIMD based sorting routines.') +# Create a new dependency variable making it easy to use this as a subproject: +x86simdsortcpp_dep = declare_dependency( + include_directories: include_directories('lib'), + link_with: libsimdsort, +) + # Build test suite if option build_tests set to true if get_option('build_tests') gtest_dep = dependency('gtest_main', required : true, static: false) subdir('tests') testexe = executable('testexe', include_directories : [lib, utils], - dependencies : gtest_dep, + dependencies : [gtest_dep, x86simdsortcpp_dep], link_whole : [libtests], - link_with : libsimdsort, ) test('x86 simd sort tests', testexe) endif @@ -94,10 +94,9 @@ if get_option('build_benchmarks') subdir('benchmarks') benchexe = executable('benchexe', include_directories : [src, lib, utils, bench], - dependencies : [gbench_dep, thread_dep], + dependencies : [gbench_dep, thread_dep, x86simdsortcpp_dep], link_args: ['-lbenchmark_main', ipplink], link_whole : [libbench], - link_with : libsimdsort, ) endif