diff options
author | Dima Krasner <dima@dimakrasner.com> | 2017-12-09 12:57:56 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2019-08-22 11:41:44 +0200 |
commit | aed0d9dd55b1d9fb68c0e37addc2898ed838a58b (patch) | |
tree | 3be5bb5a5d428eb171d03a413573b35f089adfeb | |
parent | 9aa64bb7f8aa89bd918bb797f56a512de92c5800 (diff) | |
download | cmocka-aed0d9dd55b1d9fb68c0e37addc2898ed838a58b.tar.gz cmocka-aed0d9dd55b1d9fb68c0e37addc2898ed838a58b.tar.xz cmocka-aed0d9dd55b1d9fb68c0e37addc2898ed838a58b.zip |
meson: Initial Meson build system support
Signed-off-by: Dima Krasner <dima@dimakrasner.com>
-rw-r--r-- | meson.build | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..04c5685 --- /dev/null +++ b/meson.build @@ -0,0 +1,43 @@ +project('cmocka', 'c', version: '1.1.5', license: 'Apache-2.0') + +cc = meson.get_compiler('c') + +conf = configuration_data() + +foreach hdr: ['assert.h', 'inttypes.h', 'io.h', 'malloc.h', 'memory.h', 'setjmp.h', 'signal.h', 'stdarg.h', 'stddef.h', 'stdint.h', 'stdio.h', 'stdlib.h', 'string.h', 'strings.h', 'sys/stat.h', 'sys/types.h', 'time.h', 'unistd.h'] + conf.set('HAVE_@0@'.format(hdr.underscorify().to_upper()), cc.has_header(hdr)) +endforeach + +code = '''#include <time.h> +int a = sizeof(struct timespec); +''' +conf.set('HAVE_STRUCT_TIMESPEC', cc.compiles(code, name: 'struct timepec')) + +foreach func: ['calloc', 'exit', 'fprintf', 'free', 'longjmp', 'siglongjmp', 'malloc', 'memcpy', 'memset', 'printf', 'setjmp', 'signal', 'strsignal', 'strcmp', 'clock_gettime'] + conf.set('HAVE_@0@'.format(func.to_upper()), cc.has_function(func)) +endforeach + +code = '__thread int tls;' +conf.set('HAVE_GCC_THREAD_LOCAL_STORAGE', cc.compiles(code, name: '__thread')) + +code = '''#include <time.h> +clockid_t t = CLOCK_REALTIME;''' +conf.set('HAVE_CLOCK_REALTIME', cc.compiles(code, name: 'CLOCK_REALTIME')) + +configure_file(output: 'config.h', configuration : conf) + +cmocka_includes = [include_directories('.'), include_directories('include')] +libcmocka = library('cmocka', + 'src/cmocka.c', + c_args: ['-DHAVE_CONFIG_H'], + include_directories: cmocka_includes, + install: true, + dependencies: [cc.find_library('rt', required: false)]) +install_headers('include/cmocka.h') + +pkgconfig = import('pkgconfig') +pkgconfig.generate(libraries : [libcmocka], + version : '1.1.5', + name : 'cmocka', + filebase : 'cmocka', + description : 'The cmocka unit testing library') |