# Integrating ROOT into CMake project / Making your CMakeLists.txt ROOT alike

**URL:** <https://root-forum.cern.ch/t/integrating-root-into-cmake-project-making-your-cmakelists-txt-root-alike/44083>\
**Category:** ROOT\
**Tags:** documentation\
**Created:** [March 20, 2021, 8:57pm UTC](https://root-forum.cern.ch/t/integrating-root-into-cmake-project-making-your-cmakelists-txt-root-alike/44083 "2021-03-20T20:57:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eddy\_Offermann](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eddy_offermann/32/25079_2.png) [@Eddy\_Offermann](https://root-forum.cern.ch/u/Eddy_Offermann)\
**Post date:** [March 20, 2021, 8:57pm UTC](https://root-forum.cern.ch/t/integrating-root-into-cmake-project-making-your-cmakelists-txt-root-alike/44083/1 "2021-03-20T20:57:16Z")

</div>

[Here](https://root.cern/manual/integrate_root_into_my_cmake_project/), it is described how to add ROOT to your CMake project, however I am still missing some important elements.

- How do I make sure that I am using the same compiler/linking settings as the installed ROOT. My current solution is:

```auto
set (CMAKE_MODULE_PATH "<path_to_ROOT_module_directory>")
include(CheckCompiler)

```

However, I do not know which ROOT defined variable I should use to get the  
correct module path, something like ROOT\_MODULE\_PATH ?

- It would be great to get the same library extensions as ROOT libraries have, on  
Apple the default is “.dylib”. However, ROOT library extensions are “.so” and so it is in the rootmap files. I failed to get the right extension in the rootmap file

- One of the ROOT’s CMake targets is to move the headers of the many libraries to a central location, which is quite helpful for accessing them in other projects. Despite using for my library creation the macro ROOT\_STANDARD\_LIBRARY\_PACKAGE, my headers do not move.  
I figured out that adding

```auto
get_property(__allHeaders GLOBAL PROPERTY ROOT_HEADER_TARGETS)
get_property(__allBuiltins GLOBAL PROPERTY ROOT_BUILTIN_TARGETS)
add_custom_target(move_headers ALL DEPENDS ${ __allHeaders} ${__ allBuiltins})

```

to my CMakeLists.txt does the magic.  
Is this the proper way to accomplish this ?

-Eddy

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [March 22, 2021, 8:20am UTC](https://root-forum.cern.ch/t/integrating-root-into-cmake-project-making-your-cmakelists-txt-root-alike/44083/2 "2021-03-22T08:20:43Z")

</div>

I guess @oshadura should know the answers to your questions.  
Then we put these answers in the page you are referring to.

---

<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 5, 2021, 8:20am UTC](https://root-forum.cern.ch/t/integrating-root-into-cmake-project-making-your-cmakelists-txt-root-alike/44083/3 "2021-04-05T08:20:59Z")

</div>

Closed on April 5, 2021, 8:20am UTC

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