# CMake ROOT\_GENERATE\_DICTIONARY Include Path

**URL:** <https://root-forum.cern.ch/t/cmake-root-generate-dictionary-include-path/24381>\
**Category:** ROOT\
**Tags:** cmake\
**Created:** [April 10, 2017, 2:56pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-include-path/24381 "2017-04-10T14:56:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [April 10, 2017, 2:56pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-include-path/24381/1 "2017-04-10T14:56:58Z")

</div>

Hi,

I’ve previously [posted](https://root-forum.cern.ch/t/cmake-and-findroot/17162?u=ksmith) 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`?):

```auto
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:

```auto
 #---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

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [April 10, 2017, 3:06pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-include-path/24381/2 "2017-04-10T15:06:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mato](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mato/32/12317_2.png) [@mato](https://root-forum.cern.ch/u/mato)\
**Post date:** [April 10, 2017, 4:34pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-include-path/24381/3 "2017-04-10T16:34:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [April 10, 2017, 5:12pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-include-path/24381/4 "2017-04-10T17:12:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [April 10, 2017, 7:50pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-include-path/24381/5 "2017-04-10T19:50:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [April 24, 2017, 7:50pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-include-path/24381/6 "2017-04-24T19:50:51Z")

</div>

Closed on April 24, 2017, 7:50pm UTC

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