Warning, /frameworks/extra-cmake-modules/modules/ECMConfiguredInstall.cmake is written in an unsupported language. File is not indexed.

0001 # SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
0002 #
0003 # SPDX-License-Identifier: BSD-3-Clause
0004 
0005 #[=======================================================================[.rst:
0006 ECMConfiguredInstall
0007 --------------------
0008 
0009 Takes a list of files, runs ``configure_file`` on each and installs the resultant configured files in the given location.
0010 
0011 Any suffix of ".in" in the passed file names will be stripped from the file name at the installed location.
0012 
0013 ::
0014 
0015   ecm_install_configured_files(
0016       INPUT <file> [<file2> [...]]
0017       DESTINATION <INSTALL_DIRECTORY>
0018       [COPYONLY]
0019       [ESCAPE_QUOTES]
0020       [@ONLY]
0021       [COMPONENT <component>])
0022 
0023 Example usage:
0024 
0025 .. code-block:: cmake
0026 
0027   ecm_install_configured_files(INPUT foo.txt.in DESTINATION ${KDE_INSTALL_DATADIR} @ONLY)
0028 
0029 This will install the file as foo.txt with any cmake variable replacements made into the data directory.
0030 
0031 Since 5.73.0.
0032 #]=======================================================================]
0033 
0034 function(ecm_install_configured_files)
0035     set(options COPYONLY ESCAPE_QUOTES @ONLY)
0036     set(oneValueArgs DESTINATION COMPONENT)
0037     set(multiValueArgs INPUT)
0038 
0039     cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}"
0040                           "${multiValueArgs}" ${ARGN})
0041 
0042 
0043     if(ARGS_UNPARSED_ARGUMENTS)
0044         message(FATAL_ERROR "Unknown arguments given to ecm_install_configured_file(): \"${ARGS_UNPARSED_ARGUMENTS}\"")
0045     endif()
0046 
0047     if (NOT ARGS_DESTINATION)
0048         message(FATAL_ERROR "missing DESTINATION argument to ECMConfiguredInstall")
0049     endif()
0050 
0051     foreach(_input ${ARGS_INPUT})
0052         # convert absolute paths
0053         get_filename_component(_name ${_input} NAME)
0054 
0055         string(REGEX REPLACE "\\.in$"  "" _name ${_name})
0056 
0057         set(_out_file ${CMAKE_CURRENT_BINARY_DIR}/${_name})
0058 
0059         set(_configure_args)
0060         if (ARGS_COPY_ONLY)
0061                 list(APPEND _configure_args COPY_ONLY)
0062         endif()
0063         if (ARGS_ESCAPE_QUOTES)
0064                 list(APPEND _configure_args  ESCAPE_QUOTES)
0065         endif()
0066         if (ARGS_@ONLY)
0067                 list(APPEND _configure_args @ONLY)
0068         endif()
0069 
0070         configure_file(${_input} ${_out_file} ${_configure_args})
0071 
0072         if (DEFINED ARGS_COMPONENT)
0073             set(_component COMPONENT ${ARGS_COMPONENT})
0074         else()
0075             set(_component)
0076         endif()
0077 
0078         install(FILES ${_out_file} DESTINATION ${ARGS_DESTINATION} ${_component})
0079     endforeach()
0080 endfunction()