mirror of
1
0
Fork 0

Expand ROOT_USE_FILE

This commit is contained in:
Henry Fredrick Schreiner 2018-04-26 09:17:25 -04:00
parent 1cba97c923
commit 0c4d409829
1 changed files with 16 additions and 2 deletions

View File

@ -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)