File: DARTFindOpenGL.cmake

package info (click to toggle)
dart 6.12.1%2Bdfsg4-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 57,000 kB
  • sloc: cpp: 269,461; python: 3,911; xml: 1,273; sh: 404; makefile: 30
file content (39 lines) | stat: -rw-r--r-- 1,134 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Copyright (c) 2011-2021, The DART development contributors
# All rights reserved.
#
# The list of contributors can be found at:
#   https://github.com/dartsim/dart/blob/master/LICENSE
#
# This file is provided under the "BSD-style" License

cmake_policy(PUSH)

# Use GLVND over the legacy OpenGL libraries
if(POLICY CMP0072)
  cmake_policy(SET CMP0072 NEW)
endif()

# Use OpenGL config if available
find_package(OpenGL QUIET CONFIG)
# Otherwise, fall back to FindOpenGL.cmake provided by CMake
if(NOT OPENGL_FOUND)
  find_package(OpenGL QUIET MODULE)
endif()

cmake_policy(POP)

if((OPENGL_FOUND OR OpenGL_FOUND) AND NOT TARGET OpenGL::GL)
  add_library(OpenGL::GL INTERFACE IMPORTED)
  set_target_properties(OpenGL::GL PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
    INTERFACE_LINK_LIBRARIES "${OPENGL_gl_LIBRARY}"
  )
endif()

if((OPENGL_FOUND OR OpenGL_FOUND) AND NOT TARGET OpenGL::GLU)
  add_library(OpenGL::GLU INTERFACE IMPORTED)
  set_target_properties(OpenGL::GLU PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
    INTERFACE_LINK_LIBRARIES "${OPENGL_glu_LIBRARY}"
  )
endif()