Skip to content

Commit

Permalink
Clean up GPU/headless messaging
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Dolan <[email protected]>
  • Loading branch information
michdolan committed Jul 13, 2020
1 parent 14d8772 commit b63d696
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,16 @@ option(OCIO_WARNING_AS_ERROR "Set build error level for CI testing" OFF)
include(PackageUtils)

if(OCIO_BUILD_GPU_TESTS OR OCIO_BUILD_APPS)
set(OCIO_GL_ENABLED ON)
set(OCIO_GL_ENABLED ON)
set(OCIO_USE_GLVND OFF)
set(OCIO_EGL_HEADLESS OFF)

find_package(OpenGL COMPONENTS OpenGL)
if(NOT OpenGL_OpenGL_FOUND AND NOT OPENGL_GLU_FOUND)
package_root_message(OpenGL)
message(WARNING "OpenGL not found; GPU rendering disabled")
set(OCIO_GL_ENABLED OFF)
endif()

# OpenGL_egl_Library is defined iff GLVND is supported (CMake 10+).
if(OPENGL_egl_LIBRARY)
message(STATUS "GLVND supported")
set(OCIO_USE_GLVND ON)
else()
message(STATUS "GLVND not supported; legacy OpenGL libraries used")
set(OCIO_USE_GLVND OFF)
endif()

if(NOT APPLE)
find_package(GLEW)
if(NOT GLEW_FOUND)
Expand All @@ -120,34 +112,40 @@ if(OCIO_BUILD_GPU_TESTS OR OCIO_BUILD_APPS)
set(OCIO_GL_ENABLED OFF)
endif()

set(OCIO_EGL_HEADLESS OFF)
if(${OCIO_USE_HEADLESS})
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
if(NOT ${OCIO_USE_GLVND})
message(STATUS "Can't find EGL without GLVND support; can't render headlessly")
set(OCIO_USE_HEADLESS OFF)
set(OCIO_EGL_HEADLESS OFF)
else()
set(OCIO_EGL_HEADLESS ON)
find_package(OpenGL COMPONENTS EGL)
if(NOT OpenGL_EGL_FOUND)
message(WARNING "EGL component missing; can't render headlessly")
if(NOT OCIO_GL_ENABLED)
message(WARNING "GPU rendering disabled")
else()
# OpenGL_egl_Library is defined iff GLVND is supported (CMake 10+).
if(OPENGL_egl_LIBRARY)
message(STATUS "GLVND supported")
set(OCIO_USE_GLVND ON)
else()
message(STATUS "GLVND not supported; legacy OpenGL libraries used")
endif()

if(OCIO_USE_HEADLESS)
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
if(NOT OCIO_USE_GLVND)
message(STATUS "Can't find EGL without GLVND support; can't render headlessly")
set(OCIO_USE_HEADLESS OFF)
set(OCIO_EGL_HEADLESS OFF)
else()
add_compile_definitions(OCIO_HEADLESS_ENABLED)
find_package(OpenGL COMPONENTS EGL)
if(NOT OpenGL_EGL_FOUND)
message(WARNING "EGL component missing; can't render headlessly")
set(OCIO_USE_HEADLESS OFF)
else()
add_compile_definitions(OCIO_HEADLESS_ENABLED)
set(OCIO_EGL_HEADLESS ON)
message(STATUS "EGL enabled")
endif()
endif()
else()
message(WARNING "OS system is not Linux; can't render headlessly")
endif()
else()
message(WARNING "OS system is not Linux; can't render headlessly")
set(OCIO_EGL_HEADLESS OFF)
endif()
endif()
endif()

message(STATUS "GL enabled " ${OCIO_GL_ENABLED})
message(STATUS "EGL enabled " ${OCIO_EGL_HEADLESS})

###############################################################################
# Optimization / internal linking preferences

Expand Down

0 comments on commit b63d696

Please sign in to comment.