| Version 6 (modified by , 21 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 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
