Commit 32fd7bcc authored by Praetorius, Simon's avatar Praetorius, Simon

CMakeLists changed - must be tested further

parent 98614912
This diff is collapsed.
This diff is collapsed.
# - Try to find PETSc
# Once done this will define
# source: https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake
#
# PETSC_FOUND - system has PETSc
# PETSC_INCLUDES - the PETSc include directories
# PETSC_LIBRARIES - Link these to use PETSc
# PETSC_COMPILER - Compiler used by PETSc, helpful to find a compatible MPI
# PETSC_DEFINITIONS - Compiler switches for using PETSc
# PETSC_MPIEXEC - Executable for running MPI programs
# PETSC_VERSION - Version string (MAJOR.MINOR.SUBMINOR)
#
# Hack: PETSC_VERSION currently decides on the version based on the
# layout. Otherwise we need to run C code to determine the version.
#
# Setting these changes the behavior of the search
# PETSC_DIR - directory in which PETSc resides
# PETSC_ARCH - build architecture
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
function (petsc_get_version)
if (EXISTS "${PETSC_DIR}/include/petscversion.h")
file (STRINGS "${PETSC_DIR}/include/petscversion.h" vstrings REGEX "#define PETSC_VERSION_(RELEASE|MAJOR|MINOR|SUBMINOR|PATCH) ")
foreach (line ${vstrings})
string (REGEX REPLACE " +" ";" fields ${line}) # break line into three fields (the first is always "#define")
list (GET fields 1 var)
list (GET fields 2 val)
set (${var} ${val} PARENT_SCOPE)
set (${var} ${val}) # Also in local scope so we have access below
endforeach ()
if (PETSC_VERSION_RELEASE)
set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}p${PETSC_VERSION_PATCH}" PARENT_SCOPE)
else ()
# make dev version compare higher than any patch level of a released version
set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}.99" PARENT_SCOPE)
endif ()
else ()
message (SEND_ERROR "PETSC_DIR can not be used, ${PETSC_DIR}/include/petscversion.h does not exist")
endif ()
endfunction ()
find_path (PETSC_DIR include/petsc.h
HINTS ENV PETSC_DIR
PATHS
/usr/lib/petscdir/3.1 /usr/lib/petscdir/3.0.0 /usr/lib/petscdir/2.3.3 /usr/lib/petscdir/2.3.2 # Debian
$ENV{HOME}/petsc
DOC "PETSc Directory")
if (PETSC_DIR AND NOT PETSC_ARCH)
set (_petsc_arches
$ENV{PETSC_ARCH} # If set, use environment variable first
linux-gnu-c-debug linux-gnu-c-opt # Debian defaults
x86_64-unknown-linux-gnu i386-unknown-linux-gnu)
set (petscconf "NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
foreach (arch ${_petsc_arches})
if (NOT PETSC_ARCH)
find_path (petscconf petscconf.h
HINTS ${PETSC_DIR}
PATH_SUFFIXES ${arch}/include bmake/${arch}
NO_DEFAULT_PATH)
if (petscconf)
set (PETSC_ARCH "${arch}" CACHE STRING "PETSc build architecture")
endif (petscconf)
endif (NOT PETSC_ARCH)
endforeach (arch)
set (petscconf "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE)
endif (PETSC_DIR AND NOT PETSC_ARCH)
set (petsc_slaves LIBRARIES_SYS LIBRARIES_VEC LIBRARIES_MAT LIBRARIES_DM LIBRARIES_KSP LIBRARIES_SNES LIBRARIES_TS
INCLUDE_DIR INCLUDE_CONF)
include (cmake/FindPackageMultipass.cmake)
find_package_multipass (PETSc petsc_config_current
STATES DIR ARCH
DEPENDENTS INCLUDES LIBRARIES COMPILER MPIEXEC ${petsc_slaves})
# Determine whether the PETSc layout is old-style (through 2.3.3) or
# new-style (>= 3.0.0)
if (EXISTS "${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h") # > 2.3.3
set (petsc_conf_rules "${PETSC_DIR}/conf/rules")
set (petsc_conf_variables "${PETSC_DIR}/conf/variables")
elseif (EXISTS "${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf.h") # <= 2.3.3
set (petsc_conf_rules "${PETSC_DIR}/bmake/common/rules")
set (petsc_conf_variables "${PETSC_DIR}/bmake/common/variables")
elseif (PETSC_DIR)
message (SEND_ERROR "The pair PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} do not specify a valid PETSc installation")
else ()
message (FATAL_ERROR "PETSc could not be found. Be sure to set PETSC_DIR and PETSC_ARCH.")
endif ()
petsc_get_version()
if (petsc_conf_rules AND petsc_conf_variables AND NOT petsc_config_current)
# Put variables into environment since they are needed to get
# configuration (petscvariables) in the PETSc makefile
set (ENV{PETSC_DIR} "${PETSC_DIR}")
set (ENV{PETSC_ARCH} "${PETSC_ARCH}")
# A temporary makefile to probe the PETSc configuration
set (petsc_config_makefile "${PROJECT_BINARY_DIR}/Makefile.petsc")
file (WRITE "${petsc_config_makefile}"
"## This file was autogenerated by FindPETSc.cmake
# PETSC_DIR = ${PETSC_DIR}
# PETSC_ARCH = ${PETSC_ARCH}
include ${petsc_conf_rules}
include ${petsc_conf_variables}
show :
-@echo -n \${\${VARIABLE}}
")
macro (PETSC_GET_VARIABLE name var)
set (${var} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE)
execute_process (COMMAND ${CMAKE_MAKE_PROGRAM} --no-print-directory -f ${petsc_config_makefile} show VARIABLE=${name}
OUTPUT_VARIABLE ${var}
RESULT_VARIABLE petsc_return)
endmacro (PETSC_GET_VARIABLE)
petsc_get_variable (PETSC_LIB_DIR petsc_lib_dir)
petsc_get_variable (PETSC_EXTERNAL_LIB_BASIC petsc_libs_external)
petsc_get_variable (PETSC_CCPPFLAGS petsc_cpp_line)
petsc_get_variable (PETSC_INCLUDE petsc_include)
petsc_get_variable (PCC petsc_cc)
petsc_get_variable (MPIEXEC petsc_mpiexec)
# We are done with the temporary Makefile, calling PETSC_GET_VARIABLE after this point is invalid!
file (REMOVE ${petsc_config_makefile})
include (cmake/ResolveCompilerPaths.cmake)
# Extract include paths and libraries from compile command line
resolve_includes (petsc_includes_all "${petsc_cpp_line}")
message (STATUS "petsc_lib_dir ${petsc_lib_dir}")
macro (PETSC_FIND_LIBRARY suffix name)
set (PETSC_LIBRARY_${suffix} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # Clear any stale value, if we got here, we need to find it again
find_library (PETSC_LIBRARY_${suffix} NAMES ${name} HINTS ${petsc_lib_dir} NO_DEFAULT_PATH)
set (PETSC_LIBRARIES_${suffix} "${PETSC_LIBRARY_${suffix}}")
mark_as_advanced (PETSC_LIBRARY_${suffix})
endmacro (PETSC_FIND_LIBRARY suffix name)
# Look for petscvec first, if it doesn't exist, we must be using single-library
petsc_find_library (VEC petscvec)
if (PETSC_LIBRARY_VEC)
petsc_find_library (SYS "petscsys;petsc") # libpetscsys is called libpetsc prior to 3.1 (when single-library was introduced)
petsc_find_library (MAT petscmat)
petsc_find_library (DM petscdm)
petsc_find_library (KSP petscksp)
petsc_find_library (SNES petscsnes)
petsc_find_library (TS petscts)
macro (PETSC_JOIN libs deps)
list (APPEND PETSC_LIBRARIES_${libs} ${PETSC_LIBRARIES_${deps}})
endmacro (PETSC_JOIN libs deps)
petsc_join (VEC SYS)
petsc_join (MAT VEC)
petsc_join (DM MAT)
petsc_join (KSP DM)
petsc_join (SNES KSP)
petsc_join (TS SNES)
petsc_join (ALL TS)
else ()
set (PETSC_LIBRARY_VEC "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # There is no libpetscvec
petsc_find_library (SINGLE petsc)
foreach (pkg SYS VEC MAT DM KSP SNES TS ALL)
set (PETSC_LIBRARIES_${pkg} "${PETSC_LIBRARY_SINGLE}")
endforeach ()
endif ()
if (PETSC_LIBRARY_TS)
message (STATUS "Recognized PETSc install with separate libraries for each package")
else ()
message (STATUS "Recognized PETSc install with single library for all packages")
endif ()
include (CheckCSourceRuns)
macro (PETSC_TEST_RUNS includes libraries runs)
multipass_c_source_runs ("${includes}" "${libraries}" "
static const char help[] = \"PETSc test program.\";
#include \"petscts.h\"
int main(int argc,char *argv[]) {
PetscErrorCode ierr;
TS ts;
ierr = PetscInitialize(&argc,&argv,0,help);CHKERRQ(ierr);
ierr = TSCreate(PETSC_COMM_WORLD,&ts);CHKERRQ(ierr);
ierr = TSSetFromOptions(ts);CHKERRQ(ierr);
ierr = TSDestroy(ts);CHKERRQ(ierr);
ierr = PetscFinalize();CHKERRQ(ierr);
return 0;
}
" ${runs})
if (${${runs}})
set (PETSC_EXECUTABLE_RUNS "YES" CACHE BOOL
"Can the system successfully run a PETSc executable? This variable can be manually set to \"YES\" to force CMake to accept a given PETSc configuration, but this will almost always result in a broken build. If you change PETSC_DIR, PETSC_ARCH, or PETSC_CURRENT you would have to reset this variable." FORCE)
endif (${${runs}})
endmacro (PETSC_TEST_RUNS)
find_path (PETSC_INCLUDE_DIR petscts.h HINTS "${PETSC_DIR}" PATH_SUFFIXES include NO_DEFAULT_PATH)
find_path (PETSC_INCLUDE_CONF petscconf.h HINTS "${PETSC_DIR}" PATH_SUFFIXES "${PETSC_ARCH}/include" "bmake/${PETSC_ARCH}" NO_DEFAULT_PATH)
mark_as_advanced (PETSC_INCLUDE_DIR PETSC_INCLUDE_CONF)
set (petsc_includes_minimal ${PETSC_INCLUDE_CONF} ${PETSC_INCLUDE_DIR})
petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_minimal)
if (petsc_works_minimal)
message (STATUS "Minimal PETSc includes and libraries work. This probably means we are building with shared libs.")
set (petsc_includes_needed "${petsc_includes_minimal}")
else (petsc_works_minimal) # Minimal includes fail, see if just adding full includes fixes it
petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_allincludes)
if (petsc_works_allincludes) # It does, we just need all the includes (
message (STATUS "PETSc requires extra include paths, but links correctly with only interface libraries. This is an unexpected configuration (but it seems to work fine).")
set (petsc_includes_needed ${petsc_includes_all})
else (petsc_works_allincludes) # We are going to need to link the external libs explicitly
resolve_libraries (petsc_libraries_external "${petsc_libs_external}")
foreach (pkg SYS VEC MAT DM KSP SNES TS ALL)
list (APPEND PETSC_LIBRARIES_${pkg} ${petsc_libraries_external})
endforeach (pkg)
petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_alllibraries)
if (petsc_works_alllibraries)
message (STATUS "PETSc only need minimal includes, but requires explicit linking to all dependencies. This is expected when PETSc is built with static libraries.")
set (petsc_includes_needed ${petsc_includes_minimal})
else (petsc_works_alllibraries)
# It looks like we really need everything, should have listened to Matt
set (petsc_includes_needed ${petsc_includes_all})
petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_all)
if (petsc_works_all) # We fail anyways
message (STATUS "PETSc requires extra include paths and explicit linking to all dependencies. This probably means you have static libraries and something unexpected in PETSc headers.")
else (petsc_works_all) # We fail anyways
message (STATUS "PETSc could not be used, maybe the install is broken.")
endif (petsc_works_all)
endif (petsc_works_alllibraries)
endif (petsc_works_allincludes)
endif (petsc_works_minimal)
# We do an out-of-source build so __FILE__ will be an absolute path, hence __INSDIR__ is superfluous
if (${PETSC_VERSION} VERSION_LESS 3.1)
set (PETSC_DEFINITIONS "-D__SDIR__=\"\"" CACHE STRING "PETSc definitions" FORCE)
else ()
set (PETSC_DEFINITIONS "-D__INSDIR__=" CACHE STRING "PETSc definitions" FORCE)
endif ()
# Sometimes this can be used to assist FindMPI.cmake
set (PETSC_MPIEXEC ${petsc_mpiexec} CACHE FILEPATH "Executable for running PETSc MPI programs" FORCE)
set (PETSC_INCLUDES ${petsc_includes_needed} CACHE STRING "PETSc include path" FORCE)
set (PETSC_LIBRARIES ${PETSC_LIBRARIES_ALL} CACHE STRING "PETSc libraries" FORCE)
set (PETSC_COMPILER ${petsc_cc} CACHE FILEPATH "PETSc compiler" FORCE)
# Note that we have forced values for all these choices. If you
# change these, you are telling the system to trust you that they
# work. It is likely that you will end up with a broken build.
mark_as_advanced (PETSC_INCLUDES PETSC_LIBRARIES PETSC_COMPILER PETSC_DEFINITIONS PETSC_MPIEXEC PETSC_EXECUTABLE_RUNS)
endif ()
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (PETSc
"PETSc could not be found. Be sure to set PETSC_DIR and PETSC_ARCH."
PETSC_INCLUDES PETSC_LIBRARIES PETSC_EXECUTABLE_RUNS)
# TODO: make extensions a subproject
# add_subdirectory(${SOURCE_DIR}/compositeFEM [binarydir])
if (ENABLE_EXTENSIONS) if (ENABLE_EXTENSIONS)
option(ENABLE_BASE_PROBLEMS "Use base_problems" true) option(ENABLE_BASE_PROBLEMS "Use base_problems" true)
find_path(EXTENSIONS_DIR NAMES Helpers.h find_path(EXTENSIONS_DIR NAMES Helpers.h
......
...@@ -108,7 +108,7 @@ if (ENABLE_PARALLEL_DOMAIN) ...@@ -108,7 +108,7 @@ if (ENABLE_PARALLEL_DOMAIN)
message(SEND_ERROR "Set the domain-decomposition version correctly.") message(SEND_ERROR "Set the domain-decomposition version correctly.")
endif() endif()
INSTALL(FILES ResolveCompilerPaths.cmake FindPackageMultipass.cmake FindPETSc.cmake INSTALL(FILES cmake/ResolveCompilerPaths.cmake cmake/FindPackageMultipass.cmake cmake/FindPETSc.cmake
DESTINATION share/amdis/) DESTINATION share/amdis/)
if(USE_PETSC_DEV) if(USE_PETSC_DEV)
list(APPEND COMPILEFLAGS "-DHAVE_PETSC_DEV") list(APPEND COMPILEFLAGS "-DHAVE_PETSC_DEV")
......
# 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 ()
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(AMDiS VERSION 0.9 LANGUAGES CXX)
set(BASE_DIR ${AMDiS_SOURCE_DIR})
set(SOURCE_DIR ${BASE_DIR}/src)
list(APPEND CMAKE_MODULE_PATH ${BASE_DIR}/cmake3)
option(BUILD_SHARED_LIBS "Build all libraries as shared or static, default: shared" true)
option(ENABLE_CXX11 "Enable C++11 compiler features" false)
option(ENABLE_PARALLEL_DOMAIN "Use parallel domain decomposition" false)
option(ENABLE_UMFPACK "Use of UMFPACK solver" false)
option(ENABLE_COMPRESSION "Use output compression" false)
add_library(amdis_base INTERFACE)
add_library(AMDiS::base ALIAS amdis_base)
target_include_directories(amdis_base INTERFACE ${SOURCE_DIR})
target_compile_definitions(amdis_base INTERFACE
$<$<CONFIG:Debug>:DEBUG=1>
$<$<CONFIG:Release>:DEBUG=0>)
if (ENABLE_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 (ENABLE_CXX11)
# ------------------------------------------------------------------------------
include(find_mtl4) # -> target mtl4
include(find_boost) # -> target boost
# ------------------------------------------------------------------------------
add_library(amdis
${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
)
if (ENABLE_COMPRESSION)
target_compile_definitions(amdis PRIVATE HAVE_COMPRESSION=1)
endif (ENABLE_COMPRESSION)
include(amdis_parallel) # -> target AMDiS::parallel