Reconciling mixed X11 paths on MacOS -- how?

In a 2023 forum post, Ben Morgan wrote:

Is there an officially approved way to reconcile such mixed paths? In my own CMakeCache.txt file, I see this problem:

X11_X11_xcb_INCLUDE_PATH:PATH=/opt/homebrew/include
X11_X11_xcb_LIB:FILEPATH=/opt/homebrew/lib/libX11-xcb.dylib
X11_XRes_INCLUDE_PATH:PATH=/usr/X11R6/include
X11_XRes_LIB:FILEPATH=/usr/X11R6/lib/libXRes.dylib
X11_XShm_INCLUDE_PATH:PATH=/opt/homebrew/include
X11_XSync_INCLUDE_PATH:PATH=/opt/homebrew/include
X11_Xaccessrules_INCLUDE_PATH:PATH=/usr/X11R6/include
X11_Xaccessstr_INCLUDE_PATH:PATH=/opt/homebrew/include

and so on. Should I edit CMakeCache.txt directly, doing something like

sed -i.bak -e s@/usr/X11R6@/opt/homebrew@ CMakeCache.txt?

or should I rerun cmake with higher level -D options so that CMake will do the reconciliation for me?

Not tested across all possible combinations of options, but if you run

cmake -DCMAKE_PREFIX_PATH=/opt/X11 -DGEANT4_USE_OPENGL_X11 <otheropts>

this should pick up the XQuartz header/libs over the Homebrew ones without preventing using Homebrew for other dependencies. As said though, I haven’t tested this fully, but it should pick up a consistent set at least.

Note as with all CMake cache settings, you should start from a fresh build, or delete the cache file before running the above. If you want to retain the CMakeCache.txt then that sed would be the only way to do this (and be careful not to overwrite Homebrew paths you want!).

Thanks, Ben! Your reply suggests to me that we want the XQuartz version for everything, rather than the Homebrew installation. Is that right?

I’d rather keep my CMakeCache.txt, since I’ve got a lot of additional settings, so I’ll run the sed -i version, and then do a ccmake configure-and-generate cycle before rebuilding.

Oh, well. I did the change, did the rebuild (and I love that the CMake generated Makefiles are smart enough to know that only the G4OpenGL targets depend on the modified variables!).

Unfortunately, I’m not getting any better graphical response than before. I can’t use OGL without running full Qt user interface (which I hate for everything except graphics). That’s outside the scope of this post, so I’m marking Ben’s Solution and am done with this. Thank you again, Ben!