[petsc-users] Finding PETSc from CMake

Jed Brown jed at jedbrown.org
Thu Apr 21 23:01:45 CDT 2022


Yeah, use this; it's distributed with base CMake.

https://cmake.org/cmake/help/latest/module/FindPkgConfig.html

CMake upstream recommends writing a ${Package}Config.cmake file, but petsc.pc contains the same semantic information and the conversion to CMake dialect can be lossy.

Those Find${Package}.cmake scripts are mostly hopelessly buggy, especially if one wishes to use static libraries. (They're trying to solve a hard problem with inadequate foundation and get things wrong in confusing ways.)

Asher Mancinelli via petsc-users <petsc-users at mcs.anl.gov> writes:

> Hello,
>
> What is the preferred way to locate a PETSc installation from CMake? We usually use a FindPackageName.cmake file generated by our dependency, however it was recommended to us by a PETSc developer to use CMake's pkgconf interop to locate PETSc. This means we rely on pkgconf only to locate PETSc, which seems like overkill.
>
> Any help is appreciated, thanks,
> AM


More information about the petsc-users mailing list