FindPETSc.cmake fails when PETSC_VERSION is not found

Issue #777 resolved
Amnon Harel created an issue

Trying to build FEniCS from source, Dolfin failed to build due to a configuration error:

-- Checking for one of the modules 'craypetsc_real;PETSc'
CMake Error at cmake/modules/FindPETSc.cmake:59 (string):
  string sub-command REPLACE requires at least four arguments.

This eventually aborts the installation process.

Debugging it, this is due to PETSC_VERSION being empty in my system, while the code in lines 59-62 assumes that a meaningful PETSC_VERSION is always returned. This can be fixed by surrounding these lines with an "if" so that they run only when PETSC_FOUND:

# Extract major, minor, etc from version string
if (PETSC_FOUND)
   string(REPLACE "." ";" VERSION_LIST ${PETSC_VERSION})
   list(GET VERSION_LIST 0 PETSC_VERSION_MAJOR)
   list(GET VERSION_LIST 1 PETSC_VERSION_MINOR)
   list(GET VERSION_LIST 2 PETSC_VERSION_SUBMINOR)
endif()

At the very least, I managed to build dolfin this way on my gentoo system.

Comments (8)

  1. Prof Garth Wells

    Please send:

    • cmake version
    • DOLFIN version (git hash if using dev version)
    • Contents of PETSc.pc file
  2. Amnon Harel reporter

    cmake version 3.5.2

    dolfin-2016.1.0 (same for ffc, fiat, ufl, and dijitso, all installed from source with "pip install .")

    I don't find a PETSc.pc file. Perhaps because there is no PETSc on my system. AFAIK it is an optional component and I want to build without it.

  3. Prof Garth Wells

    The line -- Checking for one of the modules 'craypetsc_real;PETSc' indicates that you must be using a dev version and not the 2016.1 release.

    I'll check that the new PETSc detection works properly when PETSc is not available.

  4. Amnon Harel reporter

    I'm using whatever was fetched by:

    git clone https://bitbucket.org/fenics-project/dolfin/commits/tag/dolfin-2016.1.0
    

    Never tried this particular build procedure, so maybe I'm missing something :-)

  5. Johannes Ring

    That will actually give you the latest master. Use this instead if you want to checkout the dolfin-2016.1.0 tag:

    git clone https://bitbucket.org/fenics-project/dolfin.git
    git checkout dolfin-2016.1.0
    
  6. Log in to comment