CMake error building B1 on macOS11.5

Hi all,

I upgrade my mac to macOS11.5 and I’ve installed geant4.10.07 with cmake:

cmake -DCMAKE_INSTALL_PREFIX = /Users/chloe/g4/geant4.10.07.p02-install -DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_OPENGL_X11=ON -DGEANT4_INSTALL_EXAMPLES=ON -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON /Users/chloe/g4/geant4.10.07.p02

make

make install

which I think worked fine, the installation was successful.

But I got this error when try build example B1 with the following lines:

cmake -DGEANT4_PREFIX_PATH=/Users/chloe/g4/geant4.10.07.p02-install/lib64/Geant4-10.7.2 ../g4/geant4.10.07.p02/examples/basic/B1

CMake Error in CMakeLists.txt:
  Imported target "Geant4::G4OpenGL" includes non-existent path

    "/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/OpenGL.framework"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.

I checked my /Library/Developer/CommandLineTools/SDKs folder and indeed it only contains MacOSX.sdk,MacOSX10.15.sdk,MacOSX11.1.sdk,MacOSX11.3.sdk,MacOSX11.sdk, NO MacOSX11.0.sdk exists. My understanding is that the path in cmakelists.txt points to an older version sdk. Any way to edit it and is that all?

Thanks in advance!

Just to confirm, is that the exact command you used? The correct one would be:

cmake -DCMAKE_PREFIX_PATH=/Users/chloe/g4/geant4.10.07.p02-install/ ../g4/geant4.10.07.p02/examples/basic/B1

It’s possible that cmake has picked up an old install of Geant4 somewhere on the system. That can be checked by looking at the value of Geant4_DIR in the CMakeCache.txt in the directory where you’re building example B1. It should be a subdirectory of the directory where your new install of Geant4 is.

Hi Benjamin,

Yes I used the exact command and I guess I confused the two methods, -DGeant4_DIR and -DCMAKE_PREFIX_PATH. And I checked the CmakeCache.txt and located the following lines,

//The directory containing a CMake configuration file for Geant4.
Geant4_DIR:PATH=/usr/local/lib/Geant4-10.6.2

//Include for OpenGL on OS X
OPENGL_INCLUDE_DIR:PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/OpenGL.framework

//OpenGL library for OS X
OPENGL_gl_LIBRARY:FILEPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/OpenGL.framework

//GLU library for OS X (usually same as OpenGL library)
OPENGL_glu_LIBRARY:FILEPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/System/Library/Frameworks/OpenGL.framework

I replaced the MacOSX11.0.sdk with MacOSX11.3.sdk but Geant4-10.6.2 cannot be edited.
Then I tried rebuild the exampleB1 in …/B1/build,

chloe@chloes-MBP build % cmake .. 
CMake Warning at /usr/local/lib/Geant4-10.6.2/Geant4PackageCache.cmake:9 (message):
  Value of 'OPENGL_INCLUDE_DIR' is already set and does not match value set
  at Geant4 build-time
Call Stack (most recent call first):
  /usr/local/lib/Geant4-10.6.2/Geant4PackageCache.cmake:33 (geant4_set_and_check_package_variable)
  /usr/local/lib/Geant4-10.6.2/Geant4Config.cmake:241 (include)
  CMakeLists.txt:16 (find_package)


CMake Warning at /usr/local/lib/Geant4-10.6.2/Geant4PackageCache.cmake:9 (message):
  Value of 'OPENGL_gl_LIBRARY' is already set and does not match value set at
  Geant4 build-time
Call Stack (most recent call first):
  /usr/local/lib/Geant4-10.6.2/Geant4PackageCache.cmake:34 (geant4_set_and_check_package_variable)
  /usr/local/lib/Geant4-10.6.2/Geant4Config.cmake:241 (include)
  CMakeLists.txt:16 (find_package)


CMake Warning at /usr/local/lib/Geant4-10.6.2/Geant4PackageCache.cmake:9 (message):
  Value of 'OPENGL_glu_LIBRARY' is already set and does not match value set
  at Geant4 build-time
Call Stack (most recent call first):
  /usr/local/lib/Geant4-10.6.2/Geant4PackageCache.cmake:35 (geant4_set_and_check_package_variable)
  /usr/local/lib/Geant4-10.6.2/Geant4Config.cmake:241 (include)
  CMakeLists.txt:16 (find_package)


-- Configuring done
-- Generating done
-- Build files have been written to: /Users/chloe/g4/geant4.10.07.p02/examples/basic/B1/build

chloe@chloes-MBP build % make    
[ 12%] Building CXX object CMakeFiles/exampleB1.dir/exampleB1.cc.o
/Users/chloe/g4/geant4.10.07.p02/examples/basic/B1/exampleB1.cc:33:10: fatal error: 'G4RunManagerFactory.hh' file not found
#include "G4RunManagerFactory.hh"
         ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/exampleB1.dir/exampleB1.cc.o] Error 1
make[1]: *** [CMakeFiles/exampleB1.dir/all] Error 2
make: *** [all] Error 2

I did some research in the forum and found a previous answer from you :grinning:saying G4RunManagerFactory.hh is only available from version 10.7. I have 10.7 version on my machine but cmake is still looking for the old install. Could you give any clue on the solution?

Thank you very much for your reply!

Thanks for the info! To get the example using the fresh install of Geant4 10.7, go into the directory where you’re building it and delete the CMakeCache.txt file (you can also remove all files, but that one should be sufficient). Then run:

cmake -DCMAKE_PREFIX_PATH=/Users/chloe/g4/geant4.10.07.p02-install/ ../g4/geant4.10.07.p02/examples/basic/B1

CMake caches information, so this is the most reliable way to force re-finding of Geant4. Check that the CMakeCache.txt file now contains the correct vale for Geant4_DIR.

I’d guess the install in /usr/local is from Homebrew? If so, you may want to do brew unlink geant4 to ensure it won’t be automatically picked up in the future.

Yes that worked! And no…I don’t have homebrew on my laptop. I tried building example B2 and it worked smoothly for now. Thank you so much for your help!

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