CMake: build p3headlessgl display module

This commit is contained in:
rdb
2026-01-31 15:23:50 +01:00
parent bddd9e15b9
commit d237037817
3 changed files with 60 additions and 4 deletions
+26 -1
View File
@@ -17,11 +17,19 @@ elseif(HAVE_COCOA)
set(PANDAGL_PIPE_TYPE "CocoaGLGraphicsPipe")
set(PANDAGL_PIPE_INCLUDE "cocoaGLGraphicsPipe.h")
elseif(HAVE_EGL)
list(APPEND PANDAGL_LINK_TARGETS p3egldisplay)
set(PANDAGL_PIPE_TYPE "eglGraphicsPipe")
if(HAVE_X11)
list(APPEND PANDAGL_LINK_TARGETS p3x11display)
endif()
else()
message("") # Add extra line before error
message(SEND_ERROR
"When compiling with OpenGL (HAVE_GL), at least one of:
HAVE_WGL, HAVE_COCOA, or HAVE_GLX must be defined.")
HAVE_WGL, HAVE_COCOA, HAVE_GLX, or HAVE_EGL must be defined.")
endif()
@@ -42,4 +50,21 @@ install(TARGETS pandagl
DESTINATION ${MODULE_DESTINATION}
ARCHIVE COMPONENT OpenGLDevel)
if(HAVE_EGL AND HAVE_GLX AND NOT WIN32 AND NOT APPLE)
# As a temporary solution for #1086, build this module, which we can use as a
# fallback to OpenGL for headless systems.
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "OpenGLDevel")
add_metalib(p3headlessgl ${MODULE_TYPE}
INCLUDE "eglGraphicsPipe.h"
INIT init_libpandagl pandagl.h
EXPORT int get_pipe_type_p3headlessgl "eglGraphicsPipe::get_class_type().get_index()"
COMPONENTS p3egldisplay_gl p3glgsg p3glstuff)
unset(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
install(TARGETS p3headlessgl
EXPORT OpenGL COMPONENT OpenGL
DESTINATION ${MODULE_DESTINATION}
ARCHIVE COMPONENT OpenGLDevel)
endif()
export_targets(OpenGL NAMESPACE "Panda3D::OpenGL::" COMPONENT OpenGLDevel)
+5
View File
@@ -5,6 +5,11 @@ if(HAVE_GL)
set(AUX_DISPLAYS "${AUX_DISPLAYS}\naux-display pandagl")
endif()
if(HAVE_GL AND HAVE_EGL AND HAVE_GLX)
# Fallback for headless systems.
set(AUX_DISPLAYS "${AUX_DISPLAYS}\naux-display p3headlessgl")
endif()
if(HAVE_DX9)
set(AUX_DISPLAYS "${AUX_DISPLAYS}\naux-display pandadx9")
endif()
+29 -3
View File
@@ -1,8 +1,8 @@
if(NOT HAVE_EGL OR NOT HAVE_X11)
if(NOT HAVE_EGL)
return()
endif()
if(NOT HAVE_GLES1 AND NOT HAVE_GLES2)
if(NOT HAVE_GLES1 AND NOT HAVE_GLES2 AND NOT HAVE_GL)
return()
endif()
@@ -26,7 +26,33 @@ set(P3EGLDISPLAY_SOURCES
composite_sources(p3egldisplay P3EGLDISPLAY_SOURCES)
# We actually build this twice! Once for GLES1, once for GLES2.
# We actually build this thrice! Once for GL, once for GLES1, once for GLES2.
if(HAVE_GL AND NOT WIN32 AND NOT APPLE)
add_component_library(p3egldisplay_gl SYMBOL BUILDING_PANDAGL
INIT init_libegldisplay config_egldisplay.h
${P3EGLDISPLAY_HEADERS} ${P3EGLDISPLAY_SOURCES})
target_link_libraries(p3egldisplay_gl p3glgsg
PKG::EGL PKG::GL)
if(HAVE_X11 AND NOT HAVE_GLX)
target_link_librarise(p3egldisplay_gl p3x11display)
target_compile_definitions(p3egldisplay_gl PUBLIC USE_X11)
else()
target_compile_definitions(p3egldisplay_gl PRIVATE EGL_NO_X11)
endif()
if(NOT BUILD_METALIBS)
install(TARGETS p3egldisplay_gl
EXPORT OpenGL COMPONENT OpenGL
DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d
ARCHIVE COMPONENT OpenGLDevel)
endif()
install(FILES ${P3EGLDISPLAY_HEADERS} COMPONENT OpenGLDevel DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/panda3d)
endif()
if(HAVE_GLES1)
add_component_library(p3egldisplay_gles1 SYMBOL BUILDING_PANDAGLES
INIT init_libegldisplay config_egldisplay.h