2 # This module finds if IMLIB is available and determines where the
3 # include files and libraries are.
4 # On Unix/Linux it relies on the output of imlib-config.
5 # This code sets the following variables:
9 # IMLIB_FOUND = system has IMLIB lib
11 # IMLIB_LIBRARIES = full path to the libraries
12 # on Unix/Linux with additional linker flags from "imlib-config --libs"
14 # CMAKE_IMLIB_CXX_FLAGS = Unix compiler flags for IMLIB, essentially "`imlib-config --cxxflags`"
16 # IMLIB_INCLUDE_DIR = where to find headers
18 # IMLIB_LINK_DIRECTORIES = link directories, useful for rpath on Unix
21 # author Jan Woetzel and Jan-Friso Evers
22 # www.mip.informatik.uni-kiel.de/~jw
25 MESSAGE("FindIMLIB.cmake: IMLIB not (yet) supported on WIN32")
31 SET(IMLIB_CONFIG_PREFER_PATH "$ENV{IMLIB_HOME}/bin" CACHE STRING "preferred path to imlib")
32 FIND_PROGRAM(IMLIB_CONFIG imlib-config
33 ${IMLIB_CONFIG_PREFER_PATH}
39 # OK, found imlib-config.
40 # set CXXFLAGS to be fed into CXX_FLAGS by the user:
41 SET(IMLIB_CXX_FLAGS "`${IMLIB_CONFIG} --cflags`")
43 # set INCLUDE_DIRS to prefix+include
44 EXEC_PROGRAM(${IMLIB_CONFIG}
46 OUTPUT_VARIABLE IMLIB_PREFIX)
47 SET(IMLIB_INCLUDE_DIR ${IMLIB_PREFIX}/include CACHE STRING INTERNAL)
49 # extract link dirs for rpath
50 EXEC_PROGRAM(${IMLIB_CONFIG}
52 OUTPUT_VARIABLE IMLIB_CONFIG_LIBS )
54 # set link libraries and link flags
55 #SET(IMLIB_LIBRARIES "`${IMLIB_CONFIG} --libs`")
56 SET(IMLIB_LIBRARIES ${IMLIB_CONFIG_LIBS})
58 # split off the link dirs (for rpath)
59 # use regular expression to match wildcard equivalent "-L*<endchar>"
60 # with <endchar> is a space or a semicolon
61 STRING(REGEX MATCHALL "[-][L]([^ ;])+"
62 IMLIB_LINK_DIRECTORIES_WITH_PREFIX
63 "${IMLIB_CONFIG_LIBS}" )
64 #MESSAGE("DBG IMLIB_LINK_DIRECTORIES_WITH_PREFIX=${IMLIB_LINK_DIRECTORIES_WITH_PREFIX}")
66 # remove prefix -L because we need the pure directory for LINK_DIRECTORIES
67 # replace -L by ; because the separator seems to be lost otherwise (bug or feature?)
68 IF (IMLIB_LINK_DIRECTORIES_WITH_PREFIX)
69 STRING(REGEX REPLACE "[-][L]" ";" IMLIB_LINK_DIRECTORIES ${IMLIB_LINK_DIRECTORIES_WITH_PREFIX} )
70 #MESSAGE("DBG IMLIB_LINK_DIRECTORIES=${IMLIB_LINK_DIRECTORIES}")
71 ENDIF (IMLIB_LINK_DIRECTORIES_WITH_PREFIX)
73 # replace space separated string by semicolon separated vector to make
74 # it work with LINK_DIRECTORIES
75 SEPARATE_ARGUMENTS(IMLIB_LINK_DIRECTORIES)
81 IMLIB_LINK_DIRECTORIES
82 IMLIB_CONFIG_PREFER_PATH
87 MESSAGE( "FindIMLIB.cmake: imlib-config not found. Please set it manually. IMLIB_CONFIG=${IMLIB_CONFIG}")
95 IF(IMLIB_INCLUDE_DIR OR IMLIB_CXX_FLAGS)
99 ENDIF(IMLIB_INCLUDE_DIR OR IMLIB_CXX_FLAGS)
100 ENDIF(IMLIB_LIBRARIES)
102 # make FIND_PACKAGE case sensitive compatible
103 SET(Imlib_FOUND ${IMLIB_FOUND})
104 SET(Imlib_LIBRARIES ${IMLIB_LIBRARIES})
105 SET(Imlib_INCLUDE_DIR ${IMLIB_INCLUDE_DIR})
106 SET(Imlib_CXX_FLAGS ${IMLIB_CXX_FLAGS})
107 SET(Imlib_LINK_DIRECTORIES ${IMLIB_LINK_DIRECTORIES})