Fix optional OpenGL enablement

Software renderer requires OpenGL, so AlberCore requries OpenGL.

The QT frontend currently requires OpenGL due to `ScreenWidget`
This commit is contained in:
Wunkolo 2024-03-10 13:49:50 -07:00
parent 772573527c
commit b147df6094

View file

@ -72,6 +72,9 @@ endif()
if(ENABLE_QT_GUI)
find_package(Qt6 REQUIRED COMPONENTS Widgets)
if(NOT ENABLE_OPENGL)
message(FATAL_ERROR "Qt frontend requires OpenGL")
endif()
endif()
set(SDL_STATIC ON CACHE BOOL "" FORCE)
@ -309,7 +312,6 @@ set(RENDERER_GL_SOURCE_FILES "") # Empty by default unless we are compiling with
set(RENDERER_VK_SOURCE_FILES "") # Empty by default unless we are compiling with the VK renderer
if(ENABLE_OPENGL)
find_package(OpenGL REQUIRED COMPONENTS OpenGL EGL GLX)
# This may look weird but opengl.hpp is our header even if it's in the third_party folder
set(RENDERER_GL_INCLUDE_FILES third_party/opengl/opengl.hpp
@ -419,9 +421,9 @@ if(ANDROID)
endif()
if(BUILD_HYDRA_CORE)
add_library(AlberCore SHARED ${ALL_SOURCES} src/hydra_core.cpp)
target_compile_definitions(AlberCore PRIVATE PANDA3DS_HYDRA_CORE=1)
include_directories(third_party/hydra_core/include)
add_library(AlberCore SHARED ${ALL_SOURCES} src/hydra_core.cpp)
else()
add_library(AlberCore STATIC ${ALL_SOURCES})
endif()
@ -458,7 +460,7 @@ endif()
if(ENABLE_OPENGL)
target_compile_definitions(AlberCore PUBLIC "PANDA3DS_ENABLE_OPENGL=1")
target_link_libraries(AlberCore PRIVATE OpenGL::OpenGL OpenGL::EGL OpenGL::GLX resources_renderer_gl)
target_link_libraries(AlberCore PRIVATE resources_renderer_gl)
endif()
if(ENABLE_VULKAN)
@ -502,6 +504,11 @@ if(ENABLE_QT_GUI)
if(LINUX OR FREEBSD)
find_package(X11 REQUIRED)
target_link_libraries(Alber PRIVATE ${X11_LIBRARIES})
if(ENABLE_OPENGL)
find_package(OpenGL REQUIRED COMPONENTS OpenGL EGL GLX)
target_link_libraries(Alber PRIVATE OpenGL::OpenGL OpenGL::EGL OpenGL::GLX)
endif()
endif()
qt_add_resources(AlberCore "app_images"