summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-12-06 14:26:25 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-12-06 14:26:25 (GMT)
commit0f37cd228e9668d981ff75f3e1c63d4f716b7e57 (patch)
tree72b1096688d66b1a081a07d15cacba3261708978 /Modules
parent0290bfc35dee73fb534556700554536f1164caaf (diff)
parent027ce359ff7454ac0aca4d9a9208759ef4b9c8b7 (diff)
downloadCMake-0f37cd228e9668d981ff75f3e1c63d4f716b7e57.zip
CMake-0f37cd228e9668d981ff75f3e1c63d4f716b7e57.tar.gz
CMake-0f37cd228e9668d981ff75f3e1c63d4f716b7e57.tar.bz2
Merge topic 'FindOpenGL-imported-targets'
027ce359 FindOpenGL: Provide imported targets for GL and GLU
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindOpenGL.cmake59
1 files changed, 59 insertions, 0 deletions
diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake
index 295de65..503d955 100644
--- a/Modules/FindOpenGL.cmake
+++ b/Modules/FindOpenGL.cmake
@@ -7,6 +7,16 @@
#
# FindModule for OpenGL and GLU.
#
+# IMPORTED Targets
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines the :prop_tgt:`IMPORTED` targets:
+#
+# ``OpenGL::GL``
+# Defined if the system has OpenGL.
+# ``OpenGL::GLU``
+# Defined if the system has GLU.
+#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
@@ -160,6 +170,55 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL REQUIRED_VARS ${_OpenGL_REQUIRED_VARS})
unset(_OpenGL_REQUIRED_VARS)
+# OpenGL:: targets
+if(OPENGL_FOUND)
+ if(NOT TARGET OpenGL::GL)
+ if(IS_ABSOLUTE "${OPENGL_gl_LIBRARY}")
+ add_library(OpenGL::GL UNKNOWN IMPORTED)
+ if(OPENGL_gl_LIBRARY MATCHES "/([^/]+)\\.framework$")
+ set(_gl_fw "${OPENGL_gl_LIBRARY}/${CMAKE_MATCH_1}")
+ if(EXISTS "${_gl_fw}.tbd")
+ set(_gl_fw "${_gl_fw}.tbd")
+ endif()
+ set_target_properties(OpenGL::GL PROPERTIES
+ IMPORTED_LOCATION "${_gl_fw}")
+ else()
+ set_target_properties(OpenGL::GL PROPERTIES
+ IMPORTED_LOCATION "${OPENGL_gl_LIBRARY}")
+ endif()
+ else()
+ add_library(OpenGL::GL INTERFACE IMPORTED)
+ set_target_properties(OpenGL::GL PROPERTIES
+ IMPORTED_LIBNAME "${OPENGL_gl_LIBRARY}")
+ endif()
+ set_target_properties(OpenGL::GL PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}")
+ endif()
+
+ if(OPENGL_GLU_FOUND AND NOT TARGET OpenGL::GLU)
+ if(IS_ABSOLUTE "${OPENGL_glu_LIBRARY}")
+ add_library(OpenGL::GLU UNKNOWN IMPORTED)
+ if(OPENGL_glu_LIBRARY MATCHES "/([^/]+)\\.framework$")
+ set(_glu_fw "${OPENGL_glu_LIBRARY}/${CMAKE_MATCH_1}")
+ if(EXISTS "${_glu_fw}.tbd")
+ set(_glu_fw "${_glu_fw}.tbd")
+ endif()
+ set_target_properties(OpenGL::GLU PROPERTIES
+ IMPORTED_LOCATION "${_glu_fw}")
+ else()
+ set_target_properties(OpenGL::GLU PROPERTIES
+ IMPORTED_LOCATION "${OPENGL_glu_LIBRARY}")
+ endif()
+ else()
+ add_library(OpenGL::GLU INTERFACE IMPORTED)
+ set_target_properties(OpenGL::GLU PROPERTIES
+ IMPORTED_LIBNAME "${OPENGL_glu_LIBRARY}")
+ endif()
+ set_target_properties(OpenGL::GLU PROPERTIES
+ INTERFACE_LINK_LIBRARIES OpenGL::GL)
+ endif()
+endif()
+
mark_as_advanced(
OPENGL_INCLUDE_DIR
OPENGL_xmesa_INCLUDE_DIR