aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Fleury <emmanuel.fleury@u-bordeaux.fr>2020-02-20 14:09:30 +0100
committerAndreas Schneider <asn@cryptomilk.org>2020-10-04 09:54:24 +0200
commit071a3a187fcbdc5f02d41265b6275afe31a250bc (patch)
treea08d6847075825b96a480c5f3c91fe0b0b4b380e
parenta731966c628ee519a53eaf9eda66834d9800f8fa (diff)
downloadcmocka-071a3a187fcbdc5f02d41265b6275afe31a250bc.tar.gz
cmocka-071a3a187fcbdc5f02d41265b6275afe31a250bc.tar.xz
cmocka-071a3a187fcbdc5f02d41265b6275afe31a250bc.zip
Better integration of cmocka as meson-build git subprojects
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--meson.build59
1 files changed, 36 insertions, 23 deletions
diff --git a/meson.build b/meson.build
index 28fdc08..8eae406 100644
--- a/meson.build
+++ b/meson.build
@@ -1,46 +1,59 @@
-project('cmocka', 'c', version: '1.1.5', license: 'Apache-2.0')
+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))
+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'))
+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))
+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'))
+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'))
+conf.set('HAVE_CLOCK_REALTIME', cc.compiles(code, name : 'CLOCK_REALTIME'))
-configure_file(output: 'config.h', configuration : conf)
+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')
+libcmocka = library('cmocka', 'src/cmocka.c',
+ c_args : ['-DHAVE_CONFIG_H'],
+ include_directories : cmocka_includes,
+ install : meson.is_subproject(),
+ override_options : ['c_std=gnu99'],
+ dependencies : [cc.find_library('rt', required : false)])
+
+if meson.is_subproject()
+ cmocka_dep = declare_dependency(include_directories : cmocka_includes,
+ link_with : libcmocka)
+else
+ install_headers('include/cmocka.h')
+
+ pkgconfig = import('pkgconfig')
+ pkgconfig.generate(libraries : [libcmocka],
+ version : meson.project_version(),
+ name : 'cmocka',
+ filebase : 'cmocka',
+ description : 'The cmocka unit testing library')
+endif
if get_option('unit_testing')
subdir('tests')