Warning, /multimedia/amarok/cmake/modules/FindTaglib.cmake is written in an unsupported language. File is not indexed.

0001 # - Try to find the Taglib library
0002 # Once done this will define
0003 #
0004 #  TAGLIB_FOUND - system has the taglib library
0005 #  TAGLIB_CFLAGS - the taglib cflags
0006 #  TAGLIB_LIBRARIES - The libraries needed to use taglib
0007 
0008 # Copyright (c) 2006, Laurent Montel, <montel@kde.org>
0009 #
0010 # Redistribution and use is allowed according to the terms of the BSD license.
0011 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
0012 
0013 if(NOT TAGLIB_MIN_VERSION)
0014   set(TAGLIB_MIN_VERSION "1.6")
0015 endif()
0016 
0017 if(NOT WIN32)
0018     find_program(TAGLIBCONFIG_EXECUTABLE NAMES taglib-config PATHS
0019        ${BIN_INSTALL_DIR}
0020     )
0021 endif()
0022 
0023 #reset vars
0024 set(TAGLIB_LIBRARIES)
0025 set(TAGLIB_CFLAGS)
0026 
0027 # if taglib-config has been found
0028 if(TAGLIBCONFIG_EXECUTABLE)
0029 
0030   exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_VERSION)
0031 
0032   if("${TAGLIB_MIN_VERSION}" VERSION_GREATER TAGLIB_VERSION)
0033      message(STATUS "TagLib version too old: version searched :${TAGLIB_MIN_VERSION}, found ${TAGLIB_VERSION}")
0034      set(TAGLIB_FOUND FALSE)
0035   else()
0036 
0037      exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_LIBRARIES)
0038 
0039      exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_CFLAGS)
0040 
0041      if(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
0042         set(TAGLIB_FOUND TRUE)
0043      endif()
0044      string(REGEX REPLACE " *-I" ";" TAGLIB_INCLUDES "${TAGLIB_CFLAGS}")
0045   endif() 
0046   mark_as_advanced(TAGLIB_CFLAGS TAGLIB_LIBRARIES TAGLIB_INCLUDES)
0047 
0048 else()
0049 
0050   find_path(TAGLIB_INCLUDES
0051     NAMES
0052     tag.h
0053     PATH_SUFFIXES taglib
0054     PATHS
0055     ${INCLUDE_INSTALL_DIR}
0056   )
0057 
0058     if(NOT WIN32)
0059       # on non-win32 we don't need to take care about WIN32_DEBUG_POSTFIX
0060 
0061       find_library(TAGLIB_LIBRARIES tag PATHS ${LIB_INSTALL_DIR})
0062 
0063     else()
0064 
0065       # 1. get all possible libnames
0066       set(args PATHS ${LIB_INSTALL_DIR})
0067       set(newargs "")               
0068       set(libnames_release "")      
0069       set(libnames_debug "")        
0070 
0071       list(LENGTH args listCount)
0072 
0073         # just one name
0074         list(APPEND libnames_release "tag")
0075         list(APPEND libnames_debug   "tagd")
0076 
0077         set(newargs ${args})
0078 
0079       # search the release lib
0080       find_library(TAGLIB_LIBRARIES_RELEASE
0081                    NAMES ${libnames_release}
0082                    ${newargs}
0083       )
0084 
0085       # search the debug lib
0086       find_library(TAGLIB_LIBRARIES_DEBUG
0087                    NAMES ${libnames_debug}
0088                    ${newargs}
0089       )
0090 
0091       if(TAGLIB_LIBRARIES_RELEASE AND TAGLIB_LIBRARIES_DEBUG)
0092 
0093         # both libs found
0094         set(TAGLIB_LIBRARIES optimized ${TAGLIB_LIBRARIES_RELEASE}
0095                         debug     ${TAGLIB_LIBRARIES_DEBUG})
0096 
0097       else()
0098 
0099         if(TAGLIB_LIBRARIES_RELEASE)
0100 
0101           # only release found
0102           set(TAGLIB_LIBRARIES ${TAGLIB_LIBRARIES_RELEASE})
0103 
0104         else()
0105 
0106           # only debug (or nothing) found
0107           set(TAGLIB_LIBRARIES ${TAGLIB_LIBRARIES_DEBUG})
0108 
0109         endif()
0110 
0111       endif()
0112 
0113       mark_as_advanced(TAGLIB_LIBRARIES_RELEASE)
0114       mark_as_advanced(TAGLIB_LIBRARIES_DEBUG)
0115 
0116     endif()
0117   
0118   include(FindPackageMessage)
0119   include(FindPackageHandleStandardArgs)
0120   find_package_handle_standard_args(Taglib DEFAULT_MSG TAGLIB_INCLUDES TAGLIB_LIBRARIES)
0121 
0122 endif()
0123 
0124 
0125 if(TAGLIB_FOUND)
0126   if(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
0127     message(STATUS "Taglib found: ${TAGLIB_LIBRARIES}")
0128   endif()
0129 else()
0130   if(Taglib_FIND_REQUIRED)
0131     message(FATAL_ERROR "Could not find Taglib")
0132   endif()
0133 endif()
0134