AMDISConfig.cmake.in 6.37 KB
Newer Older
1
2
3
# This configuration file is shipped with the great FEM-Toolbox AMDiS.
# It simplifies the configure of different amdis-versions.
#
4
# In order to compile an amdis-project and link against the amdis
5
# (and subsequent) libraries simply add 'AMDiS' to the target_link_libraries
6
# of your executable target. All include-paths and additional libraries are
7
# automatically added.
8
#
9
10
11
12
13
14
15
16
# 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)
#

Praetorius, Simon's avatar
Praetorius, Simon committed
17
18
if (${CMAKE_VERSION} VERSION_LESS "3.2")
    message(FATAL_ERROR "The Configuration file was created for CMake version >= 3.2")
19
20
21
22
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
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@)
31
32
33
34
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@)
35

36
set(BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
37
set(CMAKE_BUILD_TYPE @CMAKE_BUILD_TYPE@)
38
39
40
41

add_library(amdis_base INTERFACE)
add_library(AMDiS ALIAS amdis_base)

Praetorius, Simon's avatar
Praetorius, Simon committed
42
target_compile_definitions(amdis_base INTERFACE)
43

44
if (AMDIS_NEED_CXX11)
Praetorius, Simon's avatar
Praetorius, Simon committed
45
46
    include(test_compile_features)
    target_enable_cxx11(AMDIS_NEED_CXX11 amdis_base INTERFACE)
47
    target_compile_definitions(amdis_base INTERFACE HAS_CXX11=1)
48
else ()
49
    target_compile_definitions(amdis_base INTERFACE HAS_CXX11=0)
50
51
52
53
54
55
56
57
58
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})
59
    include(find_mtl4)
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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
# ---------------
79
80
81
82
83
84
85
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)
86
87
88
89

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


# Parallel amdis
# --------------
if (AMDIS_HAS_PARALLEL_DOMAIN)
100
    target_compile_definitions(amdis_base INTERFACE
101
        HAVE_PARALLEL_DOMAIN_AMDIS=1)
102

103
104
105
    include(target_enable_petsc)
    target_enable_mpi(amdis_base INTERFACE)
    target_enable_petsc(amdis_base INTERFACE)
106
107
108
endif (AMDIS_HAS_PARALLEL_DOMAIN)


109
110
111
112
113
114
# amdis extensions
# ----------------
if (AMDIS_NEED_EXTENSIONS)
    find_library(_EXTENSIONS_LIB amdis_extensions PATHS ${AMDIS_DIR}/../../lib/amdis/)
    if (_EXTENSIONS_LIB)
        target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/extensions)
115
116
117
        target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/extensions/nanoflann)
        target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/extensions/pugixml)
        target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/extensions/time)
Praetorius, Simon's avatar
Praetorius, Simon committed
118
        target_compile_definitions(amdis_base INTERFACE HAVE_EXTENSIONS=1)
119
120
121
122
123
124
125
126
127
128
129
        target_link_libraries(amdis_base INTERFACE ${_EXTENSIONS_LIB})
        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 ()
    unset(_EXTENSIONS_LIB CACHE)
endif (AMDIS_NEED_EXTENSIONS)


130
131
# reinit library
# --------------
132
133
134
135
136
137
138
139
140
141
if (AMDIS_NEED_REINIT)
    find_library(_REINIT_LIB amdis_reinit PATHS ${AMDIS_DIR}/../../lib/amdis/)
    if (_REINIT_LIB)
        target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/reinit)
        target_link_libraries(amdis_base INTERFACE ${_REINIT_LIB})
    else ()
        message(ERROR "Reinit library not found")
    endif ()
    unset(_REINIT_LIB CACHE)
endif (AMDIS_NEED_REINIT)
142
143
144
145


# compositeFEM library
# --------------------
146
147
148
if (AMDIS_NEED_COMPOSITE_FEM)
    find_library(_COMPOSITE_FEM_LIB amdis_compositeFEM PATHS ${AMDIS_DIR}/../../lib/amdis/)
    if (_COMPOSITE_FEM_LIB)
149
        target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/compositeFEM)
150
151
152
153
154
155
        target_link_libraries(amdis_base INTERFACE ${_COMPOSITE_FEM_LIB})
    else ()
        message(ERROR "CompositeFEM library not found")
    endif ()
    unset(_COMPOSITE_FEM_LIB CACHE)
endif (AMDIS_NEED_COMPOSITE_FEM)
156
157
158
159
160
161


# muparser library
# --------------------
find_library(_MUPARSER_LIB muparser PATHS ${AMDIS_DIR}/../../lib/amdis/)
if (_MUPARSER_LIB)
162
    target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/muparser)
163
164
165
166
167
168
    target_link_libraries(amdis_base INTERFACE ${_MUPARSER_LIB})
else ()
    message(ERROR "MuParser library not found")
endif ()
unset(_MUPARSER_LIB CACHE)

169

170
171
172
# Zoltan library
# --------------
if (AMDIS_NEED_ZOLTAN)
173
174
  include(target_enable_zoltan)
  target_enable_zoltan(amdis_base INTERFACE ON)
175
endif ()
Praetorius, Simon's avatar
Praetorius, Simon committed
176

177
178
179
180
# 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)
Praetorius, Simon's avatar
Praetorius, Simon committed
181
182
183
if (NOT AMDIS_COMPILEFLAGS)
  set(AMDIS_COMPILEFLAGS "")
endif()
184
185
186
187

get_target_property(_DEFINITIONS AMDiS INTERFACE_COMPILE_DEFINITIONS)
foreach(defn ${_DEFINITIONS})
  list(APPEND AMDIS_COMPILEFLAGS "-D${defn}")
Praetorius, Simon's avatar
Praetorius, Simon committed
188
endforeach(defn)