Adding a class to ROOT still an issue

Exactly one year later in version 6.26, this is still an issue.

I thought that it was/is a key feature in ROOT/CLING.

Yup, and I found out and since forgot why this doesn’t work. I’ll revive this, thanks for the ping!

But Axel, could it be that nobody else bugs you because creating your own classes and linking them to ROOT with dictionaries etc has become a very difficult task. There is as was pointed out by Maarten Ballintijn in 2018 no decent documentation about cmake.
For instance, how can you access/include the ROOT modules. I asked that question also a year ago on the forum and no solution. So I resort to hacks like:
set (CMAKE_MODULE_PATH “/Users/eddyo/src/root-6.26.00/cmake/modules”)

That we have an answer on! We have rewritten large parts of the ROOT manual, and it should now have exactly what you’re after: Integrating ROOT into CMake projects - ROOT

Can you let me know if anything is unclear or doesn’t work?

It took the ROOT team about 10 years to get a cmake environment going and now a ROOT user gets all this knowledge condensed in barely one page …

Let’s start by saying that I am very grateful to Henry Schreiner for putting those tutorial pages together, it was a life saver but also these pages have not kept up with
the changes/ additions that were made in the root package. For instance no
mention of the “ROOT_STANDARD_LIBRARY_PACKAGE” macro that takes
care of many things.

The one-page ROOT with cmake explainer refers to the “Full example”. It turns out
to be a screen shot of a CMakeLists.txt file in the ROOT test directory. I could
not find any reference to it and the actual file in the test directory has changed
(I must definitely have missed here something ?!).

So if this CMakeLists.txt file is to help a user to create an external project
using ROOT libraries, it should at least survive the following test. Copy the
test directory completely out of the ROOT directory and run cmake. To be
fair I removed all the other projects and left just “Event”:

# Copyright (C) 1995-2019, Rene Brun and Fons Rademakers.
# All rights reserved.
# For the licensing terms see $ROOTSYS/LICENSE.
# For the list of contributors see $ROOTSYS/README/CREDITS.

# CMakeLists.txt for the ROOT test programs.
# This shows nicely how to compile and link applications
# using the ROOT libraries on all supported platforms.
# Author: Pere Mato, 25/10/2010
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)


# Sergey: make no sence while CMakeLists.txt file cannot be used separately from ROOT
# but variables like ROOT_asimage_FOUND used here and produced in ROOTConfig.cmake
find_package(ROOT REQUIRED)

#---Copy the CTestCustom.cmake file into the build directory---------------------------------

  # To avoid to set ld_Library_path to locate the test libraries
  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,@loader_path/.")

  # Testing using the binary tree
  set(ROOT_root_CMD ${ROOT_BINDIR}/root.exe)
  # Testing using an installation (assuming access to ROOT CMake modules)

ROOT_ADD_TEST(show-environment COMMAND ${CMAKE_COMMAND} -E environment)

                              HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/Event.h
                              SOURCES Event.cxx LINKDEF EventLinkDef.h
                              DEPENDENCIES Hist MathCore)
  if(NOT runtime_cxxmodules)
    add_custom_command(TARGET Event POST_BUILD
      COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/libEvent_rdict.pcm
    add_custom_command(TARGET Event POST_BUILD
ROOT_EXECUTABLE(eventexe MainEvent.cxx LIBRARIES Event RIO Tree TreePlayer Hist Net)
ROOT_ADD_TEST(test-event COMMAND eventexe)

That does not work

eddyo@MacBook-Pro-2019 root-test % cmake -S . -B build
-- The C compiler identification is AppleClang
-- The CXX compiler identification is AppleClang
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/ - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:37 (include):
  include could not find requested file:


And looking at my original module path question, this error is not helpful :wink:

The other part of the one-pager is a list of cmake ROOT variables, most of them are not
used in the event example.

As a user I would like to know whether I should use


to make sure that I am using the same compiler/linker etc.

In summary, I really would like ROOT/cmake documentation

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.