From 0c4d4098291b3a6ab52fd4ba22a4a51c02c1e061 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Thu, 26 Apr 2018 09:17:25 -0400 Subject: [PATCH] Expand ROOT_USE_FILE --- chapters/packages/ROOT.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/chapters/packages/ROOT.md b/chapters/packages/ROOT.md index 56fb7b9..1ab7291 100644 --- a/chapters/packages/ROOT.md +++ b/chapters/packages/ROOT.md @@ -11,9 +11,23 @@ ROOT supports config file discovery, so you can just do: to attempt to find ROOT. If you don't have your paths set up, you can pass `-DROOT_DIR=$ROOTSYS/cmake` to find ROOT. (But, really, you should source `thisroot.sh`) -## The wrong way +## The simple but wrong way -ROOT provides a utility to set up a ROOT project, which you can activate using `include(${ROOT_USE_FILE})`. This will automatically make ugly global variables for you. It will save you a little time setting up, and will waste massive amounts of time later when you try to do anything more complicated. Don't use it. +ROOT provides a utility to set up a ROOT project, which you can activate using `include(${ROOT_USE_FILE})`. This will automatically make ugly global variables for you. It will save you a little time setting up, and will waste massive amounts of time later if you try to do anything tricky. As long as you aren't making a library, it's probably fine for simple scripts. Includes and flags are set globally, but you'll still need to link to `${ROOT_LIBRARIES}` yourself. + +Here's what it would look like: + +```cmake +cmake_minimum_required(VERSION 3.11) + +project(Simple LANGUAGES CXX) + +find_package(ROOT CONFIG REQUIRED COMPONENTS Minuit) +include("${ROOT_USE_FILE}") + +add_executable(simple simple.cxx simple.h) +target_link_libraries(simple ${ROOT_LIBRARIES}) +``` ## The right way (Targets)