AMDISConfig.cmake.in 5.53 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# This configuration file is shipped with the great FEM-Toolbox AMDiS.
# It simplifies the configure of different amdis-versions.
#
# In order to compile an amdis-project and link against the amdis 
# (and subsequent) libraries simply add 'AMDiS' to the target_link_libraries
# of your executable target. All include-paths and additional libraries are 
# automatically added.
# 
# For a fast start, you use this package in the following way
# simply look for it, possibly set the AMDiS directory
#
#   find_package(AMDiS REQUIRED)
#   add_executable(yourTarget <yourSources>)
#   target_link_libraries(yourTarget AMDiS)
#

if (${CMAKE_VERSION} VERSION_LESS "3.0")
    message(FATAL_ERROR "The Configuration file was created for CMake version >= 3.0")
endif ()

list(APPEND CMAKE_MODULE_PATH ${AMDIS_DIR})

23
24
set(IS_AMDISCONFIG true)

Praetorius, Simon's avatar
Praetorius, Simon committed
25
set(AMDIS_USE_FILE ${AMDIS_DIR}/AMDISUse.cmake)
26
27
28
29
30
31
set(AMDIS_NEED_ZOLTAN @ENABLE_ZOLTAN@)
set(AMDIS_NEED_CXX11 @ENABLE_CXX11@)
set(AMDIS_NEED_UMFPACK @ENABLE_UMFPACK@)
set(AMDIS_HAS_PARALLEL_DOMAIN @ENABLE_PARALLEL_DOMAIN@)
set(AMDIS_NEED_COMPRESSION @ENABLE_COMPRESSION@)

32
set(BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
33
34
35
36
37

add_library(amdis_base INTERFACE)
add_library(AMDiS ALIAS amdis_base)

target_compile_definitions(amdis_base INTERFACE
38
39
      $<$<CONFIG:Release>:DEBUG=0>
      $<$<NOT:$<CONFIG:Release>>:DEBUG=1>)
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
    
if (AMDIS_NEED_CXX11)
  target_compile_features(amdis_base INTERFACE 
      cxx_alias_templates 
      cxx_auto_type 
      cxx_lambdas 
      cxx_override
      cxx_range_for
      cxx_static_assert
      cxx_variadic_templates)
  target_compile_definitions(amdis_base INTERFACE HAS_CXX11=1)
else ()
  target_compile_definitions(amdis_base INTERFACE HAS_CXX11=0)
endif (AMDIS_NEED_CXX11)


# try to detect the AMDiS include directory
# -------------------------------------------
find_file(_AMDIS_H AMDiS.h PATHS ${AMDIS_DIR}/../../include/amdis/)
if (_AMDIS_H)
    get_filename_component(AMDIS_INCLUDE_DIR ${_AMDIS_H} PATH CACHE)
    target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR})
62
    include(find_mtl4)
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
else ()
    message(ERROR "Could not detect the AMDiS include directory. Please set the variable AMDIS_INCLUDE_DIR to the directory containing the AMDiS headers.")
endif ()
unset(_AMDIS_H CACHE)


# AMDiS base libraries
# --------------------
find_library(_AMDIS_LIB amdis PATHS ${AMDIS_DIR}/../../lib/amdis/)
if (_AMDIS_LIB)
    target_link_libraries(amdis_base INTERFACE ${_AMDIS_LIB})
else ()
    message(ERROR "Could not detect the AMDiS library. Please set the variable _AMDIS_LIB to the AMDiS library.")
endif ()
unset(_AMDIS_LIB CACHE)


# Boost libraries
# ---------------
82
83
84
85
86
87
88
if (NOT BOOST_ROOT)
    set(BOOST_ROOT @BOOST_ROOT@)
endif (NOT BOOST_ROOT)
if (NOT BOOST_LIBRARYDIR)
    set(BOOST_LIBRARYDIR @BOOST_LIBRARYDIR@)
endif (NOT BOOST_LIBRARYDIR)
include(find_boost)
89
90
91
92

# umfpack library
# --------------------
if (AMDIS_NEED_UMFPACK)
93
    set(AMDIS_SuiteSparse_DIR @SuiteSparse_DIR@)
94
    set(AMDIS_UMFPACK_INCLUDE_DIR @UMFPACK_INCLUDE_DIRS@)
95
96
    set(AMDIS_UMFPACK_LIB_DIR ${AMDIS_UMFPACK_INCLUDE_DIR}/../include)
    include(find_umfpack)
97
98
99
100
101
102
endif (AMDIS_NEED_UMFPACK)


# Parallel amdis
# --------------
if (AMDIS_HAS_PARALLEL_DOMAIN)
103
104
105
    target_compile_definitions(amdis_base INTERFACE 
        HAVE_PARALLEL_DOMAIN_AMDIS=1)
        
106
107
    find_package(MPI REQUIRED)
    if (MPI_FOUND)
108
109
110
        target_include_directories(amdis_base INTERFACE ${MPI_INCLUDE_PATH})
        target_compile_options(amdis_base INTERFACE ${MPI_COMPILE_FLAGS})
        target_link_libraries(amdis_base INTERFACE ${MPI_LIBRARIES})
111
112
113
114
115
116
    endif (MPI_FOUND)
    
    set(PETSC_EXECUTABLE_RUNS ON)
    set(AMDIS_PETSC_DIR @PETSC_DIR@)
    include(find_petsc)
    if (PETSc_FOUND)
117
118
119
120
121
122
123
        target_include_directories(amdis_base INTERFACE ${PETSC_INCLUDES})
        target_link_libraries(amdis_base INTERFACE
            ${PETSC_LIBRARY_SYS} 
            ${PETSC_LIBRARIES}
            blas lapack)
        target_compile_definitions(amdis_base INTERFACE 
            HAVE_PARALLEL_PETSC=1)
124
    else()
125
        message(FATAL_ERROR "Could not find PETSc!")
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
    endif (PETSc_FOUND)
endif (AMDIS_HAS_PARALLEL_DOMAIN)


# reinit library
# --------------
find_library(_REINIT_LIB amdis_reinit PATHS ${AMDIS_DIR}/../../lib/amdis/)
if (_REINIT_LIB)
    target_include_directories(amdis_base INTERFACE ${Boost_INCLUDE_DIR}/reinit)
    target_link_libraries(amdis_base INTERFACE ${_REINIT_LIB})
else ()
    message(ERROR "Reinit library not found")
endif ()
unset(_REINIT_LIB CACHE)


# compositeFEM library
# --------------------
find_library(_COMPOSITE_FEM_LIB amdis_compositeFEM PATHS ${AMDIS_DIR}/../../lib/amdis/)
if (_COMPOSITE_FEM_LIB)
    target_include_directories(amdis_base INTERFACE ${Boost_INCLUDE_DIR}/compositeFEM)
    target_link_libraries(amdis_base INTERFACE ${_COMPOSITE_FEM_LIB})
else ()
    message(ERROR "CompositeFEM library not found")
endif ()
unset(_COMPOSITE_FEM_LIB CACHE)


# muparser library
# --------------------
find_library(_MUPARSER_LIB muparser PATHS ${AMDIS_DIR}/../../lib/amdis/)
if (_MUPARSER_LIB)
    target_include_directories(amdis_base INTERFACE ${Boost_INCLUDE_DIR}/muparser)
    target_link_libraries(amdis_base INTERFACE ${_MUPARSER_LIB})
else ()
    message(ERROR "MuParser library not found")
endif ()
unset(_MUPARSER_LIB CACHE)

165

166
167
168
169
170
171
172
173
174
175
# Zoltan library
# --------------
if (AMDIS_NEED_ZOLTAN)
    find_library(ZOLTAN_LIB zoltan HINTS ENV LIBRARY_PATH DOC "Full path to the zoltan library")
    if (ZOLTAN_LIB)
	target_link_libraries(amdis_base INTERFACE ${ZOLTAN_LIB})
    else()
	message(FATAL_ERROR "Could not find zoltan library!")
    endif()
endif ()
Praetorius, Simon's avatar
Praetorius, Simon committed
176
177

set(AMDIS_LIBRARIES AMDiS)