diff --git a/meson.build b/meson.build index 8abb7be..5e3da9e 100644 --- a/meson.build +++ b/meson.build @@ -40,17 +40,37 @@ else config_h.set_quoted('BEAR_COMMAND', '') endif -if get_option('libclang') == true and cc.has_header('clang-c/Index.h') - has_clang_header = true - clang = cc.find_library('clang', dirs : ['/usr/local/opt/llvm/lib']) +opt_clang_header_dir = get_option('libclang-libdir') +opt_clang_link_dir = get_option('libclang-headerdir') + +if get_option('libclang') == true + + #check for the header + found = false + if opt_clang_header_dir != '' + found = cc.has_header('clang-c/Index.h', args : '-I'+opt_clang_header_dir) + else + found = cc.has_header('clang-c/Index.h') + endif + + if found == false + error('Clang header not found!') + endif + + clang_inc = include_directories(opt_clang_header_dir) + + #check for the library to link + if opt_clang_link_dir != '' + clang = cc.find_library('clang', dirs : [opt_clang_link_dir]) + else + clang = cc.find_library('clang') + endif clang_include_dir_command = run_command(find_program('scripts/clang_include_dir.sh')) clang_include_dir = clang_include_dir_command.stdout().strip() config_h.set_quoted('CLANG_INCLUDES', clang_include_dir) config_h.set('HAVE_LIBCLANG', '1') -else - has_clang_header = false endif subdir('po') diff --git a/meson_options.txt b/meson_options.txt index 10ae169..61f4286 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,2 +1,4 @@ option('libclang', type : 'boolean', value : true, description : 'Weather to have libclang support') option('bear', type : 'boolean', value : true, description : 'Weather to have bear support') +option('libclang-libdir', type : 'string', value : '', description : 'Specify a none default location for your clang installation') +option('libclang-headerdir', type : 'string', value : '', description : 'Specify a none default location for your clang installation') diff --git a/scripts/clang_build_include_dir.sh b/scripts/clang_build_include_dir.sh deleted file mode 100755 index a5b320e..0000000 --- a/scripts/clang_build_include_dir.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -if [[ -d /usr/local/opt/llvm ]]; then - echo "/usr/local/opt/llvm/include" -fi - diff --git a/src/bin/meson.build b/src/bin/meson.build index ee0ad99..809c4c2 100644 --- a/src/bin/meson.build +++ b/src/bin/meson.build @@ -28,14 +28,9 @@ endforeach deps = [elm, edi_lib, intl] incls = [] -if get_option('libclang') == true and has_clang_header == true +if get_option('libclang') == true deps += [clang] - - clang_build_include_dir_command = run_command(find_program('../../scripts/clang_build_include_dir.sh')) - clang_build_include_dir = clang_build_include_dir_command.stdout().strip() - if clang_build_include_dir != '' - incls += include_directories(clang_build_include_dir) - endif + incls += [clang_inc] endif executable('edi', src, diff --git a/src/tests/meson.build b/src/tests/meson.build index 0c08504..8959bf7 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -13,8 +13,9 @@ check = dependency('check') deps = [elm, check, edi_lib] -if get_option('libclang') == true and has_clang_header == true +if get_option('libclang') == true deps += [clang] + incls += [clang_inc] endif exe = executable('edi_suite', src,