find_package(ROOT) makes the following variables available:
|Include directories for the ROOT installation.
|Libraries to link against. The actual list of libraries is composed using the COMPONENTS listed in the find_package(…) command.
|Compile definitions needed to use ROOT.
|C++ compiler flags used to build ROOT.
|C compiler flags used to build ROOT.
|C++ standard used to build ROOT.
|Full path for each of the ROOT libraries listed in COMPONENTS.
|Full path for each ROOT executable (rootcling, root, hadd, etc.).
|TRUE for each enabled build option (e.g. cocoa, python, xrootd, etc.).
|TRUE if the ROOT package has been found.
|Path to a CMake module, which makes use of the previous variables and loads modules with useful macros or functions such as
One CMake target per ROOT library is also available, e.g.
To ensure compatibility between ROOT’s C++ interpreter, Cling, and compiled code, your application must be compiled with the same C++ standard with which ROOT was compiled.
The C++ standard used to build ROOT is available via the ROOT_CXX_STANDARD variable and appears also among the flags listed by
Adding additional libraries to
You can force additional ROOT libraries in the
ROOT_LIBRARIES variable using the
COMPONENTS option in the
command. For example, to add the
RooStats library, you can specify it as an extra component
(the name of the component is the name of the library without any library prefix or suffix).
Full example (event project)
The following is an example of a project that creates a library and an executable file.
See also the An Introduction to Modern CMake Guide by Henry Schreiner for more information on building your ROOT project with modern CMake.