Build

From wiki.openchemistry.org
Revision as of 12:49, 18 February 2013 by Marcus.hanwell (talk | contribs) (Wrote a summary of building open chemistry)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The Open Chemistry project uses git for version control, and CMake to direct the build process. The openchemistry repository contains git submodules with other actively developed projects such as Avogadro, MongoChem and MoleQueue. It will also automatically download source tarballs and build them for third party dependencies, with variables named USE_SYSTEM_LIBRARY to attempt to find and build against system versions.

This page goes through the steps of building the Open Chemistry projects using the openchemistry git repository. It is entirely possible to build each project individually without using the "superbuild" approach, but you will need to ensure all dependencies are built and can be found by the project. Once successfully built you will be left with several build directories which you can treat as normal build directories, developing and compiling from inside them largely ignoring the outer build tree. The Development page goes through the steps of developing and submitting patches for inclusion in the projects.

Cloning Repositories

You should clone the repositories from our source code hosting infrastructure, or the Github/Gitorious mirror. You should also track changes from here as the cloning/update process will be faster, and is always in sync with Gerrit. To clone the Open Chemistry repository that contains the other projects as submodules,

 git clone --recursive git://github.com/OpenChemistry/openchemistry.git

Updating

In order to update the repository from the openchemistry module you can run,

 git pull
 git submodule update --init

Building

It is recommended that you create a build tree outside of the source tree. Assuming you are in the directory where you cloned the repository the following commands will create a build tree, configure it and build.

 mkdir openchemistry-build
 cd openchemistry-build
 cmake ../openchemistry
 make -j5

You may wish to run cmake-gui in the build directory once it has been configured. You can build against system libraries to avoid building them (examples include Boost, Eigen, etc), and turn testing on globally (ENABLE_TESTS) if you would like to ensure all tests are configured and built for sub-projects.

Normal Development

You can also open the top-level CMakeLists.txt in Qt Creator, choose the build location, have that configure and build and then open the top-level CMakeLists.txt for each of the sub-projects. When setting the build location choose the openchemistry-build/avogadrolibs for Avogadro, openchemistry-build/molequeue for MoleQueue, etc. Once you have compiled the top-level, for normal day-to-day development you are free to ignore it and perform the majority of work in the project being developed.

Build Tree Layout

The build tree mirrors the source tree for most active projects. So avogadrolibs is in the same relative path in the source and build trees. For things such as Boost which are built from a source tarball they can be found only in the build tree, and are under thirdparty/boost-prefix, these projects are dependencies but are not expected to be edited in place.

There is a prefix directory in the base of the build tree. This acts as an install prefix for all projects, with the normal include, bin, share and lib directories. This can be used to inject an additional prefix in CMAKE_PREFIX_PATH to ensure projects build by the superbuild are found. It keeps the sub-projects relatively simple as they either find stuff in the prefix, or normal system paths.