Skip to content

Commit

Permalink
Fixed CMake configuration issue with EGL and GLES and wrong include h…
Browse files Browse the repository at this point in the history
…eader order for EGL
  • Loading branch information
eXpl0it3r committed Apr 13, 2019
1 parent 4043f71 commit 75401a3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
11 changes: 5 additions & 6 deletions src/SFML/Graphics/CMakeLists.txt
Expand Up @@ -113,12 +113,11 @@ endif()

# find external libraries
if(SFML_OPENGL_ES)
if(SFML_OS_LINUX)
sfml_find_package(EGL INCLUDE "EGL_INCLUDE_DIR" LINK "EGL_LIBRARY")
sfml_find_package(GLES INCLUDE "GLES_INCLUDE_DIR" LINK "GLES_LIBRARY")
target_link_libraries(sfml-graphics PRIVATE EGL GLES)
elseif(SFML_OS_IOS)
if(SFML_OS_IOS)
target_link_libraries(sfml-graphics PRIVATE "-framework OpenGLES")
else()
# Target GLES already defined for Window component so no sfml_find_package() here
target_link_libraries(sfml-graphics PRIVATE GLES)
endif()
else()
# Target OpenGL already defined for Window component so no sfml_find_package() here
Expand All @@ -131,7 +130,7 @@ else()
endif()

if(SFML_OS_ANDROID)
target_link_libraries(sfml-graphics PRIVATE z EGL GLESv1_CM)
target_link_libraries(sfml-graphics PRIVATE z)
elseif(SFML_OS_IOS)
target_link_libraries(sfml-graphics PRIVATE z bz2)
endif()
Expand Down
19 changes: 9 additions & 10 deletions src/SFML/Window/CMakeLists.txt
Expand Up @@ -251,14 +251,19 @@ endif()

if(SFML_OPENGL_ES)
if(SFML_OS_IOS)
sfml_add_external(OpenGL LINK "-framework OpenGLES")
elseif(SFML_OS_ANDROID)
sfml_add_external(OpenGL LINK "EGL" "GLESv1_CM")
sfml_add_external(GLES LINK "-framework OpenGLES")
else()
sfml_find_package(GLES INCLUDE "GLES_INCLUDE_DIR" LINK "GLES_LIBRARY")

sfml_find_package(EGL INCLUDE "EGL_INCLUDE_DIR" LINK "EGL_LIBRARY")
target_link_libraries(sfml-window PRIVATE EGL)
endif()

target_link_libraries(sfml-window PRIVATE GLES)
else()
sfml_find_package(OpenGL INCLUDE "OPENGL_INCLUDE_DIR" LINK "OPENGL_gl_LIBRARY")
target_link_libraries(sfml-window PRIVATE OpenGL)
endif()
target_link_libraries(sfml-window PRIVATE OpenGL)

if(SFML_OS_WINDOWS AND NOT SFML_COMPILER_MSVC)
include(CheckIncludeFile)
Expand All @@ -268,12 +273,6 @@ if(SFML_OS_WINDOWS AND NOT SFML_COMPILER_MSVC)
endif()
endif()

if(SFML_OPENGL_ES AND SFML_OS_LINUX)
sfml_find_package(EGL INCLUDE "EGL_INCLUDE_DIR" LINK "EGL_LIBRARY")
sfml_find_package(GLES INCLUDE "GLES_INCLUDE_DIR" LINK "GLES_LIBRARY")
target_link_libraries(sfml-window PRIVATE EGL GLES)
endif()

if(SFML_OS_LINUX)
sfml_find_package(UDev INCLUDE "UDEV_INCLUDE_DIR" LINK "UDEV_LIBRARIES")
target_link_libraries(sfml-window PRIVATE UDev)
Expand Down
1 change: 1 addition & 0 deletions src/SFML/Window/EGLCheck.cpp
Expand Up @@ -28,6 +28,7 @@
////////////////////////////////////////////////////////////
#include <SFML/Window/EGLCheck.hpp>
#include <SFML/System/Err.hpp>
#include <EGL/egl.h>


namespace sf
Expand Down
1 change: 0 additions & 1 deletion src/SFML/Window/EGLCheck.hpp
Expand Up @@ -29,7 +29,6 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.hpp>
#include <EGL/egl.h>
#include <string>


Expand Down
6 changes: 5 additions & 1 deletion src/SFML/Window/EglContext.hpp
Expand Up @@ -33,7 +33,11 @@
#include <SFML/Window/EGLCheck.hpp>
#include <SFML/Window/GlContext.hpp>
#include <SFML/OpenGL.hpp>

#include <SFML/Window/WindowStyle.hpp> // Prevent conflict with macro None from Xlib
#include <EGL/egl.h>
#ifdef SFML_SYSTEM_LINUX
#include <X11/Xlib.h>
#endif

namespace sf
{
Expand Down

0 comments on commit 75401a3

Please sign in to comment.