wiki:VincentTrial3

A project creation

For this example, we create a project which contains two packages. One of this package needs another package.

We do first the package creation:

> mkdir tmp
> cd tmp
> cmt create_project project v1
...
> cd  project/v1
> cmt create A v1
...
> cmt create B v1
...

The codes for A and B are the same than in our previous example, so:

> more A/v1/src/A.h
#include <iostream>

using namespace std;

class A
{
    public:
	A() {}
	~A()  {}
	void print ();
};
> more A/v1/src/A.cxx
#include "A.h"

void A::print ()
{
	cout<<"A"<<endl;
}
> more B/v1/src/B.h
#include <iostream>

using namespace std;

class B
{
    public:
	B() {}
	~B()  {}
	void print ();
};
> more B/v1/src/B.cxx
include "B.h"

void B::print ()
{
	cout<<"B"<<endl;
}
>
> more B/v1/src/main.cxx
#include "A.h"
#include "B.h"
int main()
{
    A a;
    B b;
    
    a.print ();
    b.print ();

    return 0;
}

We now have to setup all CMT setups for the package depencies and project definition. This is defined within the packages requirements files and the project file:

> more  A/v1/cmt/requirements
package A

author Vincent Garonne <garonne@lal.in2p3.fr>

library A A.cxx

macro A_linkopts " -lA "
> more  B/v1/cmt/requirements
package B

author Vincent Garonne <garonne@lal.in2p3.fr>

use A v1

# COMMENT: the order of the statements is important for the creation.
# here that means that the library is compiled before the main program
# otherwise it doesn't work  :-( .
library B B.cxx

application main main.cxx 

macro B_linkopts "  -lB "
> more cmt/project.cmt 
project project

build_strategy with_installarea

The statements "build_strategy with_installarea" tells that the executable and the shared libraries will be automatically set to a installation area (i.d. the default prefix is InstallArea ). We can now build the all stuff. The entry point is the package B this is why the cmt broadcast command should be executed from the package B:

> cd B/v1/cmt
> cmt broadcast make
...

All librairies and executable are now built:

> ls
A  B  cmt  InstallArea
> ls InstallArea/
Linux-i686
> ls InstallArea/Linux-i686/
bin  lib
> ls InstallArea/Linux-i686/bin/
main.exe  main.exe.cmtref
> ls InstallArea/Linux-i686/lib/
libA.so  libA.so.cmtref  libB.so  libB.so.cmtref

We can also setup all environnemts variables(PATH, LD_LIBRARY_PATH, ...) by running the setup script:

> source setup.csh 

Now directly running the application is possible since the application has been installed after being built in an automatic installation area :

> main.exe
A
B

REMARK

We can directly create all the packages inside the project. For this we do a container which is a empty package containing only a requirements file:

> cmt create container v1
...
> more  container/v1/cmt/requirements 
package container
use A v1
use B v1
> more cmt/project.cmt
project project

container container v1

build_strategy with_installarea
> cd container/v1/cmt/
> cmt broadcast make
...
> source setup.csh
> main.exe
A
B
Last modified 19 years ago Last modified on May 12, 2005, 4:54:27 PM