Remove cycle suppression
[gromacs.git] / cmake / FindOpenCL.cmake
blob4542403f36024e3780c3e6122d36f05be1a29ec9
2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
14 # GROMACS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
35 #.rst:
36 # FindOPENCL
37 # ----------
39 # Try to find OPENCL
41 # Once done this will define::
43 #   OPENCL_FOUND          - True if OPENCL was found
44 #   OPENCL_INCLUDE_DIRS   - include directories for OPENCL
45 #   OPENCL_LIBRARIES      - link against this library to use OPENCL
46 #   OPENCL_VERSION_STRING - Highest supported OPENCL version (eg. 1.2)
47 #   OPENCL_VERSION_MAJOR  - The major version of the OPENCL implementation
48 #   OPENCL_VERSION_MINOR  - The minor version of the OPENCL implementation
50 # The module will also define two cache variables::
52 #   OPENCL_INCLUDE_DIR    - the OPENCL include directory
53 #   OPENCL_LIBRARY        - the path to the OPENCL library
55 # This is a modified version of FindOpenCL.cmake from cmake v3.1.0
56 # (see comments at the end of the file).
57 # The following changes have been made:
58 #     1. OpenCL is written in all caps (OPENCL)
59 #     2. The following block has been modified:
60 #include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
61 #find_package_handle_standard_args(
62 #  OpenCL
63 #  FOUND_VAR OpenCL_FOUND
64 #  REQUIRED_VARS OpenCL_LIBRARY OpenCL_INCLUDE_DIR
65 #  VERSION_VAR OpenCL_VERSION_STRING)
66 #     has been replaced by:
67 #include(FindPackageHandleStandardArgs)
68 #FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENCL
69 #  REQUIRED_VARS OPENCL_LIBRARY OPENCL_INCLUDE_DIR
70 #  VERSION_VAR OPENCL_VERSION_STRING)
71 #     3. The following block has been modified:
72 #  find_library(OPENCL_LIBRARY
73 #   NAMES OPENCL)
74 #     has been replaced by:
75 #  find_library(OPENCL_LIBRARY
76 #   NAMES OpenCL)
78 function(_FIND_OPENCL_VERSION)
79   include(CheckSymbolExists)
80   include(CMakePushCheckState)
81   set(CMAKE_REQUIRED_QUIET ${OPENCL_FIND_QUIETLY})
83   CMAKE_PUSH_CHECK_STATE()
84   foreach(VERSION "2_0" "1_2" "1_1" "1_0")
85     set(CMAKE_REQUIRED_INCLUDES "${OPENCL_INCLUDE_DIR}")
87     if(APPLE)
88       CHECK_SYMBOL_EXISTS(
89         CL_VERSION_${VERSION}
90         "OpenCL/cl.h"
91         OPENCL_VERSION_${VERSION})
92     else()
93       CHECK_SYMBOL_EXISTS(
94         CL_VERSION_${VERSION}
95         "CL/cl.h"
96         OPENCL_VERSION_${VERSION})
97     endif()
99     if(OPENCL_VERSION_${VERSION})
100       string(REPLACE "_" "." VERSION "${VERSION}")
101       set(OPENCL_VERSION_STRING ${VERSION} PARENT_SCOPE)
102       string(REGEX MATCHALL "[0-9]+" version_components "${VERSION}")
103       list(GET version_components 0 major_version)
104       list(GET version_components 1 minor_version)
105       set(OPENCL_VERSION_MAJOR ${major_version} PARENT_SCOPE)
106       set(OPENCL_VERSION_MINOR ${minor_version} PARENT_SCOPE)
107       break()
108     endif()
109   endforeach()
110   CMAKE_POP_CHECK_STATE()
111 endfunction()
113 find_path(OPENCL_INCLUDE_DIR
114   NAMES
115     CL/cl.h OpenCL/cl.h
116   PATHS
117     ENV "PROGRAMFILES(X86)"
118     ENV AMDAPPSDKROOT
119     ENV INTELOCLSDKROOT
120     ENV NVSDKCOMPUTE_ROOT
121     ENV CUDA_PATH
122     ENV CUDA_HOME
123     ENV ATISTREAMSDKROOT
124   PATH_SUFFIXES
125     include
126     OPENCL/common/inc
127     "AMD APP/include")
129 if(CMAKE_SIZEOF_VOID_P EQUAL 4)
130     find_library(OPENCL_LIBRARY
131         NAMES OPENCL OpenCL
132         PATHS
133         ENV "PROGRAMFILES(X86)"
134         ENV AMDAPPSDKROOT
135         ENV INTELOCLSDKROOT
136         ENV CUDA_PATH
137         ENV CUDA_HOME
138         ENV NVSDKCOMPUTE_ROOT
139         ENV ATISTREAMSDKROOT
140         PATH_SUFFIXES
141         "AMD APP/lib/x86"
142         lib/x86
143         lib/Win32
144         lib
145         OPENCL/common/lib/Win32)
146 elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
147     find_library(OPENCL_LIBRARY
148         NAMES OPENCL OpenCL
149         PATHS
150         ENV "PROGRAMFILES(X86)"
151         ENV AMDAPPSDKROOT
152         ENV INTELOCLSDKROOT
153         ENV CUDA_PATH
154         ENV CUDA_HOME
155         ENV NVSDKCOMPUTE_ROOT
156         ENV ATISTREAMSDKROOT
157         PATH_SUFFIXES
158         "AMD APP/lib/x86_64"
159         lib/x86_64
160         lib/x64
161         lib64
162         OPENCL/common/lib/x64)
163 endif()
165 _FIND_OPENCL_VERSION()
167 set(OPENCL_LIBRARIES ${OPENCL_LIBRARY})
168 set(OPENCL_INCLUDE_DIRS ${OPENCL_INCLUDE_DIR})
170 include(FindPackageHandleStandardArgs)
171 FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENCL
172   REQUIRED_VARS OPENCL_LIBRARY OPENCL_INCLUDE_DIR
173   VERSION_VAR OPENCL_VERSION_STRING)
175 mark_as_advanced(
176   OPENCL_INCLUDE_DIR
177   OPENCL_LIBRARY)
179 #=============================================================================
180 # Copyright 2014 Matthaeus G. Chajdas
182 # Distributed under the OSI-approved BSD License (the "License");
183 # see accompanying file Copyright.txt for details.
185 # This software is distributed WITHOUT ANY WARRANTY; without even the
186 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
187 # See the License for more information.
188 #=============================================================================
189 # cmake 3.1.0 Copyright.txt file content is attached below:
191 #CMake - Cross Platform Makefile Generator
192 #Copyright 2000-2014 Kitware, Inc.
193 #Copyright 2000-2011 Insight Software Consortium
194 #All rights reserved.
196 #Redistribution and use in source and binary forms, with or without
197 #modification, are permitted provided that the following conditions
198 #are met:
200 #* Redistributions of source code must retain the above copyright
201 #  notice, this list of conditions and the following disclaimer.
203 #* Redistributions in binary form must reproduce the above copyright
204 #  notice, this list of conditions and the following disclaimer in the
205 #  documentation and/or other materials provided with the distribution.
207 #* Neither the names of Kitware, Inc., the Insight Software Consortium,
208 #  nor the names of their contributors may be used to endorse or promote
209 #  products derived from this software without specific prior written
210 #  permission.
212 #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
213 #"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
214 #LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
215 #A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
216 #HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
217 #SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
218 #LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
219 #DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
220 #THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
221 #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
222 #OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
224 #------------------------------------------------------------------------------
226 #The above copyright and license notice applies to distributions of
227 #CMake in source and binary form.  Some source files contain additional
228 #notices of original copyright by their contributors; see each source
229 #for details.  Third-party software packages supplied with CMake under
230 #compatible licenses provide their own copyright notices documented in
231 #corresponding subdirectories.
233 #------------------------------------------------------------------------------
235 #CMake was initially developed by Kitware with the following sponsorship:
237 # * National Library of Medicine at the National Institutes of Health
238 #   as part of the Insight Segmentation and Registration Toolkit (ITK).
240 # * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
241 #   Visualization Initiative.
243 # * National Alliance for Medical Image Computing (NAMIC) is funded by the
244 #   National Institutes of Health through the NIH Roadmap for Medical Research,
245 #   Grant U54 EB005149.
247 # * Kitware, Inc.