CMake ROOT_GENERATE_DICTIONARY Include Path

Hi,

I’ve previously posted about some improvements to the CMake Macro that ROOT provides and these were included in ROOT 5, but seem to have been dropped in ROOT 6. In particular I believe that the ROOT_GENERATE_DICTIONARY should search the include paths for the include files needed, at the moment it seems the paths need to be hard coded (or the headers need to be in ${CMAKE_CURRENT_SOURCE_DIR}/inc?):

include_directories(../include)
#Would like to use the following
#ROOT_GENERATE_DICTIONARY(CustomClassesDict AClass.hpp LINKDEF CustomCLasses_LinkDef.h)
#but instead need hard coded paths:
ROOT_GENERATE_DICTIONARY(CustomClassesDict ../include/AClass.hpp LINKDEF ../include/CustomCLasses_LinkDef.h)

The issue is in RootNewMacros.cmake, instead of using a GLOB which is not recommended and oddly picking and choosing hard coded paths (some places use inc/ and others ${CMAKE_BINARY_DIR}/include) the macro should use the find_file command from CMake. I don’t have the time at the moment to improve the macro again, but here is a brief excerpt of my suggested improvements from the previous post:

 #---Get the list of include directories------------------
  get_directory_property(incdirs INCLUDE_DIRECTORIES)
  set(includedirs) 
  foreach( d ${incdirs})    
  	set(includedirs ${includedirs} -I${d})
  endforeach()
  #---Get LinkDef.h file------------------------------------
  set(linkdefs)
  foreach( f ${ARG_LINKDEF})
      find_file(linkFile ${f} PATHS ${incdirs})
      set(linkdefs ${linkdefs} ${linkFile})
      unset(linkFile CACHE)
  endforeach()
  #---Get the list of header files-------------------------
  set(headerfiles)
  foreach(fp ${ARG_UNPARSED_ARGUMENTS})
      find_file(headerFile ${fp} PATHS ${incdirs})
      set(headerfiles ${headerfiles} ${headerFile})
      unset(headerFile CACHE)
  endforeach()

If I find sometime I will rewrite the macro again and post it here.

Thanks

Also, I’ve created a small test bed project that can be used for testing at https://github.com/ksmith0/root-cmake

In ROOT 5 we have etc/cmake/FindROOT.cmake and in ROOT 6 (master) we do not have this file anymore and we generate ROOTConfig.cmake, which makes use of RootNewMacros.cmake. This file was changed recently to accommodate these kind of requests and indeed uses find_file(…). Which version are you using of ROOT?

1 Like

Good to hear. I’m using ROOT 6.08/06.

It is a little unfortunate as there may be a gap of users for whom the Custom Class CMake file will not work. I will either have to list the relative paths for those users or package a custom version of the cmake modules with the project.

Found it in the JIRA bug tracker: https://sft.its.cern.ch/jira/browse/ROOT-8701

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