Compiling Dolfin with newer PETSc Version failed as version number is not updated by cmake

Issue #732 invalid
Max Winkler created an issue

I encountered some problems when compiling dolfin-1.6.0 with a newer PETSc version and PETSc4py. To reproduce the problem install petsc-3.4.x (e.g. from the repositories of your Linux distribution, mine was Debian 8), and compile dolfin-1.6.0. The CMake script should find all directories automatically.

Then, download a newer version of petsc and petsc4py (I have version 3.7.0) and install them. I compiled the Source code from the official web pages of PETSc and PETSc4py. After updating the CMake-Script using cmake-gui I got the error

-- Checking for package 'PETSc'
-- PETSC_DIR is /usr/local
-- PETSC_ARCH is 
-- Found petscconf.h in /usr/local
-- Performing test PETSC_TEST_RUNS - Success
-- PETSc configured without Cusp support
-- Found PETSc: /usr/local/lib/libpetsc.so (Required is at least version "3.4") 
-- Checking for package 'PETSc4Py'
-- petc4py-version is 3.7.0
CMake Warning at CMakeLists.txt:419 (message):
  PETSc version 3.4.2 and petsc4py version 3.7.0 do not match.  Disabling
  PETSc4py.

The problem is that the petsc version 3.4.2 is read out, although version 3.7.0 is installed. I found out that the variable PETSC_VERSION is cached somewhere and is set to 3.4.2. Removing CMakeCache.txt does not solve the problem as this file is generated by cmake again with the entry PETSC_VERSION=3.4.2.

As a workaround i changed line 250 in the file ${DOLFIN_ROOT}/cmake/modules/FindPETSc.cmake from

set(PETSC_VERSION ${OUTPUT} CACHE TYPE STRING)

to

set(PETSC_VERSION ${OUTPUT})

In both cases the variable OUTPUT contains "3.7.0" but in the first case, the cached value "3.4.2" is taken. Actually there is no reason to reuse a cached variable here as the current PETSc version is read out directly before this.

Comments (4)

  1. Max Winkler reporter

    You're right. Some interfaces have changed from petsc 3.6 to 3.7, and dolfin won't compile. But the problem I described occurs also when linking dolfin with petsc-3.6.0.

  2. Jan Blechta

    Ok, but we don't maintain 1.6.0. Plese, try reproducing the problem with dev or latest release. It would be very helpful if you could provide a script for reproducing the problem in a Docker container.

  3. Prof Garth Wells

    I expect that you have some cache files laying about, or your PETSC_DIR is pointing to the wrong version of PETSC.

    If DOLFIN is checking /usr/local before PETSC_DIR, then that is something we would need to fix.

  4. Log in to comment