We are building a small library to be used in the RDF eco-system. We’d like to have it used inside ROOT from the command line, and also be available for linking if someone was building a stand-alone program.
What is the best way to package and distribute this? I’m guessing the recommended advice is to use CMAKE - any hints on using external libraries? Example CMAKE file?
Hi @Gordon_Watts ,
a very basic CMakeLists.txt for a project depending on ROOT looks like this:
cmake_minimum_required(VERSION 3.9)
project (example_root_project CXX)
# Look for ROOT
# As long as an installation is available in the environment, this will succeed.
message(STATUS "Looking for ROOT")
find_package(ROOT REQUIRED COMPONENTS RIO) # can also list components that must be present
message(STATUS "ROOT ${ROOT_VERSION} found at ${ROOT_BINDIR}")
add_subdirectory(src)
Then, to use it in the ROOT prompt you would have to gSystem->Load any library object and #include any header.
To link it when building a standalone program the usual C++ methods work, e.g. adding the installation directory of the project to your LD_LIBRARY_PATH, or cloning the project into the project that depends on it and build them together via cmake.
I can help if you get stuck, although I won’t have time to put together a full blown example before at least next week.
Our build system experts @amadio@oshadura and @bellenot might have more tips and suggestions.
P.S. @Axel it would be cool to have a cookie-cutter skeleton project that people can clone to jumpstart their project.