File: FindTaglib.cmake

package info (click to toggle)
amarok 3.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 112,168 kB
  • sloc: cpp: 195,056; xml: 4,322; ansic: 2,634; javascript: 673; ruby: 528; python: 507; sh: 252; makefile: 12
file content (134 lines) | stat: -rw-r--r-- 3,629 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# - Try to find the Taglib library
# Once done this will define
#
#  TAGLIB_FOUND - system has the taglib library
#  TAGLIB_CFLAGS - the taglib cflags
#  TAGLIB_LIBRARIES - The libraries needed to use taglib

# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

if(NOT TAGLIB_MIN_VERSION)
  set(TAGLIB_MIN_VERSION "1.6")
endif()

if(NOT WIN32)
    find_program(TAGLIBCONFIG_EXECUTABLE NAMES taglib-config PATHS
       ${BIN_INSTALL_DIR}
    )
endif()

#reset vars
set(TAGLIB_LIBRARIES)
set(TAGLIB_CFLAGS)

# if taglib-config has been found
if(TAGLIBCONFIG_EXECUTABLE)

  execute_process(COMMAND ${TAGLIBCONFIG_EXECUTABLE} --version RESULT_VARIABLE _return_VALUE OUTPUT_VARIABLE TAGLIB_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)

  if("${TAGLIB_MIN_VERSION}" VERSION_GREATER TAGLIB_VERSION)
     message(STATUS "TagLib version too old: version searched :${TAGLIB_MIN_VERSION}, found ${TAGLIB_VERSION}")
     set(TAGLIB_FOUND FALSE)
  else()

     execute_process(COMMAND ${TAGLIBCONFIG_EXECUTABLE} --libs RESULT_VARIABLE _return_VALUE OUTPUT_VARIABLE TAGLIB_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE)

     execute_process(COMMAND ${TAGLIBCONFIG_EXECUTABLE} --cflags RESULT_VARIABLE _return_VALUE OUTPUT_VARIABLE TAGLIB_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)

     if(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
        set(TAGLIB_FOUND TRUE)
     endif()
     string(REGEX REPLACE " *-I" ";" TAGLIB_INCLUDES "${TAGLIB_CFLAGS}")
  endif()
  mark_as_advanced(TAGLIB_CFLAGS TAGLIB_LIBRARIES TAGLIB_INCLUDES)

else()

  find_path(TAGLIB_INCLUDES
    NAMES
    tag.h
    PATH_SUFFIXES taglib
    PATHS
    ${INCLUDE_INSTALL_DIR}
  )

    if(NOT WIN32)
      # on non-win32 we don't need to take care about WIN32_DEBUG_POSTFIX

      find_library(TAGLIB_LIBRARIES tag PATHS ${LIB_INSTALL_DIR})

    else()

      # 1. get all possible libnames
      set(args PATHS ${LIB_INSTALL_DIR})
      set(newargs "")
      set(libnames_release "")
      set(libnames_debug "")

      list(LENGTH args listCount)

        # just one name
        list(APPEND libnames_release "tag")
        list(APPEND libnames_debug   "tagd")

        set(newargs ${args})

      # search the release lib
      find_library(TAGLIB_LIBRARIES_RELEASE
                   NAMES ${libnames_release}
                   ${newargs}
      )

      # search the debug lib
      find_library(TAGLIB_LIBRARIES_DEBUG
                   NAMES ${libnames_debug}
                   ${newargs}
      )

      if(TAGLIB_LIBRARIES_RELEASE AND TAGLIB_LIBRARIES_DEBUG)

        # both libs found
        set(TAGLIB_LIBRARIES optimized ${TAGLIB_LIBRARIES_RELEASE}
                        debug     ${TAGLIB_LIBRARIES_DEBUG})

      else()

        if(TAGLIB_LIBRARIES_RELEASE)

          # only release found
          set(TAGLIB_LIBRARIES ${TAGLIB_LIBRARIES_RELEASE})

        else()

          # only debug (or nothing) found
          set(TAGLIB_LIBRARIES ${TAGLIB_LIBRARIES_DEBUG})

        endif()

      endif()

      mark_as_advanced(TAGLIB_LIBRARIES_RELEASE)
      mark_as_advanced(TAGLIB_LIBRARIES_DEBUG)

    endif()

  include(FindPackageMessage)
  include(FindPackageHandleStandardArgs)
  find_package_handle_standard_args(Taglib DEFAULT_MSG TAGLIB_INCLUDES TAGLIB_LIBRARIES)

endif()


if(TAGLIB_FOUND)
  if(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
    message(STATUS "Taglib found: ${TAGLIB_LIBRARIES}")
  endif()
else()
  if(Taglib_FIND_REQUIRED)
    message(FATAL_ERROR "Could not find Taglib")
  endif()
endif()