forked from openmm/openmm-torch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindOpenCL.cmake
95 lines (91 loc) · 2.69 KB
/
FindOpenCL.cmake
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
### OPENCL_INCLUDE_DIR ###
# Try OPENCL_DIR variable before looking elsewhere
find_path(OPENCL_INCLUDE_DIR
NAMES OpenCL/opencl.h CL/opencl.h
PATHS $ENV{OPENCL_DIR}
PATH_SUFFIXES "include"
NO_DEFAULT_PATH
)
# Next look in environment variables set by OpenCL SDK installations
find_path(OPENCL_INCLUDE_DIR
NAMES OpenCL/opencl.h CL/opencl.h
PATHS
$ENV{CUDA_PATH}
$ENV{AMDAPPSDKROOT}
PATH_SUFFIXES "include"
NO_DEFAULT_PATH
)
# On Macs, look inside the platform SDK
if(DEFINED CMAKE_OSX_SYSROOT)
find_path(OPENCL_INCLUDE_DIR
NAMES opencl.h opencl.h
PATHS
"${CMAKE_OSX_SYSROOT}/System/Library/Frameworks/OpenCL.framework/Headers"
NO_DEFAULT_PATH
)
endif(DEFINED CMAKE_OSX_SYSROOT)
# As a last resort, look in default system areas followed by other possible locations
find_path(OPENCL_INCLUDE_DIR
NAMES OpenCL/opencl.h CL/opencl.h
PATHS
"C:/CUDA"
"/usr/local/cuda"
"/usr/local/streamsdk"
"/usr"
PATH_SUFFIXES "include"
)
### OPENCL_LIBRARY ###
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
set(path_suffixes "lib/x86_64")
else("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
set(path_suffixes "lib/x86")
endif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
elseif(MSVC)
if(CMAKE_CL_64)
set(path_suffixes "lib/x64" "lib/x86_64")
else(CMAKE_CL_64)
set(path_suffixes "lib/Win32" "lib/x86")
endif(CMAKE_CL_64)
else(MSVC)
set(path_suffixes "lib")
endif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
# Try OPENCL_DIR variable before looking elsewhere
find_library(OPENCL_LIBRARY
NAMES OpenCL
PATHS
$ENV{OPENCL_DIR}
${OPENCL_LIB_SEARCH_PATH}
PATH_SUFFIXES ${path_suffixes}
NO_DEFAULT_PATH
)
# Next look in environment variables set by OpenCL SDK installations
find_library(OPENCL_LIBRARY
NAMES OpenCL
PATHS
$ENV{CUDA_PATH}
$ENV{AMDAPPSDKROOT}
PATH_SUFFIXES ${path_suffixes}
NO_DEFAULT_PATH
)
# As a last resort, look in default system areas followed by other possible locations
find_library(OPENCL_LIBRARY
NAMES OpenCL
PATHS
"C:/CUDA"
"/usr/local/cuda"
"/usr/local/streamsdk"
"/usr"
PATH_SUFFIXES ${path_suffixes} "lib"
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OPENCL DEFAULT_MSG OPENCL_LIBRARY OPENCL_INCLUDE_DIR)
if(OPENCL_FOUND)
set(OPENCL_LIBRARIES ${OPENCL_LIBRARY})
mark_as_advanced(CLEAR OPENCL_INCLUDE_DIR)
mark_as_advanced(CLEAR OPENCL_LIBRARY)
else(OPENCL_FOUND)
set(OPENCL_LIBRARIES)
mark_as_advanced(OPENCL_INCLUDE_DIR)
mark_as_advanced(OPENCL_LIBRARY)
endif(OPENCL_FOUND)