From 47a49ed6f9b517288a90c7f482c5b128cb715370 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Wed, 17 Oct 2018 00:17:40 +0100 Subject: [PATCH] Use predefined version when not building from git repo --- meson.build | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 3b3c471..07b50ac 100644 --- a/meson.build +++ b/meson.build @@ -1,8 +1,20 @@ -project('compton', 'c') +project('compton', 'c', version: '2') cc = meson.get_compiler('c') -version = run_command('git', 'describe').stdout().strip() +version = '' +git = find_program('git', required: false) +if git.found() + gitv = run_command('git', 'describe') + if gitv.returncode() == 0 + version = gitv.stdout().strip() + endif +endif + +if version == '' + # use project version by default + version = 'v'+meson.project_version() +endif add_global_arguments('-std=c11', language: 'c') add_global_arguments('-DCOMPTON_VERSION="'+version+'"', language: 'c')