AMDIS.cmake.in 7.51 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
set(AMDIS_NEED_CXX11 @ENABLE_CXX11@)
set(AMDIS_NEED_UMFPACK @ENABLE_UMFPACK@)
set(AMDIS_NEED_COMPRESSION @ENABLE_COMPRESSION@)
set(AMDIS_NEED_EXTENSIONS @ENABLE_EXTENSIONS@)
set(AMDIS_NEED_BASE_PROBLEMS @ENABLE_BASE_PROBLEMS@)
set(AMDIS_NEED_REINIT @ENABLE_REINIT@)
set(AMDIS_NEED_COMPOSITE_FEM @ENABLE_COMPOSITE_FEM@)
set(AMDIS_NEED_ZOLTAN @ENABLE_ZOLTAN@)
set(AMDIS_NEED_BDDCML @ENABLE_BDDCML@)
set(AMDIS_NEED_HYPRE @ENABLE_HYPRE@)
set(AMDIS_NEED_PNG @ENABLE_PNG@)
set(AMDIS_NEED_SEQ_PETSC @ENABLE_SEQ_PETSC@)

set(BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)

add_library(amdis_base INTERFACE)
add_library(AMDiS ALIAS amdis_base)

target_compile_definitions(amdis_base INTERFACE)

if (AMDIS_NEED_CXX11)
22
23
24
25
26
27
  target_enable_cxx14(SUPPORTS_CXX14 amdis_base INTERFACE)
  if (NOT SUPPORTS_CXX14)
    target_enable_cxx11(SUPPORTS_CXX11 amdis_base INTERFACE)
  endif ()
  
  if (NOT SUPPORTS_CXX11 AND NOT SUPPORTS_CXX14)
28
    message(FATAL_ERROR "AMDiS was compiled with c++11 support, but the current compiler does not support this feature!")
29
  endif ()
30
  target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=1)
31
else ()
32
  target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=0)
33
34
35
36
37
38
39
40
41
42
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})
else ()
43
  message(FATAL_ERROR "Could not detect the AMDiS include directory. Please set the variable AMDIS_INCLUDE_DIR to the directory containing the AMDiS headers.")
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
endif ()
unset(_AMDIS_H CACHE)


# MTL4 libraries
# --------------------
target_enable_mtl4(amdis_base INTERFACE ON)


# AMDiS base libraries
# --------------------
find_library(_AMDIS_LIB  amdis${POSTFIX}  PATHS ${AMDIS_DIR}/../../lib/amdis/)
find_library(_AMDIS_LIBD amdis${POSTFIX}d PATHS ${AMDIS_DIR}/../../lib/amdis/) # debug version
if (_AMDIS_LIB)
  target_link_libraries(amdis_base INTERFACE optimized ${_AMDIS_LIB})
endif ()
if (_AMDIS_LIBD)
  target_link_libraries(amdis_base INTERFACE debug ${_AMDIS_LIBD})
endif ()

if (NOT(_AMDIS_LIB OR _AMDIS_LIBD))
65
  message(FATAL_ERROR "Could not detect the AMDiS${POSTFIX} library. Please set the variable _AMDIS_LIB to the AMDiS${POSTFIX} library.")
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
endif ()


# Boost libraries
# ---------------
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)
target_enable_boost(amdis_base INTERFACE ON)


# umfpack library
# --------------------
if (AMDIS_NEED_UMFPACK)
  set(AMDIS_SuiteSparse_DIR @SuiteSparse_DIR@)
  set(AMDIS_UMFPACK_INCLUDE_DIR @UMFPACK_INCLUDE_DIRS@)
  set(AMDIS_UMFPACK_LIB_DIR ${AMDIS_UMFPACK_INCLUDE_DIR}/../include)
  target_enable_umfpack(amdis_base INTERFACE ON)
endif (AMDIS_NEED_UMFPACK)


# amdis extensions
# ----------------
if (AMDIS_NEED_EXTENSIONS)
  find_library(_EXTENSIONS_LIB  amdisextensions${POSTFIX}  PATHS ${AMDIS_DIR}/../../lib/amdis/)
  find_library(_EXTENSIONS_LIBD amdisextensions${POSTFIX}d PATHS ${AMDIS_DIR}/../../lib/amdis/) # debug version
  if (_EXTENSIONS_LIB OR _EXTENSIONS_LIBD)
    target_include_directories(amdis_base INTERFACE
      ${AMDIS_INCLUDE_DIR}/extensions
      ${AMDIS_INCLUDE_DIR}/extensions/nanoflann
      ${AMDIS_INCLUDE_DIR}/extensions/pugixml
      ${AMDIS_INCLUDE_DIR}/extensions/time)
    target_compile_definitions(amdis_base INTERFACE HAVE_EXTENSIONS=1)
    if (AMDIS_NEED_BASE_PROBLEMS)
      target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/extensions/base_problems)
    endif (AMDIS_NEED_BASE_PROBLEMS)
  else ()
106
    message(FATAL_ERROR "Extensions library not found")
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
  endif ()

  if (_EXTENSIONS_LIB)
    target_link_libraries(amdis_base INTERFACE optimized ${_EXTENSIONS_LIB})
  endif ()
  if (_EXTENSIONS_LIBD)
    target_link_libraries(amdis_base INTERFACE debug ${_EXTENSIONS_LIBD})
  endif ()
endif (AMDIS_NEED_EXTENSIONS)


# reinit library
# --------------
if (AMDIS_NEED_REINIT)
  find_library(_REINIT_LIB  amdisreinit${POSTFIX}  PATHS ${AMDIS_DIR}/../../lib/amdis/)
  find_library(_REINIT_LIBD amdisreinit${POSTFIX}d PATHS ${AMDIS_DIR}/../../lib/amdis/) # debug version
123
  if (_REINIT_LIB OR _REINIT_LIBD)
124
125
    target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/reinit)
  else ()
126
    message(FATAL_ERROR "Reinit library not found")
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
  endif ()

  if (_REINIT_LIB)
    target_link_libraries(amdis_base INTERFACE optimized ${_REINIT_LIB})
  endif ()
  if (_REINIT_LIBD)
    target_link_libraries(amdis_base INTERFACE debug ${_REINIT_LIBD})
  endif ()
endif (AMDIS_NEED_REINIT)


# compositeFEM library
# --------------------
if (AMDIS_NEED_COMPOSITE_FEM)
  find_library(_COMPOSITE_FEM_LIB  amdiscompositefem${POSTFIX}  PATHS ${AMDIS_DIR}/../../lib/amdis/)
  find_library(_COMPOSITE_FEM_LIBD amdiscompositefem${POSTFIX}d PATHS ${AMDIS_DIR}/../../lib/amdis/) # debug version
  if (_COMPOSITE_FEM_LIB OR _COMPOSITE_FEM_LIBD)
    target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/compositeFEM)
  else ()
146
    message(FATAL_ERROR "CompositeFEM library not found")
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
  endif ()

  if (_COMPOSITE_FEM_LIB)
    target_link_libraries(amdis_base INTERFACE optimized ${_COMPOSITE_FEM_LIB})
  endif ()
  if (_COMPOSITE_FEM_LIBD)
    target_link_libraries(amdis_base INTERFACE debug ${_COMPOSITE_FEM_LIBD})
  endif ()
endif (AMDIS_NEED_COMPOSITE_FEM)


# muparser library
# --------------------
find_library(_MUPARSER_LIB muparser PATHS ${AMDIS_DIR}/../../lib/amdis/)
if (_MUPARSER_LIB)
  target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/muparser)
  target_link_libraries(amdis_base INTERFACE ${_MUPARSER_LIB})
else ()
165
  message(FATAL_ERROR "MuParser library not found")
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
endif ()
unset(_MUPARSER_LIB CACHE)


# Additional libraries
# ==============================================================================

# Parallel amdis
# --------------
if (AMDIS_HAS_PARALLEL_DOMAIN)
  target_enable_mpi(amdis_base INTERFACE ON)
  target_enable_petsc(amdis_base INTERFACE ON)

  target_compile_definitions(amdis_base INTERFACE
      HAVE_PARALLEL_DOMAIN_AMDIS=1)
endif (AMDIS_HAS_PARALLEL_DOMAIN)


# Zoltan library
# --------------
if (AMDIS_NEED_ZOLTAN)
187
188
189
  if (NOT DEFINED ZOLTAN_DIR)
    set(ZOLTAN_DIR "@ZOLTAN_DIR@")
  endif ()
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
  target_enable_zoltan(amdis_base INTERFACE ON)
endif ()


# BSSCML library
# --------------
if (AMDIS_NEED_BDDCML)
  target_enable_bddcml(amdis_base INTERFACE ON)
endif ()


# Hypre library
# --------------
if (AMDIS_NEED_HYPRE)
  target_enable_hypre(amdis_base INTERFACE ON)
endif ()


# PNG library
# --------------
if (AMDIS_NEED_PNG)
  target_enable_png(amdis_base INTERFACE ON)
endif ()

214

215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# Sequential PETSc library
# --------------
if (AMDIS_NEED_SEQ_PETSC AND NOT AMDIS_HAS_PARALLEL_DOMAIN)
  target_enable_mpi(amdis_base INTERFACE ON)
  target_enable_petsc(amdis_base INTERFACE ON)
  target_compile_definitions(amdis_base INTERFACE HAVE_SEQ_PETSC=1)
endif ()

# ==============================================================================

# Extract some variables from INTERFACE target AMDiS
get_target_property(AMDIS_INCLUDE_DIRS AMDiS INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(AMDIS_LIBRARIES AMDiS INTERFACE_LINK_LIBRARIES)
get_target_property(AMDIS_COMPILEFLAGS AMDiS INTERFACE_COMPILE_OPTIONS)
if (NOT AMDIS_COMPILEFLAGS)
  set(AMDIS_COMPILEFLAGS "")
endif()

get_target_property(_DEFINITIONS AMDiS INTERFACE_COMPILE_DEFINITIONS)
foreach(defn ${_DEFINITIONS})
  list(APPEND AMDIS_COMPILEFLAGS "-D${defn}")
endforeach(defn)