AMDIS.cmake.in 7.33 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
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@)
set(CMAKE_BUILD_TYPE @CMAKE_BUILD_TYPE@)

add_library(amdis_base INTERFACE)
add_library(AMDiS ALIAS amdis_base)

target_compile_definitions(amdis_base INTERFACE)

if (AMDIS_NEED_CXX11)
  target_enable_cxx11(AMDIS_NEED_CXX11 amdis_base INTERFACE)
  if (NOT AMDIS_NEED_CXX11)
    message(FATAL_ERROR "AMDiS was compiled with c++11 support, but the current compiler does not support this feature!")
  endif (NOT AMDIS_NEED_CXX11)
  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})
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)


# 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))
  message(ERROR "Could not detect the AMDiS${POSTFIX} library. Please set the variable _AMDIS_LIB to the AMDiS${POSTFIX} library.")
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 ()
    message(ERROR "Extensions library not found")
  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
  if (_REINIT_LIB OR _REINIT_LIB)
    target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/reinit)
  else ()
    message(ERROR "Reinit library not found")
  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 ()
    message(ERROR "CompositeFEM library not found")
  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 ()
  message(ERROR "MuParser library not found")
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)
  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 ()

# 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)