FindImlib2.cmake 3.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #
  2. # This module finds if IMLIB2 is available and determines where the
  3. # include files and libraries are.
  4. # On Unix/Linux it relies on the output of imlib2-config.
  5. # This code sets the following variables:
  6. #
  7. #
  8. #
  9. # IMLIB2_FOUND = system has IMLIB2 lib
  10. #
  11. # IMLIB2_LIBRARIES = full path to the libraries
  12. # on Unix/Linux with additional linker flags from "imlib2-config --libs"
  13. #
  14. # CMAKE_IMLIB2_CXX_FLAGS = Unix compiler flags for IMLIB2, essentially "`imlib2-config --cxxflags`"
  15. #
  16. # IMLIB2_INCLUDE_DIR = where to find headers
  17. #
  18. # IMLIB2_LINK_DIRECTORIES = link directories, useful for rpath on Unix
  19. #
  20. #
  21. # author Jan Woetzel and Jan-Friso Evers
  22. # www.mip.informatik.uni-kiel.de/~jw
  23. IF(WIN32)
  24. MESSAGE("FindIMLIB2.cmake: IMLIB2 not (yet) supported on WIN32")
  25. SET(IMLIB2_FOUND OFF )
  26. ELSE(WIN32)
  27. IF(UNIX)
  28. SET(IMLIB2_CONFIG_PREFER_PATH "$ENV{IMLIB2_HOME}/bin" CACHE STRING "preferred path to imlib2")
  29. FIND_PROGRAM(IMLIB2_CONFIG imlib2-config
  30. ${IMLIB2_CONFIG_PREFER_PATH}
  31. /usr/bin/
  32. /opt/gnome/bin/)
  33. IF (IMLIB2_CONFIG)
  34. # OK, found imlib2-config.
  35. # set CXXFLAGS to be fed into CXX_FLAGS by the user:
  36. SET(IMLIB2_CXX_FLAGS "`${IMLIB2_CONFIG} --cflags`")
  37. # set INCLUDE_DIRS to prefix+include
  38. EXEC_PROGRAM(${IMLIB2_CONFIG}
  39. ARGS --prefix
  40. OUTPUT_VARIABLE IMLIB2_PREFIX)
  41. SET(IMLIB2_INCLUDE_DIR ${IMLIB2_PREFIX}/include CACHE STRING INTERNAL)
  42. # extract link dirs for rpath
  43. EXEC_PROGRAM(${IMLIB2_CONFIG}
  44. ARGS --libs
  45. OUTPUT_VARIABLE IMLIB2_CONFIG_LIBS)
  46. # set link libraries and link flags
  47. #SET(IMLIB2_LIBRARIES "`${IMLIB2_CONFIG} --libs`")
  48. SET(IMLIB2_LIBRARIES ${IMLIB2_CONFIG_LIBS})
  49. # split off the link dirs (for rpath)
  50. # use regular expression to match wildcard equivalent "-L*<endchar>"
  51. # with <endchar> is a space or a semicolon
  52. STRING(REGEX MATCHALL "[-][L]([^ ;])+"
  53. IMLIB2_LINK_DIRECTORIES_WITH_PREFIX
  54. "${IMLIB2_CONFIG_LIBS}")
  55. #MESSAGE("DBG IMLIB2_LINK_DIRECTORIES_WITH_PREFIX=${IMLIB2_LINK_DIRECTORIES_WITH_PREFIX}")
  56. # remove prefix -L because we need the pure directory for LINK_DIRECTORIES
  57. # replace -L by ; because the separator seems to be lost otherwise (bug or feature?)
  58. IF (IMLIB2_LINK_DIRECTORIES_WITH_PREFIX)
  59. STRING(REGEX REPLACE "[-][L]" ";" IMLIB2_LINK_DIRECTORIES ${IMLIB2_LINK_DIRECTORIES_WITH_PREFIX} )
  60. #MESSAGE("DBG IMLIB2_LINK_DIRECTORIES=${IMLIB2_LINK_DIRECTORIES}")
  61. ENDIF (IMLIB2_LINK_DIRECTORIES_WITH_PREFIX)
  62. # replace space separated string by semicolon separated vector to make
  63. # it work with LINK_DIRECTORIES
  64. SEPARATE_ARGUMENTS(IMLIB2_LINK_DIRECTORIES)
  65. MARK_AS_ADVANCED(IMLIB2_CXX_FLAGS
  66. IMLIB2_INCLUDE_DIR
  67. IMLIB2_LIBRARIES
  68. IMLIB2_LINK_DIRECTORIES
  69. IMLIB2_CONFIG_PREFER_PATH
  70. IMLIB2_CONFIG)
  71. ELSE(IMLIB2_CONFIG)
  72. MESSAGE( "FindIMLIB2.cmake: imlib2-config not found. Please set it manually. IMLIB2_CONFIG=${IMLIB2_CONFIG}")
  73. ENDIF(IMLIB2_CONFIG)
  74. ENDIF(UNIX)
  75. ENDIF(WIN32)
  76. IF(IMLIB2_LIBRARIES)
  77. IF(IMLIB2_INCLUDE_DIR OR IMLIB2_CXX_FLAGS)
  78. SET(IMLIB2_FOUND 1)
  79. ENDIF(IMLIB2_INCLUDE_DIR OR IMLIB2_CXX_FLAGS)
  80. ENDIF(IMLIB2_LIBRARIES)