Commit 7aef2864 authored by Praetorius, Simon's avatar Praetorius, Simon

Merge branch 'issue/cmake_2-8-10' into 'master'

Issue/cmake 2 8 10

Rewritten the cmake configuration for cmake version 2.8.10 in the same style as cmake 3.0 variant

See merge request !11
parents 1efa4a14 7d4dfda1
## This file should be placed in the root directory of your project.
## Then modify the CMakeLists.txt file in the root directory of your
## project to incorporate the testing dashboard.
##
## # The following are required to submit to the CDash dashboard:
## ENABLE_TESTING()
## INCLUDE(CTest)
set(CTEST_PROJECT_NAME "AMDiS")
set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "my.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=AMDiS")
set(CTEST_DROP_SITE_CDASH TRUE)
# set(CTEST_USE_LAUNCHERS 1)
\ No newline at end of file
<html>
<head>
<title> Using AMDiS with cmake </title>
<style type="text/css" >
.desc { background-color:#E0E0E0; margin-left:100px }
</style >
</head>
<body>
<h1> Using AMDiS with cmake </h1>
With this short page, I will show you, how to use the cmake buildsystem with AMDiS. The introduction consists of two main parts:
<ol>
<li> <a href="#compiling" > compiling and installing AMDiS with CMake </a ></li>
<li> <a href="#using" > using the cmake installed AMDiS in your project </a ></li>
<li> <a href="#faq" > some frequently asked questions </a ></li>
</ol>
<h2> <a name="compiling" > Compiling and installing AMDiS with CMake </a > </h2>
<h3> configure </h3>
There are 3 different configure tools for CMake:
<ul> <li> cmake (non interactive) </li>
<li> ccmake (interactive on command line) </li>
<li> cmake-gui (qt-based gui) </li></ul>
<p>I will use the cmake and ccmake. The autoconf/automake implementation was used directly inside the AMDiS source directory (i.e. the directory you get through svn). To use the CMake buildsystem, I recommend a different directory structure for building and compiling AMDiS. The script <a href="https://fusionforge.zih.tu-dresden.de/frs/download.php/34/getamdis_cmake.sh" >getamdis_cmake.sh</a>, which can be found on <a href="https://fusionforge.zih.tu-dresden.de" >https://fusionforge.zih.tu-dresden.de</a>, creates such a directory structure.</p>
Assume, you have AMDiS downloaded in the directory
<pre class="desc" >
${HOME}/work/ </pre>
, the AMDiS source directory is
<pre class="desc">
${HOME}/work/amdis/AMDiS </pre>
. To configure and compile AMDiS I recommend using out of source builds. This means, you should create a directory amdis_build
<pre class="desc">
mkdir ${HOME}/work/amdis_build </pre>
and do the remaining work from there.
<pre class="desc">
cd ${HOME}/work/amdis_build </pre>
The simplest configuration of AMDiS, i.e. without umfpack and parallelization, only sets the install destination to the directory "${HOME}/programs/". To do this, you have to call cmake with your install destination and the AMDiS source directory as commandline arguments
<pre class="desc" >
cmake -DCMAKE_INSTALL_PREFIX=${HOME}/programs/ ../amdis/AMDiS</pre>
Compilation and installation is the same as with automake/autoconf:
<pre class="desc">
make && make install </pre >
The last command will install AMDiS to ${HOME}/programs
<h2> <a name="using" > Using the cmake installed AMDiS in your project </a > </h2>
A cmake-project consists of the source files and a file CMakeLists.txt, which contains a description of needed libraries, headers and programs. If you have a simple project with one program "fooProg", which have to compile only one source file "src/foo.cc", your CMakeLists.txt consist of the following lines:
<pre class="desc" >
project(projectName) <br>
cmake_minimum_required(VERSION 2.8)<br><br>
find_package(AMDIS REQUIRED)<br>
if(AMDIS_FOUND)<br>
include(${AMDIS_USE_FILE})<br>
add_executable(fooProg src/foo.cc)<br>
target_link_libraries(fooProg ${AMDIS_LIBRARIES})<br>
endif(AMDIS_FOUND)<br>
</pre >
The first two lines
<pre class="desc" >
project(projectName) <br>
cmake_minimum_required(VERSION 2.8)
</pre >
tell cmake the name of your project and that you whish to use only cmake versions newer than 2.8.<br>
The line
<pre class="desc" >
find_package(AMDIS REQUIRED)
</pre >
tells cmake, that you want to use AMDiS and it should complain if AMDiS was not found. CMake will print an error message, bu will not stop the execution! With the command
<pre class="desc" >
include(${AMDIS_USE_FILE})
</pre >
we read an AMDiS specific configuration file, which sets some compilerflags and adds the include directorys. The program is added with
<pre class="desc" >
add_executable(fooProg src/foo.cc)
</pre >
and we have to tell cmake, that we need the library amdis and each library amdis depends on. This is done with the command
<pre class="desc" >
target_link_libraries(fooProg ${AMDIS_LIBRARIES})
</pre >
If cmake does not find AMDiS, you have to set the variable AMDIS_DIR to the directory containing the file AMDiSConfig.cmake. This file resides in
<pre class="desc" >
${CMAKE_INSTALL_PREFIX}/share/amdis/
</pre >
where CMAKE_INSTALL_PREFIX is the directory you choose during installation of amdis.
<h2 > <a name="faq" > Frequently asked questions </a ></h2 >
<h3 > Boost </h3>
If you have different boost versions on your system and you do not want to use the standard version in /usr/lib and /usr/include, you should set the environment variable BOOST_ROOT to your boost-installation.
<h3 > I will not set the AMDIS_DIR in every project. </h3 >
If you always use the same AMDiS directory, you can add the directory to your PATH variable.
</body>
</html>
#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:
# AMDIS_INCLUDE_DIR the amdis-directory only
# AMDIS_INCLUDE_DIRS all include directories (mtl, umfpack, parmetis, metis, ...)
# AMDIS_LIBRARIES the needed libraries
# AMDIS_LIBRARY_DIRS the link directories
# AMDiS_COMPILEFLAGS some compile flags for amdis
# This configuration file is shipped with the FEM-Toolbox AMDiS.
# It simplifies the configure of different amdis-versions.
#
# We set the following variables:
# AMDIS_INCLUDE_DIRS all include directories (mtl, umfpack, parmetis, metis, ...)
# AMDIS_LIBRARIES the needed libraries
# 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 )
# include(${AMDIS_USE_FILE})
# add_executable(yourTarget <yourSources>)
# target_link_libraries(yourTarget ${AMDIS_LIBRARIES})
# Use this package in the following way:
#
# find_package(AMDiS REQUIRED [PARALLEL|SEQUENTIAL])
# add_executable(yourTarget <yourSources>)
# include_directories(${AMDIS_INCLUDE_DIRS})
# compile_definitions(${AMDIS_COMPILEFLAGS})
# target_link_libraries(yourTarget ${AMDIS_LIBRARIES})
#
#The AMDIS_USE_FILE adds the include and link-directories for amdis to cmake.
# The default component for this package is SEQUENTIAL.
#
#If you use the parallel amdis-version, the AMDIS_USE_FILE also trys to detect
#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
#and omit the AMDIS_USE_FILE. Then you also have to set the flags, include
#and library directories.
################## ONLY WORKAROUND AND WARNING ###################
#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()
##################################################################
# try to detect the AMDiS include directory
# -------------------------------------------
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)
set(AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR})
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)
# set(MTL_DIR @MTL_INCLUDE_DIR@ CACHE PATH "the mtl directory")
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/mtl4)
# AMDiS base libraries
# --------------------
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)
set(AMDIS_LIBRARY_DIRS ${AMDIS_LIBRARY_DIR})
set(AMDIS_LIBRARIES "${_AMDIS_LIB}" CACHE STRING "amdis libraries")
else()
message(ERROR "could not detect the AMDiS library directory. Please set the variable AMDIS_LIBRARY_DIR to the directory containg the AMDiS library")
endif()
unset(_AMDIS_LIB CACHE)
if (${CMAKE_VERSION} VERSION_LESS "2.8.10")
message(FATAL_ERROR "The Configuration file was created for CMake version >= 2.8.10")
endif ()
list(APPEND CMAKE_MODULE_PATH ${AMDIS_DIR})
# Boost libraries
# ---------------
set(AMDIS_HAS_PARALLEL_DOMAIN @ENABLE_PARALLEL_DOMAIN@)
set(AMDIS_NEED_COMPRESSION @ENABLE_COMPRESSION@)
set(IS_AMDISCONFIG true)
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.42")
if(AMDIS_HAS_PARALLEL_DOMAIN)
set(BOOST_VERSION "1.48")
endif(AMDIS_HAS_PARALLEL_DOMAIN)
if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost ${BOOST_VERSION} REQUIRED ${BOOST_LIBS_REQUIRED})
else()
set(Boost_USE_STATIC_LIBS OFF)
find_package(Boost ${BOOST_VERSION} REQUIRED ${BOOST_LIBS_REQUIRED})
endif()
if(Boost_FOUND)
list(APPEND AMDIS_LIBRARIES ${Boost_LIBRARIES})
list(APPEND AMDIS_LIBRARY_DIRS ${Boost_LIBRARY_DIRS})
list(APPEND AMDIS_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
else()
message(ERROR "Boost libraries not found")
endif(Boost_FOUND)
# more libraries and include-directories added by default
# -------------------------------------------------------
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/reinit)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/compositeFEM)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/muparser)
# ------------------------------------------------------------------
set(AMDIS_NEED_ZOLTAN @ENABLE_ZOLTAN@)
set(AMDIS_OPENMP @ENABLE_OPENMP@)
set(AMDIS_USE_FILE ${AMDIS_DIR}/AMDISUse.cmake)
set(AMDIS_NEED_CXX11 @ENABLE_CXX11@)
set(AMDIS_NEED_UMFPACK @ENABLE_UMFPACK@)
set(AMDIS_NEED_HYPRE @ENABLE_HYPRE@)
set(AMDIS_NEED_SEQ_PETSC @ENABLE_SEQ_PETSC@)
set(AMDIS_NEED_PNG @ENABLE_PNG@)
set(AMDIS_NEED_BDDCML @ENABLE_BDDCML@)
set(AMDIS_NEED_MKL @ENABLE_MKL@)
set(AMDIS_NEED_COMPRESSION @ENABLE_COMPRESSION@)
set(AMDIS_NEED_EXTENSIONS @ENABLE_EXTENSIONS@)
set(AMDIS_NEED_BASE_PROBLEMS @ENABLE_BASE_PROBLEMS@)
set(AMDIS_USE_FILE ${AMDIS_DIR}/AMDISUse.cmake)
set(AMDIS_COMPILEFLAGS "@COMPILEFLAGS@")
set(AMDIS_VERSION @CurrentRevision@)
set(AMDIS_MAJOR_VERSION @AMDIS_MAJOR@)
set(AMDIS_MINOR_VERSION @AMDIS_MINOR@)
set(AMDIS_SUB_MINOR_VERSION @AMDIS_SUB_MINOR@)
set(AMDIS_NEED_REINIT @ENABLE_REINIT@)
set(AMDIS_NEED_COMPOSITE_FEM @ENABLE_COMPOSITE_FEM@)
set(AMDIS_NEED_ZOLTAN @ENABLE_ZOLTAN@)
set(AMDIS_NEED_BDDCML @ENABLE_BDDCML@)
set(AMDIS_NEED_HYPRE @ENABLE_HYPRE@)
set(AMDIS_NEED_PNG @ENABLE_PNG@)
set(AMDIS_NEED_SEQ_PETSC @ENABLE_SEQ_PETSC@)
set(BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
set(CMAKE_BUILD_TYPE @CMAKE_BUILD_TYPE@)
set(AMDIS_COMPILEFLAGS "")
set(AMDIS_INCLUDE_DIRS "")
set(AMDIS_LIBRARIES "")
# Include macros
# ----------------
include(enable_cxx11)
include(enable_mtl4)
include(enable_boost)
include(enable_umfpack)
include(enable_petsc)
include(enable_zoltan)
include(enable_bddcml)
include(enable_hypre)
include(enable_png)
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release")
endif()
if (AMDIS_NEED_CXX11)
enable_cxx11(AMDIS_NEED_CXX11 AMDIS_COMPILEFLAGS)
if (NOT AMDIS_NEED_CXX11)
message(FATAL_ERROR "AMDiS was compiled with c++11 support, but the current compiler does not support this feature!")
endif (NOT AMDIS_NEED_CXX11)
list(APPEND AMDIS_COMPILEFLAGS "-DHAS_CXX11=1")
if (${CMAKE_VERSION} VERSION_GREATER "3.0")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
else()
if (CMAKE_COMPILER_IS_GNUCXX)
set(GXX_MIN_VER "4.8")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS GXX_MIN_VER)
message (FATAL_ERROR "For C++11-Features the G++ Compiler must be at least version $GXX_MIN_VER")
endif ()
list(APPEND AMDIS_COMPILEFLAGS "-std=gnu++11")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CLANG_MIN_VER "3.0")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_MIN_VER)
message (FATAL_ERROR "For C++11-Features the Clang Compiler must be at least version $CLANG_MIN_VER")
endif ()
list(APPEND AMDIS_COMPILEFLAGS "-std=c++11")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(INTEL_MIN_VER "12.1")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS INTEL_MIN_VER)
message (FATAL_ERROR "For C++11-Features the Intel C++ Compiler must be at least version $INTEL_MIN_VER")
endif ()
list(APPEND AMDIS_COMPILEFLAGS "-std=c++11")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(MSVC_MIN_VER "12.0")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS MSVC_MIN_VER)
message (FATAL_ERROR "For C++11-Features the MSVC C++ Compiler must be at least version $MSVC_MIN_VER")
endif ()
endif ()
endif()
else ()
list(APPEND AMDIS_COMPILEFLAGS "-DHAS_CXX11=0")
endif (AMDIS_NEED_CXX11)
#load mpi-compiler for use with parmetis and parallel_domain
if(AMDIS_HAS_PARALLEL_DOMAIN)
find_package(MPI REQUIRED)
list(APPEND AMDIS_LIBRARIES ${MPI_LIBRARIES})
list(APPEND AMDIS_COMPILEFLAGS ${MPI_COMPILE_FLAGS})
list(APPEND AMDIS_INCLUDE_DIRS ${MPI_INCLUDE_PATH})
find_library(PARMETIS_LIB parmetis)
if(PARMETIS_LIB)
list(APPEND AMDIS_LIBRARIES ${PARMETIS_LIB})
else(PARMETIS_LIB)
message(FATAL_ERROR "could not find the parmetis libraries needed by amdis")
endif(PARMETIS_LIB)
find_library(METIS_LIB metis)
if(METIS_LIB)
list(APPEND AMDIS_LIBRARIES ${METIS_LIB})
else(METIS_LIB)
message(FATAL_ERROR "could not find the metis libraries needed by amdis")
endif(METIS_LIB)
if(AMDIS_HAS_PARALLEL_DOMAIN STREQUAL "PETSC")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${AMDIS_DIR})
set(PETSC_EXECUTABLE_RUNS ON)
find_package(PETSc REQUIRED)
if(PETSC_FOUND)
list(APPEND AMDIS_LIBRARIES ${PETSC_LIBRARY_SYS} ${PETSC_LIBRARIES})
list(APPEND AMDIS_INCLUDE_DIRS ${PETSC_INCLUDES})
else()
message(FATAL_ERROR "Could not find PETSc!")
endif(PETSC_FOUND)
elseif(AMDIS_HAS_PARALLEL_DOMAIN STREQUAL "PMTL")
find_package(MTL REQUIRED)
list(APPEND AMDIS_LIBRARIES ${MTL_LIBRARIES})
endif()
elseif(AMDIS_NEED_SEQ_PETSC)
find_package(MPI REQUIRED)
if(MPI_FOUND)
list(APPEND AMDIS_LIBRARIES ${MPI_LIBRARIES})
list(APPEND AMDIS_COMPILEFLAGS ${MPI_COMPILE_FLAGS})
list(APPEND AMDIS_INCLUDE_DIRS ${MPI_INCLUDE_PATH})
endif(MPI_FOUND)
set(CMAKE_MODULE_PATH ${AMDIS_DIR})
set(PETSC_EXECUTABLE_RUNS ON)
find_package(PETSc REQUIRED)
if(PETSC_FOUND)
list(APPEND AMDIS_LIBRARIES ${PETSC_LIBRARY_SYS} ${PETSC_LIBRARIES})
list(APPEND AMDIS_INCLUDE_DIRS ${PETSC_INCLUDES})
else()
message(FATAL_ERROR "Could not find PETSc!")
endif(PETSC_FOUND)
endif()
if(AMDIS_NEED_HYPRE)
find_package(HYPRE REQUIRED HINTS ${AMDIS_DIR})
if(HAVE_HYPRE)
if(NOT MPI_FOUND)
find_package(MPI REQUIRED)
if(MPI_FOUND)
list(APPEND AMDIS_LIBRARIES ${MPI_LIBRARIES})
list(APPEND AMDIS_COMPILEFLAGS ${MPI_COMPILE_FLAGS})
list(APPEND AMDIS_INCLUDE_DIRS ${MPI_INCLUDE_PATH})
endif()
endif()
list(APPEND AMDIS_INCLUDE_DIRS ${HYPRE_INCLUDE_DIRECTORIES})
list(APPEND AMDIS_COMPILEFLAGS "-DMTL_HAS_HYPRE")
list(APPEND AMDIS_LIBRARIES ${HYPRE_LIBRARIES} )
endif()
endif(AMDIS_NEED_HYPRE)
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)
# AMDiS-Extensions library
# ------------------------
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)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/extensions/pugixml)
find_library(_EXTENSIONS_LIB extensions PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/amdis/)
if(_EXTENSIONS_LIB)
# 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)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR})
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)
# MTL4 libraries
# --------------------
enable_mtl4(AMDIS_COMPILEFLAGS AMDIS_INCLUDE_DIRS AMDIS_LIBRARIES ON)
if (AMDIS_FIND_REQUIRED_PARALLEL AND AMDIS_FIND_REQUIRED_SEQUENTIAL)
message(WARNING "Choose either SEQUENTIAL or PARALLEL as component, not both! Falling back to the default SEQUENTIAL.")
set(AMDIS_FIND_REQUIRED_PARALLEL OFF)
endif ()
# enable component PARALLEL
# -------------------------
if (AMDIS_FIND_REQUIRED_PARALLEL)
set(AMDIS_HAS_PARALLEL_DOMAIN ON)
set(POSTFIX "-parallel")
else ()
set(AMDIS_HAS_PARALLEL_DOMAIN OFF)
set(POSTFIX "")
endif (AMDIS_FIND_REQUIRED_PARALLEL)
# AMDiS base libraries
# --------------------
find_library(_AMDIS_LIB amdis${POSTFIX} PATHS ${AMDIS_DIR}/../../lib/amdis/)
if (_AMDIS_LIB)
list(APPEND AMDIS_LIBRARIES ${_AMDIS_LIB})
else ()
message(ERROR "Could not detect the AMDiS${POSTFIX} library. Please set the variable _AMDIS_LIB to the AMDiS${POSTFIX} library.")
endif ()
unset(_AMDIS_LIB CACHE)
# Boost libraries
# ---------------
if (NOT BOOST_ROOT)
set(BOOST_ROOT @BOOST_ROOT@)
endif (NOT BOOST_ROOT)
if (NOT BOOST_LIBRARYDIR)
set(BOOST_LIBRARYDIR @BOOST_LIBRARYDIR@)
endif (NOT BOOST_LIBRARYDIR)
enable_boost(AMDIS_COMPILEFLAGS AMDIS_INCLUDE_DIRS AMDIS_LIBRARIES ON)
# umfpack library
# --------------------
if (AMDIS_NEED_UMFPACK)
set(AMDIS_SuiteSparse_DIR @SuiteSparse_DIR@)
set(AMDIS_UMFPACK_INCLUDE_DIR @UMFPACK_INCLUDE_DIRS@)
set(AMDIS_UMFPACK_LIB_DIR ${AMDIS_UMFPACK_INCLUDE_DIR}/../include)
enable_umfpack(AMDIS_COMPILEFLAGS AMDIS_INCLUDE_DIRS AMDIS_LIBRARIES ON)
endif (AMDIS_NEED_UMFPACK)
# amdis extensions
# ----------------
if (AMDIS_NEED_EXTENSIONS)
find_library(_EXTENSIONS_LIB amdis${POSTFIX}_extensions PATHS ${AMDIS_DIR}/../../lib/amdis/)
if (_EXTENSIONS_LIB)
list(APPEND AMDIS_INCLUDE_DIRS
${AMDIS_INCLUDE_DIR}/extensions
${AMDIS_INCLUDE_DIR}/extensions/nanoflann
${AMDIS_INCLUDE_DIR}/extensions/pugixml
${AMDIS_INCLUDE_DIR}/extensions/time)
list(APPEND AMDIS_COMPILEFLAGS "-DHAVE_EXTENSIONS=1")
list(APPEND AMDIS_LIBRARIES ${_EXTENSIONS_LIB})
endif()
if (AMDIS_NEED_BASE_PROBLEMS)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/extensions/base_problems)
endif (AMDIS_NEED_BASE_PROBLEMS)
else ()
message(FATAL_ERROR "Extensions library not found")
endif ()
unset(_EXTENSIONS_LIB CACHE)
endif(AMDIS_NEED_EXTENSIONS)
# AMDiS BaseProblems libraries
# ----------------------------
if(AMDIS_NEED_BASE_PROBLEMS)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/base_problems)
find_library(_BASE_PROBLEMS_LIB base_problems PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/amdis/)
if(_BASE_PROBLEMS_LIB)
list(APPEND AMDIS_LIBRARIES ${_BASE_PROBLEMS_LIB})
endif()
unset(_BASE_PROBLEMS_LIB CACHE)
endif(AMDIS_NEED_BASE_PROBLEMS)
# ----------------------------
find_library(_REINIT_LIB reinit PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/amdis/)
find_library(_COMPOSITE_FEM_LIB compositeFEM PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/amdis/)
find_library(_MUPARSER_LIB muparser PATHS ${AMDIS_LIBRARY_DIR} ${AMDIS_DIR}/../../lib/amdis/)
if(_REINIT_LIB)
list(APPEND AMDIS_LIBRARIES ${_REINIT_LIB})
else()
message(ERROR "Reinit library not found")
endif()
unset(_REINIT_LIB CACHE)
if(_COMPOSITE_FEM_LIB)
list(APPEND AMDIS_LIBRARIES ${_COMPOSITE_FEM_LIB})
else()
message(ERROR "CompositeFEM library not found")
endif()
unset(_COMPOSITE_FEM_LIB CACHE)
if(_MUPARSER_LIB)
endif (AMDIS_NEED_EXTENSIONS)
# reinit library
# --------------
if (AMDIS_NEED_REINIT)
find_library(_REINIT_LIB amdis${POSTFIX}_reinit PATHS ${AMDIS_DIR}/../../lib/amdis/)
if (_REINIT_LIB)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/reinit)
list(APPEND AMDIS_LIBRARIES ${_REINIT_LIB})
else ()
message(FATAL_ERROR "Reinit library not found")
endif ()
unset(_REINIT_LIB CACHE)
endif (AMDIS_NEED_REINIT)
# compositeFEM library
# --------------------
if (AMDIS_NEED_COMPOSITE_FEM)
find_library(_COMPOSITE_FEM_LIB amdis${POSTFIX}_compositeFEM PATHS ${AMDIS_DIR}/../../lib/amdis/)
if (_COMPOSITE_FEM_LIB)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/compositeFEM)
list(APPEND AMDIS_LIBRARIES ${_COMPOSITE_FEM_LIB})
else ()
message(FATAL_ERROR "CompositeFEM library not found")
endif ()
unset(_COMPOSITE_FEM_LIB CACHE)
endif (AMDIS_NEED_COMPOSITE_FEM)
# muparser library
# --------------------
find_library(_MUPARSER_LIB muparser PATHS ${AMDIS_DIR}/../../lib/amdis/)
if (_MUPARSER_LIB)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_INCLUDE_DIR}/muparser)
list(APPEND AMDIS_LIBRARIES ${_MUPARSER_LIB})
else()
else ()
message(ERROR "MuParser library not found")
endif()
endif ()
unset(_MUPARSER_LIB CACHE)
# ----------------------------
if(AMDIS_NEED_UMFPACK)
if (WIN32)
set(SuiteSparse_USE_LAPACK_BLAS ON)
endif (WIN32)
find_package(SuiteSparse QUIET)
if (SuiteSparse_FOUND)
include(${USE_SuiteSparse})
list(APPEND AMDIS_LIBRARIES ${SuiteSparse_LIBRARIES})
list(APPEND AMDIS_INCLUDE_DIRS ${SuiteSparse_INCLUDE_DIR} ${SuiteSparse_METIS_INCLUDE_DIR})
message("AMDIS_INCLUDE_DIRS = ${AMDIS_INCLUDE_DIRS}")
else (SuiteSparse_FOUND)
set(AMDIS_UMFPACK_PATH @UMFPACK_PATH@)
list(APPEND AMDIS_INCLUDE_DIRS ${AMDIS_UMFPACK_PATH})
find_library(UMFPACK_LIB umfpack
HINTS ENV LIBRARY_PATH
DOC "The UMFPACK library")
if(UMFPACK_LIB)
list(APPEND AMDIS_LIBRARIES ${UMFPACK_LIB})
else()
message(FATAL_ERROR "Could not find the UMFPACK library")
endif()
if("$ENV{BLA_VENDOR}" STREQUAL "ACML")
find_library(ACML_LIBRARY acml HINTS ENV ACML_LIB)
if(ACML_LIBRARY)
list(APPEND AMDIS_LIBRARIES ${ACML_LIBRARY}) #fortran ffio m rt) #needed for open64
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"
HINTS ENV MKL_LIB
DOC "The BLAS library")
if(BLAS_LIBRARY)
list(APPEND AMDIS_LIBRARIES ${BLAS_LIBRARY})
list(APPEND AMDIS_LIBRARY_DIRS ${BLAS_LIBRARY_DIR})
else()
find_package(BLAS)
if(BLAS_FOUND)
list(APPEND AMDIS_LIBRARIES ${BLAS_LIBRARIES})
else()
message(STATUS "Could not find the BLAS library. Please set the variable BLAS_LIBRARY to the blas library with full path")
endif()
endif()
endif("$ENV{BLA_VENDOR}" STREQUAL "ACML")
find_library(AMD_LIB amd
HINTS ENV LIBRARY_PATH
DOC "The AMD library")
if(AMD_LIB)
list(APPEND AMDIS_LIBRARIES ${AMD_LIB})
else()
message(FATAL_ERROR "Could not find the AMD library.")
endif()
#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})")
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.} ;