summaryrefslogtreecommitdiff
path: root/build3/findOpenCL.lua
blob: 45688f87cf3fe880f01595976b61f02c8cfd9b0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175

	function findOpenCL_clew()
		return true;
	end

	function findOpenCL_Apple()
--		if os.is("macosx") then
--			return true	
--		else
			return false
--		end
	end

	
	function findOpenCL_AMD()
--		local amdopenclpath = os.getenv("AMDAPPSDKROOT")
--		if (amdopenclpath) then
--			return true
--		end
		return false
	end

	function findOpenCL_NVIDIA()
--		local nvidiaopenclpath = os.getenv("CUDA_PATH")
--		if (nvidiaopenclpath) then
--			return true
--		end
		return false
	end

	function findOpenCL_Intel()
--		if os.is("Windows") then
--			local intelopenclpath = os.getenv("INTELOCLSDKROOT")
--			if (intelopenclpath) then
--			return true
--			end
--		end
--		if os.is("Linux") then
--			local intelsdk = io.open("/usr/include/CL/opencl.h","r")
--			if (intelsdk) then
--				return true;
--			end
--		end
		return false
	end
		
	function initOpenCL_clew()
		configuration{}
		includedirs {
			projectRootDir .. "src/clew"
		}
		defines {"B3_USE_CLEW"}
		files {
			projectRootDir .. "src/clew/clew.c",
			projectRootDir .. "src/clew/clew.h"
		}
		 if os.is("Linux") then
        	        links {"dl"}
        	end
	end

	function initOpenCL_Apple()
		configuration{}
		includedirs {
			"/System/Library/Frameworks/OpenCL.framework"
		}
		libdirs "/System/Library/Frameworks/OpenCL.framework"
		links
		{
			"OpenCL.framework"
		}
	end
	
	function initOpenCL_AMD()
		configuration {}
		local amdopenclpath = os.getenv("AMDAPPSDKROOT")
		if (amdopenclpath) then
			defines { "ADL_ENABLE_CL" , "CL_PLATFORM_AMD"}
			includedirs {
				"$(AMDAPPSDKROOT)/include"				
			}
			configuration "x32"
				libdirs {"$(AMDAPPSDKROOT)/lib/x86"}
			configuration "x64"
				libdirs {"$(AMDAPPSDKROOT)/lib/x86_64"}
			configuration {}
			links {"OpenCL"}
			return true
		end
		return false
	end


	function initOpenCL_NVIDIA()
		configuration {}
		local nvidiaopenclpath = os.getenv("CUDA_PATH")
		if (nvidiaopenclpath) then
			defines { "ADL_ENABLE_CL" , "CL_PLATFORM_NVIDIA"}
			includedirs {
				"$(CUDA_PATH)/include"				
			}
			configuration "x32"
				libdirs {"$(CUDA_PATH)/lib/Win32"}
			configuration "x64"
				libdirs {"$(CUDA_PATH)/lib/x64"}
			configuration {}
			links {"OpenCL"}
			return true
		end
		return false
	end

	function initOpenCL_Intel()
		configuration {}
		if os.is("Windows") then
		local intelopenclpath = os.getenv("INTELOCLSDKROOT")
		if (intelopenclpath) then
			defines { "ADL_ENABLE_CL" , "CL_PLATFORM_INTEL"}
			includedirs {
				"$(INTELOCLSDKROOT)/include"				
			}
			configuration "x32"
				libdirs {"$(INTELOCLSDKROOT)/lib/x86"}
			configuration "x64"
				libdirs {"$(INTELOCLSDKROOT)/lib/x64"}
			configuration {}
			links {"OpenCL"}
			return true
		end
		end
		if os.is("Linux") then
			defines { "ADL_ENABLE_CL" , "CL_PLATFORM_INTEL"}
                        configuration {}
                        links {"OpenCL"}
		end
		return false
	end
	
	function findOpenCL (vendor )
		if vendor=="clew" then
			return findOpenCL_clew()
		end
		if vendor=="AMD" then
			return findOpenCL_AMD()
		end
		if vendor=="NVIDIA" then
			return findOpenCL_NVIDIA()
		end
			if vendor=="Intel" then
			return findOpenCL_Intel()
		end
		if vendor=="Apple" then
			return findOpenCL_Apple()
		end
		return false
	end
	
	function initOpenCL ( vendor )
		if vendor=="clew" then
			initOpenCL_clew()
		end
		if vendor=="AMD" then
			initOpenCL_AMD()
		end
		if vendor=="NVIDIA" then
			return initOpenCL_NVIDIA()
		end
		if vendor=="Intel" then
			initOpenCL_Intel()
		end
		if vendor=="Apple" then
			return initOpenCL_Apple()
		end
	end