Two versions of root_generate_dictionary CMake function in some ROOT6 installations

Dear ROOT-ers,

I am building a library based on ROOT and managed with CMake, which includes generating dictionaries for some classes with rootcling. For this, I am using the root_generate_dictionary helper CMake function.
However, I recently noticed that in certain installations of ROOT 6, there are two CMake files defining this function:

  1. $ROOTSYS/cmake/modules/RootNewMacros.cmake
    I understand that this provides the “right” version of root_generate_dictionary which should be used?

  2. $ROOTSYS/etc/cmake/FindROOT.cmake
    I guess that it is there cor compatibility reasons? The function root_generate_dictionary defined here is slightly different and does not understand the MODULE keyword.

My CMake configuration for ROOT looks like this:

find_package(ROOT QUIET)


I am not setting any CMake-related paths explicitly except for what is setting.

My problem is that on ROOT installations where both definitions of root_generate_dictionary are present, CMake keeps using the one from FindROOT.cmake, which causes incorrect dictionary generation since I am using the MODULE keyword which this version does not expect.

On different systems with different ROOT installations, the 2nd version (FindROOT.cmake, or in fact the whole etc/cmake directory) either is there or not even though I am quite certain that ROOT was installed always in a similar way (out-of source CMake build with prefix set to a local directory, with make install at the end and sourcing

Therefore, I am wondering about two things:

  1. Why does CMake load the modules from $ROOTSYS/etc/cmake first rather than from $ROOTSYS/cmake when CMAKE_PREFIX_PATH is set to the same as $ROOTSYS?
  2. Which factor decides whether $ROOTSYS/etc/cmake/FindROOT.cmake is present in a given ROOT installation or not?

I am not an expert especially in CMake usage, so I would appreciate any hints on what I might be doing wrong.

Many thanks,

ROOT Version: 6.12, 6.14
Platform: GNU/Linux
Compiler: g++

The FindROOT.cmake file is unnecessary and should not be used. ROOTConfig.cmake should be used instead. Please either move to a newer version (the file FindROOT.cmake has actually been removed from ROOT altogether), or set only CMAKE_PREFIX_PATH to the prefix of ROOT instead of sourcing I consider sourcing that script for installed versions of ROOT a bad practice. You should build ROOT with a certain prefix (e.g. /opt/root/6.14), then use make install to install it there. If you use -Drpath=ON to configure, then you won’t need to set anything other than just PATH, PYTHONPATH and CMAKE_PREFIX_PATH to use that ROOT (that is, no LD_LIBRARY_PATH needs to be set).

Dear Guilherme,

Thank you for your explanation. It is good to know that the conflicting file was removed which essentially solves my problems.

Your remark about avoiding was also very interesting - I did not realize how little environment is sufficient to be set. However, I have to admit that is very convenient for setting up ROOT by less experienced users on their own so we will probably stick to it for now.


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