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><ahref="#compiling"> compiling and installing AMDiS with CMake </a></li>
<li><ahref="#using"> using the cmake installed AMDiS in your project </a></li>
<li><ahref="#faq"> some frequently asked questions </a></li>
</ol>
<h2><aname="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 <ahref="https://fusionforge.zih.tu-dresden.de/frs/download.php/34/getamdis_cmake.sh">getamdis_cmake.sh</a>, which can be found on <ahref="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
<preclass="desc">
${HOME}/work/ </pre>
, the AMDiS source directory is
<preclass="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
<preclass="desc">
mkdir ${HOME}/work/amdis_build </pre>
and do the remaining work from there.
<preclass="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
Compilation and installation is the same as with automake/autoconf:
<preclass="desc">
make && make install </pre>
The last command will install AMDiS to ${HOME}/programs
<h2><aname="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:
tell cmake the name of your project and that you whish to use only cmake versions newer than 2.8.<br>
The line
<preclass="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
<preclass="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
<preclass="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
<preclass="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
<preclass="desc">
${CMAKE_INSTALL_PREFIX}/share/amdis/
</pre>
where CMAKE_INSTALL_PREFIX is the directory you choose during installation of amdis.
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.
message(ERROR "Could not detect the AMDiS include directory. Please set the variable AMDIS_INCLUDE_DIR to the directory containing the AMDiS headers.")
#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")
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")