v0.14.0
FindPETSC.cmake
Go to the documentation of this file.
1 # - Try to find MOAB
2 # Once done this will define
3 #
4 # PETSC_DIR - directory in which PETSc resides
5 # PETSC_ARCH - build architecture
6 #
7 
8 # If unset, try environment
9 if(NOT PETSC_DIR)
10  set(PETSC_DIR $ENV{PETSC_DIR})
11 endif(NOT PETSC_DIR)
12 if(NOT PETSC_ARCH)
13  set(PETSC_ARCH $ENV{PETSC_ARCH})
14 endif(NOT PETSC_ARCH)
15 
16 find_file(PETSC_VARIABLES_FILE petscvariables
17  HINTS
18  ${PETSC_DIR}/${PETSC_ARCH}/conf
19  ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf
20  ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc-conf
21 )
22 if(NOT PETSC_VARIABLES_FILE)
23  message(FATAL_ERROR ${PETSC_VARIABLES_FILE})
24 endif(NOT PETSC_VARIABLES_FILE)
25 
26 file(STRINGS ${PETSC_VARIABLES_FILE} PETSC_VARIABLES)
27 foreach(LINE ${PETSC_VARIABLES})
28  string(REGEX REPLACE " = " ";" FIELDS ${LINE})
29  list(LENGTH FIELDS LISTLEN)
30  if(LISTLEN EQUAL 2)
31  list(GET FIELDS 0 VAR)
32  list(GET FIELDS 1 VAL)
33  set("PETSCVAR_${VAR}" ${VAL} CACHE INTERNAL "petsc varible")
34  #message(STATUS PETSCVAR_${VAR})
35  endif(LISTLEN EQUAL 2)
36 endforeach(LINE ${PETSC_VARIABLES})