So after a long time I finally figured out today how to set alternative
compile options in CMT when using the LHCb framework.
First there are some additonal tags besides the well known tags
for production and debugging code
slc4_amd64_gcc34
slc4_amd64_gcc34_db
one is for code coverage the other for performance tests
tag slc3_ia32_gcc344_cov
tag slc3_ia32_gcc344_pro
Most important is where all this stuff is set,
it’s in
GaudiPolicy/cmt/requirements
Problem with the XXX_cov and XXX_pro is that there are no
supported prebuild binaries by CERN. So it’s all or nothing either
you build everything on your own or you are stuck. You can work
around that with a little hack:
getpack the GaudiPolicy package to your local cmtuser directory
and just add your additional flags to a supported tag.
If you just want to alter the cppflags for one package you would
just add something like this to the package’s requirements file:
macro_append cppflags " -g "
or
macro_append cppflags "" Linux " -g " Windows " -foo -bar"
Where Linux and Windows would act as a switch for different
compilation setups.and the quoted strings would be the appended
options. Note the first empty qoutes in the second example it’s just
the empty standard case.
Update:
As Stefan Roiser pointed out to me over at the cmt mailing list,
one possibility would be to produce your own requirements file
/my/dir/to/cmt/requirements
put your macro_append etc into there and set an enviornment variable
CMTUSERCONTEXT=/my/dir/to/cmt
Then your requirements file should be processed last, thus changing
appending your compiler flags etc as a last step of the configuration before
executing the make.
Also on the cmt mailing list Grigory Rybkin explained, that if you ever wonder
why your cppflags or any other macro behave weird you could check with
cmt show macro cppflags
Example output for package Moore on a Linux machine:
# Package CMT v1r20p20070208 defines macro cppflags as '-pipe -ansi -pedantic -W -Wall -Wwrite-strings
-Wpointer-arith -Woverloaded-virtual ' for tag 'Linux'
# Package GaudiPolicy v8r5 defines macro cppflags as ' -fmessage-length=0 -Df2cFortran -fPIC -shared
-D_GNU_SOURCE -Dlinux -Dunix -pipe -ansi -Wall -Wextra -pthread ' for default tag
# Package GaudiConf v10r13 appends to macro cppflags : ' -DAPPNAME=\"${package}\"
-DAPPVERS=\"${version}\" ' for default tag
# Package RichKernel v7r17 appends to macro cppflags : ' -DRICHDEBUG ' for tag 'Linux&debug'
# Package LHCbKernel v9r2 remove from macro cppflags : '-DGOD_NOALLOC' for default tag
#
# Selection :
cppflags=' -fmessage-length=0 -Df2cFortran -fPIC -shared -D_GNU_SOURCE -Dlinux -Dunix -pipe -ansi
-Wall -Wextra -pthread -DAPPNAME=\"${package}\" -DAPPVERS=\"${version}\" -DRICHDEBUG '
And then use the “-e” option of make via brodcast, like:
cppflags=MYFLAGS cmt br make -e
it orders make to give environment precedence over variables from makefiles.