Integrating ROOT in a CMake Project: find_package options

I am integrating ROOT in my c++ project, following root.cern.ch/how/integrate-root … ject-cmake . I would like to add the TObjArray.h to my headers, and I was wondering if i have to add something to

#---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS) find_package(ROOT REQUIRED COMPONENTS RIO Net)
i tried ObjArray, but running cmake says that it is not found. So I realized it is not needed to compile the program.

Anyway this opens for a more general question: is there somowhere a list of all the possible options to pass to the find_package command, that are specifically defined for ROOT? that would be lovely.

Thanks!

here i found a good starting point: lcio.desy.de/v01-51/FindROOT.cmake

[code]# Please note that by convention components should be entered exactly as

the library names, i.e. the component name equivalent to the library

$ROOTSYS/lib/libMathMore.so should be called MathMore and NOT:

mathmore or Mathmore or MATHMORE

However to follow the usual cmake convention it is agreed that the

ROOT_${COMPONENT}_FOUND variables are ALL uppercase, i.e. the MathMore

component returns: ROOT_MATHMORE_FOUND and NOT ROOT_MathMore_FOUND

The additional ROOT components can be defined directly in the cmake commando:

FIND_PACKAGE( ROOT COMPONENTS MathMore Gdml Geo …)

Or in the variable ROOT_USE_COMPONENTS before calling find_package, i.e.:

SET( ROOT_USE_COMPONENTS MathMore Gdml Geo )

FIND_PACKAGE( ROOT )

The Minuit2 component is always added for backwards compatibility.

@author Jan Engels, DESY

[/code]

but still you need to go try if that library is needed. And some options are not trivial: RIO, for example. Also: is libCore always included?

[quote]Also: is libCore always included?[/quote]Yes.

I believe you are missing these two lines following find_package(ROOT)

include_directories(${ROOT_INCLUDE_DIR})
link_directories(${ROOT_LIBRARY_DIR})

[quote=“ksmith”]I believe you are missing these two lines following find_package(ROOT)

include_directories(${ROOT_INCLUDE_DIR}) link_directories(${ROOT_LIBRARY_DIR}) [/quote]

thanks but my code compiles, I was more asking if there is some documentation about the find_package(ROOT COMPONENTS) options. Also, are you sure link_directories is really needed? Mine works perfectly without it, just linking the libraries.

@pcanal, thanks!

Following your suggestion I’ll extend the documentation on find_package(ROOT …).