"Fossies" - the Fresh Open Source Software Archive

Member "navit-0.5.6/navit/icons/CMakeLists.txt" (6 Mar 2021, 5679 Bytes) of package /linux/privat/navit-0.5.6.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "CMakeLists.txt": 0.5.5_vs_0.5.6.

    1 macro(convert_to_png IMAGE_INPUT IMAGE_OUTPUT SCALE)
    2 	get_filename_component(FILE_EXT ${IMAGE_INPUT} EXT)
    3 	string(TOUPPER ${FILE_EXT} FILE_TYPE)
    4 	string(REGEX REPLACE "^\\." "" FILE_TYPE ${FILE_TYPE})
    5 	if(${IMAGE_CONVERTER_${FILE_TYPE}} MATCHES "rsvg-convert")
    6 		if (${SCALE} GREATER 0)
    7 			set(SCALE_ARGS --width=${SCALE} --height=${SCALE})
    8 		else()
    9 			set(SCALE_ARGS)
   10 		endif()
   11 		set(COMMAND_ARGS ${SCALE_ARGS} --output ${IMAGE_OUTPUT} ${IMAGE_INPUT})
   12 	elseif(${IMAGE_CONVERTER_${FILE_TYPE}} MATCHES "convert")
   13 		if (${SCALE} GREATER 0)
   14 			set(SCALE_ARGS -resize ${SCALE}x${SCALE})
   15 		else()
   16 			set(SCALE_ARGS)
   17 		endif()
   18 		set(COMMAND_ARGS -background none ${IMAGE_INPUT} ${SCALE_ARGS} ${IMAGE_OUTPUT})
   19 	elseif(${IMAGE_CONVERTER_${FILE_TYPE}} MATCHES "ksvgtopng")
   20 		set (NEW_SCALE ${SCALE})
   21 		if (${SCALE} EQUAL 0)
   22 			file(STRINGS  ${IMAGE_INPUT} NEW_SCALE_LINE REGEX "[^-]width=\"[0-9pxt.]*\"")
   23 			string(REGEX MATCH "width=\"([0-9]*)[pxt]*\"" NEW_SCALE_LINE ${NEW_SCALE_LINE})
   24 			set(NEW_SCALE ${CMAKE_MATCH_1})
   25 		endif()
   26 		set(COMMAND_ARGS ${NEW_SCALE} ${NEW_SCALE}  ${IMAGE_INPUT} ${IMAGE_OUTPUT})
   27 	elseif(${IMAGE_CONVERTER_${FILE_TYPE}} MATCHES "inkscape")
   28 		if (${SCALE} GREATER 0)
   29 			set(SCALE_ARGS --export-width=${SCALE} --export-height=${SCALE})
   30 		else()
   31 			set(SCALE_ARGS)
   32 		endif()
   33 		set(COMMAND_ARGS --export-type=png --export-background-opacity=0 ${SCALE_ARGS} --export-filename=${IMAGE_OUTPUT} ${IMAGE_INPUT})
   34 	else()
   35 		message(FATAL_ERROR "no svg2png converter defined here.")
   36 	endif()
   37 
   38 	add_custom_command (
   39 		OUTPUT ${IMAGE_OUTPUT}
   40 		DEPENDS ${IMAGE_INPUT}
   41 		COMMAND ${IMAGE_CONVERTER_${FILE_TYPE}} ${COMMAND_ARGS}
   42 		)
   43 endmacro()
   44 
   45 macro(add_scale_targets IMAGE_SRC IMAGE_NAME)
   46 	string(REPLACE "," ";" SCALES "${ARGN}")
   47 	set(add_scale_targets_is_first_scale 1)
   48 	foreach (CURRENT_SCALE ${SCALES})
   49 		if(add_scale_targets_is_first_scale EQUAL 1)
   50 			set (IMAGE_DST ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_NAME}.png)
   51 			set(add_scale_targets_is_first_scale 0)
   52 		elseif (${CURRENT_SCALE} EQUAL 0)
   53 			set (IMAGE_DST ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_NAME}.png)
   54 			message_error( "Image size value of 0 to leave image unscaled can only be given as the first value in row, e.g. -D svg2png_scaling=0,16,32 " )
   55 		else()
   56 			set (IMAGE_DST ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_NAME}_${CURRENT_SCALE}_${CURRENT_SCALE}.png)
   57 		endif()
   58 
   59 		if(NOT CURRENT_SCALE EQUAL -1)
   60 			convert_to_png(
   61 				${CMAKE_CURRENT_SOURCE_DIR}/${IMAGE_SRC}
   62 				${IMAGE_DST}
   63 				${CURRENT_SCALE}
   64 				)
   65 			list(APPEND IMAGE_TARGETS ${IMAGE_DST})
   66 		endif()
   67 	endforeach()
   68 endmacro()
   69 
   70 if(NOT DEFINED NAVIT_BINARY)
   71 	set(NAVIT_BINARY navit CACHE STRING "Navit binary name  not defined")
   72 endif()
   73 #patch binary name in desktop file
   74 configure_file(desktop_icons/navit.desktop.in desktop_icons/${PACKAGE}.desktop)
   75 install(FILES  ${CMAKE_CURRENT_BINARY_DIR}/desktop_icons/${PACKAGE}.desktop DESTINATION share/applications)
   76 install(FILES  desktop_icons/22x22/navit.png DESTINATION share/icons/hicolor/22x22/apps RENAME ${PACKAGE}.png)
   77 install(FILES  desktop_icons/86x86/navit.png DESTINATION share/icons/hicolor/86x86/apps RENAME ${PACKAGE}.png)
   78 install(FILES  desktop_icons/108x108/navit.png DESTINATION share/icons/hicolor/108x108/apps RENAME ${PACKAGE}.png)
   79 install(FILES  desktop_icons/128x128/navit.png DESTINATION share/icons/hicolor/128x128/apps RENAME ${PACKAGE}.png)
   80 install(FILES  desktop_icons/256x256/navit.png DESTINATION share/icons/hicolor/256x256/apps RENAME ${PACKAGE}.png)
   81 #install(FILES  bench.xpm DESTINATION )
   82 
   83 if (USE_SVG OR SVG2PNG)
   84 	FILE(GLOB SVG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.svg" "*.svgz")
   85 
   86 	if(USE_SVG)
   87 		list(APPEND IMAGES_TO_COPY ${SVG_FILES})
   88 	endif(USE_SVG)
   89 	if(SVG2PNG)
   90 		list(APPEND FILES_TO_PNG ${SVG_FILES})
   91 	endif(SVG2PNG)
   92 endif()
   93 
   94 FILE(GLOB XPM_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.xpm")
   95 if(XPM2PNG)
   96 	foreach (IMAGE_SRC ${SVG_FILES})
   97 		string(REGEX REPLACE ".[a-z]*\$" "" IMAGE ${IMAGE_SRC})
   98 		list(APPEND SVG_FILES_BASENAMES ${IMAGE})
   99 	endforeach()
  100 	foreach (IMAGE_SRC ${XPM_FILES})
  101 		string(REGEX REPLACE ".[a-z]*\$" "" IMAGE ${IMAGE_SRC})
  102 		list(FIND SVG_FILES_BASENAMES ${IMAGE} DUP_IMG)
  103 		if ( ${DUP_IMG} LESS 0 )
  104 			list(APPEND FILES_TO_PNG ${IMAGE_SRC})
  105 		else()
  106 			message(STATUS "image '${IMAGE}': XPM version skipped in favor of SVG")
  107 		endif()
  108 	endforeach()
  109 else()
  110 	list(APPEND IMAGES_TO_COPY ${XPM_FILES})
  111 endif(XPM2PNG)
  112 
  113 foreach (IMAGE_SRC ${FILES_TO_PNG})
  114 	string(REGEX REPLACE ".[a-z]*\$" "" IMAGE ${IMAGE_SRC})
  115 
  116 	if ( IMAGE_SRC MATCHES ".*svgz*" )
  117 		if ( DEFINED svg2png_scaling_nav AND ${IMAGE} MATCHES "^nav_")
  118 			add_scale_targets(${IMAGE_SRC} ${IMAGE} ${svg2png_scaling_nav})
  119 		elseif( DEFINED svg2png_scaling_flag AND ${IMAGE} MATCHES "^country_")
  120 			add_scale_targets(${IMAGE_SRC} ${IMAGE} ${svg2png_scaling_flag})
  121 		elseif( DEFINED svg2png_scaling)
  122 			add_scale_targets(${IMAGE_SRC} ${IMAGE} ${svg2png_scaling})
  123 		endif()
  124 	else()
  125 		add_scale_targets(${IMAGE_SRC} ${IMAGE} 0)
  126 	endif()
  127 
  128 endforeach()
  129 
  130 foreach (IMAGE_FILE ${IMAGES_TO_COPY})
  131 	add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_FILE}"
  132 		DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${IMAGE_FILE}"
  133 		COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${IMAGE_FILE}"
  134 		"${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_FILE}"
  135 		)
  136 	list(APPEND IMAGE_TARGETS "${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_FILE}")
  137 endforeach()
  138 
  139 add_custom_target(images ALL DEPENDS ${IMAGE_TARGETS})
  140 add_custom_target(images_resource COMMAND mkdir -p ../resources/share/navit/xpm COMMAND cp ${IMAGE_TARGETS} ../resources/share/navit/xpm)
  141 add_dependencies(images_resource images)
  142 
  143 install(
  144 	FILES ${IMAGE_TARGETS}
  145 	DESTINATION ${IMAGE_DIR}
  146 	PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
  147 	)