# Cmake: root\_generate\_dictionary naming rootmap and pcm file using target output name instead of target name?

**URL:** <https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114>\
**Category:** ROOT\
**Tags:** cmake\
**Created:** [May 31, 2023, 2:04pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114 "2023-05-31T14:04:26Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![laurent.aphecetche](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/laurent.aphecetche/32/24627_2.png) [@laurent.aphecetche](https://root-forum.cern.ch/u/laurent.aphecetche)\
**Post date:** [May 31, 2023, 2:04pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114/1 "2023-05-31T14:04:26Z")

</div>

Hi,

Is there a way to get the CMake macro `root_generate_dictionary` to name its output files (rootmap and pcm) after the target output name (`OUTPUT_NAME` target property) instead of the default/current target name itself ?

Thanks

_ROOT Version:_ \>= 6.28  
_Platform:_ Not relevant  
_Compiler:_ Not relevant

* * *

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [June 1, 2023, 7:19am UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114/2 "2023-06-01T07:19:32Z")

</div>

Dear @laurent.aphecetche ,

Maybe @bellenot knows more about this.

Cheers,  
Vincenzo

---

<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:** [June 1, 2023, 7:21am UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114/3 "2023-06-01T07:21:14Z")

</div>

Hi @laurent.aphecetche, I have to check, but what problem do you want to solve exactly?

---

<div class="post-metadata">

**Author:** ![laurent.aphecetche](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/laurent.aphecetche/32/24627_2.png) [@laurent.aphecetche](https://root-forum.cern.ch/u/laurent.aphecetche)\
**Post date:** [June 1, 2023, 8:41am UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114/4 "2023-06-01T08:41:34Z")

</div>

Hi,

Well, I have a project specific cmake helper function `xxx_add_library` which encapsulates a series of steps that one usually have to do to create a library (call cmake own `add_library`, sets a few properties, create a root dictionary if there’s a linkdef, install the lib, etc…).  
In this function I have something like :

```auto
set_target_properties(${target} PROPERTIES OUTPUT_NAME ${basename}

...

root_generate_dictionary(G__${basename}
       "${A_ROOT_DICTIONARY}" ${A_LINKDEF} MODULE ${target})

```

where `target` is computed from some `basename` (e.g. adding a project-specific prefix), and thus is not the name of the output artifact. Doing so I end up with 3 files installed, e.g. if `basename=MyLib` and `target=prefix-long-name-derived-from-MyLib`:

`libMyLib.dylib|so`  
`prefix-long-name-derived-from-MyLib_rdict.pcm`  
`prefix-long-name-derived-from-MyLib.rootmap`

whereas I’d like to have :

`libMyLib.dylib|so`  
`libMyLib_rdict.pcm`  
`libMyLib.rootmap`

---

<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:** [June 1, 2023, 8:43am UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114/5 "2023-06-01T08:43:09Z")

</div>

OK, thanks for the explanation. We’ll see what can be done

---

<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:** [June 1, 2023, 2:47pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114/6 "2023-06-01T14:47:46Z")

</div>

So looking at the `ROOT_GENERATE_DICTIONARY` in [RootMacros.cmake](https://github.com/root-project/root/blob/master/cmake/modules/RootMacros.cmake#L541-L544), I see:

```auto
  set(library_name ${libprefix}${library_target_name}${libsuffix})
  set(newargs -s ${library_output_dir}/${library_name})
  set(rootmap_name ${library_output_dir}/${libprefix}${library_target_name}.rootmap)
  set(pcm_name ${library_output_dir}/${libprefix}${library_target_name}_rdict.pcm)

```

So it looks like they should have the same base name, or did I miss something?

---

<div class="post-metadata">

**Author:** ![laurent.aphecetche](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/laurent.aphecetche/32/24627_2.png) [@laurent.aphecetche](https://root-forum.cern.ch/u/laurent.aphecetche)\
**Post date:** [June 1, 2023, 3:21pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114/7 "2023-06-01T15:21:48Z")

</div>

as far as I understand this part of the `RootMacros.cmake` the problem is that `${library_target_name}` is the value of the `MODULE` parameter given to the macro and _not_ the artifact name (set with `OUTPUT_NAME`)

---

<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:** [June 2, 2023, 6:21am UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114/8 "2023-06-02T06:21:55Z")

</div>

OK, thanks, I’ll investigate.

---

<div class="post-metadata">

**Author:** ![laurent.aphecetche](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/laurent.aphecetche/32/24627_2.png) [@laurent.aphecetche](https://root-forum.cern.ch/u/laurent.aphecetche)\
**Post date:** [June 8, 2023, 1:09pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114/9 "2023-06-08T13:09:50Z")

</div>

Hi,

An extra question if I may …  
Do I understand correctly that the rootmap files are actually no longer needed (since root 6.16 or something) ? (and if that’s indeed the case, then why root\_generate\_dictionary is generating them) ?

Thanks,

---

<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:** [June 8, 2023, 1:10pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114/10 "2023-06-08T13:10:37Z")

</div>

I think @Axel can give more details about that

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [June 8, 2023, 3:22pm UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114/11 "2023-06-08T15:22:24Z")

</div>

Since then, we have to mode for dictionary. The legacy mode that still require rootmap file and for the header files to present/accessible at run-time. The new C++ module based mode where instead of the rootmap file and header we generate the pre-compiled module file corresponding to those headers. Use the `MODULE` option to request the new mode.

---

<div class="post-metadata">

**Author:** ![laurent.aphecetche](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/laurent.aphecetche/32/24627_2.png) [@laurent.aphecetche](https://root-forum.cern.ch/u/laurent.aphecetche)\
**Post date:** [June 9, 2023, 8:10am UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114/12 "2023-06-09T08:10:58Z")

</div>

Hi Philippe,

Hum… I do use the MODULE option (see above) but still I have both outputs.

---

<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:** [June 23, 2023, 8:11am UTC](https://root-forum.cern.ch/t/cmake-root-generate-dictionary-naming-rootmap-and-pcm-file-using-target-output-name-instead-of-target-name/55114/13 "2023-06-23T08:11:10Z")

</div>

Closed on June 23, 2023, 8:11am UTC

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