1
0
mirror of synced 2024-12-22 12:40:00 +01:00

Adding Minuit2 page

This commit is contained in:
Henry Fredrick Schreiner 2018-09-10 11:44:41 +02:00
parent 582429d07a
commit d10a00caa1
3 changed files with 50 additions and 4 deletions

View File

@ -39,4 +39,5 @@
* [Simple Example](examples/root-simple/README.md) * [Simple Example](examples/root-simple/README.md)
* [Simple Example CMake 3.11+](examples/root-simple-3.11/README.md) * [Simple Example CMake 3.11+](examples/root-simple-3.11/README.md)
* [Dictionary Example](examples/root-dict/README.md) * [Dictionary Example](examples/root-dict/README.md)
* [Minuit2](chapters/packages/Minuit2.md)

View File

@ -0,0 +1,44 @@
# Minuit2
Minuit2 is available in standalone mode, for use in cases where ROOT is either not available or not built with Minuit2 enabled. This will cover recommended usages, as well as some aspects of the design.
## Usage
Minuit2 can be used in any of the standard CMake ways, either from the ROOT source or from a standalone source distribution:
```cmake
# Check for Minuit2 in ROOT if you want
# and then link to ROOT::Minuit2 instead
add_subdirectory(minuit2) # or root/math/minuit2
# OR
find_package(Minuit2 CONFIG) # Either build or install
target_link_libraries(MyProgram PRIVATE Minuit2::Minuit2)
```
## Development
Minuit2 is a good example of potential solutions to the problem of integrating a modern (CMake 3.1+) build into an existing framework.
To handle the two different CMake systems, the main `CMakeLists.txt` defines common options, then calls a `Standalone.cmake` file if this is not building as part of ROOT.
The hardest part in the ROOT case is that Minuit2 requires files that are outside the `math/minuit2` directory. This was solved by adding a `copy_standalone.cmake` file with a function that takes a filename list and then either returns a list of filenames inplace in the original source, or copies files into the local source and returns a list of the new locations, or returns just the list of new locations if the original source does not exist (standalone).
```bash
# Copies files into source directory
cmake /root/math/minuit2 -Dminuit2-standalone=ON
# Makes .tar.gz from source directory
make package_source
# Optional, clean the source directory
make purge
```
This is only intended for developers wanting to produce source packages - a normal user *does not pass this option* and will not create source copies.
You can use `make install` or `make package` (binary packages) without adding this `standalone` option, either from inside the ROOT source or from a standalone package.
[Minuit2]: https://root.cern.ch

View File

@ -2,18 +2,19 @@
ROOT is a C++ Toolkit for High Energy Physics. It is huge. There are really a lot of ways to use it in CMake, though many/most of the examples you'll find are probably wrong. Here's my recommendation. ROOT is a C++ Toolkit for High Energy Physics. It is huge. There are really a lot of ways to use it in CMake, though many/most of the examples you'll find are probably wrong. Here's my recommendation.
Most importantly, there are lots of improvements in CMake in more recent versions of ROOT - try to use 6.14+!
## Finding ROOT ## Finding ROOT
ROOT supports config file discovery, so you can just do: ROOT 6.10+ supports config file discovery, so you can just do:
[import:'find_package', lang:'cmake'](../../examples/root-simple/CMakeLists.txt) [import:'find_package', lang:'cmake'](../../examples/root-simple/CMakeLists.txt)
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`) 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 too-simple way ## The too-simple way
ROOT [provaides a utility](https://root.cern.ch/how/integrate-root-my-project-cmake) to set up a ROOT project, which you can activate using `include("${ROOT_USE_FILE}")`. This will automatically make ugly directory level and 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, along with possibly `ROOT_EXE_LINKER_FLAGS` (You will have to `separate_arguments` first before linking or you will get an error if there are multiple flags, like on macOS). ROOT [provides a utility](https://root.cern.ch/how/integrate-root-my-project-cmake) to set up a ROOT project, which you can activate using `include("${ROOT_USE_FILE}")`. This will automatically make ugly directory level and 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, along with possibly `ROOT_EXE_LINKER_FLAGS` (You will have to `separate_arguments` first before linking or you will get an error if there are multiple flags, like on macOS).
Here's what it would look like: Here's what it would look like:
@ -21,7 +22,7 @@ Here's what it would look like:
## The right way (Targets) ## The right way (Targets)
ROOT 6.12 and earlier do not add the include directory for imported targets. The latest git master has corrected this error. To fix this error for older ROOT versions, you'll need something like: ROOT 6.12 and earlier do not add the include directory for imported targets. ROOT 6.14+ has corrected this error. To fix this error for older ROOT versions, you'll need something like:
[import:'setup_includes', lang:'cmake'](../../examples/root-simple/CMakeLists.txt) [import:'setup_includes', lang:'cmake'](../../examples/root-simple/CMakeLists.txt)