# OOFEM wiki

### Site Tools

cmake

This is an old revision of the document!

# CMake tutorial

## Developers

To add new files to be compiled, you will need to edit one of the following files

oofem/src/oofemlib/CMakeLists.txt
oofem/src/sm/CMakeLists.txt
oofem/src/fm/CMakeLists.txt
oofem/src/tm/CMakeLists.txt

Add new files to new lines which makes it less likely to conflict when merging code in git.

set (oofemlib_element
element.C
structuralelement.C
nlstructuralelement.C
my_new_element.C
)

For more complex additions that require new configuration options, you will need to modify CMakeLists.txt in the root directory

oofem/CMakeLists.txt

If new tests files are added CMake will find them automatically, just re-run cmake from the build directory.

## Linux

1. Install CMake from the package system of your choice.
2. Create a out-of-tree build directory
mkdir -p ~/build/debug/
cd ~/build/debug/
cmake ~/oofem/
make
ctest

Instead of cmake can use ccmake which uses an ncurses interface, or cmake-gui for a GUI. Use the command make help for a list of all targets.

### CTest

Some useful options for ctest include running the tests in parallel;

ctest -j 4

and regex search for limiting the tests you wish to check (the following example runs cemhyd01.in and cemhyd02.in)

ctest -R cemhyd

and lastly a verbose option to see what went wrong

ctest -V

## CPack

CPack allows you to make source and binary releases. You will first need to configure using cmake (as detailed above). The following commands are executed from the build directory.

To generate a source package (which excludes .git/ and generated files) run

make source_package

To generate a DEB, RPM, ZIP binary packages, run

cpack -G DEB
cpack -G RPM
cpack -G ZIP
...