# Understanding cmake root\_generate\_dictionary

**URL:** <https://root-forum.cern.ch/t/understanding-cmake-root-generate-dictionary/56090>\
**Category:** ROOT\
**Tags:** cmake\
**Created:** [August 21, 2023, 1:20pm UTC](https://root-forum.cern.ch/t/understanding-cmake-root-generate-dictionary/56090 "2023-08-21T13:20:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaxNoe](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/maxnoe/32/34145_2.png) [@MaxNoe](https://root-forum.cern.ch/u/MaxNoe)\
**Post date:** [August 21, 2023, 1:20pm UTC](https://root-forum.cern.ch/t/understanding-cmake-root-generate-dictionary/56090/1 "2023-08-21T13:20:20Z")

</div>

Hi,

I am trying to move a large, historic code-base using root from hand-written Makefiles to cmake.  
I am having troubles understanding how to correctly use `root_generate_dictionary` and how to properly setup the project so that the generated files are installed into `CMAKE_INSTALL_PREFIX` at a location where root and the generated executables are looking for them.

The library is split into multiple subdirectories, for which – at least in the current setup – each directory has its own dictionary / LinkDef.h / Incl.h .

In the top-level directory, I have

```auto
add_library(myproject)
root_generate_dictionary(G__myproject MyProjcetIncl.h MODULE myproject MULTIDICT LINKDEF MyProjectLinkDef.h 

add_subdirectory(foo)
add_subdirectory(bar)

```

In each of the subdirectories, there are `FooLinkDef.h` and `FooInc.h` files, and i put the following in the `CMakeLists.txt` of those:

```auto
target_sources(myproject <source files>)
target_include_directories(myproject PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
  $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDE_DIR}/foo>
)

root_generate_dictionary(FooDict FooIncl.h MULTIDICT MODULE myproject LINKDEF FooLinkDef.h)

```

This seems to work, has a couple of issues though:

- The pcm files are generated in the subdirectories of the build dir, but root seems to expect them at the base, next to the `libmyproject.so`.
- The pcm files are not installed, although looking into the code, they should be…
- In general, I found the documentation on how to use `root_generate_dictionary` lacking and hard to understand, especially for the case of multiple dictionaries. The arguments are not explained in the cmake macro

Is the general setup ok?

How can I address the mentioned issues?

Any help would be greatly appreciated.

_ROOT Version:_ 6.28/04  
_Platform:_ Ubuntu 22.04  
_Compiler:_ gcc 11.4

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [August 22, 2023, 9:54am UTC](https://root-forum.cern.ch/t/understanding-cmake-root-generate-dictionary/56090/2 "2023-08-22T09:54:37Z")

</div>

Maybe @bellenot can help a bit here.

Cheers,  
J.

---

<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:** [September 5, 2023, 9:54am UTC](https://root-forum.cern.ch/t/understanding-cmake-root-generate-dictionary/56090/3 "2023-09-05T09:54:51Z")

</div>

Closed on September 5, 2023, 9:54am UTC

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