/CMakeModules/FindTaglib.cmake

http://github.com/tomahawk-player/tomahawk · CMake · 87 lines · 56 code · 17 blank · 14 comment · 8 complexity · 57e98de6dc41a5bb7f7628b5bbd4a78a MD5 · raw file

  1. # - Try to find the Taglib library
  2. # Once done this will define
  3. #
  4. # TAGLIB_FOUND - system has the taglib library
  5. # TAGLIB_CFLAGS - the taglib cflags
  6. # TAGLIB_LIBRARIES - The libraries needed to use taglib
  7. # Copyright (c) 2006, Laurent Montel, <montel@kde.org>
  8. #
  9. # Redistribution and use is allowed according to the terms of the BSD license.
  10. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  11. IF(TAGLIB_FOUND)
  12. MESSAGE(STATUS "Using manually specified taglib locations")
  13. ELSE()
  14. if(NOT TAGLIB_MIN_VERSION)
  15. set(TAGLIB_MIN_VERSION "1.6")
  16. endif(NOT TAGLIB_MIN_VERSION)
  17. if(NOT WIN32)
  18. find_program(TAGLIBCONFIG_EXECUTABLE NAMES taglib-config PATHS
  19. ${BIN_INSTALL_DIR}
  20. )
  21. endif(NOT WIN32)
  22. #reset vars
  23. set(TAGLIB_LIBRARIES)
  24. set(TAGLIB_CFLAGS)
  25. # MESSAGE( STATUS "PATHS: ${PATHS}")
  26. # if taglib-config has been found
  27. if(TAGLIBCONFIG_EXECUTABLE)
  28. exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_VERSION)
  29. if(TAGLIB_VERSION VERSION_LESS "${TAGLIB_MIN_VERSION}")
  30. message(STATUS "TagLib version not found: version searched :${TAGLIB_MIN_VERSION}, found ${TAGLIB_VERSION}")
  31. set(TAGLIB_FOUND FALSE)
  32. else(TAGLIB_VERSION VERSION_LESS "${TAGLIB_MIN_VERSION}")
  33. exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_LIBRARIES)
  34. exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_CFLAGS)
  35. if(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
  36. set(TAGLIB_FOUND TRUE)
  37. # message(STATUS "Found taglib: ${TAGLIB_LIBRARIES}")
  38. endif(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
  39. string(REGEX REPLACE " *-I" ";" TAGLIB_INCLUDES "${TAGLIB_CFLAGS}")
  40. endif(TAGLIB_VERSION VERSION_LESS "${TAGLIB_MIN_VERSION}")
  41. mark_as_advanced(TAGLIB_CFLAGS TAGLIB_LIBRARIES TAGLIB_INCLUDES)
  42. else(TAGLIBCONFIG_EXECUTABLE)
  43. include(FindLibraryWithDebug)
  44. include(FindPackageHandleStandardArgs)
  45. find_path(TAGLIB_INCLUDES
  46. NAMES
  47. tag.h
  48. PATH_SUFFIXES taglib
  49. PATHS
  50. ${INCLUDE_INSTALL_DIR}
  51. )
  52. find_library_with_debug(TAGLIB_LIBRARIES
  53. WIN32_DEBUG_POSTFIX d
  54. NAMES tag
  55. PATHS
  56. ${LIB_INSTALL_DIR}
  57. )
  58. find_package_handle_standard_args(Taglib DEFAULT_MSG
  59. TAGLIB_INCLUDES TAGLIB_LIBRARIES)
  60. endif(TAGLIBCONFIG_EXECUTABLE)
  61. ENDIF()
  62. if(TAGLIB_FOUND)
  63. if(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
  64. message(STATUS "Found TagLib: ${TAGLIB_LIBRARIES}")
  65. endif(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
  66. else(TAGLIB_FOUND)
  67. if(Taglib_FIND_REQUIRED)
  68. message(FATAL_ERROR "Could not find Taglib")
  69. endif(Taglib_FIND_REQUIRED)
  70. endif(TAGLIB_FOUND)