AMDISConfig.cmake.in 9.02 KB
Newer Older
1
2
3
#This configuration file is shipped with the great FEM-Toolbox AMDiS.
#It simplifies the configure of different amdis-version and sets some variables.
#We set the following variables:
Naumann, Andreas's avatar
Naumann, Andreas committed
4
5
6
# AMDIS_INCLUDE_DIR 	the amdis-directory only
# AMDIS_INCLUDE_DIRS	all include directories (mtl, umfpack, parmetis, metis, ...)
# AMDIS_LIBRARIES	the needed libraries
Naumann, Andreas's avatar
Naumann, Andreas committed
7
# AMDIS_LIBRARY_DIRS	the link directories
8
9
10
11
12
13
# AMDiS_COMPILEFLAGS	some compile flags for amdis
#
#
# For a fast start, you use this package in the following way
# simply look for it, possibly set the AMDiS directory
# find_package(AMDiS )
Naumann, Andreas's avatar
Naumann, Andreas committed
14
# include(${AMDIS_USE_FILE})
15
# add_executable(yourTarget <yourSources>)
Naumann, Andreas's avatar
Naumann, Andreas committed
16
# target_link_libraries(yourTarget ${AMDIS_LIBRARIES})
17
18
#
#
Naumann, Andreas's avatar
Naumann, Andreas committed
19
#The AMDIS_USE_FILE adds the include and link-directories for amdis to cmake.
20
# 
Naumann, Andreas's avatar
Naumann, Andreas committed
21
#If you use the parallel amdis-version, the AMDIS_USE_FILE also trys to detect
22
23
#the mpi and petsc configuration. If those versions don't fit your needs,
#you can change the corresponding directories, or simply do this work at your own
Naumann, Andreas's avatar
Naumann, Andreas committed
24
#and omit the AMDIS_USE_FILE. Then you also have to set the flags, include 
25
26
#and library directories.

27
################## ONLY WORKAROUND AND WARNING ###################
28
29
30
#if(NOT "$ENV{LIBRARY_PATH}" STREQUAL "")
#        message(WARNING "the environment variable LIBRARY_PATH is set. this can lead to problems during linking. \n You can unset it in your CMakeLists.txt with the command unset(ENV{LIBRARY_PATH}).\n")
#endif()
31
##################################################################
32
#try to detect the AMDiS include directory
Naumann, Andreas's avatar
Naumann, Andreas committed
33
34
35
find_file(_AMDIS_H AMDiS.h PATHS ${AMDIS_INCLUDE_DIR} ${AMDIS_DIR}/../../include/amdis/ /usr/include/amdis/)
if(_AMDIS_H)
	get_filename_component(AMDIS_INCLUDE_DIR ${_AMDIS_H} PATH CACHE)
Naumann, Andreas's avatar
Naumann, Andreas committed
36
	set(AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR})
37
else()
Naumann, Andreas's avatar
Naumann, Andreas committed
38
	message(ERROR "could not detect the AMDiS include directory. Please set the variable AMDIS_INCLUDE_DIR to the directory containing the AMDiS headers.")
39
endif()
Naumann, Andreas's avatar
Naumann, Andreas committed
40
unset(_AMDIS_H CACHE)
Naumann, Andreas's avatar
Naumann, Andreas committed
41
42
set(MTL_DIR ${AMDIS_INCLUDE_DIR}/mtl4 CACHE PATH "the mtl directory")
list(APPEND AMDIS_INCLUDE_DIRS ${MTL_DIR})
43

Praetorius, Simon's avatar
Praetorius, Simon committed
44
45
if(WIN32)
  set(LIBEXT lib)
46
else()
Praetorius, Simon's avatar
Praetorius, Simon committed
47
48
49
  set(LIBEXT so)
endif()

Naumann, Andreas's avatar
Naumann, Andreas committed
50
51
52
find_library(_AMDIS_LIB amdis PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/amdis/ /usr/include/amdis)
if(_AMDIS_LIB)
	get_filename_component(AMDIS_LIBRARY_DIR ${_AMDIS_LIB} PATH CACHE)
Naumann, Andreas's avatar
Naumann, Andreas committed
53
	set(AMDIS_LIBRARY_DIRS ${AMDIS_LIBRARY_DIR})
Praetorius, Simon's avatar
Praetorius, Simon committed
54
	set(AMDIS_LIBRARIES "${_AMDIS_LIB};${AMDIS_LIBRARY_DIR}/libmuparser.${LIBEXT}" CACHE STRING "amdis libraries")
55
else()
Naumann, Andreas's avatar
Naumann, Andreas committed
56
	message(ERROR "could not detect the AMDiS library directory. Please set the variable AMDIS_LIBRARY_DIR to the directory containg the AMDiS library")
57
endif()
Naumann, Andreas's avatar
Naumann, Andreas committed
58
unset(_AMDIS_LIB CACHE)
59

Praetorius, Simon's avatar
Praetorius, Simon committed
60
find_package(Boost 1.42 REQUIRED system iostreams filesystem program_options)
61
if(Boost_FOUND)
Naumann, Andreas's avatar
Naumann, Andreas committed
62
	list(APPEND AMDIS_LIBRARIES ${Boost_LIBRARIES})
Naumann, Andreas's avatar
Naumann, Andreas committed
63
	list(APPEND AMDIS_LIBRARY_DIRS ${Boost_LIBRARY_DIRS})
Naumann, Andreas's avatar
Naumann, Andreas committed
64
	list(APPEND AMDIS_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
65
endif(Boost_FOUND)
66

67
68
set(AMDIS_NEED_ZOLTAN @ENABLE_ZOLTAN@)
set(AMDIS_HAS_PARALLEL_DOMAIN @ENABLE_PARALLEL_DOMAIN@)
69
set(AMDIS_OPENMP @ENABLE_OPENMP@)
70
set(AMDIS_NEED_UMFPACK @ENABLE_UMFPACK@)
71
72
set(AMDIS_NEED_HYPRE @ENABLE_HYPRE@)
set(AMDIS_NEED_PETSC @ENABLE_PETSC@)
Praetorius, Simon's avatar
Praetorius, Simon committed
73
set(AMDIS_NEED_PNG @ENABLE_PNG@)
74
set(AMDIS_NEED_BDDCML @ENABLE_BDDCML@)
75
set(AMDIS_NEED_MKL @ENABLE_MKL@)
76
77
set(AMDIS_NEED_EXTENSIONS @ENABLE_EXTENSIONS@)
set(AMDIS_NEED_BASE_PROBLEMS @ENABLE_BASE_PROBLEMS@)
78
79
set(AMDIS_USE_FILE ${AMDIS_DIR}/AMDISUse.cmake)
set(AMDIS_COMPILEFLAGS "@COMPILEFLAGS@")
80
81
82
set(AMDIS_VERSION @CurrentRevision@)
set(AMDIS_MAJOR_VERSION @AMDIS_MAJOR@)
set(AMDIS_MINOR_VERSION @AMDIS_MINOR@)
83

84
85
86
87
88
89
90
91
92
93
94
95
96
97
if(CMAKE_BUILD_TYPE STREQUAL "")
	set(CMAKE_BUILD_TYPE "Release")
endif()

if(AMDIS_OPENMP)
  if(CMAKE_CXX_COMPILER MATCHES ".*icpc")
        list(APPEND AMDIS_COMPILEFLAGS "-openmp")
        list(APPEND AMDIS_LIBRARIES "-openmp")
  else()
    list(APPEND AMDIS_COMPILEFLAGS "-fopenmp")
        list(APPEND AMDIS_LIBRARIES "-fopenmp")
  endif()
endif(AMDIS_OPENMP)

98
if(AMDIS_NEED_UMFPACK)
99
100
	set(AMDIS_UMFPACK_PATH @UMFPACK_PATH@)
	list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_UMFPACK_PATH})
101
	find_library(UMFPACK_LIB umfpack
102
103
104
		HINTS ENV LIBRARY_PATH
		DOC "The UMFPACK library")
	if(UMFPACK_LIB)
105
106
		list(APPEND AMDIS_LIBRARIES ${UMFPACK_LIB})
	else()
107
		message(FATAL_ERROR "Could not find the UMFPACK library")
108
	endif()
109
110
111
	if("$ENV{BLA_VENDOR}" STREQUAL "ACML")
	  find_library(ACML_LIBRARY acml HINTS ENV ACML_LIB)
	  if(ACML_LIBRARY)
112
	    list(APPEND AMDIS_LIBRARIES ${ACML_LIBRARY}) #fortran ffio m rt) #needed for open64
113
114
115
116
117
	  else()
	    message(FATAL_ERROR "could not find the acml libraries, required by acml blas")
	  endif(ACML_LIBRARY)
	else()
	  find_library(BLAS_LIBRARY NAMES "blas" "goto" "mkl"
118
119
		HINTS ENV MKL_LIB
		DOC "The BLAS library")
120
	  if(BLAS_LIBRARY)
121
122
		list(APPEND AMDIS_LIBRARIES ${BLAS_LIBRARY})
		list(APPEND AMDIS_LIBRARY_DIRS ${BLAS_LIBRARY_DIR})
123
	  else()
124
		message(ERROR "Could not find the BLAS library. Please set the variable BLAS_LIBRARY to the blas library with full path")
125
126
	  endif()
	endif("$ENV{BLA_VENDOR}" STREQUAL "ACML")
127

128
	find_library(AMD_LIB amd
129
130
131
		HINTS ENV LIBRARY_PATH
		DOC "The AMD library")
	if(AMD_LIB)
132
133
		list(APPEND AMDIS_LIBRARIES ${AMD_LIB})
	else()
134
		message(FATAL_ERROR "Could not find the AMD library.")
135
	endif()
136
137
138
139
140
141
142
	#check for if we need cholmod	
	set(_CHOLMOD_TEST_DIR ${CMAKE_BINARY_DIR}/CMakeFiles/cholmodTest/)
	file(WRITE ${_CHOLMOD_TEST_DIR}/CMakeLists.txt "project(cholmodTest)
			cmake_minimum_required(VERSION 2.8)
			include_directories(${AMDIS_INCLUDE_DIRS})
			add_executable(cholmodTest cholmodTest.cpp)
			target_link_libraries(cholmodTest ${AMDIS_LIBRARIES})")
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
	file(WRITE ${_CHOLMOD_TEST_DIR}/cholmodTest.cpp "#include <stdio.h>

#include \"umfpack.h\"

int n = 5 ;

int Ap [ ] = {0, 2, 5, 9, 10, 12} ;

int Ai [ ] = { 0, 1, 0, 2, 4, 1, 2, 3, 4, 2, 1, 4} ;

double Ax [ ] = {2., 3., 3., -1., 4., 4., -3., 1., 2., 2., 6., 1.} ;

double b [ ] = {8., 45., -3., 3., 19.} ;

double x [5] ;

int main (void)

{

double *null = (double *) NULL ;

int i ;

void *Symbolic, *Numeric ;

(void) umfpack_di_symbolic (n, n, Ap, Ai, Ax, &Symbolic, null, null) ;

(void) umfpack_di_numeric (Ap, Ai, Ax, Symbolic, &Numeric, null, null) ;

umfpack_di_free_symbolic (&Symbolic) ;

(void) umfpack_di_solve (UMFPACK_A, Ap, Ai, Ax, x, b, Numeric, null, null) ;

umfpack_di_free_numeric (&Numeric) ;

179

180
181
182
183
184
185

return (0) ;

}")
# "#include <umfpack.h> 
#			int main(int , char* argv[]) { double c[UMFPACK_CONTROL]; umfpack_dl_defaults(c); return 0;}")
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
	try_compile(CHOLMOD_TEST ${_CHOLMOD_TEST_DIR}/build ${_CHOLMOD_TEST_DIR} cholmodTest
			OUTPUT_VARIABLE CHOLMOD_OUT)
	if(NOT CHOLMOD_TEST)
	  find_library(CHOLMOD_LIB cholmod)
	  if(CHOLMOD_LIB)
	    list(APPEND AMDIS_LIBRARIES ${CHOLMOD_LIB})
	  else()
	    message(FATAL_ERROR "your umfpack seems to need cholmod, but cmake could not find it")
	  endif()
	  find_library(COLAMD_LIB colamd)
	  if(COLAMD_LIB)
	    list(APPEND AMDIS_LIBRARIES ${COLAMD_LIB})
	  else()
	    message(FATAL_ERROR "your umfpack seems to need colamd, but cmake could not find it")
	  endif()

	endif()
203
endif(AMDIS_NEED_UMFPACK)
204

Praetorius, Simon's avatar
Praetorius, Simon committed
205
206
207
208
209
210
211
212
213
214
215
216
217
if(AMDIS_NEED_PNG)
	set(AMDIS_PNG_PATH @PNG_PATH@)
	list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_PNG_PATH})

	find_library(PNG_LIB png
		HINTS ENV LIBRARY_PATH
		DOC "The PNG library")
	if(PNG_LIB)
		list(APPEND AMDIS_LIBRARIES ${PNG_LIB})
	else()
		message(FATAL_ERROR "Could not find the PNG library")
	endif()
endif(AMDIS_NEED_PNG)
Thomas Witkowski's avatar
Thomas Witkowski committed
218

219
220
221
222
223
224
if(AMDIS_NEED_BDDCML)
	set(AMDIS_BDDCML_PATH @BDDCML_PATH@)
	list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_BDDCML_PATH})

	set(AMDIS_BDDCML_LIB @BDDCML_LIB@)
	list(APPEND AMDIS_LIBRARIES ${AMDIS_BDDCML_LIB})
225
226
227

	set(AMDIS_BDDCML_LINK_LIST @BDDCML_LINK_LIST@)
	list(APPEND AMDIS_LIBRARIES ${AMDIS_BDDCML_LINK_LIST})
228
229
endif(AMDIS_NEED_BDDCML)

230
231
232
233
if(AMDIS_NEED_EXTENSIONS)
	list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/extensions)
	list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/extensions/time)
	list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/extensions/nanoflann)
Praetorius, Simon's avatar
Praetorius, Simon committed
234
	list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/extensions/pugixml)
Praetorius, Simon's avatar
Praetorius, Simon committed
235
	list(APPEND AMDIS_LIBRARIES ${AMDIS_LIBRARY_DIR}/libextensions.${LIBEXT})
236
237
238
239
endif(AMDIS_NEED_EXTENSIONS)

if(AMDIS_NEED_BASE_PROBLEMS)
	list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/base_problems)
Praetorius, Simon's avatar
Praetorius, Simon committed
240
	list(APPEND AMDIS_LIBRARIES ${AMDIS_LIBRARY_DIR}/libbase_problems.${LIBEXT})
241
endif(AMDIS_NEED_BASE_PROBLEMS)
Praetorius, Simon's avatar
Praetorius, Simon committed
242
243
244
245

#add directories for reinit
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/reinit)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/compositeFEM)
246
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/muparser)
Praetorius, Simon's avatar
Praetorius, Simon committed
247

Praetorius, Simon's avatar
Praetorius, Simon committed
248
249
list(APPEND AMDIS_LIBRARIES ${AMDIS_LIBRARY_DIR}/libcompositeFEM.${LIBEXT})	
list(APPEND AMDIS_LIBRARIES ${AMDIS_LIBRARY_DIR}/libreinit.${LIBEXT})	
Praetorius, Simon's avatar
Praetorius, Simon committed
250

Naumann, Andreas's avatar
Naumann, Andreas committed
251
if(${AMDIS_FIND_COMPONENTS} MATCHES umfpack )
252
253
254
	if(NOT AMDIS_NEED_UMFPACK)
	  set(AMDIS_umfpack_FOUND FALSE)
	  message(SEND_ERROR "The selected amdis was not compiled with umfpack")
255
256
257
	endif()
endif()

258
if(AMDIS_NEED_ZOLTAN)
259
260
261
262
263
264
265
266
267
	find_library(ZOLTAN_LIB zoltan 
		HINTS ENV LIBRARY_PATH
		DOC "full path to the zoltan library")		

	if(ZOLTAN_LIB)
		list(APPEND AMDIS_LIBRARIES ${ZOLTAN_LIB})	
	else()
		message(FATAL_ERROR "Could not find zoltan library!")
	endif()
268
endif()
Praetorius, Simon's avatar
Praetorius, Simon committed
269