Skip to content

Commit

Permalink
CMake: improved handling of OpenGL and X11 libraries on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Feb 5, 2024
1 parent 7962896 commit cb4fb07
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
19 changes: 12 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -469,35 +469,40 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
endif()
endif()

if(PLATFORM_MACOS)
if(PLATFORM_LINUX)
find_library(OPENGL_LIBRARY GL)
if (NOT OPENGL_LIBRARY)
message(FATAL_ERROR "Failed to find OpenGL library")
endif()
elseif(PLATFORM_MACOS)
find_library(APP_KIT AppKit)
if (NOT APP_KIT)
message(FATAL_ERROR "AppKit not found")
message(FATAL_ERROR "Failed to find AppKit framework")
endif()
elseif(PLATFORM_IOS)
find_library(CORE_FOUNDATION CoreFoundation)
if(NOT CORE_FOUNDATION)
message(FATAL_ERROR "Cannot find CoreFoundation framework")
message(FATAL_ERROR "Failed to find CoreFoundation framework")
endif()

find_library(FOUNDATION Foundation)
if(NOT FOUNDATION)
message(FATAL_ERROR "Cannot find Foundation framework")
message(FATAL_ERROR "Failed to find Foundation framework")
endif()

find_library(OPENGLES OpenGLES)
if(NOT OPENGLES)
message(FATAL_ERROR "Cannot find OpenGLES framework")
message(FATAL_ERROR "Failed to find OpenGLES framework")
endif()
elseif(PLATFORM_TVOS)
find_library(CORE_FOUNDATION CoreFoundation)
if(NOT CORE_FOUNDATION)
message(FATAL_ERROR "Cannot find CoreFoundation framework")
message(FATAL_ERROR "Failed to find CoreFoundation framework")
endif()

find_library(FOUNDATION Foundation)
if(NOT FOUNDATION)
message(FATAL_ERROR "Cannot find Foundation framework")
message(FATAL_ERROR "Failed to find Foundation framework")
endif()
endif()

Expand Down
3 changes: 2 additions & 1 deletion Graphics/Archiver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ if(GL_SUPPORTED OR GLES_SUPPORTED)
if(PLATFORM_WIN32)
target_link_libraries(Diligent-Archiver-static PRIVATE GLEW::glew opengl32.lib)
elseif(PLATFORM_LINUX)
target_link_libraries(Diligent-Archiver-static PRIVATE GLEW::glew GL X11)
find_package(X11 REQUIRED)
target_link_libraries(Diligent-Archiver-static PRIVATE GLEW::glew ${OPENGL_LIBRARY} X11::X11)
elseif(PLATFORM_MACOS)
find_package(OpenGL REQUIRED)
target_link_libraries(Diligent-Archiver-static PRIVATE GLEW::glew ${OPENGL_LIBRARY})
Expand Down
3 changes: 2 additions & 1 deletion Graphics/GraphicsEngineOpenGL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ if(PLATFORM_WIN32)
elseif(PLATFORM_ANDROID)
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPENDENCIES} GLESv3 EGL)
elseif(PLATFORM_LINUX)
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPENDENCIES} GLEW::glew GL X11)
find_package(X11 REQUIRED)
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPENDENCIES} GLEW::glew ${OPENGL_LIBRARY} X11::X11)
elseif(PLATFORM_MACOS)
find_package(OpenGL REQUIRED)
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPENDENCIES} GLEW::glew ${OPENGL_LIBRARY})
Expand Down

0 comments on commit cb4fb07

Please sign in to comment.