File: draco_install.cmake

package info (click to toggle)
draco 1.4.1+dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 11,652 kB
  • sloc: cpp: 30,429; javascript: 49; makefile: 20; sh: 13
file content (83 lines) | stat: -rw-r--r-- 3,321 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
if(DRACO_CMAKE_DRACO_INSTALL_CMAKE_)
  return()
endif() # DRACO_CMAKE_DRACO_INSTALL_CMAKE_
set(DRACO_CMAKE_DRACO_INSTALL_CMAKE_ 1)

# Sets up the draco install targets. Must be called after the static library
# target is created.
macro(draco_setup_install_target)
  include(GNUInstallDirs)

  # pkg-config: draco.pc
  set(prefix "${CMAKE_INSTALL_PREFIX}")
  set(exec_prefix "\${prefix}")
  set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
  set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
  set(draco_lib_name "draco")

  configure_file("${draco_root}/cmake/draco.pc.template"
                 "${draco_build}/draco.pc" @ONLY NEWLINE_STYLE UNIX)
  install(FILES "${draco_build}/draco.pc"
          DESTINATION "${prefix}/${CMAKE_INSTALL_LIBDIR}/pkgconfig")

  # CMake config: draco-config.cmake
  set(DRACO_INCLUDE_DIRS "${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
  configure_file("${draco_root}/cmake/draco-config.cmake.template"
                 "${draco_build}/draco-config.cmake" @ONLY NEWLINE_STYLE UNIX)
  install(
    FILES "${draco_build}/draco-config.cmake"
    DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/draco")

  foreach(file ${draco_sources})
    if(file MATCHES "h$")
      list(APPEND draco_api_includes ${file})
    endif()
  endforeach()

  set(include_directory "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")

  foreach(draco_api_include ${draco_api_includes})
    # Strip $draco_src_root from the file paths: we need to install relative to
    # $include_directory.
    string(REPLACE "${draco_src_root}/" "" draco_api_include "${draco_api_include}")
    get_filename_component(file_directory ${draco_api_include} DIRECTORY)
    set(target_directory "${include_directory}/draco/${file_directory}")
    install(FILES ${draco_src_root}/${draco_api_include}
            DESTINATION "${target_directory}")
  endforeach()

  install(
    FILES "${draco_build}/draco/draco_features.h"
    DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/draco/")

  install(TARGETS draco_decoder DESTINATION
                  "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
  install(TARGETS draco_encoder DESTINATION
                  "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")

  if(WIN32)
    install(TARGETS draco DESTINATION
                    "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
  else()
    target_include_directories(draco_static INTERFACE ${DRACO_INCLUDE_DIRS})
    install(TARGETS draco_static EXPORT draco-targets DESTINATION
                    "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
    if(BUILD_SHARED_LIBS)
      target_include_directories(draco_shared INTERFACE ${DRACO_INCLUDE_DIRS})
      install(TARGETS draco_shared EXPORT draco-targets DESTINATION
                      "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
    endif()
    install(EXPORT draco-targets NAMESPACE draco:: DESTINATION
                   "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/draco")
  endif()

  if(DRACO_UNITY_PLUGIN)
    install(TARGETS dracodec_unity DESTINATION
                    "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
  endif()
  if(DRACO_MAYA_PLUGIN)
    install(TARGETS draco_maya_wrapper DESTINATION
                    "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
  endif()

endmacro()