| 1 |
# - Try to find slepc4py |
| 2 |
# Once done this will define |
| 3 |
# |
| 4 |
# SLEPC4PY_FOUND - system has slepc4py |
| 5 |
# SLEPC4PY_INCLUDE_DIRS - include directories for slepc4py |
| 6 |
# SLEPC4PY_VERSION - version of slepc4py |
| 7 |
# SLEPC4PY_VERSION_MAJOR - first number in SLEPC4PY_VERSION |
| 8 |
# SLEPC4PY_VERSION_MINOR - second number in SLEPC4PY_VERSION |
| 9 |
|
| 10 |
# Based on FindPETSc4py.cmake |
| 11 |
|
| 12 |
#============================================================================= |
| 13 |
# Copyright (C) 2013 Lawrence Mitchell |
| 14 |
# All rights reserved. |
| 15 |
# |
| 16 |
# Redistribution and use in source and binary forms, with or without |
| 17 |
# modification, are permitted provided that the following conditions |
| 18 |
# are met: |
| 19 |
# |
| 20 |
# 1. Redistributions of source code must retain the above copyright |
| 21 |
# notice, this list of conditions and the following disclaimer. |
| 22 |
# 2. Redistributions in binary form must reproduce the above copyright |
| 23 |
# notice, this list of conditions and the following disclaimer in |
| 24 |
# the documentation and/or other materials provided with the |
| 25 |
# distribution. |
| 26 |
# |
| 27 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 28 |
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 29 |
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 30 |
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 31 |
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 32 |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 33 |
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 34 |
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 35 |
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 36 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| 37 |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 38 |
# POSSIBILITY OF SUCH DAMAGE. |
| 39 |
#============================================================================= |
| 40 |
|
| 41 |
message(STATUS "Checking for package 'SLEPc4Py'") |
| 42 |
|
| 43 |
if(SLEPC4PY_INCLUDE_DIRS) |
| 44 |
# In cache already |
| 45 |
set(SLEPC4PY_FIND_QUIETLY TRUE) |
| 46 |
endif(SLEPC4PY_INCLUDE_DIRS) |
| 47 |
|
| 48 |
execute_process( |
| 49 |
COMMAND ${PYTHON_EXECUTABLE} -c "import slepc4py; print(slepc4py.get_include())" |
| 50 |
OUTPUT_VARIABLE SLEPC4PY_INCLUDE_DIRS |
| 51 |
RESULT_VARIABLE SLEPC4PY_NOT_FOUND |
| 52 |
ERROR_QUIET |
| 53 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
| 54 |
) |
| 55 |
|
| 56 |
if(SLEPC4PY_INCLUDE_DIRS) |
| 57 |
set(SLEPC4PY_FOUND TRUE) |
| 58 |
set(SLEPC4PY_INCLUDE_DIRS ${SLEPC4PY_INCLUDE_DIRS} CACHE STRING "slepc4py include path") |
| 59 |
else(SLEPC4PY_INCLUDE_DIRS) |
| 60 |
set(SLEPC4PY_FOUND FALSE) |
| 61 |
endif(SLEPC4PY_INCLUDE_DIRS) |
| 62 |
|
| 63 |
if(SLEPC4PY_FOUND) |
| 64 |
execute_process( |
| 65 |
COMMAND ${PYTHON_EXECUTABLE} -c "import slepc4py; print(slepc4py.__version__)" |
| 66 |
OUTPUT_VARIABLE SLEPC4PY_VERSION |
| 67 |
RESULT_VARIABLE SLEPC4PY_NOT_FOUND |
| 68 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
| 69 |
) |
| 70 |
string(REPLACE "." ";" SLEPC4PY_VERSION_LIST ${SLEPC4PY_VERSION}) |
| 71 |
list(GET SLEPC4PY_VERSION_LIST 0 SLEPC4PY_VERSION_MAJOR) |
| 72 |
list(GET SLEPC4PY_VERSION_LIST 1 SLEPC4PY_VERSION_MINOR) |
| 73 |
if(NOT SLEPC4PY_FIND_QUIETLY) |
| 74 |
message(STATUS "slepc4py version ${SLEPC4PY_VERSION} found") |
| 75 |
endif(NOT SLEPC4PY_FIND_QUIETLY) |
| 76 |
else(SLEPC4PY_FOUND) |
| 77 |
if(SLEPC4PY_FIND_REQUIRED) |
| 78 |
message(FATAL_ERROR "slepc4py missing") |
| 79 |
endif(SLEPC4PY_FIND_REQUIRED) |
| 80 |
endif(SLEPC4PY_FOUND) |
| 81 |
|
| 82 |
mark_as_advanced(SLEPC4PY_INCLUDE_DIRS, SLEPC4PY_VERSION, SLEPC4PY_VERSION_MAJOR, SLEPC4PY_VERSION_MINOR) |
| 83 |
|
| 84 |
if (SLEPc4py_FIND_VERSION) |
| 85 |
# Check if version found is >= required version |
| 86 |
if (NOT "${SLEPC4PY_VERSION}" VERSION_LESS "${SLEPc4py_FIND_VERSION}") |
| 87 |
set(SLEPC4PY_VERSION_OK TRUE) |
| 88 |
endif() |
| 89 |
else() |
| 90 |
# No specific version requested |
| 91 |
set(SLEPC4PY_VERSION_OK TRUE) |
| 92 |
endif() |
| 93 |
mark_as_advanced(SLEPC4PY_VERSION_OK) |
| 94 |
|
| 95 |
# Standard package handling |
| 96 |
include(FindPackageHandleStandardArgs) |
| 97 |
find_package_handle_standard_args(SLEPc4py |
| 98 |
"SLEPc4py could not be found. Be sure to set PYTHONPATH appropriately." |
| 99 |
SLEPC4PY_INCLUDE_DIRS SLEPC4PY_VERSION SLEPC4PY_VERSION_OK) |