Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!
Geant4 Version: geant4-v11.2.2
_Operating System:_Mac OS
_Compiler/Version:_Apple clang version 15.0.0 (clang-1500.3.9.4)
_CMake Version:_cmake version 3.21.4
I am trying to build a new application based on the G01 example.
I have copied the directory and have made changes to the CMakeList.txt for the change of name.
When I run cmake it runs okay
cmake -DCMAKE_PREFIX_PATH=$G4INSTALL .
– Configuring done
– Generating done
– Build files have been written to: /Users/keithsloan/geant4-v11.2.2-Examples/KS_LGC01/build
But on subsequent make i get
keithsloan@Keiths-iMac-2 build % make
[ 25%] Building CXX object CMakeFiles/load_gdml_color.dir/load_gdml_color.cc.o
/Users/keithsloan/geant4-v11.2.2-Examples/KS_LGC01/load_gdml_color.cc:71:10: fatal error: ‘GeometryMoments.hh’ file not found #include “GeometryMoments.hh”
^~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/load_gdml_color.dir/load_gdml_color.cc.o] Error 1
make[1]: *** [CMakeFiles/load_gdml_color.dir/all] Error 2
So it looks like the CMakeList.txt needs extra info on where to find various include directories
In my experience you probably only need to change the final name at the bottom of the cmakelists file. You would probably have to share the rest of the changes you made but geant4 invludes are inherited from the main cmake file under the directory you installed the toolkit. Ie installDir/lib/cmake/Geant4
I create build under KS_LGC01
cd to build
Then do cmake -DGeant4_DIR=$G4DIR … -DCMAKE_PREFIX_PATH=$G4INSTALL .
and then make from there but the includes are in KS_LGC01/include
but not in KS_LGC01/build/include