AMDIS.cmake.in 7.45 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
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)
27
  target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=1)
28
else ()
29
  target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=0)
30
31
32
33
34
35
36
37
38
39
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 ()
40
  message(FATAL_ERROR "Could not detect the AMDiS include directory. Please set the variable AMDIS_INCLUDE_DIR to the directory containing the AMDiS headers.")
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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))
62
  message(FATAL_ERROR "Could not detect the AMDiS${POSTFIX} library. Please set the variable _AMDIS_LIB to the AMDiS${POSTFIX} library.")
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
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 ()
103
    message(FATAL_ERROR "Extensions library not found")
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  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
120
  if (_REINIT_LIB OR _REINIT_LIBD)
121
122
    target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/reinit)
  else ()
123
    message(FATAL_ERROR "Reinit library not found")
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
  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 ()
143
    message(FATAL_ERROR "CompositeFEM library not found")
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
  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 ()
162
  message(FATAL_ERROR "MuParser library not found")
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
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)
184
185
186
  if (NOT DEFINED ZOLTAN_DIR)
    set(ZOLTAN_DIR "@ZOLTAN_DIR@")
  endif ()
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
  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 ()

211

212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# 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)