FindDevIL.cmake 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindDevIL
  5. ---------
  6. This module locates the developer's image library.
  7. https://openil.sourceforge.net/
  8. IMPORTED Targets
  9. ^^^^^^^^^^^^^^^^
  10. .. versionadded:: 3.21
  11. This module defines the :prop_tgt:`IMPORTED` targets:
  12. ``DevIL::IL``
  13. Defined if the system has DevIL.
  14. ``DevIL::ILU``
  15. Defined if the system has DevIL Utilities.
  16. ``DevIL::ILUT``
  17. Defined if the system has DevIL Utility Toolkit.
  18. Result Variables
  19. ^^^^^^^^^^^^^^^^
  20. This module sets:
  21. ``IL_LIBRARIES``
  22. The name of the IL library. These include the full path to
  23. the core DevIL library. This one has to be linked into the
  24. application.
  25. ``ILU_LIBRARIES``
  26. The name of the ILU library. Again, the full path. This
  27. library is for filters and effects, not actual loading. It
  28. doesn't have to be linked if the functionality it provides
  29. is not used.
  30. ``ILUT_LIBRARIES``
  31. The name of the ILUT library. Full path. This part of the
  32. library interfaces with OpenGL. It is not strictly needed
  33. in applications.
  34. ``IL_INCLUDE_DIR``
  35. where to find the il.h, ilu.h and ilut.h files.
  36. ``DevIL_FOUND``
  37. This is set to TRUE if all the above variables were set.
  38. This will be set to false if ILU or ILUT are not found,
  39. even if they are not needed. In most systems, if one
  40. library is found all the others are as well. That's the
  41. way the DevIL developers release it.
  42. ``DevIL_ILUT_FOUND``
  43. .. versionadded:: 3.21
  44. This is set to TRUE if the ILUT library is found.
  45. #]=======================================================================]
  46. # TODO: Add version support.
  47. # Tested under Linux and Windows (MSVC)
  48. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  49. find_path(IL_INCLUDE_DIR il.h
  50. PATH_SUFFIXES include IL
  51. DOC "The path to the directory that contains il.h"
  52. )
  53. #message("IL_INCLUDE_DIR is ${IL_INCLUDE_DIR}")
  54. find_library(IL_LIBRARIES
  55. NAMES IL DEVIL
  56. PATH_SUFFIXES libx32 lib64 lib lib32
  57. DOC "The file that corresponds to the base il library."
  58. )
  59. #message("IL_LIBRARIES is ${IL_LIBRARIES}")
  60. find_library(ILUT_LIBRARIES
  61. NAMES ILUT
  62. PATH_SUFFIXES libx32 lib64 lib lib32
  63. DOC "The file that corresponds to the il (system?) utility library."
  64. )
  65. #message("ILUT_LIBRARIES is ${ILUT_LIBRARIES}")
  66. find_library(ILU_LIBRARIES
  67. NAMES ILU
  68. PATH_SUFFIXES libx32 lib64 lib lib32
  69. DOC "The file that corresponds to the il utility library."
  70. )
  71. #message("ILU_LIBRARIES is ${ILU_LIBRARIES}")
  72. FIND_PACKAGE_HANDLE_STANDARD_ARGS(DevIL DEFAULT_MSG
  73. IL_LIBRARIES ILU_LIBRARIES
  74. IL_INCLUDE_DIR)
  75. # provide legacy variable for compatibility
  76. set(IL_FOUND ${DevIL_FOUND})
  77. # create imported targets ONLY if we found DevIL.
  78. if(DevIL_FOUND)
  79. # Report the ILUT found if ILUT_LIBRARIES contains valid path.
  80. if (ILUT_LIBRARIES)
  81. set(DevIL_ILUT_FOUND TRUE)
  82. else()
  83. set(DevIL_ILUT_FOUND FALSE)
  84. endif()
  85. if(NOT TARGET DevIL::IL)
  86. add_library(DevIL::IL UNKNOWN IMPORTED)
  87. set_target_properties(DevIL::IL PROPERTIES
  88. INTERFACE_INCLUDE_DIRECTORIES "${IL_INCLUDE_DIR}"
  89. IMPORTED_LOCATION "${IL_LIBRARIES}")
  90. endif()
  91. # DevIL Utilities target
  92. if(NOT TARGET DevIL::ILU)
  93. add_library(DevIL::ILU UNKNOWN IMPORTED)
  94. set_target_properties(DevIL::ILU PROPERTIES
  95. IMPORTED_LOCATION "${ILU_LIBRARIES}")
  96. target_link_libraries(DevIL::ILU INTERFACE DevIL::IL)
  97. endif()
  98. # ILUT (if found)
  99. if(NOT TARGET DevIL::ILUT AND DevIL_ILUT_FOUND)
  100. add_library(DevIL::ILUT UNKNOWN IMPORTED)
  101. set_target_properties(DevIL::ILUT PROPERTIES
  102. IMPORTED_LOCATION "${ILUT_LIBRARIES}")
  103. target_link_libraries(DevIL::ILUT INTERFACE DevIL::ILU)
  104. endif()
  105. endif()