Table Of Contents

Previous topic

8.2. Compilation errors

Next topic

8.4. Inputs/Outputs (I/O) in C++

Download

8.3. CMT: a tool for the configuration management

8.3.1. Introduction

The software configuration (this is a rather crude definition) is the activity in charge of description and control of all that constitutes a software project. This includes such various informations as:

  • the name of the author of the software,
  • project managers,
  • the structural decomposition of the project in independent or correlated parts (“packages”)
  • resources needed to build or use of the software,
  • description of components (libraries, applications, etc. ...),
  • actions to build the software (compilation, link editing, etc. ...).

For example, simply building an application, even simple, but made with some source modules, and using some libraries (eg graphics) quickly becomes tedious if one only manually chain the commands for compiling and editing links , especially memorizing options compilations that quickly become very complex.

The first tool available is the tool make. This tool can fully describe the components of an application in terms of source files, libraries, compiled modules to be assembled, etc. It can detect among all possible actions for the reconstruction of a software product, needed after partial modification of the source files.

However, the tool will become very complex to handle. Indeed, we must describe in a text file called traditionally Makefile all rules of dependency between the modules, then all actions to be taken to make each item. Detailed knowledge of all options to compile, link etc. .. is necessary, and make has no way to know the structure of the development (where are the sources, the compilation, packages produced by other persons of the same project) or to manage information specific to a given platform.

A number of tools (mostly commercial) exist in some environments to meet a little better on these issues. One can cite MS Visual in Windows environments, and in the Unix world, many commercial products provide similar services.

We will consider a tool (not commercial) called CMT used in our physical environment, which automates the setup process significantly. One can also read the complete documentation of this tool.

8.3.2. The CMT tool

Among the services provided by this tool, we will mainly consider here:

  • steering CMT
  • description of the source files of an application to automatically generate the necessary files needed by make .
  • the ability to modify the compilation options or linking.
  • the ability to build reusable libraries.
  • the declaration of the use of external (external packages)

8.3.2.1. How to control CMT

Each work location (ie where we will produce an application for example) is called a package in CMT terminology. Each package will be described by a text file named requirements installed in its directory cmt . CMT will find in this file all informations needed to manage the configuration of the product. We will now describe some of this information, those most often used.

When it was installed for the first time such a file requirements in a directory, thus defining a package, it is necessary to configure the package with the command cmt config to run locally, and only once. This will produce a universal Makefile (that means that remain unchanged regardless of changes in the package).

In the future use of the tool make the command make , CMT will be used transparently to automatically regenerate the correct configuration settings of make.

8.3.2.2. Description of the source files for an application

If you want to build an application, we must give it a name (eg foo ). The name is used among others things to name the executable file ( toto.exe ).

application foo foo.cpp ../somewhere/a.cpp -s=../lib x.cpp y.cpp z.cpp

Then we need to specify all source files that will be compiled and then assembled to make the application. These source files can be in the proper directory of the package (the current directory) or not. In the example shown here, we have:

  • foo.cpp is a source file in the current directory
  • a.cpp is a source file in the directory ../somewhere
  • option -s=../lib indicates that the next source files will be searched in this directory (until the next option -s= )

8.3.2.4. Construction of libraries

A library can pre-compile and pre-assemble C++ modules so that multiple applications can use them without having to rebuild them systematically.

We define a library with the following statement, put in the requirements, giving it a name and describing the source files (as for applications):

library event a.cpp b.cpp c.cpp

Then, for an application ( foo , for example) uses this library, it is sufficient to install a dedicated macro as follows:

macro foolinkopts "L-.-levent"

which means in this example that the application foo will be linked with the library named event and located in the current directory (option -L. ).

8.3.2.5. Statement by the use of external

Numerous external packages, usually providing specialized libraries can be registered to CMT and be referenced easily through the following instructions:

use OPAC v3
use Ci   v5r2

Each of these instructions gives automatic and transparent access to the libraries provided by these packages.

8.3.3. Using CMT

$> cd a_working_directory
$> cmt create MyPackage v1
$> cd MyPackage/cmt
$> vi ../src/...
$> vi requirements
$> source setup.sh
$> cmt make

For more information, visit the website CMT