CMake cannot find PETSc

unfortunately I am having trouble when I try to build “preCICE using CMake”

  build]$ cmake -DBUILD_SHARED_LIBS=ON ..
.....-- Validating Prettyprint - success
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
  PETSc could not be found.  Be sure to set PETSC_DIR and PETSC_ARCH.
  suitable version "3.13.0", minimum required is "3.6")
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
  cmake/modules/FindPETSc.cmake:345 (find_package_handle_standard_args)
  CMakeLists.txt:209 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/guido/precice-2.0.2/build/CMakeFiles/CMakeOutput.log".
See also "/home/guido/precice-2.0.2/build/CMakeFiles/CMakeError.log".

I installed PETSc version “3.13.0” from source ,

PETSC_DIR                        /home/guido/petsc/petsc

install according

make all test
 Configure stage complete. Now build PETSc libraries with:
   make PETSC_DIR=/home/guido/petsc/petsc PETSC_ARCH=arch-linux-c-debug all

build]$ ccmake -DBUILD_SHARED_LIBS=ON ..

PETSC_CURRENT                    ON 
PETSC_DIR                        /home/guido/petsc/petsc
ccmake  in (t)oggle mode 
PETSC                            ON  
PETSC_CURRENT                    ON  
PETSC_DIR                        /home/guido/petsc/petsc PETSC_INCLUDE_CONF               PETSC_INCLUDE_CONF-NOTFOUND  
PETSC_INCLUDE_DIR                /home/guido/petsc/petsc/include PETSC_LIBRARY_SINGLE             PETSC_LIBRARY_SINGLE-NOTFOUND       
PKG_CONFIG_EXECUTABLE            /usr/bin/pkg-config
....  petsc]$ ls $PETSC_DIR/$PETSC_ARC 
arch-linux-c-debug  configure      configure.log.bkp  gmakefile       GNUmakefile  interfaces   lib      linux-precice  make.log     RDict.log  src
bitbucket-pipelines.yml  config              configure.log  CONTRIBUTING       gmakefile.test  include      Jenkinsfile  LICENSE  makefile  share     systems

[--- petsc]$  ls $PETSC_DIR/$PETSC_ARCH/include 
petscaodef.mod     petscdmda.mod         petscdmlabel.mod       petscdmplexdef.mod   petscis.mod           petscmatdef.mod    .....

When compiling PETSc you should choose a prefix (installation directory). Then, after compilation PETSc prints a command for installation (something like make PETSC_DIR=.... Did you run this command?

If you do not run this command, you will have incomplete headers, for example, as the files are all copied to the correct location during the install step. Your include/ dir seems to lack the C headers and more. My include/ of PETSc looks like this for example

index.html                  petscdmdatypes.h.html    petscdrawtypes.h       petscmatelemental.h       petsctao.h.html
makefile                    petscdmfield.h           petscdrawtypes.h.html  petscmatelemental.h.html  petsctaolinesearch.h
makefile.html               petscdmfield.h.html      petscds.h              petscmath.h               petsctaolinesearch.h.html
petsc                       petscdmforest.h          petscds.h.html         petscmath.h.html          petsctime.h
1 Like