AMDISConfig.cmake.in 6.54 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
# 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})

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


add_library(amdis_base INTERFACE)
add_library(AMDiS ALIAS amdis_base)

target_compile_definitions(amdis_base INTERFACE
      $<$<CONFIG:Debug>:DEBUG=1>
      $<$<CONFIG:Release>:DEBUG=0>)
    
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})
    target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/mtl4)
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
# ---------------
set(BOOST_LIBS_REQUIRED system iostreams filesystem program_options date_time)
if (WIN32)
    list(APPEND BOOST_LIBS_REQUIRED zlib)
    if (AMDIS_NEED_COMPRESSION)
	list(APPEND BOOST_LIBS_REQUIRED bzip2)
    endif ()
endif ()

set(BOOST_VERSION "1.48")
find_package(Boost ${BOOST_VERSION} REQUIRED ${BOOST_LIBS_REQUIRED})

if (Boost_FOUND)
    target_include_directories(amdis_base INTERFACE ${Boost_INCLUDE_DIR})
    target_link_libraries(amdis_base INTERFACE ${Boost_LIBRARIES})
else ()
    message(ERROR "Boost libraries not found")
endif(Boost_FOUND)


# umfpack library
# --------------------
if (AMDIS_NEED_UMFPACK)
    set(AMDIS_UMFPACK_INCLUDE_DIR @UMFPACK_INCLUDE_DIRS@)
    set(AMDIS_UMFPACK_LIB_DIR ${AMDIS_UMFPACK_INCLUDE_DIR}/../lib)
    find_file(UMFPACK_H umfpack.h HINTS ${AMDIS_UMFPACK_INCLUDE_DIR})
    find_library(UMFPACK_LIBRARY umfpack HINTS ${AMDIS_UMFPACK_LIB_DIR})
    if (UMFPACK_H AND UMFPACK_LIBRARY)	
	get_filename_component(UMFPACK_INCLUDE_DIRS ${UMFPACK_H} PATH)
	target_include_directories(amdis_base INTERFACE ${UMFPACK_INCLUDE_DIRS})
	
	find_library(AMD_LIBRARY amd HINTS ${AMDIS_UMFPACK_LIB_DIR})
	find_library(BLAS_LIBRARY blas HINTS ${AMDIS_UMFPACK_LIB_DIR})
	if (AMD_LIBRARY AND BLAS_LIBRARY)
	    target_link_libraries(amdis_base INTERFACE 
		${UMFPACK_LIBRARY}
		${AMD_LIBRARY}
		${BLAS_LIBRARY})
	    # TODO: add test whether umfpack is configured successfully
	endif()
    else()
	message(FATAL_ERROR "Could not find the UMFPACK library")
    endif()
endif (AMDIS_NEED_UMFPACK)


# Parallel amdis
# --------------
if (AMDIS_HAS_PARALLEL_DOMAIN)
    find_package(MPI REQUIRED)
    if (MPI_FOUND)
	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})
    endif (MPI_FOUND)
    
    set(PETSC_EXECUTABLE_RUNS ON)
    set(AMDIS_PETSC_DIR @PETSC_DIR@)
    include(find_petsc)
    if (PETSc_FOUND)
	target_include_directories(amdis_base INTERFACE ${PETSC_INCLUDES})
	target_link_libraries(amdis_base INTERFACE
	    ${PETSC_LIBRARY_SYS} 
	    ${PETSC_LIBRARIES})
    else()
	message(FATAL_ERROR "Could not find PETSc!")
    endif (PETSc_FOUND)
    
    find_library(_AMDIS_PARALLEL_LIB amdis_parallel PATHS ${AMDIS_DIR}/../../lib/amdis/)
    if (_AMDIS_PARALLEL_LIB)
	target_link_libraries(amdis_base INTERFACE ${_AMDIS_PARALLEL_LIB})
    else ()
	message(ERROR "Could not detect the AMDiS::parallel library. Please set the variable _AMDIS_PARALLEL_LIB to this library.")
    endif ()
    unset(_AMDIS_PARALLEL_LIB CACHE)
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)

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