diff options
author | Brad King <brad.king@kitware.com> | 2014-06-06 13:44:57 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2014-06-06 13:44:57 (GMT) |
commit | 618b7df5bf7767561822c1673a9640860a2613a1 (patch) | |
tree | 26b5c8d2dc0a961af31fa67a6251eb7128b9a9f6 | |
parent | c6e7c18bcc2943962074f101e2a44229f3699022 (diff) | |
parent | b7804cb6ce1d479ae54f742faf359d061c079be4 (diff) | |
download | CMake-618b7df5bf7767561822c1673a9640860a2613a1.zip CMake-618b7df5bf7767561822c1673a9640860a2613a1.tar.gz CMake-618b7df5bf7767561822c1673a9640860a2613a1.tar.bz2 |
Merge topic 'FindOpenGL-target'
b7804cb6 FindOpenGL: Provide imported targets for GL and GLU
-rw-r--r-- | Modules/FindOpenGL.cmake | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index a83a6c3..85c3b94 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -4,6 +4,16 @@ # # FindModule for OpenGL and GLU. # +# IMPORTED Targets +# ^^^^^^^^^^^^^^^^ +# +# This module defines the :prop_tgt:`IMPORTED` targets: +# +# ``OpenGL::OpenGL`` +# Defined if the system has OpenGL. +# ``OpenGL::GLU`` +# Defined if the system has GLU. +# # Result Variables # ^^^^^^^^^^^^^^^^ # @@ -181,6 +191,36 @@ 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) + add_library(OpenGL::GL UNKNOWN IMPORTED) + set_target_properties(OpenGL::GL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}") + if(OPENGL_gl_LIBRARY MATCHES "/([^/]+)\\.framework$") + set_target_properties(OpenGL::GL PROPERTIES + IMPORTED_LOCATION "${OPENGL_gl_LIBRARY}/${CMAKE_MATCH_1}") + else() + set_target_properties(OpenGL::GL PROPERTIES + IMPORTED_LOCATION "${OPENGL_gl_LIBRARY}") + endif() + endif() + + if(OPENGL_GLU_FOUND AND NOT TARGET OpenGL::GLU) + add_library(OpenGL::GLU UNKNOWN IMPORTED) + set_target_properties(OpenGL::GLU PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES OpenGL::GL) + if(OPENGL_glu_LIBRARY MATCHES "/([^/]+)\\.framework$") + set_target_properties(OpenGL::GLU PROPERTIES + IMPORTED_LOCATION "${OPENGL_glu_LIBRARY}/${CMAKE_MATCH_1}") + else() + set_target_properties(OpenGL::GLU PROPERTIES + IMPORTED_LOCATION "${OPENGL_glu_LIBRARY}") + endif() + endif() +endif() + mark_as_advanced( OPENGL_INCLUDE_DIR OPENGL_xmesa_INCLUDE_DIR |