Warning, /games/kgoldrunner/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     get_filename_component(_svgzdir "${svgz_file}" DIRECTORY)
0036 
0037     if(TARGET 7Zip::7Zip)
0038         add_custom_command(
0039             OUTPUT ${svgz_file}
0040             COMMAND ${CMAKE_COMMAND} -E make_directory ${_svgzdir} # ensure output dir exists
0041             COMMAND 7Zip::7Zip
0042             ARGS
0043                 a
0044                 -bd # silence logging
0045                 -mx9 # compress best
0046                 -tgzip
0047                 ${svgz_file} ${svg_file}
0048             DEPENDS ${svg_file}
0049             COMMENT "Gzipping ${_fileName}"
0050         )
0051     else()
0052         add_custom_command(
0053             OUTPUT ${svgz_file}
0054             COMMAND ${CMAKE_COMMAND} -E make_directory ${_svgzdir} # ensure output dir exists
0055             COMMAND gzip::gzip
0056             ARGS
0057                 -9 # compress best
0058                 -n # no original name and timestamp stored, for reproducibility
0059                 -c # write to stdout
0060                 ${svg_file} > ${svgz_file}
0061             DEPENDS ${svg_file}
0062             COMMENT "Gzipping ${_fileName}"
0063         )
0064     endif()
0065 
0066     add_custom_target("${target_prefix}${_fileName}z" ALL DEPENDS ${svgz_file})
0067 endfunction()