[petsc-users] Placing FindPETSc.cmake

Stefano Zampini stefano.zampini at gmail.com
Fri May 11 13:34:40 CDT 2018


CMAKE is case sensitive on this. You should use find_package(PETSc ….)


> On May 11, 2018, at 9:28 PM, Evan Um <evanum at gmail.com> wrote:
> 
> Hi,
> 
> I would like to ask a question about FindPETSc.cmake. I place the cmake file in the same directory where main.cpp is placed. I also placed the file in /usr/share/cmake_xx/Modules.

Actually, it can be put in any directory pointed by the variable CMAKE_MODULE_PATH. If I were you, I would not modify /usr/share/ 

> Where should i put the file? What else should I do to use the file in cmake? Do I need any other lines in my cmakelists.txt except find_package(petsc)? Thanks for your comments.
> 
> Evan
> 
> -------------------------------------------------------------
> 
> cmake_minimum_required(VERSION 3.10)
> 
> project(hellopetsc)
> 
> SET(CMAKE_CXX_STANDARD 11)
> SET(CMAKE_C_COMPILER mpicc)
> SET(CMAKE_CXX_COMPILER mpicxx)
> 
> find_package(PETSC COMPONENTS CXX)
> 
> add_executable(hellopetsc main.cpp)
> 
> ------------------------------------------------------------
> CMake Warning at CMakeLists.txt:9 (find_package):
>   By not providing "FindPETSC.cmake" in CMAKE_MODULE_PATH this project has
>   asked CMake to find a package configuration file provided by "PETSC", but
>   CMake did not find one.
> 
>   Could not find a package configuration file provided by "PETSC" with any of
>   the following names:
> 
>     PETSCConfig.cmake
>     petsc-config.cmake
> 
>   Add the installation prefix of "PETSC" to CMAKE_PREFIX_PATH or set
>   "PETSC_DIR" to a directory containing one of the above files.  If "PETSC"
>   provides a separate development package or SDK, be sure it has been
>   installed.



More information about the petsc-users mailing list