Best practice for a project with multiple LinkDef.h's

Dear ROOT experts,

I’d like to organize a project with multiple sub-projects, each with their own LinkDef.h files and corresponding ROOT_GENERATE_DICTIONARY() calls in CmakeLists.txt files.

The problem is that the “standard preamble” as recommended below:

// Standard preamble: turn off creation of dictionaries for "everything":
// we then turn it on only for the types we are interested in.
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

included and compiled in packages A → B, then dictionary will not be generated for any of my classes in A due to the preamble of B. I cannot think of a general way to solve this, only to simply enforce the master order in advance and comment them out in all subsequent projects. This would leave project B not adhering to the recommendation if e.g. it is being compiled standalone elsewhere.

Please forgive me if I am missing some basic scheme to resolve this, but any pointers to such would be greatly appreciated!

Best,

Tae

Hi @taehyounpark,

I’m not sure if I clearly understood your problem. Could you perhaps post how you run ROOT_GENERATE_DICTIONARY()?

From what I understand, you are chaining LinkDefs(?)

When both LinkDefs are fed to the same rootcling run B’s “preamble” resets the selection and wipes out A’s types.

If that is the case, you can generate one dictionary per CMake target/library and pass only that target’s LinkDef.h:

ROOT_GENERATE_DICTIONARY(BDict ${B_HEADERS} LINKDEF B_LinkDef.h)

Cheers,
Dev