diff --git a/cmake/modules/FindIMLIB.cmake b/cmake/modules/FindIMLIB.cmake new file mode 100644 index 000000000..975d2d2b9 --- /dev/null +++ b/cmake/modules/FindIMLIB.cmake @@ -0,0 +1,60 @@ +# - Try to find the Imlib graphics library +# Once done this will define +# +# IMLIB_FOUND - system has IMLIB +# IMLIB_INCLUDE_DIR - the IMLIB include directory +# IMLIB_LIBRARIES - Link these to use IMLIB +# IMLIB_DEFINITIONS - Compiler switches required for using IMLIB +# + +IF (DEFINED CACHED_IMLIB) + + # in cache already + IF ("${CACHED_IMLIB}" STREQUAL "YES") + SET(IMLIB_FOUND TRUE) + ENDIF ("${CACHED_IMLIB}" STREQUAL "YES") + +ELSE (DEFINED CACHED_IMLIB) + + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + INCLUDE(UsePkgConfig) + + PKGCONFIG(libagg _IMLIBIncDir _IMLIBLinkDir _IMLIBLinkFlags _IMLIBCflags) + + set(IMLIB_DEFINITIONS ${_IMLIBCflags}) + + FIND_PATH(IMLIB_INCLUDE_DIR Imlib.h + ${_IMLIBIncDir} + /usr/include + /usr/local/include + ) + + FIND_LIBRARY(IMLIB_LIBRARIES NAMES Imlib + PATHS + ${_IMLIBLinkDir} + /usr/lib + /usr/local/lib + ) + + if (IMLIB_INCLUDE_DIR AND IMLIB_LIBRARIES) + SET(imlib_found true) + endif (IMLIB_INCLUDE_DIR AND IMLIB_LIBRARIES) + + if (IMLIB_FOUND) + set(CACHED_IMLIB "YES") + if (NOT IMLIB_FIND_QUIETLY) + message(STATUS "Found IMLIB: ${IMLIB_LIBRARIES}") + endif (NOT IMLIB_FIND_QUIETLY) + else (IMLIB_FOUND) + set(CACHED_IMLIB "NO") + if (IMLIB_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find IMLIB") + endif (IMLIB_FIND_REQUIRED) + endif (IMLIB_FOUND) + + MARK_AS_ADVANCED(IMLIB_INCLUDE_DIR IMLIB_LIBRARIES) + + set(CACHED_IMLIB ${CACHED_IMLIB} CACHE INTERNAL "If liImlib was checked") + +ENDIF (DEFINED CACHED_IMLIB)