spank-olm

WIP Do not look
git clone git://archive.git.mtrnord.blog/MTRNord/spank-olm.git
Log | Files | Refs | README | LICENSE

meson.build (3764B)


      1 project('spank-olm', 'c', 'cpp',
      2         version : '1.0.0',
      3         default_options : [
      4             'c_std=c11',
      5             'cpp_std=c++20',
      6             'b_lto=true',
      7             'b_thinlto_cache=true',
      8             'warning_level=3',
      9             # do a release (optimised) build by default
     10             'buildtype=release',
     11             # turn off asserts etc. in release mode
     12             'b_ndebug=if-release'])
     13 
     14 # libFuzzer related things
     15 fuzzing_engine = get_option('fuzzing_engine')
     16 if fuzzing_engine == 'libfuzzer'
     17     if not cc.has_argument('-fsanitize=fuzzer')
     18         error('fuzzing_engine libfuzzer requires "-fsanitize=fuzzer"')
     19     endif
     20     fuzzer_args = ['-fsanitize=fuzzer-no-link', '-fsanitize=fuzzer']
     21     add_project_arguments(cc.first_supported_argument(fuzzer_args), language : ['cpp', 'c'])
     22 endif
     23 
     24 # Check if we are building for WASM
     25 is_wasm = host_machine.system() == 'emscripten'
     26 
     27 # Add specific arguments for WASM
     28 if is_wasm
     29     add_project_arguments('-flto', language : 'cpp')
     30     add_project_link_arguments('-flto', '-lembind', '-sEMBIND_AOT=1', '-sEXPORT_ES6=1', '-sMODULARIZE=1', '-sENVIRONMENT=web,worker', '-sEXPORT_NAME=SpankOlmLibrarys', '-sFILESYSTEM=0', '-sEXPORT_ALL=1', '--emit-tsd=interface.d.ts', language : 'cpp')
     31 endif
     32 
     33 # Cmake doesnt work with meson, so we need to require pkg-config
     34 if is_wasm
     35     # Custom path for libbotan-3.a when targeting WASM
     36     botan_wasm_path = get_option('botan_wasm_path')
     37     botan_include_path = get_option('botan_include_path')
     38     botan_incdir = include_directories(botan_include_path)
     39     cc = meson.get_compiler('c')
     40     botan_dep = cc.find_library('botan-3', dirs : meson.global_source_root() / botan_wasm_path, required : true, static : true)
     41     botan_dep = declare_dependency(dependencies : botan_dep, include_directories : botan_incdir)
     42 else
     43     botan_dep = dependency('botan-3', version : '>=3.6.0', required : true, method : 'pkg-config')
     44 endif
     45 
     46 spank_olm_deps = [botan_dep]
     47 
     48 incdir = include_directories('include')
     49 # List of source files
     50 src_files = files(
     51     'src/spank-olm.cpp',
     52     'src/account.cpp',
     53     'src/megolm.cpp',
     54     'src/pickle.cpp', )
     55 
     56 if is_wasm
     57     spank_olm = executable('spank_olm', src_files, install : true, dependencies : spank_olm_deps, include_directories : incdir, override_options : ['b_lto=false'])
     58 else
     59     spank_olm = library('spank_olm', src_files, install : true, dependencies : spank_olm_deps, include_directories : incdir)
     60 endif
     61 
     62 spank_olm_dep = declare_dependency(
     63     include_directories : incdir,
     64     link_with : spank_olm,
     65     dependencies : spank_olm_deps,
     66 )
     67 
     68 if get_option('build_tests') and not is_wasm
     69     snitch_dep = dependency('snitch')
     70 
     71     test('list_test', executable('list_test', 'tests/list_test.cpp', dependencies : [snitch_dep, spank_olm_dep], include_directories : incdir))
     72     test('account_test', executable('account_test', 'tests/account_test.cpp', dependencies : [snitch_dep, spank_olm_dep], include_directories : incdir))
     73 endif
     74 
     75 # Only build if we are not building wasm
     76 if not is_wasm
     77     # Generate and install pkg-config file
     78     pkgconfig = {
     79         'prefix' : get_option('prefix'),
     80         'libdir' : get_option('libdir'),
     81         'includedir' : join_paths(get_option('prefix'), get_option('includedir')),
     82         'name' : 'spank-olm',
     83         'description' : 'A C++ library based on libolm',
     84         'version' : meson.project_version(),
     85         'requires' : 'botan-3',
     86         'libs' : '-L${libdir} -lspank_olm',
     87         'cflags' : '-I${includedir}/spank-olm'
     88     }
     89 
     90     configure_file(
     91         input : 'misc/spank-olm.pc.in',
     92         output : 'spank-olm.pc',
     93         configuration : pkgconfig,
     94         install : true,
     95         install_dir : join_paths(get_option('libdir'), 'pkgconfig')
     96     )
     97 
     98     subdir('fuzz')
     99 endif