project(AMDiS) cmake_minimum_required(VERSION 2.6) #needs: --enable-debug, enable-intel --enable-openmp --enable-parmetis --enable-parallel-domain --enable-umfpack --enable-mkl --enable-boost --enable-marmot SET(LIB_DIR ${AMDiS_SOURCE_DIR}/lib) SET(SOURCE_DIR ${AMDiS_SOURCE_DIR}/src) #TODO: use the cmake build type SET(MTL_DIR ${LIB_DIR}/mtl4/ CACHE PATH "mtl4 directory") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -Wall -DDEBUG=0") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -DDEBUG=1 -O0") #define the build type, empty can be everything and nothing if(CMAKE_BUILD_TYPE STREQUAL "") set(CMAKE_BUILD_TYPE "Release") endif() #option(ENABLE_INTEL "use intel compiler" false) option(ENABLE_OPENMP "use openmp" false) option(ENABLE_PARALLEL_DOMAIN "use parallel domain decomposition" false) set(ENABLE_PARMETIS off) #SET(PETSC_DIR "" CACHE PATH "Petsc directory for parallel domain decomposition" ) #SET(PETSC_ARCH "" CACHE STRING "Petsc architecture") option(ENABLE_UMFPACK "use umfpack solver" false) option(ENABLE_MKL "use the mkl" false) SET(MKL_DIR "" CACHE PATH "MKL directory") option(ENABLE_TESTS "compile the tests" false) if(ENABLE_INTEL) Message("please set the icc manually") INCLUDE (CMakeForceCompiler) CMAKE_FORCE_C_COMPILER(icc "intel C compiler") CMAKE_FORCE_CXX_COMPILER(icpc "intel C++ compiler") #SET(CMAKE_C_COMPILER "icc") endif(ENABLE_INTEL) find_package(Boost 1.42 REQUIRED) if(Boost_FOUND) include_directories(${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) link_directories(${Boost_LIBRARY_DIRS}) endif(Boost_FOUND) SET(AMDIS_SRC ${SOURCE_DIR}/DOFIndexed.cc ${SOURCE_DIR}/io/GNUPlotWriter.cc ${SOURCE_DIR}/VertexVector.cc ${SOURCE_DIR}/PeriodicBC.cc ${SOURCE_DIR}/Recovery.cc ${SOURCE_DIR}/RecoveryEstimator.cc ${SOURCE_DIR}/ResidualEstimator.cc ${SOURCE_DIR}/Cholesky.cc ${SOURCE_DIR}/AdaptBase.cc ${SOURCE_DIR}/StandardProblemIteration.cc ${SOURCE_DIR}/ProblemScal.cc ${SOURCE_DIR}/ProblemVec.cc ${SOURCE_DIR}/ProblemImplicit.cc ${SOURCE_DIR}/ProblemVecDbg.cc ${SOURCE_DIR}/DualTraverse.cc ${SOURCE_DIR}/ElementData.cc ${SOURCE_DIR}/ComponentTraverseInfo.cc ${SOURCE_DIR}/CreatorMap.cc ${SOURCE_DIR}/ProblemInterpolScal.cc ${SOURCE_DIR}/ProblemInterpolVec.cc ${SOURCE_DIR}/io/MacroInfo.cc ${SOURCE_DIR}/io/MacroReader.cc ${SOURCE_DIR}/io/ValueReader.cc ${SOURCE_DIR}/Projection.cc ${SOURCE_DIR}/SubAssembler.cc ${SOURCE_DIR}/ZeroOrderAssembler.cc ${SOURCE_DIR}/FirstOrderAssembler.cc ${SOURCE_DIR}/SecondOrderAssembler.cc ${SOURCE_DIR}/Assembler.cc ${SOURCE_DIR}/AdaptInfo.cc ${SOURCE_DIR}/Marker.cc ${SOURCE_DIR}/SurfaceQuadrature.cc ${SOURCE_DIR}/LeafData.cc ${SOURCE_DIR}/BoundaryManager.cc ${SOURCE_DIR}/DirichletBC.cc ${SOURCE_DIR}/RobinBC.cc ${SOURCE_DIR}/io/FileWriter.cc ${SOURCE_DIR}/io/ElementFileWriter.cc ${SOURCE_DIR}/ElInfo.cc ${SOURCE_DIR}/ElInfoStack.cc ${SOURCE_DIR}/OperatorTerm.cc ${SOURCE_DIR}/ZeroOrderTerm.cc ${SOURCE_DIR}/FirstOrderTerm.cc ${SOURCE_DIR}/SecondOrderTerm.cc ${SOURCE_DIR}/Operator.cc ${SOURCE_DIR}/Mesh.cc ${SOURCE_DIR}/MeshStructure.cc ${SOURCE_DIR}/AdaptStationary.cc ${SOURCE_DIR}/AdaptInstationary.cc ${SOURCE_DIR}/DOFVector.cc ${SOURCE_DIR}/Estimator.cc ${SOURCE_DIR}/ProblemInstat.cc ${SOURCE_DIR}/ProblemNonLin.cc ${SOURCE_DIR}/NonLinUpdater.cc ${SOURCE_DIR}/QPsiPhi.cc ${SOURCE_DIR}/BasisFunction.cc ${SOURCE_DIR}/Boundary.cc ${SOURCE_DIR}/CoarseningManager.cc ${SOURCE_DIR}/CoarseningManager1d.cc ${SOURCE_DIR}/CoarseningManager2d.cc ${SOURCE_DIR}/CoarseningManager3d.cc ${SOURCE_DIR}/DOFAdmin.cc ${SOURCE_DIR}/DOFMatrix.cc ${SOURCE_DIR}/Element.cc ${SOURCE_DIR}/ElInfo1d.cc ${SOURCE_DIR}/ElInfo2d.cc ${SOURCE_DIR}/ElInfo3d.cc ${SOURCE_DIR}/FiniteElemSpace.cc ${SOURCE_DIR}/FixVec.cc ${SOURCE_DIR}/Global.cc ${SOURCE_DIR}/Lagrange.cc ${SOURCE_DIR}/Line.cc ${SOURCE_DIR}/MacroElement.cc ${SOURCE_DIR}/io/MacroWriter.cc ${SOURCE_DIR}/Parameters.cc ${SOURCE_DIR}/Parametric.cc ${SOURCE_DIR}/Quadrature.cc ${SOURCE_DIR}/RCNeighbourList.cc ${SOURCE_DIR}/RefinementManager.cc ${SOURCE_DIR}/RefinementManager1d.cc ${SOURCE_DIR}/RefinementManager2d.cc ${SOURCE_DIR}/RefinementManager3d.cc ${SOURCE_DIR}/Tetrahedron.cc ${SOURCE_DIR}/Traverse.cc ${SOURCE_DIR}/TraverseParallel.cc ${SOURCE_DIR}/Triangle.cc ${SOURCE_DIR}/io/ValueWriter.cc ${SOURCE_DIR}/io/VtkWriter.cc ${SOURCE_DIR}/io/DofWriter.cc ${SOURCE_DIR}/io/PngWriter.cc ${SOURCE_DIR}/io/PovrayWriter.cc ${SOURCE_DIR}/io/DataCollector.cc ${SOURCE_DIR}/ScalableQuadrature.cc ${SOURCE_DIR}/SubElInfo.cc ${SOURCE_DIR}/parallel/InteriorBoundary.cc ${SOURCE_DIR}/ElementDofIterator.cc ${SOURCE_DIR}/Debug.cc ${SOURCE_DIR}/Serializer.cc ${SOURCE_DIR}/io/ArhReader.cc ${SOURCE_DIR}/io/ArhWriter.cc ${SOURCE_DIR}/time/RosenbrockAdaptInstationary.cc ${SOURCE_DIR}/time/RosenbrockStationary.cc ${SOURCE_DIR}/time/RosenbrockMethod.cc ) if(ENABLE_PARALLEL_DOMAIN) find_package(MPI REQUIRED) if(MPI_FOUND) #INCLUDE (CMakeForceCompiler) #CMAKE_FORCE_C_COMPILER(mpicc "MPI C compiler") #CMAKE_FORCE_CXX_COMPILER(mpiCC "MPI C++ compiler") list(APPEND AMDiS_COMPILEFLAGS ${MPI_COMPILE_FLAGS}) include_directories(${MPI_INCLUDE_PATH}) endif(MPI_FOUND) add_custom_target(parmetis-lib ALL make WORKING_DIRECTORY ${LIB_DIR}/ParMetis-3.1 ) include_directories( ${LIB_DIR}/ParMetis-3.1) INSTALL(FILES ${LIB_DIR}/ParMetis-3.1/parmetis.h ${LIB_DIR}/ParMetis-3.1/libparmetis.a ${LIB_DIR}/ParMetis-3.1/libmetis.a DESTINATION lib/amdis/parmetis ) set(ENABLE_PARMETIS ON) find_file(ZOLTAN_HEADER_DIR "zoltan_cpp.h") if( ZOLTAN_HEADER_DIR ) get_filename_component(ZOLTAN_HEADER_DIR "${ZOLTAN_HEADER_DIR}" PATH CACHE) include_directories(${ZOLTAN_HEADER_DIR}) else() message( FATAL_ERROR "could not find zoltan.") endif( ZOLTAN_HEADER_DIR ) set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};/usr/share/cmake-2.8/Modules/;${CMAKE_SOURCE_DIR}/") set(PETSC_EXECUTABLE_RUNS ON) find_package(PETSc REQUIRED) include_directories(${PETSC_DIR}/include ${PETSC_DIR}/${PETSC_ARCH}/include) SET(PARALLEL_DOMAIN_AMDIS_SRC ${SOURCE_DIR}/parallel/ParMetisPartitioner.cc ${SOURCE_DIR}/parallel/MeshDistributor.cc ${SOURCE_DIR}/parallel/MeshPartitioner.cc ${SOURCE_DIR}/parallel/MeshManipulation.cc ${SOURCE_DIR}/parallel/StdMpi.cc ${SOURCE_DIR}/parallel/ParallelDebug.cc ${SOURCE_DIR}/parallel/MpiHelper.cc ${SOURCE_DIR}/parallel/ElementObjectData.cc ${SOURCE_DIR}/parallel/ParallelProblemStatBase.cc ${SOURCE_DIR}/parallel/PetscSolver.cc ${SOURCE_DIR}/parallel/ZoltanPartitioner.cc) SET(COMPILEFLAGS "${COMPILEFLAGS} -DHAVE_PARALLEL_DOMAIN_AMDIS=1") INSTALL(FILES ResolveCompilerPaths.cmake FindPackageMultipass.cmake FindPETSc.cmake DESTINATION share/amdis/) endif(ENABLE_PARALLEL_DOMAIN) if(ENABLE_OPENMP) find_package(OpenMP) if(OPENMP_FOUND) SET(COMPILEFLAGS "${COMPILEFLAGS} ${OpenMP_CXX_FLAGS}") else() message(WARNING "your compiler seems not supporting openmp") endif() endif(ENABLE_OPENMP) if(ENABLE_UMFPACK) include_directories(${LIB_DIR}/UFconfig ${LIB_DIR}/AMD/Include ${LIB_DIR}/UMFPACK/Include) SET(COMPILEFLAGS "${COMPILEFLAGS} -DHAVE_UMFPACK=1 -DMTL_HAS_UMFPACK") FILE(GLOB UMFPACK_HEADERS "${LIB_DIR}/UMFPACK/Include/*.h") INSTALL(FILES ${UMFPACK_HEADERS} DESTINATION include/amdis/umfpack/) list(APPEND deb_add_dirs "include/amdis/umfpack") FILE(GLOB UMFPACK_HEADERS "${LIB_DIR}/AMD/Include/*.h") INSTALL(FILES ${UMFPACK_HEADERS} DESTINATION include/amdis/amd/) list(APPEND deb_add_dirs "include/amdis/amd") FILE(GLOB HEADERS "${LIB_DIR}/UFconfig/*.h") INSTALL(FILES ${HEADERS} DESTINATION include/amdis/ufconfig/) list(APPEND deb_add_dirs "include/amdis/ufconfig") FILE(GLOB HEADERS "${LIB_DIR}/UFconfig/xerbla/*.h") INSTALL(FILES ${HEADERS} DESTINATION include/amdis/ufconfig/xerbla) list(APPEND deb_add_dirs "include/amdis/ufconfig/xerbla") #add some rules to build the umfpack and amd libs # message("adding command for libumfpack:${CMAKE_CURRENT_SOURCE_DIR}/${LIB_DIR}/UMFPACK/Lib/libumfpack.a ") add_custom_target(umfpack-lib ALL make WORKING_DIRECTORY ${LIB_DIR}/UMFPACK ) add_custom_target(amd-lib ALL make WORKING_DIRECTORY ${LIB_DIR}/AMD ) INSTALL(FILES ${LIB_DIR}/UMFPACK/Lib/libumfpack.a DESTINATION lib/amdis/umfpack/) list(APPEND deb_add_dirs "lib/amdis/umfpack") INSTALL(FILES ${LIB_DIR}/AMD/Lib/libamd.a DESTINATION lib/amdis/amd/) list(APPEND deb_add_dirs "lib/amdis/amd") SET(RPM_DEPEND_STR "blas") LIST(APPEND AMDiS_LIBS amdis blas amd umfpack) endif(ENABLE_UMFPACK) if(ENABLE_MKL) include_directories(${MKL_DIR}) SET(COMPILEFLAGS "${COMPILEFLAGS} -DHAVE_MKL=1") endif(ENABLE_MKL) SET(COMPOSITE_SOURCE_DIR compositeFEM/src) SET(COMPOSITE_FEM_SRC ${COMPOSITE_SOURCE_DIR}/CFE_Integration.cc ${COMPOSITE_SOURCE_DIR}/CFE_NormAndErrorFcts.cc ${COMPOSITE_SOURCE_DIR}/CompositeFEMMethods.cc ${COMPOSITE_SOURCE_DIR}/LevelSetAdaptMesh.cc ${COMPOSITE_SOURCE_DIR}/PenaltyOperator.cc ${COMPOSITE_SOURCE_DIR}/ElementLevelSet.cc ${COMPOSITE_SOURCE_DIR}/CompositeFEMOperator.cc ${COMPOSITE_SOURCE_DIR}/SubPolytope.cc ${COMPOSITE_SOURCE_DIR}/SubElementAssembler.cc ) #mtl4 includes include_directories(${MTL_DIR}) include_directories(${SOURCE_DIR}) add_library(amdis SHARED ${AMDIS_SRC} ${PARALLEL_DOMAIN_AMDIS_SRC}) add_library(compositeFEM SHARED ${COMPOSITE_FEM_SRC}) target_link_libraries(compositeFEM amdis) LIST(APPEND AMDiS_LIBS amdis boost_system boost_iostreams) if(WIN32) SET(COMPILEFLAGS "${COMPILEFLAGS} -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS") endif(WIN32) message("compileflags: ${COMPILEFLAGS}") #SET_TARGET_PROPERTIES(amdis PROPERTIES COMPILE_FLAGS "${COMPILEFLAGS}") add_definitions(${COMPILEFLAGS}) if(ENABLE_MARMOT) Message("please set marmotcc manually") endif(ENABLE_MARMOT) #dont change this destination. the GUI depends on it to guess the buildsystem list(APPEND deb_add_dirs "lib/amdis") install(TARGETS amdis compositeFEM LIBRARY DESTINATION lib/amdis/ ) FILE(GLOB HEADERS "${SOURCE_DIR}/*.h") INSTALL(FILES ${HEADERS} DESTINATION include/amdis/) list(APPEND deb_add_dirs "include/amdis") FILE(GLOB HEADERS "${SOURCE_DIR}/*.hh") 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}/time/*.h") INSTALL(FILES ${HEADERS} DESTINATION include/amdis/time/) list(APPEND deb_add_dirs "include/amdis/time") FILE(GLOB HEADERS "${SOURCE_DIR}/itl/*.hpp") INSTALL(FILES ${HEADERS} DESTINATION include/amdis/itl) list(APPEND deb_add_dirs "include/amdis/itl") 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) configure_file(${AMDiS_SOURCE_DIR}/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/") INSTALL(FILES ${AMDiS_SOURCE_DIR}/AMDiSUse.cmake 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) list(REMOVE_DUPLICATES deb_add_dirs) #PACKAGES #let cmake look for the svn-version find_package(Subversion) if(Subversion_FOUND) Subversion_WC_INFO(${AMDiS_SOURCE_DIR} mtlSubinfo) set(CurrentRevision ${mtlSubinfo_WC_REVISION}) # message("current revision: ${mtlSubinfo_WC_REVISION}") else(Subversion_FOUND) set(CurrentRevision "0") endif(Subversion_FOUND) set(CPACK_PACKAGE_NAME "AMDiS") set(CPACK_PACKAGE_CONTACT "Andreas.Naumann@tu-dresden.de") set(CPACK_PACKAGE_VERSION "0.9.${CurrentRevision}") set(CPACK_GENERATOR "RPM" "DEB" "TGZ") set(CPACK_INSTALL_PREFIX "/usr/") configure_file(${AMDiS_SOURCE_DIR}/preinst.in ${AMDiS_BINARY_DIR}/preinst @ONLY) configure_file(${AMDiS_SOURCE_DIR}/postrm.in ${AMDiS_BINARY_DIR}/postrm @ONLY) set(CPACK_RPM_PACKAGE_REQUIRES "boost-devel >= 1.42, ${RPM_DEPEND_STR}") set(CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-dev (>= 1.42), libboost-iostreams-dev (>= 1.42), libboost-system-dev (>= 1.42)") set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${AMDiS_BINARY_DIR}/preinst" "${AMDiS_BINARY_DIR}/postrm") include(CPack) if(ENABLE_TESTS) ENABLE_TESTING() add_subdirectory(test) endif(ENABLE_TESTS)