AmdisMacros.cmake 2.11 KB
Newer Older
1
2
include(AmdisCXXFeatures)
include(AddAmdisExecutable)
3

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# some optimization of the compile times
find_program(CCACHE_PROGRAM ccache)
if (CCACHE_PROGRAM)
  set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif ()

if (UNIX AND NOT APPLE)
  execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE ld_version)
  if ("${ld_version}" MATCHES "GNU gold")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold -Wl,--disable-new-dtags")
  endif()
endif()


Praetorius, Simon's avatar
Praetorius, Simon committed
19
20
21
22
if (NOT BACKEND)
  set(BACKEND "ISTL" CACHE STRING "LinearAlgebra backend. One of MTL, EIGEN, PETSC, ISTL")
  set_property(CACHE BACKEND PROPERTY STRINGS "MTL" "EIGEN" "ISTL" "PETSC")
endif (NOT BACKEND)
Praetorius, Simon's avatar
Praetorius, Simon committed
23

24
if (BACKEND STREQUAL "MTL" OR BACKEND STREQUAL "MTL4")
25
  find_package(MTL REQUIRED)
Praetorius, Simon's avatar
Praetorius, Simon committed
26
  set(AMDIS_HAS_MTL TRUE)
27
28
29
30
31
  message(STATUS "  Found MTL, version: ${MTL_VERSION}")
  dune_register_package_flags(LIBRARIES MTL::MTL COMPILE_DEFINITIONS "ENABLE_MTL=1")

  find_package(HYPRE)
  if (HYPRE_FOUND)
Praetorius, Simon's avatar
Praetorius, Simon committed
32
    set(AMDIS_HAS_HYPRE TRUE)
33
34
    dune_register_package_flags(LIBRARIES HYPRE::HYPRE COMPILE_DEFINITIONS "ENABLE_HYPRE=1")
  endif(HYPRE_FOUND)
35
elseif (BACKEND STREQUAL "EIGEN" OR BACKEND STREQUAL "EIGEN3")
36
  find_package(Eigen3 REQUIRED 3.3.5)
Praetorius, Simon's avatar
Praetorius, Simon committed
37
  set(AMDIS_HAS_EIGEN TRUE)
38
  if (EIGEN3_FOUND)
39
40
    message(STATUS "  Found Eigen3, version: ${Eigen3_VERSION}")
    dune_register_package_flags(LIBRARIES Eigen3::Eigen COMPILE_DEFINITIONS "ENABLE_EIGEN=1")
41
  endif (EIGEN3_FOUND)
Praetorius, Simon's avatar
Praetorius, Simon committed
42
43
44
elseif (BACKEND STREQUAL "PETSC")
  find_package(PETSc REQUIRED)
  if (PETSc_FOUND)
Praetorius, Simon's avatar
Praetorius, Simon committed
45
    set(AMDIS_HAS_PETSC TRUE)
Praetorius, Simon's avatar
Praetorius, Simon committed
46
47
    dune_register_package_flags(LIBRARIES PETSc::PETSc COMPILE_DEFINITIONS "ENABLE_PETSC=1")
  endif (PETSc_FOUND)
48
49
elseif (BACKEND STREQUAL "ISTL")
  if (NOT dune-istl_FOUND)
Praetorius, Simon's avatar
Praetorius, Simon committed
50
    message(FATAL_ERROR "Need dune-istl, MTL, PETSc, or Eigen3 as linear algebra backend. Change flag BACKEND!")
51
52
  endif ()
else ()
Praetorius, Simon's avatar
Praetorius, Simon committed
53
  message(FATAL_ERROR "BACKEND must be one of MTL, EIGEN, PETSC, ISTL")
54
endif ()
Praetorius, Simon's avatar
Praetorius, Simon committed
55
56
57


set(DUNE_CUSTOM_PKG_CONFIG_SECTION "set(BACKEND \"${BACKEND}\")")