Warning, /games/libkmahjongg/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 find_package(svgcleaner) 0028 set_package_properties(gzip PROPERTIES 0029 TYPE OPTIONAL 0030 PURPOSE "For shrinking the installed SVG files a bit." 0031 ) 0032 0033 function(generate_svgz svg_file svgz_file target_prefix) 0034 cmake_parse_arguments(ARGS "NO_CLEANING" "" "" ${ARGN}) 0035 0036 if (NOT IS_ABSOLUTE ${svg_file}) 0037 set(svg_file "${CMAKE_CURRENT_SOURCE_DIR}/${svg_file}") 0038 endif() 0039 if (NOT EXISTS ${svg_file}) 0040 message(FATAL_ERROR "No such file found: ${svg_file}") 0041 endif() 0042 get_filename_component(_fileName "${svg_file}" NAME) 0043 0044 if(TARGET svgcleaner::svgcleaner AND NOT ARGS_NO_CLEANING) 0045 get_filename_component(cleaned_svg_dir ${svgz_file} DIRECTORY) 0046 get_filename_component(cleaned_svg_basename ${svgz_file} NAME_WLE) 0047 set(cleaned_svg_file "${cleaned_svg_dir}/${cleaned_svg_basename}-cleaned.svg") 0048 0049 add_custom_command( 0050 OUTPUT ${cleaned_svg_file} 0051 COMMAND svgcleaner::svgcleaner 0052 ARGS 0053 "--quiet" 0054 "--no-defaults" 0055 # remove unused elements & attributes 0056 "--remove-metadata=yes" 0057 "--remove-comments=yes" 0058 "--remove-declarations=yes" 0059 "--remove-nonsvg-elements=yes" 0060 "--remove-unused-defs=yes" 0061 "--remove-nonsvg-attributes=yes" 0062 "--remove-text-attributes=yes" 0063 "--remove-unused-coordinates=yes" 0064 "--remove-default-attributes=yes" 0065 "--remove-needless-attributes=yes" 0066 "--simplify-transforms=yes" 0067 # minimize path expressions 0068 "--paths-to-relative=yes" 0069 "--remove-unused-segments=yes" 0070 "--convert-segments=yes" 0071 "--trim-paths=yes" 0072 "--remove-dupl-cmd-in-paths=yes" 0073 "--use-implicit-cmds=yes" 0074 # keep full values 0075 "--coordinates-precision=12" 0076 "--properties-precision=12" 0077 "--transforms-precision=12" 0078 "--paths-coordinates-precision=12" 0079 ${svg_file} 0080 ${cleaned_svg_file} 0081 DEPENDS ${svg_file} 0082 COMMENT "Optimizing ${_fileName}" 0083 ) 0084 set(svg_file ${cleaned_svg_file}) 0085 endif() 0086 0087 if(TARGET 7Zip::7Zip) 0088 add_custom_command( 0089 OUTPUT ${svgz_file} 0090 COMMAND 7Zip::7Zip 0091 ARGS 0092 a 0093 -bd # silence logging 0094 -mx9 # compress best 0095 -tgzip 0096 ${svgz_file} ${svg_file} 0097 DEPENDS ${svg_file} 0098 COMMENT "Gzipping ${_fileName}" 0099 ) 0100 else() 0101 add_custom_command( 0102 OUTPUT ${svgz_file} 0103 COMMAND gzip::gzip 0104 ARGS 0105 -9 # compress best 0106 -n # no original name and timestamp stored, for reproducibility 0107 -c # write to stdout 0108 ${svg_file} > ${svgz_file} 0109 DEPENDS ${svg_file} 0110 COMMENT "Gzipping ${_fileName}" 0111 ) 0112 endif() 0113 0114 add_custom_target("${target_prefix}${_fileName}z" ALL DEPENDS ${svgz_file}) 0115 endfunction() 0116 0117 # setup generral renderig check target 0118 add_custom_target(check_rendering)