Example B1 Building Errors with Cmake

I setup openGl to work with Geant4 and now I’m trying to run exampled B1, which I previously had no errors building. Now when I run cmake
-DGeant4_DIR="%HOMEPATH%\Geant4\geant4_10_06-install\lib\Geant4-10.6.1" “%HOMEPATH%\Geant4\geant4_10_06-install\share\Geant4-10.6.1\examples\basic\B1”

I get the error

CMake Error at /Users/Stephen/Geant4/geant4_10_06-install/lib/Geant4-10.6.1/Geant4PackageCache.cmake:18 (geant4_set_and_check_package_variable):
geant4_set_and_check_package_variable Macro invoked with incorrect
arguments for macro named: geant4_set_and_check_package_variable
Call Stack (most recent call first):
/Users/Stephen/Geant4/geant4_10_06-install/lib/Geant4-10.6.1/Geant4Config.cmake:240 (include)
CMakeLists.txt:14 (find_package)

– Found OpenGL: opengl32
– Configuring incomplete, errors occurred!
See also “C:/Users/Stephen/Geant4/geant4_10_06-install/share/Geant4-10.6.1/examples/basic/B1-build/CMakeFiles/CMakeOutput.log”.

I read in another post that this was due to an issue locating the openGl libraries but the answer was very vague and I can’t figure out how to fix it. Any help would be much appreciated

Apologies, this is a bug in the Geant4PackageCache.cmake for windows. There’ll be a patch in due course, but for now, open the /Users/Stephen/Geant4/geant4_10_06-install/lib/Geant4-10.6.1/Geant4PackageCache.cmake file, and remove the geant4_set_and_check_package_variable lines that refer to OPENGL_INCLUDE_DIR and OPENGL_gl_LIBRARY. Save it, then try reconfiguring your build of B1 (no need to rebuild/install Geant4 itself).

1 Like

Thanks very much for the prompt reply. Running into another issue now that I am unable to pen the .cmake file to edit it? Not really sure why. If you could explain how to open a .cmake file I’d really appreciate it as I can’t seem to find any explanations online

.cmake files are just plain text, so can be opened in your editor of choice.

Got it. It’s building now with no errors, thanks very much for the help!

1 Like