From 2c6ffd80d5e785dfba356ad47198ced0577e3483 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Thu, 26 Aug 2021 15:45:31 -0400 Subject: [PATCH] meson: add openmp support to the build Requires meson 0.47 (and thus python 3.5) --- meson.build | 4 +++- meson_options.txt | 1 + src/meson.build | 11 ++++++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 69d281c..78769d1 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,9 @@ project('libb2', 'c', version: '0.98.1', - meson_version: '>=0.38.0', + meson_version: '>=0.47.0', default_options: ['optimization=3']) +openmp = dependency('openmp', required: get_option('openmp')) + conf = configuration_data() cc = meson.get_compiler('c') diff --git a/meson_options.txt b/meson_options.txt index 437009c..bd179d9 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,2 +1,3 @@ option('fat', type: 'boolean', value: false, description: 'build a fat binary on systems which support it') option('native', type: 'boolean', value: true, description: 'build a native binary with all optimizations supported') +option('openmp', type: 'feature', value: 'auto', description: 'build with OpenMP support') diff --git a/src/meson.build b/src/meson.build index 785988b..bb7cd07 100644 --- a/src/meson.build +++ b/src/meson.build @@ -25,26 +25,32 @@ if get_option('fat') internal_libs += [ static_library('blake2_ref', 'blake2b-ref.c', 'blake2s-ref.c', + dependencies: openmp, c_args: ['-DSUFFIX=_ref'] ), static_library('blake2_sse2', 'blake2b.c', 'blake2s.c', + dependencies: openmp, c_args: ['-DSUFFIX=_sse2', '-msse2'] ), static_library('blake2_ssse3', 'blake2b.c', 'blake2s.c', + dependencies: openmp, c_args: ['-DSUFFIX=_ssse3', '-msse2', '-mssse3'] ), static_library('blake2_sse4.1', 'blake2b.c', 'blake2s.c', + dependencies: openmp, c_args: ['-DSUFFIX=_sse41', '-msse2', '-mssse3', '-msse4.1'] ), static_library('blake2_avx', 'blake2b.c', 'blake2s.c', + dependencies: openmp, c_args: ['-DSUFFIX=_avx', '-msse2', '-mssse3', '-msse4.1', '-mavx'] ), static_library('blake2_xop', 'blake2b.c', 'blake2s.c', + dependencies: openmp, c_args: ['-DSUFFIX=_xop', '-msse2', '-mssse3', '-msse4.1', '-mavx', '-mxop'] ), ] @@ -64,6 +70,7 @@ install_headers('blake2.h') libb2 = library('b2', sources, c_args: '-DSUFFIX=', link_with: internal_libs, + dependencies: openmp, version: '1.0.4', install: true, ) @@ -72,10 +79,8 @@ libb2_dep = declare_dependency( link_with: libb2, include_directories: include_directories('.') ) -import('pkgconfig').generate( #libb2, # requires meson_version 0.46, not in Ubuntu 18.04 +import('pkgconfig').generate(libb2, name: 'libb2', - libraries: libb2, # implied in 0.46 - version: meson.project_version(), # implied in 0.46 description: 'C library providing BLAKE2b, BLAKE2s, BLAKE2bp, BLAKE2sp', url: 'https://github.com/BLAKE2/libb2', )