Warning, /games/kblocks/cmake/InternalMacros.cmake is written in an unsupported language. File is not indexed.

0001 # SPDX-FileCopyrightText: 2021-2022 Friedrich W. H. Kossebau <kossebau@kde.org>
0002 #
0003 # SPDX-License-Identifier: BSD-3-Clause
0004 
0005 if(WIN32)
0006     find_package(7z)
0007     set_package_properties(7z PROPERTIES
0008         TYPE REQUIRED
0009         PURPOSE "For installing SVG files as SVGZ"
0010     )
0011 else()
0012     find_package(gzip)
0013     set_package_properties(gzip PROPERTIES
0014         TYPE REQUIRED
0015         PURPOSE "For installing SVG files as SVGZ"
0016     )
0017 endif()
0018 
0019 
0020 function(generate_svgz svg_file svgz_file target_prefix)
0021     if (NOT IS_ABSOLUTE ${svg_file})
0022         set(svg_file "${CMAKE_CURRENT_SOURCE_DIR}/${svg_file}")
0023     endif()
0024     if (NOT EXISTS ${svg_file})
0025         message(FATAL_ERROR "No such file found: ${svg_file}")
0026     endif()
0027     get_filename_component(_fileName "${svg_file}" NAME)
0028 
0029     if(WIN32)
0030         add_custom_command(
0031             OUTPUT ${svgz_file}
0032             COMMAND 7z::7z
0033             ARGS
0034                 a
0035                 -tgzip
0036                 ${svgz_file} ${svg_file}
0037             DEPENDS ${svg_file}
0038             COMMENT "Gzipping ${_fileName}"
0039         )
0040     else()
0041         add_custom_command(
0042             OUTPUT ${svgz_file}
0043             COMMAND ${gzip_EXECUTABLE}
0044             ARGS
0045                 -9n
0046                 -c
0047                 ${svg_file} > ${svgz_file}
0048             DEPENDS ${svg_file}
0049             COMMENT "Gzipping ${_fileName}"
0050         )
0051     endif()
0052 
0053     add_custom_target("${target_prefix}${_fileName}z" ALL DEPENDS ${svgz_file})
0054 endfunction()