clover/meson: Define OpenCL header macros
authorPierre Moreau <pierre.morrow@free.fr>
Tue, 17 Dec 2019 17:11:10 +0000 (18:11 +0100)
committerMarge Bot <eric+marge@anholt.net>
Thu, 23 Jan 2020 11:12:33 +0000 (11:12 +0000)
Rather than defining the macros any time right before including an
OpenCL header, set Meson to define them for the whole clover project.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Acked-by: Francisco Jerez <currojerez@riseup.net>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3137>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3137>

src/gallium/state_trackers/clover/api/dispatch.hpp
src/gallium/state_trackers/clover/core/error.hpp
src/gallium/state_trackers/clover/core/object.hpp
src/gallium/state_trackers/clover/llvm/codegen/common.cpp
src/gallium/state_trackers/clover/meson.build

index 808b760a36c50acd17049d3c810b83948f32332e..ae93273f563f210e3640f9762a8e42f93879863c 100644 (file)
 #ifndef API_DISPATCH_HPP
 #define API_DISPATCH_HPP
 
-#define CL_TARGET_OPENCL_VERSION 220
-
-#define CL_USE_DEPRECATED_OPENCL_1_0_APIS
-#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
-#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
-#define CL_USE_DEPRECATED_OPENCL_2_0_APIS
-#define CL_USE_DEPRECATED_OPENCL_2_1_APIS
-
-
 #include "CL/cl.h"
 #include "CL/cl_ext.h"
 #include "CL/cl_egl.h"
index a38bbfa53c1a94ffaa5aa76773ebd6c605825bb4..0490c19a276d42462a8db23e7849942e573c0550 100644 (file)
@@ -23,7 +23,6 @@
 #ifndef CLOVER_CORE_ERROR_HPP
 #define CLOVER_CORE_ERROR_HPP
 
-#define CL_TARGET_OPENCL_VERSION 220
 #include "CL/cl.h"
 
 #include <stdexcept>
index 8ed8e35630f894fbd398376243ace9b32ce362be..8fc2175d236f2828ba2516e69fa7a53f7999f9aa 100644 (file)
@@ -27,7 +27,6 @@
 #include <functional>
 #include <vector>
 
-#define CL_TARGET_OPENCL_VERSION 220
 #include "CL/cl.h"
 
 #include "core/error.hpp"
index 3879fb61a02702b9e5aa2d0dc65c8307fb604c23..36e2adad0abee9c04c70303c082587038afee62d 100644 (file)
@@ -33,7 +33,6 @@
 #include "llvm/codegen.hpp"
 #include "llvm/metadata.hpp"
 
-#define CL_TARGET_OPENCL_VERSION 220
 #include "CL/cl.h"
 
 #include "pipe/p_state.h"
index 8bc29cf6970fbef238784a047e3c8c9d4d07fc9a..7606a6beaf6f6aad83d29944a576d91b2cbd5a30 100644 (file)
 # SOFTWARE.
 
 clover_cpp_args = []
+clover_opencl_cpp_args = [
+  '-DCL_TARGET_OPENCL_VERSION=220',
+  '-DCL_USE_DEPRECATED_OPENCL_1_0_APIS',
+  '-DCL_USE_DEPRECATED_OPENCL_1_1_APIS',
+  '-DCL_USE_DEPRECATED_OPENCL_1_2_APIS',
+  '-DCL_USE_DEPRECATED_OPENCL_2_0_APIS',
+  '-DCL_USE_DEPRECATED_OPENCL_2_1_APIS'
+]
 clover_spirv_cpp_args = []
 clover_incs = [inc_include, inc_src, inc_gallium, inc_gallium_aux]
 
@@ -53,6 +61,7 @@ libclllvm = static_library(
   include_directories : clover_incs,
   cpp_args : [
     clover_cpp_args,
+    clover_opencl_cpp_args,
     clover_spirv_cpp_args,
     cpp_vis_args,
     '-DLIBCLC_INCLUDEDIR="@0@/"'.format(dep_clc.get_pkgconfig_variable('includedir')),
@@ -70,7 +79,7 @@ libclspirv = static_library(
   'clspirv',
   files('spirv/invocation.cpp', 'spirv/invocation.hpp'),
   include_directories : clover_incs,
-  cpp_args : [clover_spirv_cpp_args, cpp_vis_args],
+  cpp_args : [clover_opencl_cpp_args, clover_spirv_cpp_args, cpp_vis_args],
   dependencies : [dep_spirv_tools],
   override_options : clover_cpp_std,
 )
@@ -80,7 +89,7 @@ libclnir = static_library(
   files('nir/invocation.cpp', 'nir/invocation.hpp'),
   include_directories : [clover_incs, inc_mesa],
   dependencies : idep_nir,
-  cpp_args : [clover_spirv_cpp_args, cpp_vis_args],
+  cpp_args : [clover_opencl_cpp_args, clover_spirv_cpp_args, cpp_vis_args],
   override_options : clover_cpp_std,
 )
 
@@ -144,7 +153,12 @@ libclover = static_library(
   'clover',
   [clover_files, sha1_h],
   include_directories : clover_incs,
-  cpp_args : [clover_spirv_cpp_args, clover_cpp_args, cpp_vis_args],
+  cpp_args : [
+    clover_opencl_cpp_args,
+    clover_spirv_cpp_args,
+    clover_cpp_args,
+    cpp_vis_args
+  ],
   link_with : [libclllvm, libclspirv, libclnir],
   override_options : clover_cpp_std,
 )