premake4: add option to force dynamic loading of OpenGL and X11

--force_dlopen_opengl and --force_dlopen_x11
This commit is contained in:
Erwin Coumans
2014-08-18 22:19:34 -07:00
parent bf1bd07636
commit d93b27f16c
2 changed files with 22 additions and 8 deletions

View File

@@ -14,8 +14,8 @@
configuration {"MacOSX"} configuration {"MacOSX"}
links { "OpenGL.framework"} links { "OpenGL.framework"}
configuration {"not Windows", "not MacOSX"} configuration {"not Windows", "not MacOSX"}
if os.isdir("/usr/include") and os.isfile("/usr/include/GL/gl.h") then if not _OPTIONS["force_dlopen_opengl"] and (os.isdir("/usr/include") and os.isfile("/usr/include/GL/gl.h")) then
links {"GL","GLU"} links {"GL"}
else else
print("No GL/gl.h found, using dynamic loading of GL using glew") print("No GL/gl.h found, using dynamic loading of GL using glew")
defines {"GLEW_INIT_OPENGL11_FUNCTIONS=1"} defines {"GLEW_INIT_OPENGL11_FUNCTIONS=1"}
@@ -57,16 +57,17 @@
end end
if os.is("Linux") then if os.is("Linux") then
configuration{"Linux"} configuration{"Linux"}
--if os.isdir("/usr/include") and os.isfile("/usr/include/GL/glew.h") then 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"} links {"GLEW"}
-- else else
--print("Using static glew and dynamic loading of glx functions") print("Using static glew and dynamic loading of glx functions")
defines { "GLEW_STATIC","GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1"} defines { "GLEW_STATIC","GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1"}
includedirs { includedirs {
projectRootDir .. "btgui/OpenGLWindow/GlewWindows" projectRootDir .. "btgui/OpenGLWindow/GlewWindows"
} }
files { projectRootDir .. "btgui/OpenGLWindow/GlewWindows/glew.c"} files { projectRootDir .. "btgui/OpenGLWindow/GlewWindows/glew.c"}
-- end links {"dl"}
end
end end
configuration{} configuration{}
@@ -74,7 +75,7 @@
function initX11() function initX11()
if os.is("Linux") then 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"} links{"X11","pthread"}
else else
print("No X11/X.h found, using dynamic loading of X11") print("No X11/X.h found, using dynamic loading of X11")

View File

@@ -12,6 +12,19 @@
act = _ACTION act = _ACTION
end 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 newoption
{ {
trigger = "midi", trigger = "midi",