CMakeLists.txt 20.6 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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
cmake_minimum_required(VERSION 2.8.10)
project(AMDIS)
cmake_policy(SET CMP0017 OLD)
if(POLICY CMP0042)
	cmake_policy(SET CMP0042 NEW)
endif()
if(POLICY CMP0054)
	cmake_policy(SET CMP0054 NEW)
endif()

SET(LIB_DIR ${AMDIS_SOURCE_DIR}/lib)
SET(SOURCE_DIR ${AMDIS_SOURCE_DIR}/src)

#TODO: use the cmake build type
SET(MTL_INCLUDE_DIR ${LIB_DIR}/mtl4/ CACHE PATH "mtl4 directory")

# set global compile_definitions for all target, depending on build-type
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
    $<$<CONFIG:Debug>:DEBUG=1>
    $<$<CONFIG:Release>:DEBUG=0>)

# find_package(Subversion QUIET)
# if(Subversion_FOUND)
#   Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} svn_info)
#   #message("svn-rev: ${svn_info_WC_REVISION}")
#   set(AMDIS_SUB_MINOR "${svn_info_WC_REVISION}")
# endif()
set(CurrentRevision "0.9")
if(NOT AMDIS_MAJOR)
  set(AMDIS_MAJOR "0")
endif()
if(NOT AMDIS_MINOR)
  set(AMDIS_MINOR "9")
endif()
list(APPEND COMPILEFLAGS "-DAMDIS_VERSION=${CurrentRevision}")

#define the build type, empty can be everything and nothing
if(CMAKE_BUILD_TYPE STREQUAL "")
	set(CMAKE_BUILD_TYPE "Release")
endif()

if(CMAKE_CXX_COMPILER MATCHES ".*icpc")
	Message("Compiler: Intel")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -diag-disable 654 -diag-disable 858")
endif()


SET(ENABLE_PARALLEL_DOMAIN "OFF" CACHE STRING "use parallel domain decomposition. please set to one of: PMTL, PETSC, OFF" )
option(ENABLE_CXX11 "Enable C++11 compiler features" false)
option(ENABLE_SEQ_PETSC "Use sequential PETSc solvers" false)
option(ENABLE_UMFPACK "Use of UMFPACK solver" false)
option(ENABLE_HYPRE "Use HYPRE AMG solver" false)
option(ENABLE_PNG "use png reader/writer" false)
option(ENABLE_BDDCML "Use of BDDCML library" false)
mark_as_advanced(ENABLE_BDDCML)
option(ENABLE_EXTENSIONS "Use extensions" false)
option(ENABLE_OPENMP "Use OpenMP" false)
option(ENABLE_COMPRESSION "Use output compression" false)
option(ENABLE_OUTPUT "AMDiS output printing, disable only for debugging!" true)
mark_as_advanced(ENABLE_OUTPUT)


find_package(Boost 1.44 REQUIRED)
if (Boost_FOUND)
  list(APPEND AMDIS_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
  message("boost lib-dirs: ${Boost_LIBRARY_DIRS}")
  message("use the boost dir: ${Boost_INCLUDE_DIR}")
  #if (WIN32)
	#message("the windows find_boost does not set the boost library paths, please set it")
	#SET(Boost_LIBRARY_DIRS CACHE PATH "The directory containing the boost libraries")
  #endif (WIN32)
  list(APPEND AMDIS_LINK_DIRS ${Boost_LIBRARY_DIRS})
endif (Boost_FOUND)


SET(AMDIS_SRC ${SOURCE_DIR}/AdaptBase.cc
            ${SOURCE_DIR}/AdaptInfo.cc
            ${SOURCE_DIR}/AdaptInstationary.cc
            ${SOURCE_DIR}/AdaptStationary.cc
            ${SOURCE_DIR}/AMDiS.cc
            ${SOURCE_DIR}/Assembler.cc
            ${SOURCE_DIR}/BasisFunction.cc
            ${SOURCE_DIR}/Boundary.cc
            ${SOURCE_DIR}/BoundaryManager.cc
            ${SOURCE_DIR}/BoundaryObject.cc
            ${SOURCE_DIR}/Bubble.cc
            ${SOURCE_DIR}/Cholesky.cc
            ${SOURCE_DIR}/CoarseningManager.cc
            ${SOURCE_DIR}/CoarseningManager1d.cc
            ${SOURCE_DIR}/CoarseningManager2d.cc
            ${SOURCE_DIR}/CoarseningManager3d.cc
            ${SOURCE_DIR}/ComponentTraverseInfo.cc
            ${SOURCE_DIR}/CouplingIterationInterface.cc
            ${SOURCE_DIR}/CreatorMap.cc
            ${SOURCE_DIR}/DOFAdmin.cc
            ${SOURCE_DIR}/DOFIndexed.cc
            ${SOURCE_DIR}/DOFMatrix.cc
            ${SOURCE_DIR}/DOFVector.cc
            ${SOURCE_DIR}/Debug.cc
            ${SOURCE_DIR}/DirichletBC.cc
            ${SOURCE_DIR}/DualTraverse.cc
            ${SOURCE_DIR}/ElInfo.cc
            ${SOURCE_DIR}/ElInfo1d.cc
            ${SOURCE_DIR}/ElInfo2d.cc
            ${SOURCE_DIR}/ElInfo3d.cc
            ${SOURCE_DIR}/ElInfoStack.cc
            ${SOURCE_DIR}/Element.cc
            ${SOURCE_DIR}/ElementData.cc
            ${SOURCE_DIR}/ElementDofIterator.cc
            ${SOURCE_DIR}/ElementRegion_ED.cc
            ${SOURCE_DIR}/FiniteElemSpace.cc
            ${SOURCE_DIR}/FirstOrderAssembler.cc
            ${SOURCE_DIR}/FirstOrderTerm.cc
            ${SOURCE_DIR}/FixVec.cc
            ${SOURCE_DIR}/Global.cc
            ${SOURCE_DIR}/GlobalDOFNumbering.cc
            ${SOURCE_DIR}/GlobalElementNumbering.cc
            ${SOURCE_DIR}/Initfile.cc
            ${SOURCE_DIR}/Lagrange.cc
            ${SOURCE_DIR}/LeafData.cc
            ${SOURCE_DIR}/Line.cc
            ${SOURCE_DIR}/MacroElement.cc
            ${SOURCE_DIR}/Marker.cc
            ${SOURCE_DIR}/MatrixVector.cc
            ${SOURCE_DIR}/Mesh.cc
            ${SOURCE_DIR}/MeshStructure.cc
            ${SOURCE_DIR}/Operator.cc
            ${SOURCE_DIR}/OperatorTerm.cc
            ${SOURCE_DIR}/Parametric.cc
            ${SOURCE_DIR}/PeriodicBC.cc
            ${SOURCE_DIR}/ProblemInstat.cc
            ${SOURCE_DIR}/ProblemInterpol.cc
            ${SOURCE_DIR}/ProblemStat.cc
            ${SOURCE_DIR}/ProblemStatDbg.cc
            ${SOURCE_DIR}/Projection.cc
            ${SOURCE_DIR}/QPInfo.cc
            ${SOURCE_DIR}/QPsiPhi.cc
            ${SOURCE_DIR}/Quadrature.cc
            ${SOURCE_DIR}/RCNeighbourList.cc
            ${SOURCE_DIR}/Recovery.cc
            ${SOURCE_DIR}/RefinementManager.cc
            ${SOURCE_DIR}/RefinementManager1d.cc
            ${SOURCE_DIR}/RefinementManager2d.cc
            ${SOURCE_DIR}/RefinementManager3d.cc
            ${SOURCE_DIR}/RobinBC.cc
            ${SOURCE_DIR}/ScalableQuadrature.cc
            ${SOURCE_DIR}/SecondOrderAssembler.cc
            ${SOURCE_DIR}/SecondOrderTerm.cc
            ${SOURCE_DIR}/Serializer.cc
            ${SOURCE_DIR}/StandardProblemIteration.cc
            ${SOURCE_DIR}/SubAssembler.cc
            ${SOURCE_DIR}/SubElInfo.cc
            ${SOURCE_DIR}/SubQuadrature.cc
            ${SOURCE_DIR}/SurfaceQuadrature.cc
            ${SOURCE_DIR}/SurfaceRegion_ED.cc
            ${SOURCE_DIR}/SystemVector.cc
            ${SOURCE_DIR}/Tetrahedron.cc
            ${SOURCE_DIR}/Timer.cc
            ${SOURCE_DIR}/Traverse.cc
            ${SOURCE_DIR}/Triangle.cc
            ${SOURCE_DIR}/VertexVector.cc
            ${SOURCE_DIR}/ZeroOrderAssembler.cc
            ${SOURCE_DIR}/ZeroOrderTerm.cc
            ${SOURCE_DIR}/est/Estimator.cc
            ${SOURCE_DIR}/est/RecoveryEstimator.cc
            ${SOURCE_DIR}/est/ResidualEstimator.cc
            ${SOURCE_DIR}/est/SimpleResidualEstimator.cc
            ${SOURCE_DIR}/io/ArhReader.cc
            ${SOURCE_DIR}/io/detail/ArhReader.cc
            ${SOURCE_DIR}/io/Arh2Reader.cc
            ${SOURCE_DIR}/io/Arh2Writer.cc
            ${SOURCE_DIR}/io/Arh3Reader.cc
            ${SOURCE_DIR}/io/Arh3Writer.cc
            ${SOURCE_DIR}/io/detail/Arh2Reader.cc
            ${SOURCE_DIR}/io/detail/ArhWriter.cc
            ${SOURCE_DIR}/io/detail/Arh2Writer.cc
            ${SOURCE_DIR}/io/detail/Arh3Reader.cc
            ${SOURCE_DIR}/io/detail/Arh3Writer.cc
            ${SOURCE_DIR}/io/DofWriter.cc
            ${SOURCE_DIR}/io/ElementFileWriter.cc
            ${SOURCE_DIR}/io/FileWriterInterface.cc
            ${SOURCE_DIR}/io/FileWriter.cc
            ${SOURCE_DIR}/io/GNUPlotWriter.cc
            ${SOURCE_DIR}/io/MacroInfo.cc
            ${SOURCE_DIR}/io/MacroReader.cc
            ${SOURCE_DIR}/io/MacroWriter.cc
            ${SOURCE_DIR}/io/PngReader.cc
            ${SOURCE_DIR}/io/PngWriter.cc
            ${SOURCE_DIR}/io/PovrayWriter.cc
            ${SOURCE_DIR}/io/Spreadsheet.cc
            ${SOURCE_DIR}/io/ValueReader.cc
            ${SOURCE_DIR}/io/ValueWriter.cc
            ${SOURCE_DIR}/io/VtkWriter.cc
            ${SOURCE_DIR}/io/VtkVectorWriter.cc
            ${SOURCE_DIR}/io/detail/VtkWriter.cc
            ${SOURCE_DIR}/nonlin/ProblemNonLin.cc
            ${SOURCE_DIR}/solver/SolverMatrix.cc
            ${SOURCE_DIR}/time/RosenbrockAdaptInstationary.cc
            ${SOURCE_DIR}/time/RosenbrockMethod.cc
            ${SOURCE_DIR}/time/RosenbrockStationary.cc
	      )


include(cmake/enable_cxx11.cmake)
include(cmake/enable_parallel_domain.cmake)
include(cmake/enable_seq_petsc.cmake)
include(cmake/enable_umfpack.cmake)
include(cmake/enable_hypre.cmake)
include(cmake/enable_png.cmake)
include(cmake/enable_bddcml.cmake)
include(cmake/enable_extensions.cmake)
include(cmake/enable_openmp.cmake)

if(ENABLE_COMPRESSION)
    list(APPEND COMPILEFLAGS "-DHAVE_COMPRESSION=1")
endif(ENABLE_COMPRESSION)

if(NOT ENABLE_OUTPUT)
    message(WARNING "AMDiS cout output disabled!")
    list(APPEND COMPILEFLAGS "-DSUPPRESS_OUTPUT")
endif(NOT ENABLE_OUTPUT)

if(ENABLE_MARMOT)
	Message("please set marmotcc manually")
endif(ENABLE_MARMOT)

# TODO: make composidte-fem and reinit a subproject
# add_subdirectory(${SOURCE_DIR}/compositeFEM [binarydir])

# composite fem includes
SET(COMPOSITE_SOURCE_DIR ${SOURCE_DIR}/compositeFEM)
SET(COMPOSITE_FEM_SRC ${COMPOSITE_SOURCE_DIR}/CFE_Integration.cc
		      ${COMPOSITE_SOURCE_DIR}/CFE_NormAndErrorFcts.cc
		      ${COMPOSITE_SOURCE_DIR}/CompositeFEMMethods.cc
		      ${COMPOSITE_SOURCE_DIR}/CompositeFEMOperator.cc
		      ${COMPOSITE_SOURCE_DIR}/LevelSetAdaptMesh.cc
		      ${COMPOSITE_SOURCE_DIR}/PenaltyOperator.cc
		      ${COMPOSITE_SOURCE_DIR}/ElementLevelSet.cc
		      ${COMPOSITE_SOURCE_DIR}/SubPolytope.cc
		      ${COMPOSITE_SOURCE_DIR}/SubElementAssembler.cc )

# reinit includes
set(REINIT_SOURCE_DIR ${SOURCE_DIR}/reinit)
file(GLOB REINIT_SRC ${REINIT_SOURCE_DIR}/*.cc)
list(APPEND AMDIS_INCLUDE_DIRS ${REINIT_SOURCE_DIR})

# muparser includes
set(MUPARSER_SOURCE_DIR ${AMDIS_SOURCE_DIR}/lib/muparser_v134)
file(GLOB MUPARSER_SRC ${MUPARSER_SOURCE_DIR}/src/*.cpp)
list(APPEND AMDIS_INCLUDE_DIRS ${MUPARSER_SOURCE_DIR}/include)

# mtl4 includes
list(APPEND AMDIS_INCLUDE_DIRS ${MTL_INCLUDE_DIR})
list(APPEND AMDIS_INCLUDE_DIRS ${SOURCE_DIR})


include_directories(${AMDIS_INCLUDE_DIRS})

if(WIN32)
  add_library(amdis STATIC ${AMDIS_SRC} ${PARALLEL_DOMAIN_AMDIS_SRC})
  add_library(compositeFEM STATIC ${COMPOSITE_FEM_SRC})
  add_library(reinit STATIC ${REINIT_SRC})
  add_library(muparser STATIC ${MUPARSER_SRC})
else()
  add_library(amdis SHARED ${AMDIS_SRC} ${PARALLEL_DOMAIN_AMDIS_SRC})
  add_library(compositeFEM SHARED ${COMPOSITE_FEM_SRC})
  add_library(reinit SHARED ${REINIT_SRC})
  add_library(muparser SHARED ${MUPARSER_SRC})
endif()


list(APPEND AMDIS_LIBS amdis ${Boost_LIBRARIES})

# some special treatements for Windows systems
# --------------------------------------------
if(WIN32)
	list(APPEND COMPILEFLAGS "-D_SCL_SECURE_NO_WARNINGS" "-D_CRT_SECURE_NO_WARNINGS")
endif(WIN32)

# some special treatements for MacOS Systems
# ------------------------------------------
if(CMAKE_SYSTEM_NAME MATCHES Darwin)
  if(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
     SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -flat_namespace -single_module -undefined dynamic_lookup")
     SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -flat_namespace -single_module -undefined dynamic_lookup")

     set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -bind_at_load -m64")
     set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -bind_at_load -m64")
  endif()
endif()


message("compileflags: ${COMPILEFLAGS}")
add_definitions(${COMPILEFLAGS})

#dont change this destination. the GUI depends on it to guess the buildsystem

FILE(GLOB HEADERS "${SOURCE_DIR}/*.h")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/)
list(APPEND deb_add_dirs "include/amdis")

FILE(GLOB HEADERS "${SOURCE_DIR}/config/*.h*")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/config/)
list(APPEND deb_add_dirs "include/amdis/config")

FILE(GLOB HEADERS "${SOURCE_DIR}/*.hh")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/)

FILE(GLOB HEADERS "${SOURCE_DIR}/*.hpp")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/)

FILE(GLOB HEADERS "${SOURCE_DIR}/parallel/*.h")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/parallel/)
list(APPEND deb_add_dirs "include/amdis/parallel")

FILE(GLOB HEADERS "${SOURCE_DIR}/nonlin/*.h")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/nonlin/)
list(APPEND deb_add_dirs "include/amdis/nonlin")

FILE(GLOB HEADERS "${SOURCE_DIR}/est/*.h")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/est/)
list(APPEND deb_add_dirs "include/amdis/est")

FILE(GLOB HEADERS "${SOURCE_DIR}/expressions/*.h*")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/expressions/)
list(APPEND deb_add_dirs "include/amdis/expressions")

FILE(GLOB HEADERS "${SOURCE_DIR}/operations/*.h*")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/operations/)
list(APPEND deb_add_dirs "include/amdis/operations")

FILE(GLOB HEADERS "${SOURCE_DIR}/traits/*.h*")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/traits/)
list(APPEND deb_add_dirs "include/amdis/traits")

FILE(GLOB HEADERS "${SOURCE_DIR}/utility/*.h*")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/utility/)
list(APPEND deb_add_dirs "include/amdis/utility")

FILE(GLOB HEADERS "${SOURCE_DIR}/time/*.h")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/time/)
list(APPEND deb_add_dirs "include/amdis/time")

FILE(GLOB HEADERS "${SOURCE_DIR}/traits/*.h*")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/traits/)
list(APPEND deb_add_dirs "include/amdis/traits")

FILE(GLOB HEADERS "${SOURCE_DIR}/solver/*.h")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/solver)
list(APPEND deb_add_dirs "include/amdis/solver")

FILE(GLOB HEADERS "${SOURCE_DIR}/solver/*.hh")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/solver)
list(APPEND deb_add_dirs "include/amdis/solver")

FILE(GLOB HEADERS "${SOURCE_DIR}/solver/details/*.h")
INSTALL(FILES ${HEADERS}
        DESTINATION include/amdis/solver/details)
list(APPEND deb_add_dirs "include/amdis/solver/details")

FILE(GLOB HEADERS "${SOURCE_DIR}/solver/itl/*.hpp")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/solver/itl)
list(APPEND deb_add_dirs "include/amdis/solver/itl")

FILE(GLOB HEADERS "${SOURCE_DIR}/solver/details/*.h")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/solver/details)
list(APPEND deb_add_dirs "include/amdis/solver/details")


FILE(GLOB HEADERS "${SOURCE_DIR}/io/*.h")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/io)
list(APPEND deb_add_dirs "include/amdis/io")

FILE(GLOB HEADERS "${SOURCE_DIR}/io/*.hh")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/io)

FILE(GLOB HEADERS "${SOURCE_DIR}/io/detail/*h")
INSTALL(FILES ${HEADERS}
        DESTINATION include/amdis/io/detail)
list(APPEND deb_add_dirs "include/amdis/io/detail")

FILE(GLOB HEADERS "${REINIT_SOURCE_DIR}/*.h")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/reinit)
list(APPEND deb_add_dirs "include/amdis/reinit")

FILE(GLOB HEADERS "${COMPOSITE_SOURCE_DIR}/*.h")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/compositeFEM)
list(APPEND deb_add_dirs "include/amdis/compositeFEM")

FILE(GLOB HEADERS "${MUPARSER_SOURCE_DIR}/include/*.h")
INSTALL(FILES ${HEADERS}
	DESTINATION include/amdis/muparser)
list(APPEND deb_add_dirs "include/amdis/muparser")

list(APPEND deb_add_dirs "lib/amdis")
install(TARGETS amdis compositeFEM reinit muparser
	DESTINATION lib/amdis/ )

configure_file(${AMDIS_SOURCE_DIR}/cmake/AMDISConfig.cmake.in
		${AMDIS_BINARY_DIR}/AMDISConfig.cmake
		@ONLY
	      )

INSTALL(FILES ${AMDIS_BINARY_DIR}/AMDISConfig.cmake
	DESTINATION share/amdis/)
list(APPEND deb_add_dirs "share/amdis/")

FILE(GLOB CMAKE_FILES "${AMDIS_SOURCE_DIR}/cmake/*.cmake")
INSTALL(FILES ${CMAKE_FILES}
	DESTINATION share/amdis/)

#install mtl
INSTALL(DIRECTORY ${AMDIS_SOURCE_DIR}/lib/mtl4/
	DESTINATION include/amdis/mtl4/
	FILES_MATCHING PATTERN "*.hpp"
	PATTERN ".svn" EXCLUDE
	PATTERN ".svn/*" EXCLUDE
	PATTERN "mtl4/libs" EXCLUDE
	PATTERN "mtl4/extern" EXCLUDE
       )
FILE(GLOB_RECURSE mtl4_files
		RELATIVE ${AMDIS_SOURCE_DIR}/lib/mtl4/boost/
		${AMDIS_SOURCE_DIR}/lib/mtl4/boost/*.hpp)
foreach(mtl4_file in ${mtl4_files})
    get_filename_component(mtl4File_path ${mtl4_file} PATH)
    list(APPEND deb_add_dirs "include/amdis/mtl4/boost/${mtl4File_path}")
endforeach(mtl4_file)

#install documentation
FILE(GLOB DOCS "${AMDIS_SOURCE_DIR}/doc/*.pdf")
INSTALL(FILES  ${DOCS} DESTINATION share/amdis/doc)
list(APPEND deb_add_dirs "share/amdis/doc")

list(REMOVE_DUPLICATES deb_add_dirs)

ENABLE_TESTING()
INCLUDE(CTest)
INCLUDE(Dart)
if(NOT CTEST_MODEL)
        set(CTEST_MODEL "Experimental")
endif()
if( NOT N_TEST_PROC)
	set(N_TEST_PROC "8")
endif()
configure_file(cmake/myMake.sh.in myMake.sh @ONLY)
configure_file(cmake/CTestScript.cmake.in CTestScript.cmake @ONLY)


# PACKAGES
# ========================================================
set(CPACK_PACKAGE_NAME "AMDIS")
set(CPACK_PACKAGE_CONTACT "Andreas.Naumann@tu-dresden.de")
set(CPACK_PACKAGE_VERSION "${CurrentRevision}")
set(CPACK_GENERATOR "RPM" "DEB" "TGZ")
set(CPACK_INSTALL_PREFIX "/usr/")
set(CPACK_RESOURCE_FILE_LICENSE "${AMDIS_SOURCE_DIR}/license.opensource.txt")

# library depends on boost, but boost libraries have version-number in name on some systems.
# so we have to find a workaround to enforce allowed boost versions
set(boost_ver ${Boost_MINOR_VERSION})
math(EXPR boost_ver_start "${Boost_MINOR_VERSION}+1")
math(EXPR boost_ver_stop "${Boost_MINOR_VERSION}+10")

set(boost_depends "libboost${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})")
set(boost_iostreams_depends "libboost-iostreams${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})")
set(boost_system_depends "libboost-system${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})")
set(boost_filesystem_depends "libboost-filesystem${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})")

foreach(boost_ver RANGE ${boost_ver_start} ${boost_ver_stop})
  set(boost_depends "${boost_depends} | libboost${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})")
  set(boost_iostreams_depends "${boost_iostreams_depends} | libboost-iostreams${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})")
  set(boost_system_depends "${boost_system_depends} | libboost-system${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})")
  set(boost_filesystem_depends "${boost_filesystem_depends} | libboost-filesystem${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})")
endforeach(boost_ver)

configure_file(${AMDIS_SOURCE_DIR}/cmake/preinst.in
  ${AMDIS_BINARY_DIR}/preinst
  @ONLY)

configure_file(${AMDIS_SOURCE_DIR}/cmake/postrm.in
  ${AMDIS_BINARY_DIR}/postrm
  @ONLY)

#----Test if clang setup works----------------------------------------------------------------------
set(COMPILER_VERSION "")
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  exec_program(${CMAKE_C_COMPILER} ARGS "-v" OUTPUT_VARIABLE _clang_version_info)
  string(REGEX REPLACE "^.*[ ]([0-9]+)\\.[0-9].*$" "\\1" CLANG_MAJOR "${_clang_version_info}")
  string(REGEX REPLACE "^.*[ ][0-9]+\\.([0-9]).*$" "\\1" CLANG_MINOR "${_clang_version_info}")
  set(COMPILER_VERSION "clang ${CLANG_MAJOR}.${CLANG_MINOR}")
endif()

#---Obtain the major and minor version of the GNU compiler-------------------------------------------
if (CMAKE_COMPILER_IS_GNUCXX)
  exec_program(${CMAKE_C_COMPILER} ARGS "-dumpversion" OUTPUT_VARIABLE _gcc_version_info)
  string(REGEX REPLACE "^([0-9]+).*$"                   "\\1" GCC_MAJOR ${_gcc_version_info})
  string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*$"          "\\1" GCC_MINOR ${_gcc_version_info})
  string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" GCC_PATCH ${_gcc_version_info})

  if(GCC_PATCH MATCHES "\\.+")
    set(GCC_PATCH "")
  endif()
  if(GCC_MINOR MATCHES "\\.+")
    set(GCC_MINOR "")
  endif()
  if(GCC_MAJOR MATCHES "\\.+")
    set(GCC_MAJOR "")
  endif()
  set(COMPILER_VERSION "gcc ${_gcc_version_info}")
endif()

set(CPACK_RPM_PACKAGE_REQUIRES "boost-devel >= ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}, ${RPM_DEPEND_STR}")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${boost_depends},\\n ${boost_iostreams_depends},\\n ${boost_system_depends},\\n ${boost_filesystem_depends}")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "AMDiS (Adaptive Multi-Dimensional Simulations) - a C++ library to solve partial differential equations using adaptive finite elements. The main features of AMDiS are:
 .
  - full adaptive meshes in 1D, 2D and 3D
  - adaptive time stepping strategies for time dependent equations
  - uses high performance Krylov subspace solvers from MTL4 and the direct solvers UMFPACK and Intel's Pardiso
  - parallelization of the overall finite element method with excelent scaling up to several thounds of processors
  - uses PETSc for solving parallel distributed linear systems
  - easy to use interface, no additional effort to run code in parallel!
 .
  The library is compiled with ${COMPILER_VERSION} and compiled/linked with boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}.")

set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${AMDIS_BINARY_DIR}/preinst" "${AMDIS_BINARY_DIR}/postrm")

include(CPack)