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

0001 # SPDX-FileCopyrightText: 2021, 2023 Friedrich W. H. Kossebau <kossebau@kde.org>
0002 #
0003 # SPDX-License-Identifier: BSD-3-Clause
0004 
0005 find_package(7Zip)
0006 set_package_properties(7Zip PROPERTIES
0007     PURPOSE "For installing SVG files as SVGZ"
0008 )
0009 
0010 if(WIN32)
0011     set_package_properties(7Zip PROPERTIES
0012         TYPE REQUIRED
0013     )
0014 else()
0015     set_package_properties(7Zip PROPERTIES
0016         TYPE OPTIONAL
0017     )
0018     if(NOT TARGET 7Zip::7Zip)
0019         find_package(gzip)
0020         set_package_properties(gzip PROPERTIES
0021             TYPE REQUIRED
0022             PURPOSE "For installing SVG files as SVGZ (less efficient fallback for 7Zip)"
0023         )
0024     endif()
0025 endif()
0026 
0027 function(generate_svgz svg_file svgz_file target_prefix)
0028     if (NOT IS_ABSOLUTE ${svg_file})
0029         set(svg_file "${CMAKE_CURRENT_SOURCE_DIR}/${svg_file}")
0030     endif()
0031     if (NOT EXISTS ${svg_file})
0032         message(FATAL_ERROR "No such file found: ${svg_file}")
0033     endif()
0034     get_filename_component(_fileName "${svg_file}" NAME)
0035 
0036     if(TARGET 7Zip::7Zip)
0037         add_custom_command(
0038             OUTPUT ${svgz_file}
0039             COMMAND 7Zip::7Zip
0040             ARGS
0041                 a
0042                 -bd # silence logging
0043                 -mx9 # compress best
0044                 -tgzip
0045                 ${svgz_file} ${svg_file}
0046             DEPENDS ${svg_file}
0047             COMMENT "Gzipping ${_fileName}"
0048         )
0049     else()
0050         add_custom_command(
0051             OUTPUT ${svgz_file}
0052             COMMAND gzip::gzip
0053             ARGS
0054                 -9 # compress best
0055                 -n # no original name and timestamp stored, for reproducibility
0056                 -c # write to stdout
0057                 ${svg_file} > ${svgz_file}
0058             DEPENDS ${svg_file}
0059             COMMENT "Gzipping ${_fileName}"
0060         )
0061     endif()
0062 
0063     add_custom_target("${target_prefix}${_fileName}z" ALL DEPENDS ${svgz_file})
0064 endfunction()