Skip to content

Commit

Permalink
Merge r184954 - [CMake] Improve detection and usage of GL/GLES/EGL li…
Browse files Browse the repository at this point in the history
…braries.

https://bugs.webkit.org/show_bug.cgi?id=145408

Reviewed by Carlos Garcia Campos.

.:

* Source/cmake/FindEGL.cmake: Improve detection of EGL libraries.
* Source/cmake/FindGLES.cmake: Removed. It was used by the EGL port.
Remove it and make the EGL port use the improved FindOpenGLES2.cmake
instead.
* Source/cmake/FindOpenGL.cmake: Added. Add module to detect OpenGL
libraries. Detect also GLX libraries.
* Source/cmake/FindOpenGLES2.cmake: Improve detection of OpenGLES-v2
libraries. Use find_path() to get the include path.
* Source/cmake/OptionsEfl.cmake: Use now the improved FindOpenGLES2
module.
* Source/cmake/OptionsGTK.cmake: Set default value for ENABLE_GLES2
depending on the libraries found on the system.
Move the detection of GLX (and the include of CMakePushCheckState)
to FindOpenGL.cmake.
Ensure that we only define USE_GLX when we build with OpenGL
(but not with GLESv2).

Source/WebCore:

No new tests, no behavior changes.

* CMakeLists.txt: Ensure that we include the libraries and includes
for the GL/GLESv2/EGL libraries before including the ANGLE directories.
Define also any CFLAG that the system GL/GLESv2/EGL libraries may need.
* PlatformEfl.cmake: Remove some includes that are now unneeded,
because we are including now the EGL libraries on CMakeLists.txt
* PlatformGTK.cmake: Remove unneeded include (We are including the EGL
libraries now on CMakeLists.txt)
  • Loading branch information
clopez authored and carlosgcampos committed Jul 7, 2015
1 parent 5103635 commit a810bd4
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 61 deletions.
24 changes: 24 additions & 0 deletions ChangeLog
@@ -1,3 +1,27 @@
2015-05-28 Carlos Alberto Lopez Perez <clopez@igalia.com>

[CMake] Improve detection and usage of GL/GLES/EGL libraries.
https://bugs.webkit.org/show_bug.cgi?id=145408

Reviewed by Carlos Garcia Campos.

* Source/cmake/FindEGL.cmake: Improve detection of EGL libraries.
* Source/cmake/FindGLES.cmake: Removed. It was used by the EGL port.
Remove it and make the EGL port use the improved FindOpenGLES2.cmake
instead.
* Source/cmake/FindOpenGL.cmake: Added. Add module to detect OpenGL
libraries. Detect also GLX libraries.
* Source/cmake/FindOpenGLES2.cmake: Improve detection of OpenGLES-v2
libraries. Use find_path() to get the include path.
* Source/cmake/OptionsEfl.cmake: Use now the improved FindOpenGLES2
module.
* Source/cmake/OptionsGTK.cmake: Set default value for ENABLE_GLES2
depending on the libraries found on the system.
Move the detection of GLX (and the include of CMakePushCheckState)
to FindOpenGL.cmake.
Ensure that we only define USE_GLX when we build with OpenGL
(but not with GLESv2).

2015-05-15 Carlos Garcia Campos <cgarcia@igalia.com>

Unreviewed. Update OptionsGTK.cmake and NEWS for 2.8.3 release.
Expand Down
18 changes: 15 additions & 3 deletions Source/WebCore/CMakeLists.txt
Expand Up @@ -2954,18 +2954,30 @@ if (WTF_USE_3D_GRAPHICS)
# these include directories need to be added before the ANGLE directories.
if (OPENGL_FOUND)
list(APPEND WebCore_INCLUDE_DIRECTORIES
${OPENGL_INCLUDE_DIR}
${OPENGL_INCLUDE_DIRS}
)
list(APPEND WebCore_LIBRARIES
${OPENGL_gl_LIBRARY}
${OPENGL_LIBRARIES}
)
add_definitions(${OPENGL_DEFINITIONS})
elseif (OPENGLES2_FOUND)
list(APPEND WebCore_INCLUDE_DIRECTORIES
${OPENGLES2_INCLUDE_DIR}
${OPENGLES2_INCLUDE_DIRS}
)
list(APPEND WebCore_LIBRARIES
${OPENGLES2_LIBRARIES}
)
add_definitions(${OPENGLES2_DEFINITIONS})
endif ()

if (EGL_FOUND)
list(APPEND WebCore_INCLUDE_DIRECTORIES
${EGL_INCLUDE_DIRS}
)
list(APPEND WebCore_LIBRARIES
${EGL_LIBRARIES}
)
add_definitions(${EGL_DEFINITIONS})
endif ()

list(APPEND WebCore_INCLUDE_DIRECTORIES
Expand Down
17 changes: 17 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,20 @@
2015-05-28 Carlos Alberto Lopez Perez <clopez@igalia.com>

[CMake] Improve detection and usage of GL/GLES/EGL libraries.
https://bugs.webkit.org/show_bug.cgi?id=145408

Reviewed by Carlos Garcia Campos.

No new tests, no behavior changes.

* CMakeLists.txt: Ensure that we include the libraries and includes
for the GL/GLESv2/EGL libraries before including the ANGLE directories.
Define also any CFLAG that the system GL/GLESv2/EGL libraries may need.
* PlatformEfl.cmake: Remove some includes that are now unneeded,
because we are including now the EGL libraries on CMakeLists.txt
* PlatformGTK.cmake: Remove unneeded include (We are including the EGL
libraries now on CMakeLists.txt)

2015-05-07 Philip Chimento <philip.chimento@gmail.com>

[GTK] DrawingBuffer.h used outside of include guard
Expand Down
6 changes: 0 additions & 6 deletions Source/WebCore/PlatformGTK.cmake
Expand Up @@ -394,12 +394,6 @@ if (ENABLE_THREADED_COMPOSITOR)
)
endif ()

if (WTF_USE_EGL)
list(APPEND WebCore_LIBRARIES
${EGL_LIBRARY}
)
endif ()

if (WTF_USE_OPENGL_ES_2)
list(APPEND WebCore_SOURCES
platform/graphics/opengl/Extensions3DOpenGLES.cpp
Expand Down
26 changes: 20 additions & 6 deletions Source/cmake/FindEGL.cmake
Expand Up @@ -2,8 +2,9 @@
# Once done, this will define
#
# EGL_FOUND - system has EGL installed.
# EGL_INCLUDE_DIR - directories which contain the EGL headers.
# EGL_LIBRARY - libraries required to link against EGL.
# EGL_INCLUDE_DIRS - directories which contain the EGL headers.
# EGL_LIBRARIES - libraries required to link against EGL.
# EGL_DEFINITIONS - Compiler switches required for using EGL.
#
# Copyright (C) 2012 Intel Corporation. All rights reserved.
#
Expand All @@ -28,12 +29,25 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

find_path(EGL_INCLUDE_DIR NAMES EGL/egl.h)

find_package(PkgConfig)

pkg_check_modules(PC_EGL egl)

if (PC_EGL_FOUND)
set(EGL_DEFINITIONS ${PC_EGL_CFLAGS_OTHER})
endif ()

find_path(EGL_INCLUDE_DIRS NAMES EGL/egl.h
HINTS ${PC_EGL_INCLUDEDIR} ${PC_EGL_INCLUDE_DIRS}
)

set(EGL_NAMES ${EGL_NAMES} egl EGL)
find_library(EGL_LIBRARY NAMES ${EGL_NAMES})
find_library(EGL_LIBRARIES NAMES ${EGL_NAMES}
HINTS ${PC_EGL_LIBDIR} ${PC_EGL_LIBRARY_DIRS}
)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(EGL DEFAULT_MSG EGL_INCLUDE_DIR EGL_LIBRARY)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(EGL DEFAULT_MSG EGL_INCLUDE_DIRS EGL_LIBRARIES)

mark_as_advanced(EGL_INCLUDE_DIR EGL_LIBRARY)
mark_as_advanced(EGL_INCLUDE_DIRS EGL_LIBRARIES)
38 changes: 0 additions & 38 deletions Source/cmake/FindGLES.cmake

This file was deleted.

64 changes: 64 additions & 0 deletions Source/cmake/FindOpenGL.cmake
@@ -0,0 +1,64 @@
# - Try to Find OpenGL
# Once done, this will define
#
# OPENGL_FOUND - system has OpenGL installed.
# OPENGL_INCLUDE_DIRS - directories which contain the OpenGL headers.
# OPENGL_LIBRARIES - libraries required to link against OpenGL.
# OPENGL_DEFINITIONS - Compiler switches required for using OpenGL.
#
# Copyright (C) 2015 Igalia S.L.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


find_package(PkgConfig)

pkg_check_modules(PC_OPENGL gl)

if (PC_OPENGL_FOUND)
set(OPENGL_DEFINITIONS ${PC_OPENGL_CFLAGS_OTHER})
endif ()

find_path(OPENGL_INCLUDE_DIRS NAMES GL/gl.h
HINTS ${PC_OPENGL_INCLUDEDIR} ${PC_OPENGL_INCLUDE_DIRS}
)

set(OPENGL_NAMES ${OPENGL_NAMES} gl GL)
find_library(OPENGL_LIBRARIES NAMES ${OPENGL_NAMES}
HINTS ${PC_OPENGL_LIBDIR} ${PC_OPENGL_LIBRARY_DIRS}
)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENGL DEFAULT_MSG OPENGL_INCLUDE_DIRS OPENGL_LIBRARIES)

mark_as_advanced(OPENGL_INCLUDE_DIRS OPENGL_LIBRARIES)

if (OPENGL_FOUND)
# We don't use find_package for GLX because it is part of -lGL, unlike EGL. We need to
# have OPENGL_INCLUDE_DIRS as part of the directories check_include_files() looks for in
# case OpenGL is installed into a non-standard location.
include(CMakePushCheckState)
CMAKE_PUSH_CHECK_STATE()
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${OPENGL_INCLUDE_DIRS})
check_include_files("GL/glx.h" GLX_FOUND)
CMAKE_POP_CHECK_STATE()
endif ()
16 changes: 9 additions & 7 deletions Source/cmake/FindOpenGLES2.cmake
Expand Up @@ -9,17 +9,19 @@ find_package(PkgConfig)
pkg_check_modules(PC_OPENGLES2 glesv2)

if (PC_OPENGLES2_FOUND)
set(OPENGLES2_INCLUDE_DIRS ${PC_OPENGLES2_INCLUDE_DIRS})
set(OPENGLES2_DEFINITIONS ${PC_OPENGLES2_CFLAGS_OTHER})
else ()
find_path(OPENGLES2_INCLUDE_DIRS NAMES GLES2/gl2.h)
endif ()

find_library(OPENGLES2_LIBRARIES GLESv2
HINTS ${PC_OPENGLES2_LIBRARY_DIRS} ${PC_OPENGLES2_LIBDIR}
find_path(OPENGLES2_INCLUDE_DIRS NAMES GLES2/gl2.h
HINTS ${PC_OPENGLES2_INCLUDEDIR} ${PC_OPENGLES2_INCLUDE_DIRS}
)

set(OPENGLES2_NAMES ${OPENGLES2_NAMES} glesv2 GLESv2)
find_library(OPENGLES2_LIBRARIES NAMES ${OPENGLES2_NAMES}
HINTS ${PC_OPENGLES2_LIBDIR} ${PC_OPENGLES2_LIBRARY_DIRS}
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenGLES2 DEFAULT_MSG OPENGLES2_LIBRARIES OPENGLES2_INCLUDE_DIRS)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENGLES2 DEFAULT_MSG OPENGLES2_INCLUDE_DIRS OPENGLES2_LIBRARIES)

mark_as_advanced(OPENGLES2_INCLUDE_DIRS OPENGLES2_LIBRARY)
mark_as_advanced(OPENGLES2_INCLUDE_DIRS OPENGLES2_LIBRARIES)
2 changes: 1 addition & 1 deletion Source/cmake/OptionsGTK.cmake
Expand Up @@ -335,7 +335,7 @@ if (ENABLE_X11_TARGET)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${OPENGL_INCLUDE_DIR})
set(CMAKE_REQUIRED_INCLUDES ${REQUIRED_INCLUDES_OLD})

if (GLX_FOUND)
if (GLX_FOUND AND NOT ENABLE_GLES2)
set(WTF_USE_GLX 1)
endif ()
endif ()
Expand Down

0 comments on commit a810bd4

Please sign in to comment.