Debian Codegraph @

cmake/tribits/core/package_arch/TribitsInstallHeaders.cmake

raw
1 # @HEADER
2 # *****************************************************************************
3 # TriBITS: Tribal Build, Integrate, and Test System
4 #
5 # Copyright 2013-2016 NTESS and the TriBITS contributors.
6 # SPDX-License-Identifier: BSD-3-Clause
7 # *****************************************************************************
8 # @HEADER
9
10
11 include(CMakeParseArguments)
12
13
14 # @FUNCTION: tribits_install_headers()
15 #
16 # Function used to (optionally) install header files using ``install()``
17 # command.
18 #
19 # Usage::
20 #
21 # tribits_install_headers(
22 # HEADERS <h0> <h1> ...
23 # [INSTALL_SUBDIR <subdir>]
24 # [COMPONENT <component>]
25 # )
26 #
27 # The formal arguments are:
28 #
29 # ``HEADERS <h0> <h1> ...``
30 #
31 # List of header files to install. By default, these header files are
32 # assumed to be in the current source directory. They can also contain
33 # the relative path or absolute path to the files if they are not in the
34 # current source directory.
35 #
36 # ``INSTALL_SUBDIR <subdir>``
37 #
38 # Optional subdirectory that the headers will be installed under the
39 # standard installation directory. If ``<subdir>!=""``, then the headers
40 # will be installed under
41 # ``${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/<subdir>``. Otherwise, they will
42 # be installed under ``${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/``.
43 #
44 # ``COMPONENT <component>``
45 #
46 # If specified, then ``COMPONENT <component>`` will be passed into
47 # ``install()``. Otherwise, ``COMPONENT ${PROJECT_NAME}`` will get used.
48 #
49 # If `${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS`_ is ``FALSE``, then the
50 # headers will not get installed.
51 #
52 function(tribits_install_headers)
53
54 if (${PROJECT_NAME}_VERBOSE_CONFIGURE)
55 set(TRIBITS_INSTALL_HEADERS_DEBUG_DUMP TRUE)
56 endif()
57
58 if (TRIBITS_INSTALL_HEADERS_DEBUG_DUMP)
59 message("\nTRIBITS_INSTALL_HEADERS: ${ARGN}")
60 endif()
61
62 cmake_parse_arguments(
63 #prefix
64 PARSE
65 #Options
66 ""
67 #one_value_keywords
68 ""
69 #multi_value_keywords
70 "HEADERS;INSTALL_SUBDIR;COMPONENT"
71 ${ARGN}
72 )
73
74 tribits_check_for_unparsed_arguments()
75
76 # ToDo: Assert PARSE_HEADERS has at least one argument!
77 # ToDo: Assert PARSE_INSTALL_DIR has 0 or 1 arguments!
78 # ToDo: Assert PARSE_COMONENT has 0 or 1 arguments!
79
80 if (PARSE_INSTALL_SUBDIR)
81 set(INSTALL_DIR "${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}/${PARSE_INSTALL_SUBDIR}")
82 else()
83 set(INSTALL_DIR "${${PROJECT_NAME}_INSTALL_INCLUDE_DIR}")
84 endif()
85
86 if (PARSE_COMPONENT)
87 set(COMPONENT ${PARSE_COMPONENT})
88 else()
89 set(COMPONENT ${PROJECT_NAME})
90 endif()
91
92 if (${PROJECT_NAME}_INSTALL_LIBRARIES_AND_HEADERS)
93 if (TRIBITS_INSTALL_HEADERS_DEBUG_DUMP)
94 message("\nTRIBITS_INSTALL_HEADERS: Installing headers into '${INSTALL_DIR}'")
95 endif()
96 install(
97 FILES ${PARSE_HEADERS}
98 DESTINATION "${INSTALL_DIR}"
99 COMPONENT ${COMPONENT}
100 )
101 endif()
102
103 endfunction()