Changeset View
Changeset View
Standalone View
Standalone View
cmake/modules/ImageHelper.cmake
Show All 13 Lines | COMMAND | ||||
-p "${DPI}" | -p "${DPI}" | ||||
"${SVG}" | "${SVG}" | ||||
-o "${PNG}" | -o "${PNG}" | ||||
MAIN_DEPENDENCY | MAIN_DEPENDENCY | ||||
"${SVG}" | "${SVG}" | ||||
) | ) | ||||
endmacro() | endmacro() | ||||
macro(_convert_png_to_tiff_darwin PNG TIFF) | |||||
find_program_or_fail(SIPS_EXECUTABLE sips) | |||||
add_custom_command( | |||||
OUTPUT | |||||
"${TIFF}" | |||||
COMMAND | |||||
"${SIPS_EXECUTABLE}" | |||||
-s format tiff | |||||
"${PNG}" | |||||
--out "${TIFF}" | |||||
MAIN_DEPENDENCY | |||||
"${PNG}" | |||||
) | |||||
endmacro() | |||||
macro(_convert_png_to_tiff_linux PNG TIFF) | macro(_convert_png_to_tiff_linux PNG TIFF) | ||||
# find_package(ImageMagick) does not search in the default bin | # find_package(ImageMagick) does not search in the default bin | ||||
# directories and fails. This is a known bug from FindImageMagick: | # directories and fails. This is a known bug from FindImageMagick: | ||||
# https://gitlab.kitware.com/cmake/cmake/issues/16179 | # https://gitlab.kitware.com/cmake/cmake/issues/16179 | ||||
# When the issue is solved the following can be uncommented: | # When the issue is solved the following can be uncommented: | ||||
# find_package(ImageMagick COMPONENTS convert REQUIRED CMAKE_FIND_ROOT_PATH_BOTH) | # find_package(ImageMagick COMPONENTS convert REQUIRED CMAKE_FIND_ROOT_PATH_BOTH) | ||||
# | # | ||||
# For now, use find_program as a workaround. | # For now, use find_program as a workaround. | ||||
find_program_or_fail(ImageMagick_convert_EXECUTABLE convert) | find_program_or_fail(ImageMagick_convert_EXECUTABLE convert) | ||||
add_custom_command( | add_custom_command( | ||||
OUTPUT | OUTPUT | ||||
"${TIFF}" | "${TIFF}" | ||||
COMMAND | COMMAND | ||||
"${ImageMagick_convert_EXECUTABLE}" | "${ImageMagick_convert_EXECUTABLE}" | ||||
"${PNG}" | "${PNG}" | ||||
"${TIFF}" | "${TIFF}" | ||||
MAIN_DEPENDENCY | MAIN_DEPENDENCY | ||||
"${PNG}" | "${PNG}" | ||||
) | ) | ||||
endmacro() | endmacro() | ||||
macro(convert_png_to_tiff PNG TIFF) | macro(convert_png_to_tiff PNG TIFF) | ||||
if(NOT CMAKE_CROSSCOMPILING AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | if(NOT CMAKE_CROSSCOMPILING AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||||
message(FATAL_ERROR "The PNG to TIFF conversion is only supported on Linux.") | _convert_png_to_tiff_darwin("${PNG}" "${TIFF}") | ||||
else() | else() | ||||
_convert_png_to_tiff_linux("${PNG}" "${TIFF}") | _convert_png_to_tiff_linux("${PNG}" "${TIFF}") | ||||
endif() | endif() | ||||
endmacro() | endmacro() | ||||
macro(_cat_multi_resolution_tiff_linux OUTPUT) | macro(_cat_multi_resolution_tiff_linux OUTPUT) | ||||
find_program_or_fail(TIFFCP_EXECUTABLE tiffcp) | find_program_or_fail(TIFFCP_EXECUTABLE tiffcp) | ||||
add_custom_command( | add_custom_command( | ||||
OUTPUT | OUTPUT | ||||
"${OUTPUT}" | "${OUTPUT}" | ||||
COMMAND | COMMAND | ||||
"${TIFFCP_EXECUTABLE}" | "${TIFFCP_EXECUTABLE}" | ||||
-c none | -c none | ||||
${ARGN} | ${ARGN} | ||||
"${OUTPUT}" | "${OUTPUT}" | ||||
DEPENDS | DEPENDS | ||||
${ARGN} | ${ARGN} | ||||
) | ) | ||||
endmacro() | endmacro() | ||||
macro(_cat_multi_resolution_tiff_darwin OUTPUT) | |||||
find_program_or_fail(TIFFUTIL_EXECUTABLE tiffutil) | |||||
add_custom_command( | |||||
OUTPUT | |||||
"${OUTPUT}" | |||||
COMMAND | |||||
"${TIFFUTIL_EXECUTABLE}" | |||||
-cathidpicheck ${ARGN} | |||||
-out "${OUTPUT}" | |||||
DEPENDS | |||||
${ARGN} | |||||
) | |||||
endmacro() | |||||
macro(cat_multi_resolution_tiff OUTPUT) | macro(cat_multi_resolution_tiff OUTPUT) | ||||
if(NOT CMAKE_CROSSCOMPILING AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | if(NOT CMAKE_CROSSCOMPILING AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||||
message(FATAL_ERROR "The PNG to TIFF concatenation is only supported on Linux.") | _cat_multi_resolution_tiff_darwin("${OUTPUT}" ${ARGN}) | ||||
else() | else() | ||||
_cat_multi_resolution_tiff_linux("${OUTPUT}" ${ARGN}) | _cat_multi_resolution_tiff_linux("${OUTPUT}" ${ARGN}) | ||||
endif() | endif() | ||||
endmacro() | endmacro() |