My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
CmakeInstructions  
CMake build instructions
Phase-Deploy, Featured
Updated Apr 18, 2012 by gervandi...@gmail.com

Introduction


The best way to use CMake is doing an out-of-source build by creating a directory like build/opt at the same level as the casacore directory. CMake mirrors the source directory structure in this build directory. In this way the source directory does not get polluted with object files, etc.
After the tests are built, they can be run using CTest and the results can be placed on a Dashboard.
Note that use of directories like build/opt and build/dbg is strongly recommended, because they automatically define the build type (see description of CMAKE_BUILD_TYPE below).

In the remainder of this page it is assumed that one is more or less familiar with the CMake system, although some background information is given.
cmake --help can be used to get help info.

The BuildInstructions page contains general info about how to obtain casacore and which external packages are required to build casacore.

Details

CMake is basically a configure step. A subsequent make command uses the Makefiles created by CMake.
Using the -DMODULE option it is possible to configure for a specific module, so Makefiles for only that module and the modules it depends on are generated. Furthermore it will not look for external packages the modules to build do not depend on.

Note that if a configure of the full package is done, it is still possible to build specific source files or modules by going to the correct directory in the build tree and run make in there.

The modules that can be given are:

module other modules built with it external dependencies
casa readline, dlopen, HDF5 (all optional)
tables casa Bison/flex (required)
measures tables scimath lattices meas lapack/blas (required), FFTW3 (optional)
ms measures fits msfits derivedmscal cfitsio (required)
images measures fits coordinates components mirlib cfitsio, wcslib (all required)

Build options

The options to CMake are given using -D options. The following can be given:

option default description
-DBUILD_TESTING ON ON or OFF telling if the Makefiles get commands to build test programs. If ON, test programs will be built but not executed by the make command. If OFF, the Makefiles do not contain rules to build test programs.
-DCMAKE_BUILD_TYPE Debug or Release Defines the build type. If not given Debug (-g) is used if the build directory is named dbg or debug. Otherwise Release (-O3) is used.
-DCMAKE_CXX_FLAGS -W -Wall The C++ compiler flags.
-DCMAKE_INSTALL_PREFIX /usr/local The install prefix.
-DMODULE all Defines the module (and its dependencies) to be built. Options are casa, tables, measures, ms, images, and all.
-DUSE_HDF5 OFF Defines if HDF5 needs to be found. If OFF, casacore is built without HDF5 support. Any version from HDF5-1.8.3 on can be used.
-DUSE_FFTW3 OFF Defines if FFTW3 needs to be used and found. If OFF, casacore uses FFTPack instead of FFTW3 to do Fast Fourier Transforms.
-DUSE_THREADS OFF Defines if thread-safety has to be compiled in. If ON, use of static variables in casacore is thread-safe (so far only in modules casa, tables, scimath, and measures).
-DUSE_OPENMP OFF Defines if OpenMP pragmas should be handled by the compiler. Casacore code contains a few such pragmas. In the future more casacore code will be parallelized using OpenMP.
-DBLAS_ROOT_DIR /usr/local The path where to find blas.
-DLAPACK_ROOT_DIR /usr/local The path where to find lapack.
-DCFITSIO_ROOT_DIR /usr/local The path where to find cfitsio.
-DCFITSIO_INCLUDE_DIR /usr/local/include The path where to find cfitsio header files
-DCFITSIO_LIBRARY /usr/local/lib/libcfitsio.so The name of the cfitsio library (can be used to link against static libs)
-DWCSLIB_ROOT_DIR /usr/local The path where to find wcslib.
-DHDF5_ROOT_DIR /usr/local The path where to find HDF5.
-DFFTW3_ROOT_DIR /usr/local The path where to find FFTW3. If not found, casacore uses FFTPack instead of FFTW3 to do Fast Fourier Transforms.
-DFFTW3_DISABLE_THREADS ON Defines if FFTW3 should use threads
-DDATA_DIR The location of the measures data directory to compile in as the default search location. It should be the directory containing the geodetic and ephemerides directories to use. The value can contain an environment variable that is expanded at runtime (e.g. -DDATA_DIR='$ENVVAR/measures/data'). Note it is also possible to define measure tables locations in a $HOME/.casarc file. One can use the program findmeastable to show where casacore finds them.

It will be tested if readline and dlopen are available. If not, casacore is built without support for either of them.

Generating preprocessor output or assembler code

Sometimes it is useful to look at the output of the preprocessor or the assembler code generated by the compiler. This output can be generated for a particular source file like:

cd tables
make Tables/Table.i                    # preprocess Table.cc
less CMakeFiles/casa_tables.dir/Tables/Table.cc.i

Similarly, target .s can be used to create files containing assembler code.

Executing and checking tests

Test programs can be executed using the make test or the ctest command. If done in the build directory, all tests will be executed. By doing it in, say, tables/Tables/test, only the test programs in there will be executed. Using ctest's -R or -E options, specific tests can be selected or excluded.
A casacore test not only tests if a test program succeeds, it can also check if its output matches the expected output.
ctest will report about any failing test.

It is possible to run the tests through a tool like valgrind. It can be done by defining the environment variable CASACORE_CHECK. If defined and not blank, 0, no, or NO, its value will be used as a prefix to the command to execute.
A special value is 1, yes, or YES meaning that the script casacore_memcheck is used to execute valgrind's memcheck tool to check for errors, memory leaks and, open file descriptors. If problems are found, a summary is printed and the detailed valgrind output is written to the file <pgm>.checktool.valgrind. Thus the presence of such a file indicates that valgrind found some errors for test program pgm.
If a test uses a .run file, the .checktool.valgrind file can contain errors of multiple invocations of the test program.

Examples

Install to custom location making use of multi-core processor builds

mkdir build; cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/casacore
make -j4 && make install

Statically link against wcslib

cmake -DWCSLIB_LIBRARY=/usr/local/lib/libwcs.a ..
Comment by barlen...@gmail.com, Jan 21, 2011

-DCFITSIO_INCLUDE_DIR (=/usr/include/cfitsio, for example) is also useful.

It should be emphasized that -DDATA_DIR should include /data, i.e. use /usr/lib64/casapy/data, not /usr/lib64/casapy.


Sign in to add a comment
Powered by Google Project Hosting