# Bringing (part) of ROOT in a project using FetchContent?

**URL:** <https://root-forum.cern.ch/t/bringing-part-of-root-in-a-project-using-fetchcontent/58733>\
**Category:** ROOT\
**Tags:** cmake\
**Created:** [March 26, 2024, 11:14am UTC](https://root-forum.cern.ch/t/bringing-part-of-root-in-a-project-using-fetchcontent/58733 "2024-03-26T11:14:07Z")\
**Posts on this page:** 3\
**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:** [March 26, 2024, 11:14am UTC](https://root-forum.cern.ch/t/bringing-part-of-root-in-a-project-using-fetchcontent/58733/1 "2024-03-26T11:14:07Z")

</div>

Dear all,

Is it in principle possible to bring in (part of) ROOT in a CMake-based project using FetchContent ?

Trying this in my `dependencies.cmake` file :

```auto
FetchContent_Declare(ROOT
   URL https://root.cern/download/root_v6.30.04.source.tar.gz
   FIND_PACKAGE_ARGS)

```

The first error I get is :

```auto
CMake Error at build-dev/_deps/root-src/cmake/modules/SetROOTVersion.cmake:21 (file):
  file failed to open for reading (No such file or directory):

    /Users/laurent/git.km3net.de/laphecetche/toashort-formats/core/foundation/inc/ROOT/RVersion.hxx
Call Stack (most recent call first):
  build-dev/_deps/root-src/cmake/modules/SetROOTVersion.cmake:45 (SET_VERSION_FROM_FILE)
  build-dev/_deps/root-src/cmake/modules/SetROOTVersion.cmake:99 (SET_ROOT_VERSION)
  build-dev/_deps/root-src/CMakeLists.txt:77 (include)

```

Seeing the path that is looked for (the top project that is trying to bring Root as a dependency with FetchContent and not Root project) I suspect Root is not 100% ready to be included like that (e.g. `SetROOTVersion.cmake` is using `CMAKE_SOURCE_DIR` while probably it should use `PROJECT_SOURCE_DIR` ?), but would like a confirmation 😉

---

<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:** [March 26, 2024, 11:50am UTC](https://root-forum.cern.ch/t/bringing-part-of-root-in-a-project-using-fetchcontent/58733/2 "2024-03-26T11:50:28Z")

</div>

Hi, I never tried that. Maybe @amadio knows more

---

<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 9, 2024, 11:51am UTC](https://root-forum.cern.ch/t/bringing-part-of-root-in-a-project-using-fetchcontent/58733/3 "2024-04-09T11:51:10Z")

</div>

Closed on April 9, 2024, 11:51am UTC

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