CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   PETSc from Cmake (http://www.cfd-online.com/Forums/main/83794-petsc-cmake.html)

d_dante January 11, 2011 12:40

PETSc from Cmake
 
Hi
does anyone know how to create a Cmake file to use PETSc in Fortran?

Write a make file for useing PETSc is quite simple, but how to call the PETSc's libraries in a Cmake?

d_dante January 12, 2011 08:50

Solved!
See here https://github.com/jedbrown/cmake-modules for useful cmake files for using petcs with cmake.

Here is my simple Cmakelist.txt for calling them and run one of petsc's examples

Code:

cmake_minimum_required(VERSION 2.8)
project (Test Fortran C)

SET(FIND_PETSC PROJETC_SOURCE_DIR)
SET(CMAKE_MODULE_PATH ${FIND_PETSC} )
FIND_PACKAGE(PETSc REQUIRED)
SET(FORTRAN_PREPROCESS_FLAG -I${PETSC_INCLUDE_DIR})
SET(FORTRAN_PREPROCESS_FLAG "${FORTRAN_PREPROCESS_FLAG} -I${PETSC_INCLUDE_CONF}")

ADD_EXECUTABLE(TEST ex1f.F)
SET_TARGET_PROPERTIES(TEST PROPERTIES COMPILE_FLAGS ${FORTRAN_PREPROCESS_FLAG} )
TARGET_LINK_LIBRARIES(TEST  ${PETSC_LIBRARIES})



All times are GMT -4. The time now is 01:38.