wiki:VincentTrial3

Version 4 (modified by garonne, 19 years ago) (diff)

--

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 is tha 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 file 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
> cd B/v1/cmt
> cmt broadcast make
...  
> source setup.csh 
> main.exe
A
B