iris: Fold a condition into no_gpu for consistency
[mesa.git] / src / gallium / targets / opencl / meson.build
1 # Copyright © 2017 Intel Corporation
2
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
9
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
12
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 # SOFTWARE.
20
21 opencl_link_args = []
22 opencl_link_deps = []
23 opencl_version = '1'
24
25 if with_ld_version_script
26 opencl_link_args += [
27 '-Wl,--version-script', join_paths(meson.current_source_dir(), 'opencl.sym')
28 ]
29 opencl_link_deps += files('opencl.sym')
30 endif
31
32 llvm_libdir = dep_llvm.get_configtool_variable('libdir')
33 opencl_libname = with_opencl_icd ? 'MesaOpenCL' : 'OpenCL'
34
35 polly_dep = null_dep
36 polly_isl_dep = null_dep
37 if dep_llvm.version().version_compare('>=10.0.0')
38 polly_dep = cpp.find_library('Polly', dirs : llvm_libdir, required : false)
39 polly_isl_dep = cpp.find_library('PollyISL', dirs : llvm_libdir, required : false)
40 endif
41
42 dep_clang = cpp.find_library('clang-cpp', dirs : llvm_libdir, required : false)
43
44 # meson will return clang-cpp from system dirs if it's not found in llvm_libdir
45 linker_rpath_arg = '-Wl,--rpath=@0@'.format(llvm_libdir)
46 clang_test_code = '''
47 #include <clang/Basic/Version.h>
48 int main (void) {
49 size_t found_pos = clang::getClangFullVersion().find(CLANG_VERSION_STRING);
50 return found_pos == ::std::string::npos ? 1 : 0;
51 }
52 '''
53 can_check_clang = (not meson.is_cross_build() or meson.has_exe_wrapper()) and cpp.has_link_argument(linker_rpath_arg)
54 if can_check_clang
55 test_run = cpp.run(clang_test_code, name : 'dep-clang-usable',
56 dependencies : [dep_llvm, dep_clang], args : linker_rpath_arg)
57 dep_clang_usable = test_run.compiled() and test_run.returncode() == 0
58 else
59 dep_clang_usable = true
60 endif
61 if not (dep_clang.found() and dep_clang_usable)
62 dep_clang = [
63 cpp.find_library('clangCodeGen', dirs : llvm_libdir),
64 cpp.find_library('clangFrontendTool', dirs : llvm_libdir),
65 cpp.find_library('clangFrontend', dirs : llvm_libdir),
66 cpp.find_library('clangDriver', dirs : llvm_libdir),
67 cpp.find_library('clangSerialization', dirs : llvm_libdir),
68 cpp.find_library('clangParse', dirs : llvm_libdir),
69 cpp.find_library('clangSema', dirs : llvm_libdir),
70 cpp.find_library('clangAnalysis', dirs : llvm_libdir),
71 cpp.find_library('clangAST', dirs : llvm_libdir),
72 cpp.find_library('clangASTMatchers', dirs : llvm_libdir),
73 cpp.find_library('clangEdit', dirs : llvm_libdir),
74 cpp.find_library('clangLex', dirs : llvm_libdir),
75 cpp.find_library('clangBasic', dirs : llvm_libdir),
76 polly_dep, polly_isl_dep,
77 ]
78 # check clang once more
79 if can_check_clang
80 test_run = cpp.run(clang_test_code, name : 'dep-clang-usable',
81 dependencies : [dep_llvm, dep_clang], args : linker_rpath_arg)
82 if not test_run.compiled() or test_run.returncode() != 0
83 error('No usable clang found!')
84 endif
85 endif
86 endif
87
88 libopencl = shared_library(
89 opencl_libname,
90 [],
91 link_args : [ld_args_gc_sections, opencl_link_args],
92 link_depends : opencl_link_deps,
93 link_whole : libclover,
94 link_with : [libpipe_loader_dynamic, libgallium],
95 dependencies : [
96 idep_mesautil,
97 dep_clock, dep_dl, dep_unwind, dep_elf, dep_clang
98 ],
99 version : '@0@.0.0'.format(opencl_version),
100 install : true,
101 )
102
103 if with_opencl_icd
104 _config = configuration_data()
105 _config.set('OPENCL_LIBNAME', 'MesaOpenCL')
106 _config.set('OPENCL_VERSION', opencl_version)
107 configure_file(
108 configuration : _config,
109 input : 'mesa.icd.in',
110 output : 'mesa.icd',
111 install : true,
112 install_dir : join_paths(get_option('sysconfdir'), 'OpenCL', 'vendors'),
113 )
114 endif