cmdlinerunner.cpp: use ICommandLineOptionsModule
[alexxy/gromacs.git] / cmake / FindNVML.cmake
1 #
2 # This file is part of the GROMACS molecular simulation package.
3 #
4 # Copyright (c) 2014, 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.
8 #
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.
13 #
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.
18 #
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.
23 #
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.
31 #
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.
34
35 #.rst:
36 # FindNVML
37 # --------
38 #
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 
41 #
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.
44 #
45 # FindNVML defines the following variables: 
46 #
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.
50 #
51
52 #   Jiri Kraus, NVIDIA Corp (nvidia.com - jkraus)
53 #
54 #   Copyright (c) 2008 - 2014 NVIDIA Corporation.  All rights reserved.
55 #
56 #   This code is licensed under the MIT License.  See the FindNVML.cmake script
57 #   for the text of the license.
58
59 # The MIT License
60 #
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:
68 #
69 # The above copyright notice and this permission notice shall be included
70 # in all copies or substantial portions of the Software.
71 #
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.
79 #
80 ###############################################################################
81
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   set( NVML_LIB_PATHS /usr/lib64 )
95   if(GPU_DEPLOYMENT_KIT_ROOT_DIR)
96     list(APPEND NVML_LIB_PATHS "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/src/gdk/nvml/lib")
97   endif()
98   set(NVML_NAMES nvidia-ml)
99   
100   set( NVML_INC_PATHS /usr/include/nvidia/gdk/ /usr/include )
101   if(GPU_DEPLOYMENT_KIT_ROOT_DIR)
102     list(APPEND NVML_INC_PATHS "${GPU_DEPLOYMENT_KIT_ROOT_DIR}/include/nvidia/gdk")
103   endif()
104 endif()
105
106 find_library(NVML_LIBRARY NAMES ${NVML_NAMES} PATHS ${NVML_LIB_PATHS} )
107
108 find_path(NVML_INCLUDE_DIR nvml.h PATHS ${NVML_INC_PATHS})
109
110 # handle the QUIETLY and REQUIRED arguments and set NVML_FOUND to TRUE if
111 # all listed variables are TRUE
112 include(FindPackageHandleStandardArgs)
113 FIND_PACKAGE_HANDLE_STANDARD_ARGS(NVML DEFAULT_MSG NVML_LIBRARY NVML_INCLUDE_DIR)
114
115 mark_as_advanced(NVML_LIBRARY NVML_INCLUDE_DIR)