# Root\_generate\_dictionary set output directory

**URL:** <https://root-forum.cern.ch/t/root-generate-dictionary-set-output-directory/59039>\
**Category:** ROOT\
**Tags:** cmake\
**Created:** [April 17, 2024, 9:08pm UTC](https://root-forum.cern.ch/t/root-generate-dictionary-set-output-directory/59039 "2024-04-17T21:08:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaubee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/ecb155/32.png) [@vaubee](https://root-forum.cern.ch/u/vaubee)\
**Post date:** [April 17, 2024, 9:08pm UTC](https://root-forum.cern.ch/t/root-generate-dictionary-set-output-directory/59039/1 "2024-04-17T21:08:02Z")

</div>

Hi,

I’m trying to have a project that depends on ROOT compile with cmake. I created a CMakeLists.txt file that uses root\_generate\_dictionary to create all the needed dictionaries, but I don’t want them to end up in the main build directory but rather have them show up in a sub-directory. Using `CMAKE_LIBRARY_OUTPUT_DIRECTORY` redirects where the libraries, rootmap, and pcm files are generated, but it does not affect the G\_\_.cxx files. How can I make sure that these files are also put in a subdirectory (same one as the libraries or a different one)?

---

<div class="post-metadata">

**Author:** ![mczurylo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mczurylo/32/33269_2.png) [@mczurylo](https://root-forum.cern.ch/u/mczurylo)\
**Post date:** [April 18, 2024, 9:42am UTC](https://root-forum.cern.ch/t/root-generate-dictionary-set-output-directory/59039/2 "2024-04-18T09:42:55Z")

</div>

Hi @vaubee,

thank you for your question, maybe @bellenot could help here?

Cheers,  
Marta

---

<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 18, 2024, 10:15am UTC](https://root-forum.cern.ch/t/root-generate-dictionary-set-output-directory/59039/3 "2024-04-18T10:15:21Z")

</div>

I think the only way is to copy the file using `file(COPY ...)`, something like this for example:

```auto
ROOT_GENERATE_DICTIONARY(G__Dict MyHeader.h LINKDEF MyLinkDef.h)
file(COPY G__Dict.cxx DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/subdirectory)

```

---

<div class="post-metadata">

**Author:** ![vaubee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/ecb155/32.png) [@vaubee](https://root-forum.cern.ch/u/vaubee)\
**Post date:** [April 19, 2024, 2:06pm UTC](https://root-forum.cern.ch/t/root-generate-dictionary-set-output-directory/59039/4 "2024-04-19T14:06:58Z")

</div>

I see, so there is no way to move these files out of the main build directory. Because using `file(COPY ...)` and `file(REMOVE ...)` would cause the next `make` to simply re-build it.

---

<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 19, 2024, 2:13pm UTC](https://root-forum.cern.ch/t/root-generate-dictionary-set-output-directory/59039/5 "2024-04-19T14:13:38Z")

</div>

Well yes, but is it really a big issue?

---

<div class="post-metadata">

**Author:** ![vaubee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/ecb155/32.png) [@vaubee](https://root-forum.cern.ch/u/vaubee)\
**Post date:** [April 19, 2024, 4:48pm UTC](https://root-forum.cern.ch/t/root-generate-dictionary-set-output-directory/59039/6 "2024-04-19T16:48:21Z")

</div>

No, not really.

It does clutter up the build directory quite a lot (there are 22 dictionaries being built), which doesn’t seem to be in line with the normal behavior of cmake which hides all the intermediate files in the CMakeFiles directory. I just wanted to make certain I didn’t miss any obvious option to hide those files.

---

<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:** [April 24, 2024, 10:45pm UTC](https://root-forum.cern.ch/t/root-generate-dictionary-set-output-directory/59039/7 "2024-04-24T22:45:03Z")

</div>

You might be able to achieve this by having the call to `ROOT_GENERATE_DICTIONARY` inside a `CMakeList.txt` that is in a subdirectory of your source.

---

<div class="post-metadata">

**Author:** ![vaubee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/ecb155/32.png) [@vaubee](https://root-forum.cern.ch/u/vaubee)\
**Post date:** [April 26, 2024, 4:54pm UTC](https://root-forum.cern.ch/t/root-generate-dictionary-set-output-directory/59039/8 "2024-04-26T16:54:13Z")

</div>

Yes, that would probably work. I have a sub-library that is included using `FetchContent` and the dictionaries of this library are in the `_deps/<library-name>-build` directory.

---

<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 10, 2024, 4:55pm UTC](https://root-forum.cern.ch/t/root-generate-dictionary-set-output-directory/59039/9 "2024-05-10T16:55:04Z")

</div>

Closed on May 10, 2024, 4:55pm UTC

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