User Tools

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

Install CMake from the package system of your choice. 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 of your currently configured directory, run

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

Windows (Visual Studio)

  1. Install CMake
  2. Start CMake, select the source directory, and then select a new directory for the build.
  3. Press configure, select your options, configure again
  4. Press generate to produce project files for VS.

Note: The build types (debug, release) are handled internally by Visual Studio, so no configuration option for this is presented in CMake

To run the test suite, open the solution explorer in VS and “build” the test target to run through the test suite.

cmake.1352122512.txt.gz · Last modified: 2012/11/05 14:35 by mikael.ohman