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 e709ef6
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 24 deletions.
2 changes: 0 additions & 2 deletions examples/CMakeLists.txt
@@ -1,5 +1,3 @@


# CLI based examples
if (NOT SFML_OS_IOS)
if(SFML_BUILD_NETWORK)
Expand Down
2 changes: 1 addition & 1 deletion examples/opengl/CMakeLists.txt
Expand Up @@ -16,5 +16,5 @@ endif()
sfml_add_example(opengl GUI_APP
SOURCES ${SRC}
BUNDLE_RESOURCES ${RESOURCES}
DEPENDS sfml-graphics OpenGL
DEPENDS sfml-graphics
RESOURCES_DIR resources)
8 changes: 7 additions & 1 deletion examples/window/CMakeLists.txt
Expand Up @@ -4,7 +4,13 @@ set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/window)
# all source files
set(SRC ${SRCROOT}/Window.cpp)

if(SFML_OPENGL_ES)
set(DEPENDENCY GLES)
else()
set(DEPENDENCY OpenGL)
endif()

# define the window target
sfml_add_example(window GUI_APP
SOURCES ${SRC}
DEPENDS sfml-window OpenGL)
DEPENDS sfml-window ${DEPENDENCY})
11 changes: 3 additions & 8 deletions src/SFML/Graphics/CMakeLists.txt
Expand Up @@ -113,13 +113,8 @@ 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)
target_link_libraries(sfml-graphics PRIVATE "-framework OpenGLES")
endif()
# Target GLES already defined for Window component so no sfml_find_package() here
target_link_libraries(sfml-graphics PRIVATE GLES)
else()
# Target OpenGL already defined for Window component so no sfml_find_package() here
target_link_libraries(sfml-graphics PRIVATE OpenGL)
Expand All @@ -131,7 +126,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 e709ef6

Please sign in to comment.