]> git.sesse.net Git - plocate/blobdiff - meson.build
Fix the function multiversioning Meson test.
[plocate] / meson.build
index ba12c7b35b51a43061ae281a01fd5449d6fd806e..e5632607a9bd12cef04147bb4b4cbc0bbf02a3a9 100644 (file)
@@ -1,4 +1,4 @@
-project('plocate', 'cpp', default_options: ['buildtype=debugoptimized','cpp_std=c++17'], version: '1.0.3-pre')
+project('plocate', 'cpp', default_options: ['buildtype=debugoptimized','cpp_std=c++17'], version: '1.0.6-pre')
 
 # Make the version available as a #define.
 add_project_arguments('-DPLOCATE_VERSION="' + meson.project_version() + '"', language: 'cpp')
@@ -6,13 +6,24 @@ add_project_arguments('-DPLOCATE_VERSION="' + meson.project_version() + '"', lan
 cxx = meson.get_compiler('cpp')
 uringdep = dependency('liburing', required: false)
 zstddep = dependency('libzstd')
+threaddep = dependency('threads')
+atomicdep = cxx.find_library('atomic', required: false)
 
 if not uringdep.found()
        add_project_arguments('-DWITHOUT_URING', language: 'cpp')
 endif
 
-executable('plocate', ['plocate.cpp', 'io_uring_engine.cpp', 'turbopfor.cpp', 'parse_trigrams.cpp'],
-       dependencies: [uringdep, zstddep],
+# Function multiversioning is x86-only _and_ not available on certain targets
+# (they need “ifunc”, indirect functions, a GNU extension).
+code = '''__attribute__((target("default"))) void foo();
+__attribute__((target("sse2"))) void foo();
+void bar() { foo(); }'''
+if cxx.compiles(code, name: 'function multiversioning')
+       add_project_arguments('-DHAS_FUNCTION_MULTIVERSIONING', language: 'cpp')
+endif
+
+executable('plocate', ['plocate.cpp', 'io_uring_engine.cpp', 'turbopfor.cpp', 'parse_trigrams.cpp', 'serializer.cpp', 'access_rx_cache.cpp', 'needle.cpp'],
+       dependencies: [uringdep, zstddep, threaddep, atomicdep],
        install: true,
        install_mode: ['rwxr-sr-x', 'root', 'mlocate'])
 executable('plocate-build', 'plocate-build.cpp',
@@ -21,14 +32,18 @@ executable('plocate-build', 'plocate-build.cpp',
        install_dir: get_option('sbindir'))
 
 conf_data = configuration_data()
+conf_data.set('PROCESSED_BY_MESON', '1')
 conf_data.set('sbindir', get_option('prefix') + '/' + get_option('sbindir'))
+conf_data.set('locategroup', get_option('locategroup'))
 update_script = configure_file(input: 'update-plocate.sh',
                output: 'update-plocate.sh',
                configuration: conf_data)
 
-install_data(update_script,
-       install_dir: '/etc/cron.daily',
-       rename: 'plocate')
+if get_option('install_cron')
+       install_data(update_script,
+               install_dir: '/etc/cron.daily',
+               rename: 'plocate')
+endif
 install_man('plocate.1')
 install_man('plocate-build.8')