Root_generate_dictionary set output directory


I’m trying to have a project that depends on ROOT compile with cmake. I created a CMakeLists.txt file that uses root_generate_dictionary to create all the needed dictionaries, but I don’t want them to end up in the main build directory but rather have them show up in a sub-directory. Using CMAKE_LIBRARY_OUTPUT_DIRECTORY redirects where the libraries, rootmap, and pcm files are generated, but it does not affect the G__.cxx files. How can I make sure that these files are also put in a subdirectory (same one as the libraries or a different one)?

Hi @vaubee,

thank you for your question, maybe @bellenot could help here?


I think the only way is to copy the file using file(COPY ...), something like this for example:


I see, so there is no way to move these files out of the main build directory. Because using file(COPY ...) and file(REMOVE ...) would cause the next make to simply re-build it.

Well yes, but is it really a big issue?

No, not really.

It does clutter up the build directory quite a lot (there are 22 dictionaries being built), which doesn’t seem to be in line with the normal behavior of cmake which hides all the intermediate files in the CMakeFiles directory. I just wanted to make certain I didn’t miss any obvious option to hide those files.

You might be able to achieve this by having the call to ROOT_GENERATE_DICTIONARY inside a CMakeList.txt that is in a subdirectory of your source.

Yes, that would probably work. I have a sub-library that is included using FetchContent and the dictionaries of this library are in the _deps/<library-name>-build directory.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.