1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 #[=======================================================================[.rst:
10 This module locates the developer's image library.
11 https://openil.sourceforge.net/
16 .. versionadded:: 3.21
18 This module defines the :prop_tgt:`IMPORTED` targets:
21 Defined if the system has DevIL.
24 Defined if the system has DevIL Utilities.
27 Defined if the system has DevIL Utility Toolkit.
35 The name of the IL library. These include the full path to
36 the core DevIL library. This one has to be linked into the
40 The name of the ILU library. Again, the full path. This
41 library is for filters and effects, not actual loading. It
42 doesn't have to be linked if the functionality it provides
46 The name of the ILUT library. Full path. This part of the
47 library interfaces with OpenGL. It is not strictly needed
51 where to find the il.h, ilu.h and ilut.h files.
54 This is set to TRUE if all the above variables were set.
55 This will be set to false if ILU or ILUT are not found,
56 even if they are not needed. In most systems, if one
57 library is found all the others are as well. That's the
58 way the DevIL developers release it.
61 .. versionadded:: 3.21
63 This is set to TRUE if the ILUT library is found.
64 #]=======================================================================]
66 # TODO: Add version support.
67 # Tested under Linux and Windows (MSVC)
69 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
71 find_path(IL_INCLUDE_DIR il.h
72 PATH_SUFFIXES include IL
73 DOC "The path to the directory that contains il.h"
76 #message("IL_INCLUDE_DIR is ${IL_INCLUDE_DIR}")
78 find_library(IL_LIBRARIES
80 PATH_SUFFIXES libx32 lib64 lib lib32
81 DOC "The file that corresponds to the base il library."
84 #message("IL_LIBRARIES is ${IL_LIBRARIES}")
86 find_library(ILUT_LIBRARIES
88 PATH_SUFFIXES libx32 lib64 lib lib32
89 DOC "The file that corresponds to the il (system?) utility library."
92 #message("ILUT_LIBRARIES is ${ILUT_LIBRARIES}")
94 find_library(ILU_LIBRARIES
96 PATH_SUFFIXES libx32 lib64 lib lib32
97 DOC "The file that corresponds to the il utility library."
100 #message("ILU_LIBRARIES is ${ILU_LIBRARIES}")
102 FIND_PACKAGE_HANDLE_STANDARD_ARGS(DevIL DEFAULT_MSG
103 IL_LIBRARIES ILU_LIBRARIES
105 # provide legacy variable for compatibility
106 set(IL_FOUND ${DevIL_FOUND})
108 # create imported targets ONLY if we found DevIL.
110 # Report the ILUT found if ILUT_LIBRARIES contains valid path.
112 set(DevIL_ILUT_FOUND TRUE)
114 set(DevIL_ILUT_FOUND FALSE)
117 if(NOT TARGET DevIL::IL)
118 add_library(DevIL::IL UNKNOWN IMPORTED)
119 set_target_properties(DevIL::IL PROPERTIES
120 INTERFACE_INCLUDE_DIRECTORIES "${IL_INCLUDE_DIR}"
121 IMPORTED_LOCATION "${IL_LIBRARIES}")
124 # DevIL Utilities target
125 if(NOT TARGET DevIL::ILU)
126 add_library(DevIL::ILU UNKNOWN IMPORTED)
127 set_target_properties(DevIL::ILU PROPERTIES
128 IMPORTED_LOCATION "${ILU_LIBRARIES}")
129 target_link_libraries(DevIL::ILU INTERFACE DevIL::IL)
133 if(NOT TARGET DevIL::ILUT AND DevIL_ILUT_FOUND)
134 add_library(DevIL::ILUT UNKNOWN IMPORTED)
135 set_target_properties(DevIL::ILUT PROPERTIES
136 IMPORTED_LOCATION "${ILUT_LIBRARIES}")
137 target_link_libraries(DevIL::ILUT INTERFACE DevIL::ILU)