From d93b27f16cd9f549f13da9ab3baec6a7cde2c98e Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 18 Aug 2014 22:19:34 -0700 Subject: [PATCH] premake4: add option to force dynamic loading of OpenGL and X11 --force_dlopen_opengl and --force_dlopen_x11 --- build3/findOpenGLGlewGlut.lua | 17 +++++++++-------- build3/premake4.lua | 13 +++++++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/build3/findOpenGLGlewGlut.lua b/build3/findOpenGLGlewGlut.lua index cf8521c9d..bf0dfb42e 100644 --- a/build3/findOpenGLGlewGlut.lua +++ b/build3/findOpenGLGlewGlut.lua @@ -14,8 +14,8 @@ configuration {"MacOSX"} links { "OpenGL.framework"} configuration {"not Windows", "not MacOSX"} - if os.isdir("/usr/include") and os.isfile("/usr/include/GL/gl.h") then - links {"GL","GLU"} + if not _OPTIONS["force_dlopen_opengl"] and (os.isdir("/usr/include") and os.isfile("/usr/include/GL/gl.h")) then + links {"GL"} else print("No GL/gl.h found, using dynamic loading of GL using glew") defines {"GLEW_INIT_OPENGL11_FUNCTIONS=1"} @@ -57,16 +57,17 @@ end if os.is("Linux") then configuration{"Linux"} - --if os.isdir("/usr/include") and os.isfile("/usr/include/GL/glew.h") then - -- links {"GLEW"} - -- else - --print("Using static glew and dynamic loading of glx functions") + if not _OPTIONS["force_dlopen_opengl"] and (os.isdir("/usr/include") and os.isfile("/usr/include/GL/gl.h") and os.isfile("/usr/include/GL/glew.h")) then + links {"GLEW"} + else + print("Using static glew and dynamic loading of glx functions") defines { "GLEW_STATIC","GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1"} includedirs { projectRootDir .. "btgui/OpenGLWindow/GlewWindows" } files { projectRootDir .. "btgui/OpenGLWindow/GlewWindows/glew.c"} - -- end + links {"dl"} + end end configuration{} @@ -74,7 +75,7 @@ function initX11() if os.is("Linux") then - if os.isdir("/usr/include") and os.isfile("/usr/include/X11/X.h") then + if not _OPTIONS["force_dlopen_x11"] and (os.isdir("/usr/include") and os.isfile("/usr/include/X11/X.h")) then links{"X11","pthread"} else print("No X11/X.h found, using dynamic loading of X11") diff --git a/build3/premake4.lua b/build3/premake4.lua index 558681cd6..e0b9c72fe 100644 --- a/build3/premake4.lua +++ b/build3/premake4.lua @@ -12,6 +12,19 @@ act = _ACTION end + newoption + { + trigger = "force_dlopen_opengl", + description = "Dynamically load OpenGL (instead of static/dynamic linking)" + } + + newoption + { + trigger = "force_dlopen_x11", + description = "Dynamically load OpenGL (instead of static/dynamic linking)" + } + + newoption { trigger = "midi",