PageRenderTime 172ms CodeModel.GetById 80ms app.highlight 2ms RepoModel.GetById 89ms app.codeStats 0ms

/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
 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
13IF(TAGLIB_FOUND)
14	MESSAGE(STATUS "Using manually specified taglib locations")
15ELSE()
16
17	if(NOT TAGLIB_MIN_VERSION)
18	  set(TAGLIB_MIN_VERSION "1.6")
19	endif(NOT TAGLIB_MIN_VERSION)
20
21	if(NOT WIN32)
22		find_program(TAGLIBCONFIG_EXECUTABLE NAMES taglib-config PATHS
23		   ${BIN_INSTALL_DIR}
24		)
25	endif(NOT WIN32)
26
27	#reset vars
28	set(TAGLIB_LIBRARIES)
29	set(TAGLIB_CFLAGS)
30
31#	MESSAGE( STATUS "PATHS: ${PATHS}")
32	# if taglib-config has been found
33	if(TAGLIBCONFIG_EXECUTABLE)
34
35	  exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_VERSION)
36
37	  if(TAGLIB_VERSION VERSION_LESS "${TAGLIB_MIN_VERSION}")
38		 message(STATUS "TagLib version not found: version searched :${TAGLIB_MIN_VERSION}, found ${TAGLIB_VERSION}")
39		 set(TAGLIB_FOUND FALSE)
40	  else(TAGLIB_VERSION VERSION_LESS "${TAGLIB_MIN_VERSION}")
41
42		 exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_LIBRARIES)
43
44		 exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_CFLAGS)
45
46		 if(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
47			set(TAGLIB_FOUND TRUE)
48#			message(STATUS "Found taglib: ${TAGLIB_LIBRARIES}")
49		 endif(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
50		 string(REGEX REPLACE " *-I" ";" TAGLIB_INCLUDES "${TAGLIB_CFLAGS}")
51	  endif(TAGLIB_VERSION VERSION_LESS "${TAGLIB_MIN_VERSION}")
52	  mark_as_advanced(TAGLIB_CFLAGS TAGLIB_LIBRARIES TAGLIB_INCLUDES)
53
54	else(TAGLIBCONFIG_EXECUTABLE)
55
56	  include(FindLibraryWithDebug)
57	  include(FindPackageHandleStandardArgs)
58
59	  find_path(TAGLIB_INCLUDES
60		NAMES
61		tag.h
62		PATH_SUFFIXES taglib
63		PATHS
64		${INCLUDE_INSTALL_DIR}
65	  )
66
67	  find_library_with_debug(TAGLIB_LIBRARIES
68		WIN32_DEBUG_POSTFIX d
69		NAMES tag
70		PATHS
71		${LIB_INSTALL_DIR}
72	  )
73	  
74	  find_package_handle_standard_args(Taglib DEFAULT_MSG 
75										TAGLIB_INCLUDES TAGLIB_LIBRARIES)
76	endif(TAGLIBCONFIG_EXECUTABLE)
77ENDIF()
78
79if(TAGLIB_FOUND)
80  if(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
81    message(STATUS "Found TagLib: ${TAGLIB_LIBRARIES}")
82  endif(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
83else(TAGLIB_FOUND)
84  if(Taglib_FIND_REQUIRED)
85    message(FATAL_ERROR "Could not find Taglib")
86  endif(Taglib_FIND_REQUIRED)
87endif(TAGLIB_FOUND)