You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.2 KiB
CMake
30 lines
1.2 KiB
CMake
cmake_minimum_required(VERSION 3.5.0)
|
|
|
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
# set root of location to find PETSc's pkg-config
|
|
set(PETSC $ENV{PETSC_DIR}/$ENV{PETSC_ARCH})
|
|
set(ENV{PKG_CONFIG_PATH} ${PETSC}/lib/pkgconfig)
|
|
|
|
# Remove the lines below if you do not wish to have PETSc determine the compilers
|
|
execute_process ( COMMAND pkg-config PETSc --variable=ccompiler COMMAND tr -d '\n' OUTPUT_VARIABLE C_COMPILER)
|
|
SET(CMAKE_C_COMPILER ${C_COMPILER})
|
|
execute_process ( COMMAND pkg-config PETSc --variable=cxxcompiler COMMAND tr -d '\n' OUTPUT_VARIABLE CXX_COMPILER)
|
|
if (CXX_COMPILER)
|
|
SET(CMAKE_CXX_COMPILER ${CXX_COMPILER})
|
|
endif (CXX_COMPILER)
|
|
execute_process ( COMMAND pkg-config PETSc --variable=fcompiler COMMAND tr -d '\n' OUTPUT_VARIABLE FORTRAN_COMPILER)
|
|
if (FORTRAN_COMPILER)
|
|
SET(CMAKE_Fortran_COMPILER ${FORTRAN_COMPILER})
|
|
enable_language(Fortran)
|
|
endif (FORTRAN_COMPILER)
|
|
|
|
# tells CMake to build the application ex1 from the source file ex1.c
|
|
# this must appear AFTER the compilers are set
|
|
project(main)
|
|
add_executable(main main.c)
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
pkg_search_module(PETSC REQUIRED IMPORTED_TARGET PETSc)
|
|
target_link_libraries(main PkgConfig::PETSC)
|