Use old find_library to found ctpp2 lib if meson version < 0.31.0.

We need to support as far as possible the meson version installed on
ubuntu 16.04 (LTS).

In meson 0.31.0, the find_library has moved as a method of the compiler.

Fix #10
This commit is contained in:
Matthieu Gautier 2017-01-17 17:34:32 +01:00
parent 88f6b3a0f9
commit 317b13b56b
1 changed files with 10 additions and 1 deletions

View File

@ -16,11 +16,17 @@ if get_option('default_library') == 'static'
else else
libname = 'ctpp2' libname = 'ctpp2'
endif endif
find_library_in_compiler = meson.version().version_compare('>=0.31.0')
if ctpp2_prefix_install == '' if ctpp2_prefix_install == ''
if not compiler.has_header('ctpp2/CTPP2Logger.hpp') if not compiler.has_header('ctpp2/CTPP2Logger.hpp')
error('ctpp2/CTPP2Logger.hppnot found') error('ctpp2/CTPP2Logger.hppnot found')
endif endif
if find_library_in_compiler
ctpp2_lib = compiler.find_library(libname) ctpp2_lib = compiler.find_library(libname)
else
ctpp2_lib = find_library(libname)
endif
link_args = ['-l'+libname] link_args = ['-l'+libname]
if meson.is_cross_build() if meson.is_cross_build()
if host_machine.system() == 'windows' if host_machine.system() == 'windows'
@ -29,6 +35,9 @@ if ctpp2_prefix_install == ''
endif endif
ctpp2_dep = declare_dependency(link_args:link_args) ctpp2_dep = declare_dependency(link_args:link_args)
else else
if find_library_in_compiler
error('For custom ctpp2_prefix_install you need a meson version >=0.31.0')
endif
ctpp2_include_path = ctpp2_prefix_install + '/include' ctpp2_include_path = ctpp2_prefix_install + '/include'
ctpp2_include_args = ['-I'+ctpp2_include_path] ctpp2_include_args = ['-I'+ctpp2_include_path]
if not compiler.has_header('ctpp2/CTPP2Logger.hpp', args:ctpp2_include_args) if not compiler.has_header('ctpp2/CTPP2Logger.hpp', args:ctpp2_include_args)