# CMake ROOT\_GENERATE\_DICTIONARY rootmap

**URL:** <https://root-forum.cern.ch/t/cmake-root-generate-dictionary-rootmap/24382>\
**Category:** ROOT\
**Tags:** cmake\
**Created:** [April 10, 2017, 3:23pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-rootmap/24382 "2017-04-10T15:23:10Z")\
**Posts on this page:** 7\
**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, 3:23pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-rootmap/24382/1 "2017-04-10T15:23:10Z")

</div>

Hi,

I’ve run into some issue with the auto generation of a rootmap file on a Mac from the cmake macro `ROOT_GENERATE_DICTIONARY`.  
Roughly the cmake file looks like this:

```auto
#Generate a ROOT dictionary.
ROOT_GENERATE_DICTIONARY(CustomClassesDict
   ../include/AClass.hpp
   LINKDEF ../include/CustomClasses_LinkDef.h)

#Create the CustomClasses library with the ROOT dictionary.
add_library(CustomClasses SHARED
   AClass.cpp
   CustomClassesDict)

#Link to ROOT.
target_link_libraries(CustomClasses ${ROOT_LIBRARIES})

#Set the install directory.
install(TARGETS CustomClasses DESTINATION lib/)

```

First the rootmap file needs to be installed manually, the fact that the rootmap and pcm files were being generated was not clear to me at first. Not sure there is anyway around this, but here is a short solution:

```auto
#Install the ROOT 6 PCM and rootmap files.
if (${ROOT_VERSION} VERSION_GREATER "6.0")
   install(
      FILES
      ${CMAKE_CURRENT_BINARY_DIR}/libCustomClassesDict_rdict.pcm
      ${CMAKE_CURRENT_BINARY_DIR}/libCustomClassesDict.rootmap
      DESTINATION lib/)
endif (${ROOT_VERSION} VERSION_GREATER "6.0")

```

More importantly the generate rootmap has some problems with the library name:

```auto
[libCustomClassesDict.so]
# List of selected classes
class AClass
header AClass.hpp

```

1. The library name includes the `Dict` suffix which was included to avoid a collision between target names in CMake from the `ROOT_GENERATE_DICTIONARY` and `add_library` commands. This suffix needs to be removed to allow the rootmap file to work properly.
2. The extension is `.so`, but the generated library has an extension `.dylib`. I did not manually specify the suffix, but this was decided by CMake automatically.

I’ve created a small project to demonstrate these issues at  
[https://github.com/ksmith0/root-cmake](https://github.com/ksmith0/root-cmake)

(This issue was previously discussed [here](https://root-forum.cern.ch/t/loading-a-library-from-a-script/24306/14). In addition, another issue with the include path was posted [here](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-include-path/24381).)

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [April 10, 2017, 7:13pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-rootmap/24382/2 "2017-04-10T19:13:55Z")

</div>

I suppose @mato will comment on this one as well…

Cheers, Bertrand.

---

<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 18, 2017, 2:58pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-rootmap/24382/3 "2017-04-18T14:58:37Z")

</div>

@mato Any suggestions here? Just wanted to ping you before I forget about it.

---

<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 19, 2017, 8:57am UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-rootmap/24382/4 "2017-04-19T08:57:44Z")

</div>

> [@ksmith](#):
>
> First the rootmap file needs to be installed manually, the fact that the rootmap and pcm files were being generated was not clear to me at first. Not sure there is anyway around this, but here is a short solution:

I agree that this is not very convenient. In the case of build ROOT itself, for which we use the same macro, we do the installation automatically. I’ll see if we can add an option to declare the installation automatically.

> [@ksmith](#):
>
> More importantly the generate rootmap has some problems with the library name:

Thanks for reporting. This is certainly a bug. I have created a JIRA issue [Loading...](https://sft.its.cern.ch/jira/browse/ROOT-8752)

---

<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 19, 2017, 1:55pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-rootmap/24382/5 "2017-04-19T13:55:45Z")

</div>

Thanks for the update.

---

<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 19, 2017, 2:51pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-rootmap/24382/6 "2017-04-19T14:51:22Z")

</div>

> [@ksmith](#):
>
> 1. The library name includes the Dict suffix which was included to avoid a collision between target names in CMake from the ROOT\_GENERATE\_DICTIONARY and add\_library commands. This suffix needs to be removed to allow the rootmap file to work properly.

This issue is resolved by specifying the `MODULE` option to `ROOT_GENERATE_DICTIONARY`. (@mato provided this solution in one of the bug [comments](https://sft.its.cern.ch/jira/browse/ROOT-8752?focusedCommentId=80840&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-80840).)

```cmake
ROOT_GENERATE_DICTIONARY(CustomClassesDict
   ../include/AClass.hpp
   LINKDEF ../include/CustomClasses_LinkDef.h
   MODULE CustomClasses)

```

---

<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:** [May 3, 2017, 2:51pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-rootmap/24382/7 "2017-05-03T14:51:22Z")

</div>

Closed on May 3, 2017, 2:51pm UTC

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