[Cmake-commits] CMake branch, master, updated. v3.9.3-965-gf75ac39

Kitware Robot kwrobot at kitware.com
Wed Sep 27 07:15:53 EDT 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  f75ac39692a3ec81f0e553dc4fa72c1b7f4165e7 (commit)
       via  c4d0939fba384bbaf854c21a5c22ae7c24659ee8 (commit)
       via  09350f19e073e33ea698ecb3bc45bb0a22d62a25 (commit)
       via  df965cb9638d589be55daa520c13df32e1afd91d (commit)
       via  e2e8a690cd7d1e5eba574b810842296beb603d9c (commit)
       via  a7005c985d2ed22f1192864a358eb89e2c1b63f7 (commit)
       via  1604716dfc493bf55bc1d87b5083bbe2ee709e60 (commit)
      from  f4517a4767560d7822885443434eb185612a6817 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f75ac39692a3ec81f0e553dc4fa72c1b7f4165e7
commit f75ac39692a3ec81f0e553dc4fa72c1b7f4165e7
Merge: c4d0939 df965cb
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Sep 27 11:12:09 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Sep 27 07:14:17 2017 -0400

    Merge topic 'ninja-rc-depfile-quoting'
    
    df965cb9 Ninja: Fix quoting of RC language depfile in cmcldeps call
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1309


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c4d0939fba384bbaf854c21a5c22ae7c24659ee8
commit c4d0939fba384bbaf854c21a5c22ae7c24659ee8
Merge: 09350f1 e2e8a69
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Sep 27 11:11:29 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Sep 27 07:13:12 2017 -0400

    Merge topic 'FindOpenGL-glvnd'
    
    e2e8a690 FindOpenGL: Add support for GLVND on Linux
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !782


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=09350f19e073e33ea698ecb3bc45bb0a22d62a25
commit 09350f19e073e33ea698ecb3bc45bb0a22d62a25
Merge: f4517a4 a7005c9
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Sep 27 11:10:46 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Wed Sep 27 07:11:07 2017 -0400

    Merge topic 'revert-perf-source-lookup'
    
    a7005c98 Tests: Add case for legacy source file property behavior
    1604716d Revert "Performance: Improve efficiency of source file lookup in cmMakefile"
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !1308


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=df965cb9638d589be55daa520c13df32e1afd91d
commit df965cb9638d589be55daa520c13df32e1afd91d
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Sep 25 09:52:13 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Sep 25 10:07:48 2017 -0400

    Ninja: Fix quoting of RC language depfile in cmcldeps call
    
    Since commit v3.0.0-rc1~448^2 (Ninja: use deps = gcc/msvc feature,
    2013-10-18) the value of the `DEP_FILE` binding already includes the
    needed quoting to refer to the file.  However, that commit forgot to
    update one of the `$DEP_FILE` references to not be quoted anymore.
    The offending code path currently only affects cmcldeps for RC.
    Remove the extra quoting now.
    
    Fixes: #17298

diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index a464d6e..5fb4097 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -438,7 +438,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
         : mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
       cldeps = "\"";
       cldeps += cmSystemTools::GetCMClDepsCommand();
-      cldeps += "\" " + lang + " " + vars.Source + " \"$DEP_FILE\" $out \"";
+      cldeps += "\" " + lang + " " + vars.Source + " $DEP_FILE $out \"";
       cldeps += mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
       cldeps += "\" \"" + cl + "\" ";
     }
diff --git a/Tests/VSResource/CMakeLists.txt b/Tests/VSResource/CMakeLists.txt
index 718e624..fb47c7e 100644
--- a/Tests/VSResource/CMakeLists.txt
+++ b/Tests/VSResource/CMakeLists.txt
@@ -56,3 +56,10 @@ endif()
 
 set_property(TARGET VSResource
   PROPERTY VS_GLOBAL_CMakeTestVsGlobalVariable "test val")
+
+if(CMAKE_GENERATOR MATCHES "Ninja|Visual Studio")
+  cmake_policy(PUSH)
+  cmake_policy(SET CMP0037 OLD)
+  add_library("My ResourceLib" lib.cpp lib.rc)
+  cmake_policy(POP)
+endif()

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e2e8a690cd7d1e5eba574b810842296beb603d9c
commit e2e8a690cd7d1e5eba574b810842296beb603d9c
Author:     Tom Fogal <tfogal at nvidia.com>
AuthorDate: Thu Jun 8 18:02:42 2017 -0700
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Sep 25 09:22:29 2017 -0400

    FindOpenGL: Add support for GLVND on Linux
    
    Find GLVND components if available.  Add `GLX` and `EGL` options for
    COMPONENTS that allow requesting these libraries explicitly.  Introduce
    new import targets for these windowing-system-specific libraries.
    
    On a GLVND system, populate the legacy `OPENGL_LIBRARIES` variable and
    the `OpenGL::GL` target using the `OpenGL` and `GLX` components.  On
    non-GLVND systems, continue to use the legacy `GL` library and simply do
    not provide the GLVND components.  Application code can choose to adapt
    based on the availability of GLVND components as imported targets.

diff --git a/Copyright.txt b/Copyright.txt
index 978be0a..3c92a81 100644
--- a/Copyright.txt
+++ b/Copyright.txt
@@ -76,6 +76,7 @@ The following individuals and institutions are among the Contributors:
 * Nicolas Bock <nicolasbock at gmail.com>
 * Nicolas Despres <nicolas.despres at gmail.com>
 * Nikita Krupen'ko <krnekit at gmail.com>
+* NVIDIA Corporation <www.nvidia.com>
 * OpenGamma Ltd. <opengamma.com>
 * Per Øyvind Karlsen <peroyvind at mandriva.org>
 * Peter Collingbourne <peter at pcc.me.uk>
diff --git a/Help/release/dev/FindOpenGL-glvnd.rst b/Help/release/dev/FindOpenGL-glvnd.rst
new file mode 100644
index 0000000..b3c8d53
--- /dev/null
+++ b/Help/release/dev/FindOpenGL-glvnd.rst
@@ -0,0 +1,4 @@
+FindOpenGL-glvnd
+----------------
+
+* The :module:`FindOpenGL` module gained support for GLVND on Linux.
diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake
index af83fb7..59bee41 100644
--- a/Modules/FindOpenGL.cmake
+++ b/Modules/FindOpenGL.cmake
@@ -7,15 +7,28 @@
 #
 # FindModule for OpenGL and GLU.
 #
+# Optional COMPONENTS
+# ^^^^^^^^^^^^^^^^^^^
+#
+# This module respects several optional COMPONENTS: ``EGL``, ``GLX``, and
+# ``OpenGL``.  There are corresponding import targets for each of these flags.
+#
 # IMPORTED Targets
 # ^^^^^^^^^^^^^^^^
 #
 # This module defines the :prop_tgt:`IMPORTED` targets:
 #
 # ``OpenGL::GL``
-#  Defined if the system has OpenGL.
+#  Defined to the platform-specific OpenGL libraries if the system has OpenGL.
+# ``OpenGL::OpenGL``
+#  Defined to libOpenGL if the system is GLVND-based.
+#  ``OpenGL::GL``
 # ``OpenGL::GLU``
 #  Defined if the system has GLU.
+# ``OpenGL::GLX``
+#  Defined if the system has GLX.
+# ``OpenGL::EGL``
+#  Defined if the system has EGL.
 #
 # Result Variables
 # ^^^^^^^^^^^^^^^^
@@ -23,40 +36,87 @@
 # This module sets the following variables:
 #
 # ``OPENGL_FOUND``
-#  True, if the system has OpenGL.
+#  True, if the system has OpenGL and all components are found.
 # ``OPENGL_XMESA_FOUND``
 #  True, if the system has XMESA.
 # ``OPENGL_GLU_FOUND``
 #  True, if the system has GLU.
+# ``OpenGL_OpenGL_FOUND``
+#  True, if the system has an OpenGL library.
+# ``OpenGL_GLX_FOUND``
+#  True, if the system has GLX.
+# ``OpenGL_EGL_FOUND``
+#  True, if the system has EGL.
 # ``OPENGL_INCLUDE_DIR``
 #  Path to the OpenGL include directory.
+# ``OPENGL_EGL_INCLUDE_DIRS``
+#  Path to the EGL include directory.
 # ``OPENGL_LIBRARIES``
-#  Paths to the OpenGL and GLU libraries.
+#  Paths to the OpenGL library, windowing system libraries, and GLU libraries.
+#  On Linux, this assumes glX and is never correct for EGL-based targets.
+#  Clients are encouraged to use the ``OpenGL::*`` import targets instead.
 #
-# If you want to use just GL you can use these values:
+# Cache variables
+# ^^^^^^^^^^^^^^^
 #
-# ``OPENGL_gl_LIBRARY``
-#  Path to the OpenGL library.
+# The following cache variables may also be set:
+#
+# ``OPENGL_egl_LIBRARY``
+#  Path to the EGL library.
 # ``OPENGL_glu_LIBRARY``
 #  Path to the GLU library.
+# ``OPENGL_glx_LIBRARY``
+#  Path to the GLVND 'GLX' library.
+# ``OPENGL_opengl_LIBRARY``
+#  Path to the GLVND 'OpenGL' library
+# ``OPENGL_gl_LIBRARY``
+#  Path to the OpenGL library.  New code should prefer the ``OpenGL::*`` import
+#  targets.
+#
+# Linux-specific
+# ^^^^^^^^^^^^^^
 #
-# OSX Specific
-# ^^^^^^^^^^^^
+# Some Linux systems utilize GLVND as a new ABI for OpenGL.  GLVND separates
+# context libraries from OpenGL itself; OpenGL lives in "libOpenGL", and
+# contexts are defined in "libGLX" or "libEGL".  GLVND is currently the only way
+# to get OpenGL 3+ functionality via EGL in a manner portable across vendors.
 #
-# On OSX default to using the framework version of OpenGL. People will
-# have to change the cache values of OPENGL_glu_LIBRARY and
+# On Linux systems FindOpenGL defaults to using GLVND if available.  Users can
+# utilize GLVND explicitly with targets ``OpenGL::OpenGL``, ``OpenGL::GLX``, and
+# ``OpenGL::EGL``.  Additionally, when GLVND is available the ``OpenGL::GL``
+# target is equivalent to ``OpenGL::OpenGL OpenGL::GLX``.  When the system is
+# not GLVND-based, ``OpenGL::GL`` expands to libGL as it has historically done.
+# Thus, for non-EGL-based Linux targets, the ``OpenGL::GL`` target is most
+# portable.
+#
+# For EGL targets the client must rely on GLVND support on the user's system.
+# Linking should use the ``OpenGL::OpenGL OpenGL::EGL`` targets.  Using GLES*
+# libraries is theoretically possible in place of ``OpenGL::OpenGL``, but this
+# module does not currently support that; contributions welcome.
+#
+# ``OPENGL_egl_LIBRARY`` and ``OPENGL_EGL_INCLUDE_DIRS`` are defined in the case of
+# GLVND.  For non-GLVND Linux and other systems these are left undefined.
+#
+# macOS-Specific
+# ^^^^^^^^^^^^^^
+#
+# On OSX FindOpenGL defaults to using the framework version of OpenGL. People
+# will have to change the cache values of OPENGL_glu_LIBRARY and
 # OPENGL_gl_LIBRARY to use OpenGL with X11 on OSX.
 
-
 set(_OpenGL_REQUIRED_VARS OPENGL_gl_LIBRARY)
 
-if (CYGWIN)
+# Provide OPENGL_USE_<C> variables for each component.
+foreach(component ${OpenGL_FIND_COMPONENTS})
+  string(TOUPPER ${component} _COMPONENT)
+  set(OPENGL_USE_${_COMPONENT} 1)
+endforeach()
 
+if (CYGWIN)
   find_path(OPENGL_INCLUDE_DIR GL/gl.h )
   list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
 
   find_library(OPENGL_gl_LIBRARY opengl32 )
-
   find_library(OPENGL_glu_LIBRARY glu32 )
 
 elseif (WIN32)
@@ -70,7 +130,6 @@ elseif (WIN32)
   endif()
 
 elseif (APPLE)
-
   # The OpenGL.framework provides both gl and glu
   find_library(OPENGL_gl_LIBRARY OpenGL DOC "OpenGL library for OS X")
   find_library(OPENGL_glu_LIBRARY OpenGL DOC
@@ -104,15 +163,14 @@ else()
   # fail since the compiler finds the Mesa headers but NVidia's library.
   # Make sure the NVIDIA directory comes BEFORE the others.
   #  - Atanas Georgiev <atanas at cs.columbia.edu>
-
   find_path(OPENGL_INCLUDE_DIR GL/gl.h
     /usr/share/doc/NVIDIA_GLX-1.0/include
     /usr/openwin/share/include
     /opt/graphics/OpenGL/include /usr/X11R6/include
     ${_OPENGL_INCLUDE_PATH}
   )
-  list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
-
+  find_path(OPENGL_GLX_INCLUDE_DIR GL/glx.h ${_OPENGL_INCLUDE_PATH})
+  find_path(OPENGL_EGL_INCLUDE_DIR EGL/egl.h ${_OPENGL_INCLUDE_PATH})
   find_path(OPENGL_xmesa_INCLUDE_DIR GL/xmesa.h
     /usr/share/doc/NVIDIA_GLX-1.0/include
     /usr/openwin/share/include
@@ -126,6 +184,90 @@ else()
           /usr/shlib /usr/X11R6/lib
           ${_OPENGL_LIB_PATH}
   )
+  # Search for the GLVND libraries.  We do this regardless of COMPONENTS; we'll
+  # take into account the COMPONENTS logic later.
+  find_library(OPENGL_opengl_LIBRARY
+    NAMES OpenGL
+    PATHS /usr/X11R6/lib
+          ${_OPENGL_LIB_PATH}
+  )
+
+  find_library(OPENGL_glx_LIBRARY
+    NAMES GLX
+    PATHS /usr/X11R6/lib
+          ${_OPENGL_LIB_PATH}
+  )
+
+  find_library(OPENGL_egl_LIBRARY
+    NAMES EGL
+    PATHS ${_OPENGL_LIB_PATH}
+  )
+
+  find_library(OPENGL_glu_LIBRARY
+    NAMES GLU MesaGLU
+    PATHS ${OPENGL_gl_LIBRARY}
+          /opt/graphics/OpenGL/lib
+          /usr/openwin/lib
+          /usr/shlib /usr/X11R6/lib
+  )
+
+  # FPHSA cannot handle "this OR that is required", so we conditionally set what
+  # it must look for.  First clear any previous config we might have done:
+  set(_OpenGL_REQUIRED_VARS)
+
+  # now we append the libraries as appropriate.  The complicated logic
+  # basically comes down to "use libOpenGL when we can, and add in specific
+  # context mechanisms when requested, or we need them to preserve the previous
+  # default where glx is always available."
+  if((NOT OPENGL_USE_EGL AND
+      NOT OPENGL_opengl_LIBRARY AND
+          OPENGL_glx_LIBRARY AND
+      NOT OPENGL_gl_LIBRARY) OR
+     (NOT OPENGL_USE_EGL AND
+      NOT OPENGL_glx_LIBRARY AND
+      NOT OPENGL_gl_LIBRARY) OR
+     (NOT OPENGL_USE_EGL AND
+          OPENGL_opengl_LIBRARY AND
+          OPENGL_glx_LIBRARY) OR
+     (    OPENGL_USE_EGL))
+    list(APPEND _OpenGL_REQUIRED_VARS OPENGL_opengl_LIBRARY)
+  endif()
+
+  # GLVND GLX library.  Preferred when available.
+  if((NOT OPENGL_USE_OPENGL AND
+      NOT OPENGL_USE_GLX AND
+      NOT OPENGL_USE_EGL AND
+      NOT OPENGL_glx_LIBRARY AND
+      NOT OPENGL_gl_LIBRARY) OR
+     (    OPENGL_USE_GLX AND
+      NOT OPENGL_USE_EGL AND
+      NOT OPENGL_glx_LIBRARY AND
+      NOT OPENGL_gl_LIBRARY) OR
+     (NOT OPENGL_USE_EGL AND
+          OPENGL_opengl_LIBRARY AND
+          OPENGL_glx_LIBRARY) OR
+     (OPENGL_USE_GLX AND OPENGL_USE_EGL))
+    list(APPEND _OpenGL_REQUIRED_VARS OPENGL_glx_LIBRARY)
+  endif()
+
+  # GLVND EGL library.
+  if(OPENGL_USE_EGL)
+    list(APPEND _OpenGL_REQUIRED_VARS OPENGL_egl_LIBRARY)
+  endif()
+
+  # Old-style "libGL" library: used as a fallback when GLVND isn't available.
+  if((NOT OPENGL_USE_EGL AND
+      NOT OPENGL_opengl_LIBRARY AND
+          OPENGL_glx_LIBRARY AND
+          OPENGL_gl_LIBRARY) OR
+     (NOT OPENGL_USE_EGL AND
+      NOT OPENGL_glx_LIBRARY AND
+          OPENGL_gl_LIBRARY))
+    list(APPEND _OpenGL_REQUIRED_VARS OPENGL_gl_LIBRARY)
+  endif()
+
+  # We always need the 'gl.h' include dir.
+  list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
 
   unset(_OPENGL_INCLUDE_PATH)
   unset(_OPENGL_LIB_PATH)
@@ -137,42 +279,99 @@ else()
           /usr/openwin/lib
           /usr/shlib /usr/X11R6/lib
   )
-
 endif ()
 
-if(OPENGL_gl_LIBRARY)
+if(OPENGL_xmesa_INCLUDE_DIR)
+  set( OPENGL_XMESA_FOUND "YES" )
+else()
+  set( OPENGL_XMESA_FOUND "NO" )
+endif()
 
-    if(OPENGL_xmesa_INCLUDE_DIR)
-      set( OPENGL_XMESA_FOUND "YES" )
-    else()
-      set( OPENGL_XMESA_FOUND "NO" )
-    endif()
+if(OPENGL_glu_LIBRARY)
+  set( OPENGL_GLU_FOUND "YES" )
+else()
+  set( OPENGL_GLU_FOUND "NO" )
+endif()
 
-    set( OPENGL_LIBRARIES  ${OPENGL_gl_LIBRARY} ${OPENGL_LIBRARIES})
-    if(OPENGL_glu_LIBRARY)
-      set( OPENGL_GLU_FOUND "YES" )
-      if(NOT "${OPENGL_glu_LIBRARY}" STREQUAL "${OPENGL_gl_LIBRARY}")
-        set( OPENGL_LIBRARIES ${OPENGL_glu_LIBRARY} ${OPENGL_LIBRARIES} )
-      endif()
-    else()
-      set( OPENGL_GLU_FOUND "NO" )
-    endif()
+# OpenGL_OpenGL_FOUND is a bit unique in that it is okay if /either/ libOpenGL
+# or libGL is found.
+# Using libGL with libEGL is never okay, though; we handle that case later.
+if(NOT OPENGL_opengl_LIBRARY AND NOT OPENGL_gl_LIBRARY)
+  set(OpenGL_OpenGL_FOUND FALSE)
+else()
+  set(OpenGL_OpenGL_FOUND TRUE)
+endif()
 
-    # This deprecated setting is for backward compatibility with CMake1.4
-    set (OPENGL_LIBRARY ${OPENGL_LIBRARIES})
+if(OPENGL_glx_LIBRARY AND OPENGL_GLX_INCLUDE_DIR)
+  set(OpenGL_GLX_FOUND TRUE)
+else()
+  set(OpenGL_GLX_FOUND FALSE)
+endif()
 
+if(OPENGL_egl_LIBRARY AND OPENGL_EGL_INCLUDE_DIR)
+  set(OpenGL_EGL_FOUND TRUE)
+else()
+  set(OpenGL_EGL_FOUND FALSE)
 endif()
 
-# This deprecated setting is for backward compatibility with CMake1.4
-set(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR})
+# User-visible names should be plural.
+if(OPENGL_EGL_INCLUDE_DIR)
+  set(OPENGL_EGL_INCLUDE_DIRS ${OPENGL_EGL_INCLUDE_DIR})
+endif()
 
 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL REQUIRED_VARS ${_OpenGL_REQUIRED_VARS})
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL REQUIRED_VARS ${_OpenGL_REQUIRED_VARS}
+                                  HANDLE_COMPONENTS)
 unset(_OpenGL_REQUIRED_VARS)
 
 # OpenGL:: targets
 if(OPENGL_FOUND)
-  if(NOT TARGET OpenGL::GL)
+  # ::OpenGL is a GLVND library, and thus Linux-only: we don't bother checking
+  # for a framework version of this library.
+  if(OPENGL_opengl_LIBRARY AND NOT TARGET OpenGL::OpenGL)
+    if(IS_ABSOLUTE "${OPENGL_opengl_LIBRARY}")
+      add_library(OpenGL::OpenGL UNKNOWN IMPORTED)
+      set_target_properties(OpenGL::OpenGL PROPERTIES IMPORTED_LOCATION
+                            "${OPENGL_opengl_LIBRARY}")
+    else()
+      add_library(OpenGL::OpenGL INTERFACE IMPORTED)
+      set_target_properties(OpenGL::OpenGL PROPERTIES IMPORTED_LIBNAME
+                            "${OPENGL_opengl_LIBRARY}")
+    endif()
+    set_target_properties(OpenGL::OpenGL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
+                          "${OPENGL_INCLUDE_DIR}")
+  endif()
+
+  # ::GLX is a GLVND library, and thus Linux-only: we don't bother checking
+  # for a framework version of this library.
+  if(OpenGL_GLX_FOUND AND NOT TARGET OpenGL::GLX)
+    if(IS_ABSOLUTE "${OPENGL_glx_LIBRARY}")
+      add_library(OpenGL::GLX UNKNOWN IMPORTED)
+      set_target_properties(OpenGL::GLX PROPERTIES IMPORTED_LOCATION
+                            "${OPENGL_glx_LIBRARY}")
+    else()
+      add_library(OpenGL::GLX INTERFACE IMPORTED)
+      set_target_properties(OpenGL::GLX PROPERTIES IMPORTED_LIBNAME
+                            "${OPENGL_glx_LIBRARY}")
+    endif()
+    set_target_properties(OpenGL::GLX PROPERTIES INTERFACE_LINK_LIBRARIES
+                          OpenGL::OpenGL)
+    set_target_properties(OpenGL::GLX PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
+                          "${OPENGL_GLX_INCLUDE_DIR}")
+  endif()
+
+  if(TARGET OpenGL::OpenGL AND TARGET OpenGL::GLX AND NOT TARGET OpenGL::GL)
+    # if GLVND with GLX is available, make ::GL a synonym for 'OpenGL::OpenGL
+    # OpenGL::GLX'.
+    add_library(OpenGL::GL INTERFACE IMPORTED)
+    set_target_properties(OpenGL::GL PROPERTIES INTERFACE_LINK_LIBRARIES
+                          OpenGL::OpenGL)
+    set_property(TARGET OpenGL::GL APPEND PROPERTY INTERFACE_LINK_LIBRARIES
+                 OpenGL::GLX)
+    set_target_properties(OpenGL::GL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
+                          "${OPENGL_INCLUDE_DIR}")
+
+  elseif(NOT TARGET OpenGL::GL)
     if(IS_ABSOLUTE "${OPENGL_gl_LIBRARY}")
       add_library(OpenGL::GL UNKNOWN IMPORTED)
       if(OPENGL_gl_LIBRARY MATCHES "/([^/]+)\\.framework$")
@@ -195,6 +394,28 @@ if(OPENGL_FOUND)
       INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}")
   endif()
 
+  # ::EGL is a GLVND library, and thus Linux-only: we don't bother checking
+  # for a framework version of this library.
+  # Note we test for OpenGL::OpenGL as a target.  When this module is updated to
+  # support GLES, we would additionally want to check for the hypothetical GLES
+  # target and enable EGL if either ::GLES or ::OpenGL is created.
+  if(TARGET OpenGL::OpenGL AND OpenGL_EGL_FOUND AND NOT TARGET OpenGL::EGL)
+    if(IS_ABSOLUTE "${OPENGL_egl_LIBRARY}")
+      add_library(OpenGL::EGL UNKNOWN IMPORTED)
+      set_target_properties(OpenGL::EGL PROPERTIES IMPORTED_LOCATION
+                            "${OPENGL_egl_LIBRARY}")
+    else()
+      add_library(OpenGL::EGL INTERFACE IMPORTED)
+      set_target_properties(OpenGL::EGL PROPERTIES IMPORTED_LIBNAME
+                            "${OPENGL_egl_LIBRARY}")
+    endif()
+    set_target_properties(OpenGL::EGL PROPERTIES INTERFACE_LINK_LIBRARIES
+                          OpenGL::OpenGL)
+    # Note that EGL's include directory is different from OpenGL/GLX's!
+    set_target_properties(OpenGL::EGL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
+                          "${OPENGL_EGL_INCLUDE_DIR}")
+  endif()
+
   if(OPENGL_GLU_FOUND AND NOT TARGET OpenGL::GLU)
     if(IS_ABSOLUTE "${OPENGL_glu_LIBRARY}")
       add_library(OpenGL::GLU UNKNOWN IMPORTED)
@@ -217,11 +438,31 @@ if(OPENGL_FOUND)
     set_target_properties(OpenGL::GLU PROPERTIES
       INTERFACE_LINK_LIBRARIES OpenGL::GL)
   endif()
+
+  # OPENGL_LIBRARIES mirrors OpenGL::GL's logic ...
+  set(OPENGL_LIBRARIES ${OPENGL_gl_LIBRARY})
+  if(TARGET OpenGL::GLX AND TARGET OpenGL::OpenGL)
+    set(OPENGL_LIBRARIES ${OPENGL_opengl_LIBRARY} ${OPENGL_glx_LIBRARY})
+  endif()
+  # ... and also includes GLU, if available.
+  if(TARGET OpenGL::GLU)
+    list(APPEND OPENGL_LIBRARIES ${OPENGL_glu_LIBRARY})
+  endif()
 endif()
 
+# This deprecated setting is for backward compatibility with CMake1.4
+set(OPENGL_LIBRARY ${OPENGL_LIBRARIES})
+# This deprecated setting is for backward compatibility with CMake1.4
+set(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR})
+
 mark_as_advanced(
   OPENGL_INCLUDE_DIR
   OPENGL_xmesa_INCLUDE_DIR
+  OPENGL_egl_LIBRARY
   OPENGL_glu_LIBRARY
+  OPENGL_glx_LIBRARY
   OPENGL_gl_LIBRARY
+  OPENGL_opengl_LIBRARY
+  OPENGL_EGL_INCLUDE_DIR
+  OPENGL_GLX_INCLUDE_DIR
 )
diff --git a/Tests/FindOpenGL/CMakeLists.txt b/Tests/FindOpenGL/CMakeLists.txt
index 9aa3aba..97c9e60 100644
--- a/Tests/FindOpenGL/CMakeLists.txt
+++ b/Tests/FindOpenGL/CMakeLists.txt
@@ -1,3 +1,9 @@
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMake_TEST_FindOpenGL_VND)
+  set(_vnd_testing TRUE)
+else()
+  set(_vnd_testing FALSE)
+endif()
+
 add_test(NAME FindOpenGL.Test COMMAND
   ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
   --build-and-test
@@ -6,5 +12,6 @@ add_test(NAME FindOpenGL.Test COMMAND
   ${build_generator_args}
   --build-project TestFindOpenGL
   --build-options ${build_options}
+  -DOpenGL_TEST_VND=${_vnd_testing}
   --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
   )
diff --git a/Tests/FindOpenGL/Test/CMakeLists.txt b/Tests/FindOpenGL/Test/CMakeLists.txt
index cac3424..3b5ffee 100644
--- a/Tests/FindOpenGL/Test/CMakeLists.txt
+++ b/Tests/FindOpenGL/Test/CMakeLists.txt
@@ -1,14 +1,70 @@
-cmake_minimum_required(VERSION 3.7)
+cmake_minimum_required(VERSION 3.9)
 project(TestFindOpenGL C)
 include(CTest)
 
 find_package(OpenGL REQUIRED)
 
+# import target for GLU
 add_executable(test_tgt main.c)
 target_link_libraries(test_tgt OpenGL::GLU)
 add_test(NAME test_tgt COMMAND test_tgt)
 
+# OPENGL_LIBRARIES should be whatever libraries are needed to link.
 add_executable(test_var main.c)
 target_include_directories(test_var PRIVATE ${OPENGL_INGLUDE_DIRS})
 target_link_libraries(test_var PRIVATE ${OPENGL_LIBRARIES})
 add_test(NAME test_var COMMAND test_var)
+
+# VND support adds an ::OpenGL import target.  This can be used for OpenGL-only
+# code (code that does not manipulate contexts, like our 'main.c').  Without
+# VND, ::GL can be used for both context and non-context OpenGL code.
+if(OpenGL_TEST_VND)
+  add_executable(test_comp_none main.c)
+  target_link_libraries(test_comp_none PRIVATE OpenGL::OpenGL)
+  add_test(NAME test_comp_none COMMAND test_comp_none)
+else()
+  add_executable(test_comp_none main.c)
+  target_link_libraries(test_comp_none PRIVATE OpenGL::GL)
+  add_test(NAME test_comp_none COMMAND test_comp_none)
+endif()
+
+# GLX
+if(OpenGL_TEST_VND)
+  find_package(OpenGL REQUIRED COMPONENTS OpenGL GLX)
+  add_executable(test_comp_glx main.c)
+  target_link_libraries(test_comp_glx PRIVATE OpenGL::OpenGL OpenGL::GLX)
+  add_test(NAME test_comp_glx COMMAND test_comp_glx)
+else()
+  # non-VND systems won't have it, but an optional search for GLX should still
+  # be okay.
+  find_package(OpenGL COMPONENTS GLX)
+  add_executable(test_comp_glx_novnd main.c)
+  target_link_libraries(test_comp_glx_novnd PRIVATE OpenGL::GL)
+  add_test(NAME test_comp_glx_novnd COMMAND test_comp_glx_novnd)
+endif()
+
+# EGL is only available on Linux+GLVND at present.
+if(OpenGL_TEST_VND)
+  find_package(OpenGL COMPONENTS OpenGL EGL)
+  if(OpenGL_EGL_FOUND)
+    add_executable(test_comp_egl main.c)
+    target_link_libraries(test_comp_egl PRIVATE OpenGL::OpenGL OpenGL::EGL)
+    add_test(NAME test_comp_egl COMMAND test_comp_egl)
+    # EGL-only code should not link to GLX.
+    execute_process(COMMAND ldd test_comp_egl
+                    OUTPUT_VARIABLE LDD_OUT
+                    ERROR_VARIABLE LDD_ERR)
+    if("${LDD_OUT}" MATCHES "GLX")
+      message(FATAL_ERROR "EGL-only code links to GLX!")
+    endif()
+  endif()
+
+  # all three COMPONENTS together.
+  find_package(OpenGL COMPONENTS OpenGL EGL GLX)
+  if(OpenGL_EGL_FOUND AND OpenGL_GLX_FOUND)
+    add_executable(test_comp_both main.c)
+    target_link_libraries(test_comp_both PRIVATE OpenGL::OpenGL OpenGL::EGL
+                          OpenGL::GLX)
+    add_test(NAME test_comp_both COMMAND test_comp_both)
+  endif()
+endif()

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a7005c985d2ed22f1192864a358eb89e2c1b63f7
commit a7005c985d2ed22f1192864a358eb89e2c1b63f7
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Sep 25 08:32:29 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Sep 25 09:06:35 2017 -0400

    Tests: Add case for legacy source file property behavior
    
    The change in commit 3b95ab5693 (Performance: Improve efficiency of
    source file lookup in cmMakefile, 2017-08-17) broke some legacy behavior
    of source file properties in which the order sources are first resolved
    with extensions affects how setting properties without extensions works.
    It has been reverted for now, but the discovery was made after merging
    because the broken case was not covered by our test suite.
    
    Add a test case representing the legacy behavior.
    
    Issue: #15208

diff --git a/Tests/RunCMake/get_property/source_properties-stderr.txt b/Tests/RunCMake/get_property/source_properties-stderr.txt
index 0a46f96..00a9b82 100644
--- a/Tests/RunCMake/get_property/source_properties-stderr.txt
+++ b/Tests/RunCMake/get_property/source_properties-stderr.txt
@@ -3,4 +3,10 @@ get_property: --><--
 get_source_file_property: -->value<--
 get_property: -->value<--
 get_source_file_property: -->NOTFOUND<--
-get_property: --><--$
+get_property: --><--
+get_source_file_property: -->value<--
+get_property: -->value<--
+get_source_file_property: -->NOTFOUND<--
+get_property: --><--
+get_source_file_property: -->value<--
+get_property: -->value<--$
diff --git a/Tests/RunCMake/get_property/source_properties.cmake b/Tests/RunCMake/get_property/source_properties.cmake
index 263ffe1..12d2d07 100644
--- a/Tests/RunCMake/get_property/source_properties.cmake
+++ b/Tests/RunCMake/get_property/source_properties.cmake
@@ -13,3 +13,13 @@ set_source_files_properties(file.c PROPERTIES empty "" custom value)
 check_source_file_property(file.c empty)
 check_source_file_property(file.c custom)
 check_source_file_property(file.c noexist)
+
+# Test strange legacy behavior in which the order in which source files are
+# first accessed affects how properties are applied without an extension.
+# See also issue #15208.
+get_property(lang SOURCE ${CMAKE_CURRENT_BINARY_DIR}/file2.c PROPERTY LANGUAGE)
+get_property(lang SOURCE ${CMAKE_CURRENT_BINARY_DIR}/file2.h PROPERTY LANGUAGE)
+set_property(SOURCE file2 PROPERTY custom value) # set property without extension
+check_source_file_property(file2 custom)   # should have property
+check_source_file_property(file2.h custom) # should not have property
+check_source_file_property(file2.c custom) # should have property

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1604716dfc493bf55bc1d87b5083bbe2ee709e60
commit 1604716dfc493bf55bc1d87b5083bbe2ee709e60
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Sep 25 08:33:29 2017 -0400
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Sep 25 09:06:24 2017 -0400

    Revert "Performance: Improve efficiency of source file lookup in cmMakefile"
    
    This reverts commit 3b95ab569345028a1a8fe521d5ecd81fa97f2653.
    It regressed some legacy source file property behavior.
    Revert pending further investigation.

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index c96b892..e51cfcc 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -3082,18 +3082,9 @@ void cmMakefile::SetArgcArgv(const std::vector<std::string>& args)
 cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
 {
   cmSourceFileLocation sfl(this, sourceName);
-
-#if defined(_WIN32) || defined(__APPLE__)
-  const auto& name = cmSystemTools::LowerCase(sfl.GetName());
-#else
-  const auto& name = sfl.GetName();
-#endif
-  auto sfsi = this->SourceFileSearchIndex.find(name);
-  if (sfsi != this->SourceFileSearchIndex.end()) {
-    for (auto sf : sfsi->second) {
-      if (sf->Matches(sfl)) {
-        return sf;
-      }
+  for (cmSourceFile* sf : this->SourceFiles) {
+    if (sf->Matches(sfl)) {
+      return sf;
     }
   }
   return nullptr;
@@ -3107,41 +3098,6 @@ cmSourceFile* cmMakefile::CreateSource(const std::string& sourceName,
     sf->SetProperty("GENERATED", "1");
   }
   this->SourceFiles.push_back(sf);
-
-  auto name = sf->GetLocation().GetName();
-#if defined(_WIN32) || defined(__APPLE__)
-  name = cmSystemTools::LowerCase(name);
-#endif
-
-  // For a file in the form "a.b.c" add the cmSourceFile to the index
-  // at "a.b.c", "a.b" and "a".
-  auto partial = name;
-  while (true) {
-    this->SourceFileSearchIndex[partial].insert(sf);
-    auto i = partial.rfind('.');
-    if (i == std::string::npos) {
-      break;
-    }
-    partial = partial.substr(0, i);
-  }
-
-  if (sf->GetLocation().ExtensionIsAmbiguous()) {
-    // For an ambiguous extension also add the various "known"
-    // extensions to the original filename.
-
-    const auto& srcExts = this->GetCMakeInstance()->GetSourceExtensions();
-    for (const auto& ext : srcExts) {
-      auto name_ext = name + "." + cmSystemTools::LowerCase(ext);
-      this->SourceFileSearchIndex[name_ext].insert(sf);
-    }
-
-    const auto& hdrExts = this->GetCMakeInstance()->GetHeaderExtensions();
-    for (const auto& ext : hdrExts) {
-      auto name_ext = name + "." + cmSystemTools::LowerCase(ext);
-      this->SourceFileSearchIndex[name_ext].insert(sf);
-    }
-  }
-
   return sf;
 }
 
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 2cae659..272522c 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -13,7 +13,6 @@
 #include <stddef.h>
 #include <string>
 #include <unordered_map>
-#include <unordered_set>
 #include <vector>
 
 #include "cmAlgorithms.h"
@@ -809,17 +808,7 @@ protected:
   // libraries, classes, and executables
   mutable cmTargets Targets;
   std::map<std::string, std::string> AliasTargets;
-
   std::vector<cmSourceFile*> SourceFiles;
-  // Because cmSourceFile names are compared in a fuzzy way (see
-  // cmSourceFileLocation::Match()) we can't have a straight mapping from
-  // filename to cmSourceFile.  To make lookups more efficient we store the
-  // Name portion of the cmSourceFileLocation and then compare on the list of
-  // cmSourceFiles that might match that name.  Note that on platforms which
-  // have a case-insensitive filesystem we store the key in all lowercase.
-  typedef std::unordered_set<cmSourceFile*> SourceFileSet;
-  typedef std::unordered_map<std::string, SourceFileSet> SourceFileMap;
-  SourceFileMap SourceFileSearchIndex;
 
   // Tests
   std::map<std::string, cmTest*> Tests;

-----------------------------------------------------------------------

Summary of changes:
 Copyright.txt                                      |    1 +
 Help/release/dev/FindOpenGL-glvnd.rst              |    4 +
 Modules/FindOpenGL.cmake                           |  319 +++++++++++++++++---
 Source/cmMakefile.cxx                              |   50 +--
 Source/cmMakefile.h                                |   11 -
 Source/cmNinjaTargetGenerator.cxx                  |    2 +-
 Tests/FindOpenGL/CMakeLists.txt                    |    7 +
 Tests/FindOpenGL/Test/CMakeLists.txt               |   58 +++-
 .../get_property/source_properties-stderr.txt      |    8 +-
 .../RunCMake/get_property/source_properties.cmake  |   10 +
 Tests/VSResource/CMakeLists.txt                    |    7 +
 11 files changed, 377 insertions(+), 100 deletions(-)
 create mode 100644 Help/release/dev/FindOpenGL-glvnd.rst


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list