Path: blob/21.2-virgl/src/gallium/targets/opencl/meson.build
4565 views
# Copyright © 2017 Intel Corporation12# Permission is hereby granted, free of charge, to any person obtaining a copy3# of this software and associated documentation files (the "Software"), to deal4# in the Software without restriction, including without limitation the rights5# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell6# copies of the Software, and to permit persons to whom the Software is7# furnished to do so, subject to the following conditions:89# The above copyright notice and this permission notice shall be included in10# all copies or substantial portions of the Software.1112# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR13# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,14# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE15# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER16# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,17# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE18# SOFTWARE.1920opencl_link_args = []21opencl_link_deps = []22opencl_version = '1'2324if with_ld_version_script25opencl_link_args += [26'-Wl,--version-script', join_paths(meson.current_source_dir(), 'opencl.sym')27]28opencl_link_deps += files('opencl.sym')29endif3031llvm_libdir = dep_llvm.get_variable(cmake : 'LLVM_LIBRARY_DIR', configtool: 'libdir')32opencl_libname = with_opencl_icd ? 'MesaOpenCL' : 'OpenCL'3334polly_dep = null_dep35polly_isl_dep = null_dep36if dep_llvm.version().version_compare('>=10.0.0')37polly_dep = cpp.find_library('Polly', dirs : llvm_libdir, required : false)38polly_isl_dep = cpp.find_library('PollyISL', dirs : llvm_libdir, required : false)39endif4041dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false)4243# meson will return clang-cpp from system dirs if it's not found in llvm_libdir44linker_rpath_arg = '-Wl,--rpath=@0@'.format(llvm_libdir)45clang_test_code = '''46#include <clang/Basic/Version.h>47int main (void) {48size_t found_pos = clang::getClangFullVersion().find(CLANG_VERSION_STRING);49return found_pos == ::std::string::npos ? 1 : 0;50}51'''52can_check_clang = (not meson.is_cross_build() or meson.has_exe_wrapper()) and cpp.has_link_argument(linker_rpath_arg)53if can_check_clang54test_run = cpp.run(clang_test_code, name : 'dep-clang-usable',55dependencies : [dep_llvm, dep_clang], args : linker_rpath_arg)56dep_clang_usable = test_run.compiled() and test_run.returncode() == 057else58dep_clang_usable = true59endif60if not (dep_clang.found() and dep_clang_usable)61dep_clang = [62cpp.find_library('clangCodeGen', dirs : llvm_libdir),63cpp.find_library('clangFrontendTool', dirs : llvm_libdir),64cpp.find_library('clangFrontend', dirs : llvm_libdir),65cpp.find_library('clangDriver', dirs : llvm_libdir),66cpp.find_library('clangSerialization', dirs : llvm_libdir),67cpp.find_library('clangParse', dirs : llvm_libdir),68cpp.find_library('clangSema', dirs : llvm_libdir),69cpp.find_library('clangAnalysis', dirs : llvm_libdir),70cpp.find_library('clangAST', dirs : llvm_libdir),71cpp.find_library('clangASTMatchers', dirs : llvm_libdir),72cpp.find_library('clangEdit', dirs : llvm_libdir),73cpp.find_library('clangLex', dirs : llvm_libdir),74cpp.find_library('clangBasic', dirs : llvm_libdir),75polly_dep, polly_isl_dep,76]77# check clang once more78if can_check_clang79test_run = cpp.run(clang_test_code, name : 'dep-clang-usable',80dependencies : [dep_llvm, dep_clang], args : linker_rpath_arg)81if not test_run.compiled() or test_run.returncode() != 082error('No usable clang found!')83endif84endif85endif8687# Be explicit about only using this lib on Windows, to avoid picking88# up random libs with the generic name 'libversion'89if host_machine.system() == 'windows'90dep_version = cpp.find_library('version')91else92dep_version = null_dep93endif9495ocldef = files(opencl_libname + '.def')[0]9697libopencl = shared_library(98opencl_libname,99[],100vs_module_defs : ocldef,101link_args : [ld_args_gc_sections, opencl_link_args],102link_depends : opencl_link_deps,103link_whole : libclover,104link_with : [libpipe_loader_dynamic, libgallium],105dependencies : [106idep_mesautil,107dep_clock, dep_dl, dep_unwind, dep_elf, dep_clang, dep_version108],109version : '@[email protected]'.format(opencl_version),110install : true,111)112113if with_opencl_icd114_config = configuration_data()115_config.set('OPENCL_LIBNAME', 'MesaOpenCL')116_config.set('OPENCL_VERSION', opencl_version)117configure_file(118configuration : _config,119input : 'mesa.icd.in',120output : 'mesa.icd',121install : true,122install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'),123)124endif125126127