~ubuntu-branches/debian/jessie/acoustid-fingerprinter/jessie

« back to all changes in this revision

Viewing changes to cmake/modules/FindTaglib.cmake

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams
  • Date: 2011-05-12 19:54:52 UTC
  • Revision ID: james.westby@ubuntu.com-20110512195452-bj6g545s1bx7edvc
Tags: upstream-0.1
ImportĀ upstreamĀ versionĀ 0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
8
# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
 
9
#
 
10
# Redistribution and use is allowed according to the terms of the BSD license.
 
11
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
12
 
 
13
if(NOT TAGLIB_MIN_VERSION)
 
14
  set(TAGLIB_MIN_VERSION "1.6")
 
15
endif(NOT TAGLIB_MIN_VERSION)
 
16
 
 
17
if(NOT WIN32)
 
18
    find_program(TAGLIBCONFIG_EXECUTABLE NAMES taglib-config PATHS
 
19
       ${BIN_INSTALL_DIR}
 
20
    )
 
21
endif(NOT WIN32)
 
22
 
 
23
#reset vars
 
24
set(TAGLIB_LIBRARIES)
 
25
set(TAGLIB_CFLAGS)
 
26
 
 
27
# if taglib-config has been found
 
28
if(TAGLIBCONFIG_EXECUTABLE)
 
29
 
 
30
  exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_VERSION)
 
31
 
 
32
  if(TAGLIB_VERSION STRLESS "${TAGLIB_MIN_VERSION}")
 
33
     message(STATUS "TagLib version too old: version searched :${TAGLIB_MIN_VERSION}, found ${TAGLIB_VERSION}")
 
34
     set(TAGLIB_FOUND FALSE)
 
35
  else(TAGLIB_VERSION STRLESS "${TAGLIB_MIN_VERSION}")
 
36
 
 
37
     exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_LIBRARIES)
 
38
 
 
39
     exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_CFLAGS)
 
40
 
 
41
     if(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
 
42
        set(TAGLIB_FOUND TRUE)
 
43
     endif(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
 
44
     string(REGEX REPLACE " *-I" ";" TAGLIB_INCLUDES "${TAGLIB_CFLAGS}")
 
45
  endif(TAGLIB_VERSION STRLESS "${TAGLIB_MIN_VERSION}") 
 
46
  mark_as_advanced(TAGLIB_CFLAGS TAGLIB_LIBRARIES TAGLIB_INCLUDES)
 
47
 
 
48
else(TAGLIBCONFIG_EXECUTABLE)
 
49
 
 
50
  find_path(TAGLIB_INCLUDES
 
51
    NAMES
 
52
    tag.h
 
53
    PATH_SUFFIXES taglib
 
54
    PATHS
 
55
    ${KDE4_INCLUDE_DIR}
 
56
    ${INCLUDE_INSTALL_DIR}
 
57
  )
 
58
 
 
59
    IF(NOT WIN32)
 
60
      # on non-win32 we don't need to take care about WIN32_DEBUG_POSTFIX
 
61
 
 
62
      FIND_LIBRARY(TAGLIB_LIBRARIES tag PATHS ${KDE4_LIB_DIR} ${LIB_INSTALL_DIR})
 
63
 
 
64
    ELSE(NOT WIN32)
 
65
 
 
66
      # 1. get all possible libnames
 
67
      SET(args PATHS ${KDE4_LIB_DIR} ${LIB_INSTALL_DIR})             
 
68
      SET(newargs "")               
 
69
      SET(libnames_release "")      
 
70
      SET(libnames_debug "")        
 
71
 
 
72
      LIST(LENGTH args listCount)
 
73
 
 
74
        # just one name
 
75
        LIST(APPEND libnames_release "tag")
 
76
        LIST(APPEND libnames_debug   "tagd")
 
77
 
 
78
        SET(newargs ${args})
 
79
 
 
80
      # search the release lib
 
81
      FIND_LIBRARY(TAGLIB_LIBRARIES_RELEASE
 
82
                   NAMES ${libnames_release}
 
83
                   ${newargs}
 
84
      )
 
85
 
 
86
      # search the debug lib
 
87
      FIND_LIBRARY(TAGLIB_LIBRARIES_DEBUG
 
88
                   NAMES ${libnames_debug}
 
89
                   ${newargs}
 
90
      )
 
91
 
 
92
      IF(TAGLIB_LIBRARIES_RELEASE AND TAGLIB_LIBRARIES_DEBUG)
 
93
 
 
94
        # both libs found
 
95
        SET(TAGLIB_LIBRARIES optimized ${TAGLIB_LIBRARIES_RELEASE}
 
96
                        debug     ${TAGLIB_LIBRARIES_DEBUG})
 
97
 
 
98
      ELSE(TAGLIB_LIBRARIES_RELEASE AND TAGLIB_LIBRARIES_DEBUG)
 
99
 
 
100
        IF(TAGLIB_LIBRARIES_RELEASE)
 
101
 
 
102
          # only release found
 
103
          SET(TAGLIB_LIBRARIES ${TAGLIB_LIBRARIES_RELEASE})
 
104
 
 
105
        ELSE(TAGLIB_LIBRARIES_RELEASE)
 
106
 
 
107
          # only debug (or nothing) found
 
108
          SET(TAGLIB_LIBRARIES ${TAGLIB_LIBRARIES_DEBUG})
 
109
 
 
110
        ENDIF(TAGLIB_LIBRARIES_RELEASE)
 
111
 
 
112
      ENDIF(TAGLIB_LIBRARIES_RELEASE AND TAGLIB_LIBRARIES_DEBUG)
 
113
 
 
114
      MARK_AS_ADVANCED(TAGLIB_LIBRARIES_RELEASE)
 
115
      MARK_AS_ADVANCED(TAGLIB_LIBRARIES_DEBUG)
 
116
 
 
117
    ENDIF(NOT WIN32)
 
118
  
 
119
  INCLUDE(FindPackageMessage)
 
120
  INCLUDE(FindPackageHandleStandardArgs)
 
121
  FIND_PACKAGE_HANDLE_STANDARD_ARGS(Taglib DEFAULT_MSG TAGLIB_INCLUDES TAGLIB_LIBRARIES)
 
122
 
 
123
endif(TAGLIBCONFIG_EXECUTABLE)
 
124
 
 
125
 
 
126
if(TAGLIB_FOUND)
 
127
  if(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
 
128
    message(STATUS "Taglib found: ${TAGLIB_LIBRARIES}")
 
129
  endif(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
 
130
else(TAGLIB_FOUND)
 
131
  if(Taglib_FIND_REQUIRED)
 
132
    message(FATAL_ERROR "Could not find Taglib")
 
133
  endif(Taglib_FIND_REQUIRED)
 
134
endif(TAGLIB_FOUND)
 
135