I am using cmake v 3.22.1.
On our MacOS systems we want to use XQuartz for X11 and OpenGL includes and libs, which are installed in /opt/X11/include and /opt/X11/lib, respectively. My CMakeLists.txt calls FindOpenGL and FindX11, but the result is
X11_INCLUDE_DIR: /usr/local/include;/usr/X11R6/include
X11_LIBRARIES: /usr/local/lib/libSM.dylib;/usr/local/lib/libICE.dylib;/usr/local/lib/libX11.dylib;/usr/local/lib/libXext.dylib
OPENGL_INCLUDE_DIR: /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/OpenGL.framework
OPENGL_LIBRARY: /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/OpenGL.framework;/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/OpenGL.framework
So those are the wrong places - they should be in /opt/X11.
Based on FindX11 and FindOpenGL documentation I try this before calling the FindModules:
if (APPLE)
set(X11_X11_INCLUDE_PATH /opt/X11/include/)
set(X11_X11_LIB /opt/X11/lib/)
set(OPENGL_INCLUDE_DIR /opt/X11/include/)
set(OPENGL_gl_LIBRARY /opt/X11/lib/)
endif()
And the result is:
X11_INCLUDE_DIR: /opt/X11/include/;/usr/local/include;/usr/X11R6/include
X11_LIBRARIES: /opt/X11/lib/;/usr/local/lib/libXext.dylib
OPENGL_INCLUDE_DIR: /opt/X11/include/
OPENGL_LIBRARIES: /opt/X11/lib/;/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Frameworks/OpenGL.framework
I also get these warnings:
WARNING: Target "mbgsfShared" requests linking to directory "/opt/X11/lib/". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "mbgsfShared" requests linking to directory "/opt/X11/lib/". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "mbgrdviz" requests linking to directory "/opt/X11/lib/". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "mbgrdviz" requests linking to directory "/opt/X11/lib/". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "mbedit" requests linking to directory "/opt/X11/lib/". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "mbeditviz" requests linking to directory "/opt/X11/lib/". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "mbeditviz" requests linking to directory "/opt/X11/lib/". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "mbnavadjust" requests linking to directory "/opt/X11/lib/". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "mbnavadjust" requests linking to directory "/opt/X11/lib/". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "mbnavedit" requests linking to directory "/opt/X11/lib/". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "mbnavedit" requests linking to directory "/opt/X11/lib/". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "mbvelocitytool" requests linking to directory "/opt/X11/lib/". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "mbvelocitytool" requests linking to directory "/opt/X11/lib/". Targets may link only to libraries. CMake is dropping the item.
So how do I force FindX11 and FindOpenGL to look in /opt/X11/include and /opt/X11/lib, without generating these warnings?
Thanks
Tom