# CMake error while making Garfield

**URL:** <https://root-forum.cern.ch/t/cmake-error-while-making-garfield/46588>\
**Category:** Newbie\
**Created:** [August 31, 2021, 10:59am UTC](https://root-forum.cern.ch/t/cmake-error-while-making-garfield/46588 "2021-08-31T10:59:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lorenzo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@Lorenzo](https://root-forum.cern.ch/u/Lorenzo)\
**Post date:** [August 31, 2021, 10:59am UTC](https://root-forum.cern.ch/t/cmake-error-while-making-garfield/46588/1 "2021-08-31T10:59:00Z")

</div>

i am trying to install Garfiel++, but when I run cmake i get this error output:

```auto
>cmake $GARFIELD_HOME
The CXX compiler identification is GNU 9.3.0
-- The Fortran compiler identification is GNU 9.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working Fortran compiler: /usr/bin/gfortran
-- Check for working Fortran compiler: /usr/bin/gfortran -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/bin/gfortran supports Fortran 90
-- Checking whether /usr/bin/gfortran supports Fortran 90 -- yes
-- Install path: /opt/applications/garfield/install
-- If you want to change this path call cmake -DCMAKE_INSTALL_PREFIX=my_install_path ...
CMake Error at CMakeLists.txt:71 (find_package):
  By not providing "FindROOT.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "ROOT", but
  CMake did not find one.

  Could not find a package configuration file provided by "ROOT" (requested
  version 6.0) with any of the following names:

    ROOTConfig.cmake
    root-config.cmake

  Add the installation prefix of "ROOT" to CMAKE_PREFIX_PATH or set
  "ROOT_DIR" to a directory containing one of the above files. If "ROOT"
  provides a separate development package or SDK, be sure it has been
  installed.

-- Configuring incomplete, errors occurred!
See also "/opt/applications/garfield/CMakeFiles/CMakeOutput.log".

```

ROOTSYS is set when I launch the command and my root version is 6.14, I also tried with another root version that I have installed, which is v.6.22, but I get the same output.

I also tried to follow the suggestion from the log, so I set ROOT\_DIR to a directroy containing ROOTConfig.cmake:

`export ROOT_DIR=/opt/applications/root_src/installdir/cmake`

but when I run cmake again I get exactly the same error

thanks in advance  
Lorenzo

---

<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:** [August 31, 2021, 11:33am UTC](https://root-forum.cern.ch/t/cmake-error-while-making-garfield/46588/2 "2021-08-31T11:33:15Z")

</div>

May be @hschindl can help.

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [August 31, 2021, 11:48am UTC](https://root-forum.cern.ch/t/cmake-error-while-making-garfield/46588/3 "2021-08-31T11:48:54Z")

</div>

Adding @caiazza to the thread…

Did you source the `thisroot.sh` script before executing the cmake command? Can you attach the `CMakeCache.txt` file in the build folder?

---

<div class="post-metadata">

**Author:** ![Lorenzo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@Lorenzo](https://root-forum.cern.ch/u/Lorenzo)\
**Post date:** [August 31, 2021, 1:44pm UTC](https://root-forum.cern.ch/t/cmake-error-while-making-garfield/46588/5 "2021-08-31T13:44:33Z")

</div>

Yes, thisroot.sh is correctly sourced.  
And here’s the file:  
[CMakeCache.txt](https://root-forum.cern.ch/uploads/short-url/AfLndPzP3THYIzckXkAOs7Glrvd.txt) (17.0 KB)

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [September 1, 2021, 7:22am UTC](https://root-forum.cern.ch/t/cmake-error-while-making-garfield/46588/6 "2021-09-01T07:22:17Z")

</div>

Hi,  
what platform are you using?

Perhaps @caiazza or @mato can help?

---

<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:** [September 1, 2021, 8:18am UTC](https://root-forum.cern.ch/t/cmake-error-while-making-garfield/46588/7 "2021-09-01T08:18:31Z")

</div>

Sourcing `thisroot.sh` should have defined the variable `CMAKE_PREFIX_PATH` that should contain the location of your ROOT installation, which is then used by make of Garfield++ to find ROOT.  
What is the value of `CMAKE_PREFIX_PATH` for you?

---

<div class="post-metadata">

**Author:** ![Lorenzo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/4da419/32.png) [@Lorenzo](https://root-forum.cern.ch/u/Lorenzo)\
**Post date:** [September 1, 2021, 8:26am UTC](https://root-forum.cern.ch/t/cmake-error-while-making-garfield/46588/8 "2021-09-01T08:26:21Z")

</div>

I solved the problem by modifying by hand the file CMakeCache.txt, telling ROOT\_DIR where to point, then I had also some problems with file permissions which caused problems.  
The complete solution was:  
1-checking that $ROOTSYS is correctly pointing to the installation directory of root  
2-make sure that the access to $GARFIELD\_HOME directory is allowed for every user, not only with root privilege (this is maybe not necessary?)  
3-check where $ROOT\_DIR is pointing in CMakeCache.txt, and make sure is pointing to a directory where ROOTconfig.cmake is present. The same problem arises for Geant4config.cmake, and the solution is analogous.  
Thanks to all of you for your help,  
Lorenzo
