CMake error while making Garfield

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

>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

May be @hschindl can help.

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?

Yes, thisroot.sh is correctly sourced.
And here’s the file:
CMakeCache.txt (17.0 KB)

Hi,
what platform are you using?

Perhaps @caiazza or @mato can help?

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?

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