Dictionary generation with ROOT_GENERATE_DICTIONARY

Hi there,

I’ve got a question about dictionary generation. So far, I have done this in my CMakeLists:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "$ENV{ROOTSYS}/etc/cmake/")
find_package(ROOT REQUIRED COMPONENTS TMVA TreePlayer Gui)
(... elsewhere in some subdirectory ...)
ROOT_GENERATE_DICTIONARY(G__mylib_dict ${mylib_HEADERS} LINKDEF path/Linkdef.h)

i.e. I have been using the FindROOT.cmake in etc/cmake of the installed ROOT.

Now, using a newer ROOT (some recent master version from last week), this file doesn’t exist any longer. The dictionary generation is now in root-source-code/cmake/modules/RootNewMacros.cmake (so not in $ENV{ROOTSYS} any more). First of all, I don’t like a filename containing “New”. New can quickly become “Old”. Could you rename this, please? Am I supposed to copy this file into my cmake project? (sorry, I am quite unexperienced with CMake). But even when I include this file in my CMake project, I get a Ninja error like ninja: error: '../path/Linkdef.h', needed by 'path/G__mylib_dict.cxx', missing and no known rule to make it. When I use an “old” FindROOT.cmake from ROOT 6.12 or before, everything is working fine.

What is the recommended way to use the new “RootNewMacros.cmake” and ROOT_GENERATE_DICTIONARY? Or is it meant for ROOT internal use only?

Hi. Sorry about that. I thought that nobody was using this file, as the usual way is to find ROOT via ROOTConfig.cmake. So what I recommend is that you use just find_package(ROOT REQUIRED COMPONENTS TMVA TreePlayer Gui) without setting the CMAKE_MODULE_PATH, then include ROOTUseFile.cmake to get the macros. The name RootNewMacros.cmake is actually there because there was already a RootMacros.cmake before (both exist since a while). Neither of those is supposed to be included directly, however. The advantage of using ROOTConfig.cmake is that you will have exported targets like ROOT::Core, etc, that propagate includes and library dependencies as needed. Let us know if you have problems with the approach described above. Cheers,

Ah, didn’t know that. I thought is was by using FindROOT.cmake… :slight_smile: So then I’ll try it this way. I am usually using cmake in a try+error way until it does what I want (so probably not necessarily in a way one is supposed to use it in modern days). I thought I had to include FindROOT.cmake to be able to find_package(ROOT).

Just FYI, if you installed ROOT into a non-standard location, just use the same prefix you passed to CMAKE_INSTALL_PREFIX (e.g. /usr/local) to pass to CMake with -DCMAKE_PREFIX_PATH=..., that should find ROOT via the ROOTConfig.cmake installed by ROOT. Cheers,

I do not “install” ROOT since I often try different versions. So I want my cmake work “correctly” depending on the /path/version/thisroot.sh that I have sourced. I thought it was recommended to use thisroot.sh and not install ROOT?

I think that using from the build directory is bad practice, but it is encouraged by many people, unfortunately. For example, one difference is that the build directory is usually 2GB in size, whereas an installation is only ~160MB…

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