CMake: Build OpenGL ES (1&2) display modules

Also reorganizes Package.cmake a little, getting more of the
package discovery logic under the PackageConfig.cmake system.
This commit is contained in:
Sam Edwards 2018-10-22 01:58:24 -06:00
parent a585dcf9ad
commit 11a75eab99
12 changed files with 268 additions and 48 deletions

View File

@ -0,0 +1,27 @@
# Filename: FindEGL.cmake
# Authors: CFSworks (21 Oct, 2018)
#
# Usage:
# find_package(EGL [REQUIRED] [QUIET])
#
# Once done this will define:
# EGL_FOUND - system has EGL
# EGL_INCLUDE_DIR - the include directory containing EGL/egl.h
# EGL_LIBRARY - the library to link against for EGL
#
if(NOT EGL_INCLUDE_DIR)
find_path(EGL_INCLUDE_DIR "EGL/egl.h")
mark_as_advanced(EGL_INCLUDE_DIR)
endif()
if(NOT EGL_LIBRARY)
find_library(EGL_LIBRARY
NAMES "EGL")
mark_as_advanced(EGL_LIBRARY)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(EGL DEFAULT_MSG EGL_INCLUDE_DIR EGL_LIBRARY)

View File

@ -0,0 +1,27 @@
# Filename: FindOpenGLES1.cmake
# Authors: CFSworks (21 Oct, 2018)
#
# Usage:
# find_package(OpenGLES1 [REQUIRED] [QUIET])
#
# Once done this will define:
# OPENGLES1_FOUND - system has OpenGL ES 1.x
# OPENGLES1_INCLUDE_DIR - the include directory containing GLES/gl.h
# OPENGLES1_LIBRARY - the library to link against for OpenGL ES 1.x
#
if(NOT OPENGLES1_INCLUDE_DIR)
find_path(OPENGLES1_INCLUDE_DIR "GLES/gl.h")
mark_as_advanced(OPENGLES1_INCLUDE_DIR)
endif()
if(NOT OPENGLES1_LIBRARY)
find_library(OPENGLES1_LIBRARY
NAMES "GLESv1" "GLESv1_CM" "GLES_CM")
mark_as_advanced(OPENGLES1_LIBRARY)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenGLES1 DEFAULT_MSG OPENGLES1_INCLUDE_DIR OPENGLES1_LIBRARY)

View File

@ -0,0 +1,27 @@
# Filename: FindOpenGLES2.cmake
# Authors: CFSworks (21 Oct, 2018)
#
# Usage:
# find_package(OpenGLES2 [REQUIRED] [QUIET])
#
# Once done this will define:
# OPENGLES2_FOUND - system has OpenGL ES 2.x
# OPENGLES2_INCLUDE_DIR - the include directory containing GLES2/gl2.h
# OPENGLES2_LIBRARY - the library to link against for OpenGL ES 2.x
#
if(NOT OPENGLES2_INCLUDE_DIR)
find_path(OPENGLES2_INCLUDE_DIR "GLES2/gl2.h")
mark_as_advanced(OPENGLES2_INCLUDE_DIR)
endif()
if(NOT OPENGLES2_LIBRARY)
find_library(OPENGLES2_LIBRARY
NAMES "GLESv2")
mark_as_advanced(OPENGLES2_LIBRARY)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenGLES2 DEFAULT_MSG OPENGLES2_INCLUDE_DIR OPENGLES2_LIBRARY)

View File

@ -482,20 +482,6 @@ mark_as_advanced(SDL_LIBRARY)
mark_as_advanced(SDL_LIBRARY_TEMP)
# Is X11 insalled, and where?
find_package(X11 QUIET)
if(NOT X11_Xkb_FOUND OR NOT X11_Xutil_FOUND)
# Panda implicitly requires these supplementary X11 libs; if we can't find
# them, we just say we didn't find X11 at all.
set(X11_FOUND OFF)
endif()
package_option(X11
"Provides X-server support on Unix platforms. X11 may need to be linked
against for tinydisplay, but probably only on a Linux platform.")
# TODO: XF86DGA
# This defines if we have XF86DGA installed.
#find_package(XF86DGA QUIET)

View File

@ -155,24 +155,6 @@ endif()
# Now go through all the packages and report whether we have them.
show_packages()
if(HAVE_GTK2)
message("+ gtk+-2")
else()
message("- Did not find gtk+-2")
endif()
if(HAVE_GLES)
message("+ OpenGL ES 1")
else()
message("- Did not find OpenGL ES 1")
endif()
if(HAVE_GLES2)
message("+ OpenGL ES 2")
else()
message("- Did not find OpenGL ES 2")
endif()
if(HAVE_DX9)
message("+ DirectX9")
else()
@ -185,12 +167,6 @@ else()
message("- Not building Tinydisplay")
endif()
if(HAVE_X11)
message("+ X11")
else()
message("- Did not find X11")
endif()
if(HAVE_OPENCV)
message("+ OpenCV")
else()

View File

@ -300,9 +300,11 @@ endif()
#
# ------------ FreeType ------------
# ------------ UI libraries ------------
#
# Freetype
find_package(Freetype QUIET)
package_option(FREETYPE
@ -312,12 +314,14 @@ package_option(FREETYPE
config_package(FREETYPE "FreeType")
# GTK2
# Find and configure GTK
set(Freetype_FIND_QUIETLY TRUE) # Fix for builtin FindGTK2
set(GTK2_GTK_FIND_QUIETLY TRUE) # Fix for builtin FindGTK2
find_package(GTK2 QUIET COMPONENTS gtk)
#config_package(GTK2 "gtk+-2")
package_option(GTK2)
config_package(GTK2 "gtk+-2")
#
# ------------ Physics engines ------------
@ -377,18 +381,70 @@ package_option(GL
config_package(GL "OpenGL")
# OpenGL ES 1
find_package(OpenGLES1 QUIET)
package_option(GLES1
"Enable support for OpenGL ES 1.x rendering APIs."
FOUND_AS OPENGLES1)
config_package(GLES1 "OpenGL ES 1.x")
# OpenGL ES 2
find_package(OpenGLES2 QUIET)
package_option(GLES2
"Enable support for OpenGL ES 2.x rendering APIs."
FOUND_AS OPENGLES2)
config_package(GLES2 "OpenGL ES 2.x")
#
# ------------ Display APIs ------------
#
# X11
find_package(X11 QUIET)
if(NOT X11_Xkb_FOUND OR NOT X11_Xutil_FOUND)
# Panda implicitly requires these supplementary X11 libs; if we can't find
# them, we just say we didn't find X11 at all.
set(X11_FOUND OFF)
endif()
package_option(X11
"Provides X-server support on Unix platforms. X11 may need to be linked
against for tinydisplay, but probably only on a Linux platform.")
set(HAVE_GLX_AVAILABLE OFF)
if(HAVE_GL AND HAVE_X11 AND NOT APPLE)
set(HAVE_GLX_AVAILABLE ON)
endif()
option(HAVE_GLX "Enables GLX. Requires OpenGL and X11." ${HAVE_GLX_AVAILABLE})
if(HAVE_GLX AND NOT HAVE_GLX_AVAILABLE)
message(SEND_ERROR "HAVE_GLX manually set to ON but it is not available!")
endif()
if(HAVE_GLX)
config_package(X11 "X11 (with GLX)")
else()
config_package(X11 "X11 (without GLX)")
endif()
# EGL
find_package(EGL QUIET)
package_option(EGL
"Enable support for the Khronos EGL context management interface for
OpenGL ES. This is necessary to support OpenGL ES under X11.")
config_package(EGL "EGL")
########
# TODO #
########
# Find and configure OpenGL ES 1
#find_package(GLES)
#config_package(GLES COMMENT "OpenGL ES 1")
# Find and configure OpenGL ES 2
#find_package(GLES)
#config_package(GLES COMMENT "OpenGL ES 2")
# Find and configure DirectX 9
#find_package(DX9)
#config_package(DX9 COMMENT "DirectX9")

View File

@ -19,10 +19,13 @@ add_subdirectory(src/downloadertools)
add_subdirectory(src/dxml)
add_subdirectory(src/egg)
add_subdirectory(src/egg2pg)
add_subdirectory(src/egldisplay)
add_subdirectory(src/event)
add_subdirectory(src/express)
add_subdirectory(src/ffmpeg)
add_subdirectory(src/framework)
add_subdirectory(src/glesgsg)
add_subdirectory(src/gles2gsg)
add_subdirectory(src/glgsg)
add_subdirectory(src/glstuff)
add_subdirectory(src/glxdisplay)
@ -68,6 +71,8 @@ add_subdirectory(metalibs/panda)
add_subdirectory(metalibs/pandaegg)
add_subdirectory(metalibs/pandaexpress)
add_subdirectory(metalibs/pandagl)
add_subdirectory(metalibs/pandagles)
add_subdirectory(metalibs/pandagles2)
add_subdirectory(metalibs/pandaphysics)
# Now add the Python modules:

View File

@ -0,0 +1,9 @@
if(NOT HAVE_GLES1 OR NOT HAVE_EGL)
return()
endif()
add_metalib(pandagles ${MODULE_TYPE} pandagles.cxx
COMPONENTS p3egldisplay_gles1 p3glesgsg)
set_target_properties(pandagles PROPERTIES DEFINE_SYMBOL BUILDING_PANDAGLES)
install(TARGETS pandagles DESTINATION ${MODULE_DESTINATION})

View File

@ -0,0 +1,9 @@
if(NOT HAVE_GLES2 OR NOT HAVE_EGL)
return()
endif()
add_metalib(pandagles2 ${MODULE_TYPE} pandagles2.cxx
COMPONENTS p3egldisplay_gles2 p3gles2gsg)
set_target_properties(pandagles2 PROPERTIES DEFINE_SYMBOL BUILDING_PANDAGLES2)
install(TARGETS pandagles2 DESTINATION ${MODULE_DESTINATION})

View File

@ -0,0 +1,54 @@
if(NOT HAVE_EGL OR NOT HAVE_X11)
return()
endif()
if(NOT HAVE_GLES1 AND NOT HAVE_GLES2)
return()
endif()
set(P3EGLDISPLAY_HEADERS
config_egldisplay.h
eglGraphicsBuffer.h
eglGraphicsPipe.h eglGraphicsPipe.I
eglGraphicsPixmap.h
eglGraphicsStateGuardian.h eglGraphicsStateGuardian.I
eglGraphicsWindow.h eglGraphicsWindow.I
)
set(P3EGLDISPLAY_SOURCES
config_egldisplay.cxx
eglGraphicsBuffer.cxx
eglGraphicsPipe.cxx
eglGraphicsPixmap.cxx
eglGraphicsStateGuardian.cxx
eglGraphicsWindow.cxx
)
composite_sources(p3egldisplay P3EGLDISPLAY_SOURCES)
# We actually build this twice! Once for GLES1, once for GLES2.
if(HAVE_GLES1)
add_component_library(p3egldisplay_gles1 SYMBOL BUILDING_PANDAGLES
${P3EGLDISPLAY_HEADERS} ${P3EGLDISPLAY_SOURCES})
target_compile_definitions(p3egldisplay_gles1 PUBLIC OPENGLES_1)
target_link_libraries(p3egldisplay_gles1 p3glesgsg p3x11display
PKG::EGL PKG::GLES1)
if(NOT BUILD_METALIBS)
install(TARGETS p3egldisplay_gles1 DESTINATION lib)
endif()
endif()
if(HAVE_GLES2)
add_component_library(p3egldisplay_gles2 SYMBOL BUILDING_PANDAGLES2
${P3EGLDISPLAY_HEADERS} ${P3EGLDISPLAY_SOURCES})
target_compile_definitions(p3egldisplay_gles2 PUBLIC OPENGLES_2)
target_link_libraries(p3egldisplay_gles2 p3gles2gsg p3x11display
PKG::EGL PKG::GLES2)
if(NOT BUILD_METALIBS)
install(TARGETS p3egldisplay_gles2 DESTINATION lib)
endif()
endif()
install(FILES ${P3EGLDISPLAY_HEADERS} DESTINATION include/panda3d)

View File

@ -0,0 +1,22 @@
if(NOT HAVE_GLES2)
return()
endif()
set(P3GLES2GSG_HEADERS
config_gles2gsg.h
gles2gsg.h)
set(P3GLES2GSG_SOURCES
config_gles2gsg.cxx
gles2gsg.cxx)
composite_sources(p3gles2gsg P3GLES2GSG_SOURCES)
add_component_library(p3gles2gsg SYMBOL BUILDING_PANDAGLES2
${P3GLE2SGSG_HEADERS} ${P3GLES2GSG_SOURCES})
target_link_libraries(p3gles2gsg p3glstuff panda
PKG::GLES2)
if(NOT BUILD_METALIBS)
install(TARGETS p3gles2gsg DESTINATION lib RUNTIME DESTINATION bin)
endif()
install(FILES ${P3GLES2GSG_HEADERS} DESTINATION include/panda3d)

View File

@ -0,0 +1,22 @@
if(NOT HAVE_GLES1)
return()
endif()
set(P3GLESGSG_HEADERS
config_glesgsg.h
glesgsg.h)
set(P3GLESGSG_SOURCES
config_glesgsg.cxx
glesgsg.cxx)
composite_sources(p3glesgsg P3GLESGSG_SOURCES)
add_component_library(p3glesgsg SYMBOL BUILDING_PANDAGLES
${P3GLESGSG_HEADERS} ${P3GLESGSG_SOURCES})
target_link_libraries(p3glesgsg p3glstuff panda
PKG::GLES1)
if(NOT BUILD_METALIBS)
install(TARGETS p3glesgsg DESTINATION lib RUNTIME DESTINATION bin)
endif()
install(FILES ${P3GLESGSG_HEADERS} DESTINATION include/panda3d)