Re-remove *_stochd_state function declarations
[gromacs.git] / cmake / FindNVML.cmake
blob04f44be96f76a66166220fc4de86d5e719608fd8
2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 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 # FindNVML
37 # --------
39 # Find the NVIDIA Management Library (NVML) includes and library. NVML documentation
40 # is available at: http://docs.nvidia.com/deploy/nvml-api/index.html 
42 # NVML is part of the GPU Deployment Kit (GDK) and GPU_DEPLOYMENT_KIT_ROOT_DIR can
43 # be specified if the GPU Deployment Kit is not installed in a default location.
45 # FindNVML defines the following variables: 
47 #   NVML_INCLUDE_DIR, where to find nvml.h, etc.
48 #   NVML_LIBRARY, the libraries needed to use NVML.
49 #   NVML_FOUND, If false, do not try to use NVML.
52 #   Jiri Kraus, NVIDIA Corp (nvidia.com - jkraus)
54 #   Copyright (c) 2008 - 2014 NVIDIA Corporation.  All rights reserved.
56 #   This code is licensed under the MIT License.  See the FindNVML.cmake script
57 #   for the text of the license.
59 # The MIT License
61 # License for the specific language governing rights and limitations under
62 # Permission is hereby granted, free of charge, to any person obtaining a
63 # copy of this software and associated documentation files (the "Software"),
64 # to deal in the Software without restriction, including without limitation
65 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
66 # and/or sell copies of the Software, and to permit persons to whom the
67 # Software is furnished to do so, subject to the following conditions:
69 # The above copyright notice and this permission notice shall be included
70 # in all copies or substantial portions of the Software.
72 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
73 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
74 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
75 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
76 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
77 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
78 # DEALINGS IN THE SOFTWARE.
80 ###############################################################################
82 if( CMAKE_SYSTEM_NAME STREQUAL "Windows"  )
83   set( NVML_LIB_PATHS "C:/Program Files/NVIDIA Corporation/GDK/nvml/lib" )
84   if(GPU_DEPLOYMENT_KIT_ROOT_DIR)
85     list(APPEND NVML_LIB_PATHS "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/nvml/lib")
86   endif()
87   set(NVML_NAMES nvml)
88   
89   set( NVML_INC_PATHS "C:/Program Files/NVIDIA Corporation/GDK/nvml/include" )
90   if(GPU_DEPLOYMENT_KIT_ROOT_DIR)
91     list(APPEND NVML_INC_PATHS "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/nvml/include")
92   endif()
93 else()
94   # The Linux installer for the GPU Deployment Kit adds a "usr"
95   # suffix to a custom path if one is used, so a user could
96   # reasonably set GPU_DEPLOYMENT_KIT_ROOT_DIR to the value they
97   # passed to the installer, or the root where they later found the
98   # kit to be installed. Below, we cater for both possibilities.
99   set( NVML_LIB_PATHS /usr/lib64 )
100   if(GPU_DEPLOYMENT_KIT_ROOT_DIR)
101       list(APPEND NVML_LIB_PATHS
102           "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/src/gdk/nvml/lib"
103           "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/usr/src/gdk/nvml/lib"
104           )
105   endif()
106   set(NVML_NAMES nvidia-ml)
107   
108   set( NVML_INC_PATHS /usr/include/nvidia/gdk/ /usr/include )
109   if(GPU_DEPLOYMENT_KIT_ROOT_DIR)
110       list(APPEND NVML_INC_PATHS
111           "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/include/nvidia/gdk"
112           "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/usr/include/nvidia/gdk"
113           )
114   endif()
115 endif()
117 find_library(NVML_LIBRARY NAMES ${NVML_NAMES} PATHS ${NVML_LIB_PATHS} )
119 find_path(NVML_INCLUDE_DIR nvml.h PATHS ${NVML_INC_PATHS})
121 # handle the QUIETLY and REQUIRED arguments and set NVML_FOUND to TRUE if
122 # all listed variables are TRUE
123 include(FindPackageHandleStandardArgs)
124 FIND_PACKAGE_HANDLE_STANDARD_ARGS(NVML DEFAULT_MSG NVML_LIBRARY NVML_INCLUDE_DIR)
126 mark_as_advanced(NVML_LIBRARY NVML_INCLUDE_DIR)