FindIcotool.cmake 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file LICENSE.rst or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindIcotool
  5. -----------
  6. Finds ``icotool``, command-line program for converting and creating Win32 icon
  7. and cursor files:
  8. .. code-block:: cmake
  9. find_package(Icotool [<version>] [...])
  10. Result Variables
  11. ^^^^^^^^^^^^^^^^
  12. This module defines the following variables:
  13. ``Icotool_FOUND``
  14. True if ``icotool`` has been found. For backward compatibility, the
  15. ``ICOTOOL_FOUND`` variable is also set to the same value.
  16. ``ICOTOOL_VERSION_STRING``
  17. The version of ``icotool`` found.
  18. Cache Variables
  19. ^^^^^^^^^^^^^^^
  20. The following cache variables may also be set:
  21. ``ICOTOOL_EXECUTABLE``
  22. The full path to the ``icotool`` tool.
  23. Examples
  24. ^^^^^^^^
  25. Finding ``icotool`` and executing it in a process to create ``.ico`` icon from
  26. the source ``.png`` image located in the current source directory:
  27. .. code-block:: cmake
  28. find_package(Icotool)
  29. if(Icotool_FOUND)
  30. execute_process(
  31. COMMAND
  32. ${ICOTOOL_EXECUTABLE} -c -o ${CMAKE_CURRENT_BINARY_DIR}/img.ico img.png
  33. )
  34. endif()
  35. #]=======================================================================]
  36. find_program(ICOTOOL_EXECUTABLE
  37. icotool
  38. )
  39. if(ICOTOOL_EXECUTABLE)
  40. execute_process(
  41. COMMAND ${ICOTOOL_EXECUTABLE} --version
  42. OUTPUT_VARIABLE _icotool_version
  43. ERROR_QUIET
  44. OUTPUT_STRIP_TRAILING_WHITESPACE
  45. )
  46. if("${_icotool_version}" MATCHES "^icotool \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
  47. set( ICOTOOL_VERSION_STRING
  48. "${CMAKE_MATCH_1}"
  49. )
  50. else()
  51. set( ICOTOOL_VERSION_STRING
  52. ""
  53. )
  54. endif()
  55. unset(_icotool_version)
  56. endif()
  57. include(FindPackageHandleStandardArgs)
  58. find_package_handle_standard_args(
  59. Icotool
  60. REQUIRED_VARS ICOTOOL_EXECUTABLE
  61. VERSION_VAR ICOTOOL_VERSION_STRING
  62. )
  63. mark_as_advanced(
  64. ICOTOOL_EXECUTABLE
  65. )