Generating automatically the configuration files for cmake

The tool mmxmake allows to generate automatically the cmake configuration files. So for the following, you need to have cmake installed.

The process can be decomposed into 3 steps:

  1. Initialisation and generation of the configuration, using the command mmxmake;

  2. Configuration using the command cmake;

  3. Construction using the command make.

1.Specification and configuration files

1.1.A default specification

The generation of the configuration files for cmake is based on a specification file. A default specification file can be generated in the package directory pkg, with the command

mmxmake -init

If the current directory name is pkg, a directory specif and a file specif/pkg-cmake.mmx are created or udpated if it exists. This file contains the information to generate the cmake configuration files. In our case, it looks like the following:

pkg: Package := package ("pkg", "0.1");

//List of files to be generated automaticaly 
pkg.automatic := ["CMakeLists.txt", 
                  "doc/tools",
                  "cmake/FindPkg.cmake.in" ];

create_package (pkg);

This file can be edited to tune the generated cmake files as wanted. This specification of a package can also be displayed with mmxmake -info. It gives

Package     : pkg 0.1 
Automatics  :
["CMakeLists.txt","doc/tools","cmake/FindPkg.cmake.in"] 

1.2.Specification out-of-source

This specification step can be run from another directory with the option -dir:

mmxmake ../pkg -init

In this example, the specification files are generated in the folder ../pkg.

1.3.The dependencies

To add dependencies whith other packages for the libraries or the glue, one can use the command such as:

mmxmake -init +l basix +l gmp +g numerix +v 0.1.2

The file specif/pkg-cmake.mmx then contains

pkg: Package := package ("pkg", "0.1.2");

//List of files to be generated automaticaly 
pkg.automatic := ["CMakeLists.txt" 
                  ,"doc/texmacs/index.en.tm" 
                  ,"cmake/FindPkg.cmake.in" ];

//List of packages on which the lib of the package depends 
pkg.libs := ["basix", "gmp"];

//List of packages on which the glue lib of the package depends 
pkg.glue := ["numerix"];

create_package (pkg);

Here the package pkg depends on basix and gmp for the construction of the library libpkg and numerix for the construction of the glue libmmxpkg.

Now the command mmxmake -info yields:

Package     : pkg 0.1.2 
Automatics  : ["CMakeLists.txt","doc/texmacs/index.en.tm",         
               "cmake/FindPkg.cmake.in"] 
Libs        : ["basix", "gmp"]
Glue        : ["numerix"] 

1.4.Default configuration options

Default options can be passed to the CMakeLists.txt file using a command of the form:

mmxmake -init +o glue -o test

In this exemple, the glue part will be built by default but not the test part.

If the option -init is not used, the indicated options will be updated:

mmxmake -o glue

This command turns the glue default OFF by default but keep the other options as they are.

1.5.Assembling new subpackages

To assembled in a same package several mathemagix subpackages, the following can be used:

mmxmake -init +p basix +p numerix +p mmxlight  

The following line will be added in the specification file:

pkg.subpackages :=  ["basix", "numerix", "mmxlight"];

If the packages basix, numerix, mmxlight are not available, they will be downloaded from its svn server (using an anonymous svn checkout). If you want to create a new package and add it to as a subfolder, you need first to configure this package. The corresponding subdirectories will be added in the build tree of the package pkg.

Subpackages can be included but not used by default as follows:

mmxmake -init +p basix +p numerix +p mmxlight -o numerix

The configuration is initialized if the option -init is used and updated otherwise. The following instruction will be added in the specification file:

pkg.subpackages :=  ["basix", "numerix", "mmxlight"];

set_option ("numerix", false);

In this case, when cmake is run, the package numerix will not be configured. To turn on the corresponding option for cmake, use cmake -DNUMERIX=ON ../pkg (see below).

The option -p can be used to remove a package from the list of subpackages:

mmxmake -p mmxlight

The configuration files are updated accordingly (but the corresponding folder mmxlight will not be removed). A list of Mathemagix packages is available here.

Notice that the package numerix depends on two external libraries:

If they are not installed globally, the option EXTERNAL can be turned ON to download and build them:

cmake ../pkg -DEXTERNAL=ON

The new libraries can now be built:

make

A list of Mathemagix packages is available here.

1.6.Updating the library dependencies

The list of libraries on which a package depends can be updated with the options -l +l. Here is an example:

mmxmake ../pkg -l gmp +l numerix

This will remove gmp from the list pkg.libs and add numerix to it.

1.7.Updating the glue dependencies

The list of libraries for building the glue with the mathemagix interpreter can be updated with the options +g -g. Here is an example:

mmxmake ../pkg -g numerix +g algebramix

This will remove numerix from the list pkg.glue and add to it algebramix.

1.8.Updating the axel plugin dependencies

Similarly, the dependencies for building the plugins for axel interpreter can be updated with the options +a -a:

mmxmake ../pkg +a shape

This will add shape to the list pkg.axel.

1.9.Updating the list of subpackages

Also the list of subpackages of the package can be updated +p -p:

mmxmake ../pkg +p shape

This will add shape to the list of subpackages of pkg.

2.Configuration

Once these files have been generated, they can used independently of mmxmake, with cmake in the usual way. The configuration can be done out-of-source, for instance in a folder build:

mkdir build; cd build;  

The configuration process is performed with:

cmake ../pkg 

For more details on the different options, see here.

3.Construction

Once cmake is run, the command make can be used:

make 

For more details, see here.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License. If you don't have this file, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.