• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (c) 2018, Alliance for Open Media. All rights reserved
3#
4# This source code is subject to the terms of the BSD 2 Clause License and the
5# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
6# not distributed with this source code in the LICENSE file, you can obtain it
7# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
8# License 1.0 was not distributed with this source code in the PATENTS file, you
9# can obtain it at www.aomedia.org/license/patent.
10#
11list(APPEND AOM_INSTALL_INCS "${AOM_ROOT}/aom/aom.h"
12            "${AOM_ROOT}/aom/aom_codec.h" "${AOM_ROOT}/aom/aom_frame_buffer.h"
13            "${AOM_ROOT}/aom/aom_image.h" "${AOM_ROOT}/aom/aom_integer.h"
14            "${AOM_ROOT}/aom/aom.h")
15
16if(CONFIG_AV1_DECODER)
17  list(APPEND AOM_INSTALL_INCS "${AOM_ROOT}/aom/aom_decoder.h"
18              "${AOM_ROOT}/aom/aomdx.h")
19endif()
20
21if(CONFIG_AV1_ENCODER)
22  list(APPEND AOM_INSTALL_INCS "${AOM_ROOT}/aom/aomcx.h"
23              "${AOM_ROOT}/aom/aom_encoder.h")
24endif()
25
26# Generate aom.pc and setup dependencies to ensure it is created when necessary.
27# Note: aom.pc generation uses GNUInstallDirs:
28# https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
29macro(setup_aom_install_targets)
30  if(NOT (MSVC OR XCODE))
31    include("GNUInstallDirs")
32    set(AOM_PKG_CONFIG_FILE "${AOM_CONFIG_DIR}/aom.pc")
33
34    # Create a dummy library target for creating aom.pc.
35    create_dummy_source_file(aom_pc c AOM_PKG_CONFIG_SOURCES)
36    add_library(aom_pc ${AOM_PKG_CONFIG_SOURCES})
37
38    # Setup a rule to generate aom.pc.
39    add_custom_command(
40      OUTPUT "${AOM_PKG_CONFIG_FILE}"
41      COMMAND ${CMAKE_COMMAND} ARGS
42              -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR} -DAOM_ROOT=${AOM_ROOT}
43              -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
44              -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR}
45              -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}
46              -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
47              -DCMAKE_PROJECT_NAME=${CMAKE_PROJECT_NAME}
48              -DCONFIG_MULTITHREAD=${CONFIG_MULTITHREAD}
49              -DHAVE_PTHREAD_H=${HAVE_PTHREAD_H} -P
50              "${AOM_ROOT}/build/cmake/pkg_config.cmake"
51      COMMENT "Writing aom.pc"
52      VERBATIM)
53
54    # Explicitly add a dependency on the pkg-config file to ensure it's built.
55    get_property(aom_pc_sources TARGET aom_pc PROPERTY SOURCES)
56    set_source_files_properties(${aom_pc_sources} OBJECT_DEPENDS
57                                "${AOM_PKG_CONFIG_FILE}")
58
59    # Our pkg-config file carries version information: add a dependency on the
60    # version rule.
61    add_dependencies(aom_pc aom_version)
62
63    if(CONFIG_AV1_DECODER)
64      if(ENABLE_EXAMPLES)
65        list(APPEND AOM_INSTALL_BINS aomdec)
66      endif()
67    endif()
68
69    if(CONFIG_AV1_ENCODER)
70      if(ENABLE_EXAMPLES)
71        list(APPEND AOM_INSTALL_BINS aomenc)
72      endif()
73    endif()
74
75    if(BUILD_SHARED_LIBS)
76      set(AOM_INSTALL_LIBS aom aom_static)
77    else()
78      set(AOM_INSTALL_LIBS aom)
79    endif()
80
81    # Setup the install rules.
82    install(
83      FILES ${AOM_INSTALL_INCS}
84      DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/aom")
85    install(
86      FILES "${AOM_PKG_CONFIG_FILE}"
87      DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig")
88    install(TARGETS ${AOM_INSTALL_LIBS} DESTINATION
89                    "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
90
91    if(ENABLE_EXAMPLES)
92      install(TARGETS ${AOM_INSTALL_BINS} DESTINATION
93                      "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
94    endif()
95  endif()
96endmacro()
97