Cmake questioning

Hello everybody,

I have a question about cmake command when i compile an example. My teacher told me that i have to make a variable “$geant4_envbindir” to be able to use the library and then write the following command : cmake -DGeant4_DIR=$geant4_envbindir /home/vanhee/Bureau/geant4.10.07.p03/examples/basic/B1/build/ and then use the command “make” to compile.
But, in my computer, it works without this variable and i can just write “cmake” and then “make” and it works. So my teacher wanted to know if it still necessary to use this command or if it is enough with the command “cmake”.
PS: I use manjaro and i installed Geant4 v11 from an AUR

If you’ve installed Geant4 though an AUR, i.e. as a system package, it’s almost certainly been installed in a location that CMake knows about already and so Geant4_DIR is not needed. You can double check that by looking at the contents of the CMakeCache.txt file in the location where you build exampleB1 and looking for the Geant4_DIR variable. If that’s a directory that’s somewhere under /usr or /opt, then it’s a system location. The defaults for where CMake looks for packages are documented here.

First, thank you for your fast answer.
That’s what i thought but there’s no Geant4_DIR variable in my CMakeCache.txt. Also, my teacher who works on Ubuntu did the same manipulation and it works too. So we are wondering if this Geant4_DIR is really needed.

I’ve tested this quickly on macOS (so using /usr/local as a system directory) with CMake 3.22. Here, I do get Geant4_DIR set in the CMakeCache.txt and pointing to /usr/local/lib/Geant4-11.0.0. There shouldn’t be a difference to 10.7.3, nor across systems/CMake versions.

I’m not sure therefore why there’s no Geant4_DIR set in what I’m guessing is/home/vanhee/Bureau/geant4.10.07.p03/examples/basic/B1/build/CMakeCache.txt. However, if the build is working, and the compile commands are showing the correct flags for include/link paths, then it should be o.k.!

I think too.

I am very grateful for the time you have given to answer my question.
Have a nice day.

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