Add a CMake module for icon conversions
This commit is contained in:
		@@ -9,15 +9,15 @@ find_package (Threads)
 | 
				
			|||||||
function (add_threads target)
 | 
					function (add_threads target)
 | 
				
			||||||
	if (NOT Threads_FOUND OR NOT CMAKE_USE_PTHREADS_INIT)
 | 
						if (NOT Threads_FOUND OR NOT CMAKE_USE_PTHREADS_INIT)
 | 
				
			||||||
		message (FATAL_ERROR "pthreads not found")
 | 
							message (FATAL_ERROR "pthreads not found")
 | 
				
			||||||
	endif (NOT Threads_FOUND OR NOT CMAKE_USE_PTHREADS_INIT)
 | 
						endif ()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (THREADS_HAVE_PTHREAD_ARG)
 | 
						if (THREADS_HAVE_PTHREAD_ARG)
 | 
				
			||||||
		set_property (TARGET ${target} PROPERTY
 | 
							set_property (TARGET ${target} PROPERTY
 | 
				
			||||||
			COMPILE_OPTIONS "-pthread")
 | 
								COMPILE_OPTIONS "-pthread")
 | 
				
			||||||
		set_property (TARGET ${target} PROPERTY
 | 
							set_property (TARGET ${target} PROPERTY
 | 
				
			||||||
			INTERFACE_COMPILE_OPTIONS "-pthread")
 | 
								INTERFACE_COMPILE_OPTIONS "-pthread")
 | 
				
			||||||
	endif (THREADS_HAVE_PTHREAD_ARG)
 | 
						endif ()
 | 
				
			||||||
	if (CMAKE_THREAD_LIBS_INIT)
 | 
						if (CMAKE_THREAD_LIBS_INIT)
 | 
				
			||||||
		target_link_libraries (${target} "${CMAKE_THREAD_LIBS_INIT}")
 | 
							target_link_libraries (${target} "${CMAKE_THREAD_LIBS_INIT}")
 | 
				
			||||||
	endif (CMAKE_THREAD_LIBS_INIT)
 | 
						endif ()
 | 
				
			||||||
endfunction (add_threads)
 | 
					endfunction ()
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										40
									
								
								cmake/IconUtils.cmake
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								cmake/IconUtils.cmake
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					# Public Domain
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function (icon_to_png name svg size output_dir output)
 | 
				
			||||||
 | 
						set (_dimensions "${size}x${size}")
 | 
				
			||||||
 | 
						set (_png_path "${output_dir}/hicolor/${_dimensions}/apps")
 | 
				
			||||||
 | 
						set (_png "${_png_path}/${name}.png")
 | 
				
			||||||
 | 
						set (${output} "${_png}" PARENT_SCOPE)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						set (_find_program_REQUIRE)
 | 
				
			||||||
 | 
						if (NOT ${CMAKE_VERSION} VERSION_LESS 3.18.0)
 | 
				
			||||||
 | 
							set (_find_program_REQUIRE REQUIRED)
 | 
				
			||||||
 | 
						endif ()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						find_program (rsvg_convert_EXECUTABLE rsvg-convert ${_find_program_REQUIRE})
 | 
				
			||||||
 | 
						add_custom_command (OUTPUT "${_png}"
 | 
				
			||||||
 | 
							COMMAND ${CMAKE_COMMAND} -E make_directory "${_png_path}"
 | 
				
			||||||
 | 
							COMMAND ${rsvg_convert_EXECUTABLE} "--output=${_png}"
 | 
				
			||||||
 | 
								"--width=${size}" "--height=${size}" -- "${svg}"
 | 
				
			||||||
 | 
							DEPENDS "${svg}"
 | 
				
			||||||
 | 
							COMMENT "Generating ${name} ${_dimensions} application icon" VERBATIM)
 | 
				
			||||||
 | 
					endfunction ()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# You should include a 256x256 icon--which takes less space as raw PNG.
 | 
				
			||||||
 | 
					function (icon_for_win32 ico pngs pngs_raw)
 | 
				
			||||||
 | 
						set (_raws)
 | 
				
			||||||
 | 
						foreach (png ${pngs_raw})
 | 
				
			||||||
 | 
							list (APPEND _raws "--raw=${png}")
 | 
				
			||||||
 | 
						endforeach ()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						set (_find_program_REQUIRE)
 | 
				
			||||||
 | 
						if (NOT ${CMAKE_VERSION} VERSION_LESS 3.18.0)
 | 
				
			||||||
 | 
							set (_find_program_REQUIRE REQUIRED)
 | 
				
			||||||
 | 
						endif ()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						find_program (icotool_EXECUTABLE icotool ${_find_program_REQUIRE})
 | 
				
			||||||
 | 
						add_custom_command (OUTPUT "${ico}"
 | 
				
			||||||
 | 
							COMMAND ${icotool_EXECUTABLE} -c -o "${ico}" ${_raws} -- ${pngs}
 | 
				
			||||||
 | 
							DEPENDS ${pngs} ${pngs_raw}
 | 
				
			||||||
 | 
							COMMENT "Generating Windows program icon" VERBATIM)
 | 
				
			||||||
 | 
					endfunction ()
 | 
				
			||||||
		Reference in New Issue
	
	Block a user