cmake-modules icon indicating copy to clipboard operation
cmake-modules copied to clipboard

How to use FindPETSc.cmake?

Open ghost opened this issue 8 years ago • 2 comments

Hello, I have copied the FindPETSc.cmake to /usr/share/cmake-3.7/Modules (where all the other .cmake files are). However, when I run cmake the following message is shown:

" 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. "

This is how FindPETSc.cmake is called in my top level CMakeLists: find_package(PETSC) if(PETSC_FOUND) include_directories(${PETSC_INCLUDE_DIR}) add_definitions( "-DHAS_PETSC" ) endif()

Could you please provide more information?

Thank you.

ghost avatar Feb 01 '17 16:02 ghost

CMake is case-sensitive so there is a difference between PETSc and PETSC.

Also note that it's unreasonable to ask your users to copy FindPETSc.cmake to the system module path. One would normally include the file (and its dependencies) in your source repository (you can use a git submodule, git subtree, or just copy the files in), then have

project (MyProject)
list (APPEND CMAKE_MODULE_PATH "${MyProject_SOURCE_DIR}/cmake-modules")

jedbrown avatar Feb 01 '17 16:02 jedbrown

Issue solved, thank you.

ghost avatar Feb 06 '17 17:02 ghost