Skip to content
Snippets Groups Projects
Commit 6e5c2c76 authored by Naumann, Andreas's avatar Naumann, Andreas
Browse files

updated cmake-usage with amdis

parent ce3ea440
No related branches found
No related tags found
No related merge requests found
<html> <html>
<head> <head>
<title> Using AMDiS with cmake </title> <title> Using AMDiS with cmake </title>
<style type="text/css" >
.desc { background-color:#E0E0E0; margin-left:100px }
</style >
</head> </head>
<body> <body>
<h1> Using AMDiS with cmake </h1> <h1> Using AMDiS with cmake </h1>
...@@ -17,25 +20,25 @@ There are 3 different configure tools for CMake: ...@@ -17,25 +20,25 @@ There are 3 different configure tools for CMake:
<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://gforge.zih.tu-dresden.de/frs/download.php/34/getamdis_cmake.sh" >getamdis_cmake.sh</a>, which can be found on <ah ref="https://gforge.zih.tu-dresden.de" >gforge.zih.tu-dresden.de</a>, creates such a directory structure.</p> <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://gforge.zih.tu-dresden.de/frs/download.php/34/getamdis_cmake.sh" >getamdis_cmake.sh</a>, which can be found on <ah ref="https://gforge.zih.tu-dresden.de" >gforge.zih.tu-dresden.de</a>, creates such a directory structure.</p>
Assume, you have AMDiS downloaded in the directory Assume, you have AMDiS downloaded in the directory
<p align="center"> <p class="desc" >
/home/joe/work/ /home/joe/work/
</p> </p>
, the AMDiS source directory is , the AMDiS source directory is
<p align="center"> <p class="desc">
/home/joe/work/amdis/AMDiS /home/joe/work/amdis/AMDiS
</p> </p>
. To configure and compile AMDiS I recommend to create a directory . To configure and compile AMDiS I recommend to create a directory
<p align="center"> <p class="desc">
/home/joe/work/amdis_build /home/joe/work/amdis_build
</p> </p>
and run and run
<p align="center"> <p class="desc">
cd /home/joe/work/amdis_build<br> cd /home/joe/work/amdis_build<br>
cmake -DCMAKE_INSTALL_PREFIX=/home/joe/programs/ ../amdis/AMDiS cmake -DCMAKE_INSTALL_PREFIX=${HOME}/programs/ ../amdis/AMDiS
</p> </p>
Compilation and installation is the same as with automake/autoconf: Compilation and installation is the same as with automake/autoconf:
<p align="center"> <p class="desc">
make ; make install make ; make install
</p> </p>
The last command will install AMDiS to /home/joe/programs The last command will install AMDiS to /home/joe/programs
...@@ -45,5 +48,45 @@ The last command will install AMDiS to /home/joe/programs ...@@ -45,5 +48,45 @@ The last command will install AMDiS to /home/joe/programs
If you only want to build with standard options, you can simply run If you only want to build with standard options, you can simply run
<verbatim> cmake . </verbatim> <verbatim> cmake . </verbatim>
<h2> Using the cmake installed AMDiS in your project </h2> <h2> Using the cmake installed AMDiS in your project </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:
<p 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>
</p >
The first two lines
<p class="desc" >
project(projectName) <br>
cmake_minimum_required(VERSION 2.8)
</p >
tell cmake the name of your project and that you whish to use only cmake versions newer than 2.8.<br>
The line
<p class="desc" >
find_package(AMDiS REQUIRED)
</p >
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
<p class="desc" >
include(${AMDiS_USE_FILE})
</p >
we read an AMDiS specific configuration file, which sets some compilerflags and adds the include directorys. The program is added with
<p class="desc" >
add_executable(fooProg src/foo.cc)
</p >
and we have to tell cmake, that we need the library amdis and each library amdis depends on. This is done with the command
<p class="desc" >
target_link_libraries(fooProg ${AMDiS_LIBRARIES})
</p >
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
<p class="desc" >
$CMAKE_INSTALL_PREFIX/share/amdis/
</p >
</body> </body>
</html> </html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment