Warning, /graphics/kst-plot/cmake/modules/FindNumPy.cmake is written in an unsupported language. File is not indexed.
0001 #
0002 # http://numexpr.googlecode.com/hg/FindNumPy.cmake
0003 #
0004 # - Find the NumPy libraries
0005 # This module finds if NumPy is installed, and sets the following variables
0006 # indicating where it is.
0007 #
0008 # TODO: Update to provide the libraries and paths for linking npymath lib.
0009 #
0010 # NUMPY_FOUND - was NumPy found
0011 # NUMPY_VERSION - the version of NumPy found as a string
0012 # NUMPY_VERSION_MAJOR - the major version number of NumPy
0013 # NUMPY_VERSION_MINOR - the minor version number of NumPy
0014 # NUMPY_VERSION_PATCH - the patch version number of NumPy
0015 # NUMPY_VERSION_DECIMAL - e.g. version 1.6.1 is 10601
0016 # NUMPY_INCLUDE_DIRS - path to the NumPy include files
0017
0018 #============================================================================
0019 # Copyright 2012 Continuum Analytics, Inc.
0020 #
0021 # MIT License
0022 #
0023 # Permission is hereby granted, free of charge, to any person obtaining
0024 # a copy of this software and associated documentation files
0025 # (the "Software"), to deal in the Software without restriction, including
0026 # without limitation the rights to use, copy, modify, merge, publish,
0027 # distribute, sublicense, and/or sell copies of the Software, and to permit
0028 # persons to whom the Software is furnished to do so, subject to
0029 # the following conditions:
0030 #
0031 # The above copyright notice and this permission notice shall be included
0032 # in all copies or substantial portions of the Software.
0033 #
0034 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
0035 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0036 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
0037 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
0038 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0039 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0040 # OTHER DEALINGS IN THE SOFTWARE.
0041 #
0042 #============================================================================
0043
0044 # Finding NumPy involves calling the Python interpreter
0045 if(NumPy_FIND_REQUIRED)
0046 find_package(PythonInterp REQUIRED)
0047 else()
0048 find_package(PythonInterp)
0049 endif()
0050
0051 if(PYTHONINTERP_FOUND)
0052 execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
0053 "import numpy as n; print(n.__version__); print(n.get_include());"
0054 RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS
0055 OUTPUT_VARIABLE _NUMPY_VALUES
0056 ERROR_VARIABLE _NUMPY_ERROR_VALUE
0057 OUTPUT_STRIP_TRAILING_WHITESPACE)
0058
0059 if(_NUMPY_SEARCH_SUCCESS MATCHES 0)
0060 set(NUMPY_FOUND TRUE)
0061
0062 # Convert the process output into a list
0063 string(REGEX REPLACE ";" "\\\\;" _NUMPY_VALUES ${_NUMPY_VALUES})
0064 string(REGEX REPLACE "\n" ";" _NUMPY_VALUES ${_NUMPY_VALUES})
0065 list(GET _NUMPY_VALUES 0 NUMPY_VERSION)
0066 list(GET _NUMPY_VALUES 1 NUMPY_INCLUDE_DIRS)
0067
0068 # Make sure all directory separators are '/'
0069 string(REGEX REPLACE "\\\\" "/" NUMPY_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS})
0070
0071 # Get the major and minor version numbers
0072 string(REGEX REPLACE "\\." ";" _NUMPY_VERSION_LIST ${NUMPY_VERSION})
0073 list(GET _NUMPY_VERSION_LIST 0 NUMPY_VERSION_MAJOR)
0074 list(GET _NUMPY_VERSION_LIST 1 NUMPY_VERSION_MINOR)
0075 list(GET _NUMPY_VERSION_LIST 2 NUMPY_VERSION_PATCH)
0076 math(EXPR NUMPY_VERSION_DECIMAL
0077 "(${NUMPY_VERSION_MAJOR} * 10000) + (${NUMPY_VERSION_MINOR} * 100) + ${NUMPY_VERSION_PATCH}")
0078
0079 find_package_message(NUMPY
0080 "Found NumPy: version \"${NUMPY_VERSION}\" ${NUMPY_INCLUDE_DIRS}"
0081 "${NUMPY_INCLUDE_DIRS}${NUMPY_VERSION}")
0082 else()
0083 if(NumPy_FIND_REQUIRED)
0084 message(FATAL_ERROR
0085 "NumPy import failure:\n${_NUMPY_ERROR_VALUE}")
0086 endif()
0087 set(NUMPY_FOUND FALSE)
0088 endif()
0089 else()
0090 set(NUMPY_FOUND FALSE)
0091 endif()