build: use 'feature' option type
authorIgor Gnatenko <i.gnatenko.brain@gmail.com>
Mon, 30 Jul 2018 11:17:05 +0000 (13:17 +0200)
committerIgor Gnatenko <i.gnatenko.brain@gmail.com>
Mon, 30 Jul 2018 11:21:14 +0000 (13:21 +0200)
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
meson.build
meson_options.txt
src/lib/comp/meson.build
src/lib/hash/meson.build

index 1f786f8596dc689fa7123a0d7ace791c67172dd8..1c49956f5da3a05b9d730027fd5d5c7e8ad757a1 100644 (file)
@@ -1,41 +1,19 @@
-project('zck', 'c', version: '0.9.1')
+project('zck', 'c',
+        version : '0.9.1',
+        meson_version : '>=0.47.0')
 
 so_version = '1'
 
-use_zstd = get_option('with-zstd')
-zstd_dep = []
-if use_zstd == 'yes'
-    zstd_required = true
-else
-    zstd_required = false
-endif
-if use_zstd == 'auto' or use_zstd == 'yes'
-    zstd_dep = dependency('libzstd', required:zstd_required)
-    if zstd_dep.found()
-        add_project_arguments('-DZCHUNK_ZSTD', language : 'c')
-        use_zstd = 'yes'
-    else
-        use_zstd = 'no'
-    endif
+zstd_dep = dependency('libzstd', required : get_option('with-zstd'))
+if zstd_dep.found()
+    add_project_arguments('-DZCHUNK_ZSTD', language : 'c')
 endif
 
-curl_dep = dependency('libcurl', required:true)
+curl_dep = dependency('libcurl')
 
-use_openssl = get_option('with-openssl')
-openssl_dep = []
-if use_openssl == 'yes'
-    openssl_required = true
-else
-    openssl_required = false
-endif
-if use_openssl == 'auto' or use_openssl == 'yes'
-    openssl_dep = dependency('openssl', required:openssl_required)
-    if openssl_dep.found()
-        add_project_arguments('-DZCHUNK_OPENSSL', language : 'c')
-        use_openssl = 'yes'
-    else
-        use_openssl = 'no'
-    endif
+openssl_dep = dependency('openssl', required : get_option('with-openssl'))
+if openssl_dep.found()
+    add_project_arguments('-DZCHUNK_OPENSSL', language : 'c')
 endif
 
 inc = include_directories('include')
index 67cdd4f8fa08fe284196b88559609887fb292a38..bfb4128bd37e66f7b6e87e3337cf95d83a560ab2 100644 (file)
@@ -1,2 +1,2 @@
-option('with-zstd', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')
-option('with-openssl', type : 'combo', choices : ['yes', 'no', 'auto'], value : 'auto')
+option('with-zstd', type : 'feature', value : 'auto')
+option('with-openssl', type : 'feature', value : 'auto')
index a6edc00efe3e3f895759cdfa02b1f8d23c9b78a2..b66482bbe11fc68b0887365f936454244082df9b 100644 (file)
@@ -1,5 +1,5 @@
 lib_sources += files('comp.c')
-if use_zstd == 'yes'
-        subdir('zstd')
+if zstd_dep.found()
+    subdir('zstd')
 endif
 subdir('nocomp')
index 999d85db15c24e5ec2232c17294e3e29dd6b0000..9edc4da7da246ce4168704bab04c0b25cd8665cb 100644 (file)
@@ -1,5 +1,5 @@
 lib_sources += files('hash.c')
-if use_openssl == 'no'
+if not openssl_dep.found()
     subdir('sha1')
     subdir('sha2')
 endif