Use predefined version when not building from git repo

This commit is contained in:
Yuxuan Shui 2018-10-17 00:17:40 +01:00
parent 0b866fb17f
commit 47a49ed6f9
1 changed files with 14 additions and 2 deletions

View File

@ -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')