Home | News | Documentation | Download

Using cmake to include root package

I have a small cpp program, in which I would like to use the TVector package from root. I have root installed on my pc. I am running Ubuntu.
I use cmake to generate my makefile. I know that somehow need to link to the TVector package in the make file, to be able to include:
#include “TVector.h”
in the cpp code. How do I do that?

The process described here
is too technical for me. I have tried copy/pasting it into my CMakeLists.txt file, but it did not work.

Hope you can help

Can you paste please your current working CMakeLists.txt?

A colleague fixed the problem for me. If anyone else will have the same issue, the makefile is here:

#Add this path and root’s path includes
CXXFLAGS = -I./(INCDIR) -I(shell root-config --incdir)
#Set optimisation and use C++ version from root (C++11 on lxplus)
CXXFLAGS +=-O2 -g -Wall $(shell root-config --cflags)

ROOTLIBS := (shell root-config --libs) -Wl,-rpath,(ROOTSYS)/lib

all: MySim.exe

-rm -f *.o MySim.exe

MySim.exe: %.exe:
(CXX) MySIm.cpp -o @ (MACHFLAG) (LDFLAGS) (CXXFLAGS) ^ (MIDASLIBS) (ROOTLIBS) -lm -lz -lutil -lpthread

Actually, if someone could help me translate this makefile to a CMakeLists.txt, I would be grateful!