File glew-2.2.0-fix-cmake.patch of Package glew

From c090f00bb5eabca6830d1fa26b53fb7e851ddeb4 Mon Sep 17 00:00:00 2001
From: Nigel Stewart <nigels@nigels.com>
Date: Sun, 10 Jan 2021 11:50:29 +1000
Subject: [PATCH 01/14] EGLEW: Wayland wl_display and wl_resource declarations
 for WL_bind_wayland_display

(cherry picked from commit d68cb0314990d375e75a8d5d6692a4d4f0efde7e)
---
 auto/src/eglew_head.h | 4 ++++
 1 file changed, 4 insertions(+)

Index: glew-2.2.0/auto/src/eglew_head.h
===================================================================
--- glew-2.2.0.orig/auto/src/eglew_head.h
+++ glew-2.2.0/auto/src/eglew_head.h
@@ -78,6 +78,11 @@ typedef khronos_stime_nanoseconds_t EGLn
 struct EGLClientPixmapHI;
 struct AHardwareBuffer;
 
+/* Wayland types for WL_bind_wayland_display purposes */
+struct wl_buffer;
+struct wl_display;
+struct wl_resource;
+
 #define EGL_DONT_CARE                     ((EGLint)-1)
 
 #define EGL_NO_CONTEXT                    ((EGLContext)0)
Index: glew-2.2.0/build/cmake/CMakeLists.txt
===================================================================
--- glew-2.2.0.orig/build/cmake/CMakeLists.txt
+++ glew-2.2.0/build/cmake/CMakeLists.txt
@@ -1,21 +1,12 @@
+cmake_minimum_required(VERSION 3.16)
+project(glew LANGUAGES C)
+
 if ( NOT DEFINED CMAKE_BUILD_TYPE )
   set( CMAKE_BUILD_TYPE Release CACHE STRING "Build type" )
 endif ()
 
-project (glew C)
-
-cmake_minimum_required (VERSION 2.8.12)
-
 include(GNUInstallDirs)
 
-if(POLICY CMP0003)
-  cmake_policy (SET CMP0003 NEW)
-endif()
-
-if(POLICY CMP0042)
-  cmake_policy (SET CMP0042 NEW)
-endif()
-
 set(CMAKE_DEBUG_POSTFIX d)
 
 option (BUILD_UTILS "utilities" ON)
@@ -24,6 +15,9 @@ option (GLEW_OSMESA "OSMesa mode" OFF)
 if (APPLE)
     option (BUILD_FRAMEWORK "Build Framework bundle for OSX" OFF)
 endif ()
+option (GLEW_X11 "X11 mode" ON)
+option (GLEW_EGL "EGL mode" OFF)
+option (BUILD_SHARED_LIBS "install/link shared instead of static libs" ON)
 
 set (GLEW_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..)
 
@@ -42,9 +36,17 @@ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CM
 
 find_package (OpenGL REQUIRED)
 
+# prefer GLVND
+if (OPENGL_opengl_LIBRARY)
+  set (GLEW_LIBRARIES ${OPENGL_opengl_LIBRARY})
+else ()
+  set (GLEW_LIBRARIES ${OPENGL_gl_LIBRARY})
+endif ()
+
 # X11 required except for Windows and Apple OSX platforms
-if (NOT WIN32 AND NOT APPLE)
+if (GLEW_X11 AND NOT WIN32 AND NOT APPLE)
   find_package (X11)
+  list (APPEND GLEW_LIBRARIES ${OPENGL_glx_LIBRARY} ${X11_LIBRARIES})
 endif()
 
 if (WIN32)
@@ -54,8 +56,6 @@ else ()
   set (DLL_PREFIX lib)
 endif ()
 
-set (GLEW_LIBRARIES ${OPENGL_LIBRARIES} ${X11_LIBRARIES})
-
 add_definitions (-DGLEW_NO_GLU)
 
 #### Regal mode ####
@@ -79,7 +79,7 @@ if (GLEW_OSMESA)
     set (OSMESA_LIB_NAME OSMesa)
   endif ()
   add_definitions (-DGLEW_OSMESA)
-  set (GLEW_LIBRARIES ${OSMESA_LIB_NAME} ${OPENGL_LIBRARIES})
+  list (APPEND GLEW_LIBRARIES ${OSMESA_LIB_NAME})
   set (X11_LIBRARIES)
 endif ()
 
@@ -87,17 +87,22 @@ endif ()
 
 if (GLEW_EGL AND UNIX)
   add_definitions (-DGLEW_EGL)
-  if (OpenGL::EGL)
+  if (NOT OpenGL_EGL_FOUND)
     message (FATAL_ERROR "EGL library set but not found.")
-  endif()
-  set (GLEW_LIBRARIES ${OPENGL_LIBRARIES} ${OPENGL_egl_LIBRARY})
+  endif ()
+  list (APPEND GLEW_LIBRARIES ${OPENGL_egl_LIBRARY})
 endif ()
 
 #### GLEW ####
 
 include_directories (${GLEW_DIR}/include ${X11_INCLUDE_DIR})
 
-set (GLEW_PUBLIC_HEADERS_FILES ${GLEW_DIR}/include/GL/wglew.h ${GLEW_DIR}/include/GL/glew.h ${GLEW_DIR}/include/GL/glxew.h)
+set (GLEW_PUBLIC_HEADERS_FILES
+  ${GLEW_DIR}/include/GL/wglew.h
+  ${GLEW_DIR}/include/GL/glew.h
+  ${GLEW_DIR}/include/GL/glxew.h
+  ${GLEW_DIR}/include/GL/eglew.h
+)
 set (GLEW_SRC_FILES ${GLEW_DIR}/src/glew.c)
 
 if (WIN32)
@@ -148,31 +153,24 @@ endif()
 target_link_libraries (glew LINK_PUBLIC ${GLEW_LIBRARIES})
 target_link_libraries (glew_s ${GLEW_LIBRARIES})
 
-if(CMAKE_VERSION VERSION_LESS 2.8.12)
-  set(MAYBE_EXPORT "")
-else()
-  target_compile_definitions(glew_s INTERFACE "GLEW_STATIC")
-  foreach(t glew glew_s)
-    target_include_directories(${t} PUBLIC $<INSTALL_INTERFACE:include>)
-  endforeach()
-  set(MAYBE_EXPORT EXPORT glew-targets)
-endif()
+target_compile_definitions(glew_s INTERFACE "GLEW_STATIC")
+foreach(t glew glew_s)
+  target_include_directories(${t} PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+endforeach()
 
 set(targets_to_install "")
-if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
+if(BUILD_SHARED_LIBS)
   list(APPEND targets_to_install glew)
-endif()
-
-if(NOT DEFINED BUILD_SHARED_LIBS OR NOT BUILD_SHARED_LIBS)
+else ()
   list(APPEND targets_to_install glew_s)
 endif()
 
 install ( TARGETS ${targets_to_install}
-          ${MAYBE_EXPORT}
-          RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-          LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-          ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
-          FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX}
+          EXPORT glew-targets
+          RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime
+          LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Runtime
+          ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development
+          FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT Runtime
 )
 
 if (BUILD_UTILS)
@@ -181,7 +179,7 @@ if (BUILD_UTILS)
     list (APPEND GLEWINFO_SRC_FILES ${GLEW_DIR}/build/glewinfo.rc)
   endif ()
   add_executable (glewinfo ${GLEWINFO_SRC_FILES})
-  if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
+  if(BUILD_SHARED_LIBS)
      target_link_libraries (glewinfo glew)
   else()
      target_link_libraries (glewinfo glew_s)
@@ -195,7 +193,7 @@ if (BUILD_UTILS)
     list (APPEND VISUALINFO_SRC_FILES ${GLEW_DIR}/build/visualinfo.rc)
   endif ()
   add_executable (visualinfo ${VISUALINFO_SRC_FILES})
-  if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
+  if(BUILD_SHARED_LIBS)
      target_link_libraries (visualinfo glew)
   else()
      target_link_libraries (visualinfo glew_s)
@@ -205,7 +203,8 @@ if (BUILD_UTILS)
   endif ()
 
   install ( TARGETS glewinfo visualinfo
-            DESTINATION ${CMAKE_INSTALL_BINDIR})
+            DESTINATION ${CMAKE_INSTALL_BINDIR}
+            COMPONENT Runtime)
 endif ()
 
 set (prefix ${CMAKE_INSTALL_PREFIX})
@@ -226,30 +225,31 @@ configure_file (${GLEW_DIR}/glew.pc.in $
 
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/glew.pc
         DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
+        COMPONENT Development
 )
 
-if(WIN32 AND MSVC AND (NOT MSVC_VERSION LESS 1600) AND (NOT CMAKE_VERSION VERSION_LESS "3.1"))
+if(WIN32 AND MSVC AND (NOT MSVC_VERSION LESS 1600))
     install(
         FILES $<TARGET_PDB_FILE:glew>
         DESTINATION ${CMAKE_INSTALL_LIBDIR}
         CONFIGURATIONS Debug RelWithDebInfo
+        COMPONENT Runtime
     )
 endif()
 
-install (FILES
-    ${GLEW_DIR}/include/GL/wglew.h
-    ${GLEW_DIR}/include/GL/glew.h
-    ${GLEW_DIR}/include/GL/glxew.h
-    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GL)
-
-if(MAYBE_EXPORT)
-  install(EXPORT glew-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glew
-    NAMESPACE GLEW::)
-  install(FILES
-      ${CMAKE_CURRENT_SOURCE_DIR}/glew-config.cmake
-      ${CMAKE_CURRENT_SOURCE_DIR}/CopyImportedTargetProperties.cmake
-    DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glew)
-endif()
+install (
+    FILES ${GLEW_PUBLIC_HEADERS_FILES}
+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GL
+    COMPONENT Development)
+
+install(EXPORT glew-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glew
+  COMPONENT Development
+  NAMESPACE GLEW::)
+install(FILES
+    ${CMAKE_CURRENT_SOURCE_DIR}/glew-config.cmake
+    ${CMAKE_CURRENT_SOURCE_DIR}/CopyImportedTargetProperties.cmake
+  DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glew
+  COMPONENT Development)
 
 if(NOT TARGET uninstall)
   configure_file(
Index: glew-2.2.0/build/cmake/testbuild/CMakeLists.txt
===================================================================
--- glew-2.2.0.orig/build/cmake/testbuild/CMakeLists.txt
+++ glew-2.2.0/build/cmake/testbuild/CMakeLists.txt
@@ -1,5 +1,5 @@
-cmake_minimum_required(VERSION 2.8.12)
-project(glew-cmake-test)
+cmake_minimum_required(VERSION 3.16)
+project(glew-cmake-test LANGUAGES C)
 
 find_package(GLEW REQUIRED CONFIG)
 find_package(GLEW REQUIRED CONFIG) # call twice to test multiple call
@@ -10,16 +10,10 @@ set_target_properties(cmake-test PROPERT
 target_link_libraries(cmake-test PRIVATE GLEW::GLEW ${OPENGL_LIBRARIES})
 target_include_directories(cmake-test PRIVATE ${OPENGL_INCLUDE_DIR})
 
-if(CMAKE_VERSION VERSION_LESS 3.0)
-    set(cgex $<CONFIGURATION>)
-else()
-    set(cgex $<CONFIG>)
-endif()
-
 target_compile_definitions(cmake-test PRIVATE
-    -DGLEW_CMAKE_TEST_CONFIG=${cgex}
+    -DGLEW_CMAKE_TEST_CONFIG=$<CONFIG>
     -DGLEW_CMAKE_TEST_TARGET_FILE_NAME=$<TARGET_FILE_NAME:GLEW::GLEW>
     -DGLEW_CMAKE_TEST_TARGET_TYPE=$<TARGET_PROPERTY:GLEW::GLEW,TYPE>
     )
 
-install(TARGETS cmake-test DESTINATION bin)
+install(TARGETS cmake-test DESTINATION bin COMPONENT Runtime)
Index: glew-2.2.0/README.md
===================================================================
--- glew-2.2.0.orig/README.md
+++ glew-2.2.0/README.md
@@ -108,7 +108,7 @@ _Note: you may need to call `make` in th
 
 #### Using cmake
 
-The cmake build is mostly contributer maintained.
+The cmake build is mostly contributor maintained.
 Due to the multitude of use cases this is maintained on a _best effort_ basis.
 Pull requests are welcome.
 
Index: glew-2.2.0/auto/bin/parse_spec.pl
===================================================================
--- glew-2.2.0.orig/auto/bin/parse_spec.pl
+++ glew-2.2.0/auto/bin/parse_spec.pl
@@ -114,7 +114,7 @@ my %taboo_tokens = (
 );
 
 # list of function definitions to be ignored, unless they are being defined in
-# the given spec.  This is an ugly hack arround the fact that people writing
+# the given spec.  This is an ugly hack around the fact that people writing
 # spec files seem to shut down all brain activity while they are at this task.
 #
 # This will be moved to its own file eventually.
@@ -185,7 +185,7 @@ sub normalize_prototype
     return $_;
 }
 
-# Ugly hack to work arround the fact that functions are declared in more
+# Ugly hack to work around the fact that functions are declared in more
 # than one spec file.
 sub ignore_function($$)
 {
Index: glew-2.2.0/auto/doc/advanced.html
===================================================================
--- glew-2.2.0.orig/auto/doc/advanced.html
+++ glew-2.2.0/auto/doc/advanced.html
@@ -88,7 +88,7 @@ terminated with a semicolon.
 <h3>Custom Code Generation</h3>
 <p>
 Starting from GLEW 1.3.0, it is possible to control which extensions
-to include in the libarary by specifying a list in
+to include in the library by specifying a list in
 <tt>auto/custom.txt</tt>. This is useful when you do not need all the
 extensions and would like to reduce the size of the source files.
 Type <tt>make clean; make custom</tt> in the <tt>auto</tt> directory
Index: glew-2.2.0/auto/doc/log.html
===================================================================
--- glew-2.2.0.orig/auto/doc/log.html
+++ glew-2.2.0/auto/doc/log.html
@@ -15,7 +15,7 @@
 <ul>
 <li> Bug fixes:
 <ul>
-<li> Resovled crash when glXGetCurrentDisplay() is NULL
+<li> Resolved crash when glXGetCurrentDisplay() is NULL
 <li> CMake: only install PDB files with MSVC
 <li> wglGetProcAddress crash with NOGDI defined 
 <li> Mac: using -Os rather than -O2
@@ -744,7 +744,7 @@
 </ul>
 <li> Bug fixes:
 <ul>
-<li> Incorrent 64-bit type definitions
+<li> Incorrect 64-bit type definitions
 <li> Do not strip static library on install
 <li> Missing tokens in GL_ATI_fragment_shader and WGL_{ARB,EXT}_make_current_read
 <li> Missing tokens in GL_VERSION_2_1
@@ -792,7 +792,7 @@ corruption of their values
 <li> Missing include guards in glxew.h
 <li> Makefile and install problems for Cygwin builds
 <li> Install problem for Linux AMD64 builds
-<li> Incorrent token in GL_ATI_texture_compression_3dc
+<li> Incorrect token in GL_ATI_texture_compression_3dc
 <li> Missing tokens from GL_ATIX_point_sprites
 </ul>
 </ul>
Index: glew-2.2.0/doc/advanced.html
===================================================================
--- glew-2.2.0.orig/doc/advanced.html
+++ glew-2.2.0/doc/advanced.html
@@ -186,7 +186,7 @@ terminated with a semicolon.
 <h3>Custom Code Generation</h3>
 <p>
 Starting from GLEW 1.3.0, it is possible to control which extensions
-to include in the libarary by specifying a list in
+to include in the library by specifying a list in
 <tt>auto/custom.txt</tt>. This is useful when you do not need all the
 extensions and would like to reduce the size of the source files.
 Type <tt>make clean; make custom</tt> in the <tt>auto</tt> directory
Index: glew-2.2.0/doc/log.html
===================================================================
--- glew-2.2.0.orig/doc/log.html
+++ glew-2.2.0/doc/log.html
@@ -113,7 +113,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
 <ul>
 <li> Bug fixes:
 <ul>
-<li> Resovled crash when glXGetCurrentDisplay() is NULL
+<li> Resolved crash when glXGetCurrentDisplay() is NULL
 <li> CMake: only install PDB files with MSVC
 <li> wglGetProcAddress crash with NOGDI defined 
 <li> Mac: using -Os rather than -O2
@@ -842,7 +842,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
 </ul>
 <li> Bug fixes:
 <ul>
-<li> Incorrent 64-bit type definitions
+<li> Incorrect 64-bit type definitions
 <li> Do not strip static library on install
 <li> Missing tokens in GL_ATI_fragment_shader and WGL_{ARB,EXT}_make_current_read
 <li> Missing tokens in GL_VERSION_2_1
@@ -890,7 +890,7 @@ corruption of their values
 <li> Missing include guards in glxew.h
 <li> Makefile and install problems for Cygwin builds
 <li> Install problem for Linux AMD64 builds
-<li> Incorrent token in GL_ATI_texture_compression_3dc
+<li> Incorrect token in GL_ATI_texture_compression_3dc
 <li> Missing tokens from GL_ATIX_point_sprites
 </ul>
 </ul>
openSUSE Build Service is sponsored by