1
project(Amarok)
2
3
cmake_minimum_required(VERSION 2.6.2)
4
5
set( CMAKE_MODULE_PATH    ${CMAKE_MODULE_PATH}
6
                          ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules )
7
8
option(WITH_UTILITIES "Enable building of utilities" ON)
9
option(WITH_PLAYER "Enable building of main Amarok player" ON)
10
option(WITH_MP3Tunes "Enable mp3tunes in the Amarok player, requires multiple extra dependencies" ON)
11
option(WITH_IPOD "Enable iPod support in Amarok" ON)
12
13
include(CheckLibraryExists)
14
check_library_exists(dl dlopen "" LIBDL_FOUND)
15
16
set(TAGLIB_MIN_VERSION "1.6")
17
find_package(Taglib REQUIRED)
18
19
# Check if TagLib is built with ASF and MP4 support
20
include(CheckCXXSourceCompiles)
21
set(CMAKE_REQUIRED_INCLUDES "${TAGLIB_INCLUDES}")
22
set(CMAKE_REQUIRED_LIBRARIES "${TAGLIB_LIBRARIES}")
23
24
check_cxx_source_compiles("#include <asftag.h>
25
int main() { TagLib::ASF::Tag tag; return 0;}" TAGLIB_ASF_FOUND)
26
if( NOT TAGLIB_ASF_FOUND )
27
    message(FATAL_ERROR "TagLib does not have ASF support compiled in.")
28
endif( NOT TAGLIB_ASF_FOUND ) 
29
30
check_cxx_source_compiles("#include <mp4tag.h>
31
int main() { TagLib::MP4::Tag tag(0, 0); return 0;}" TAGLIB_MP4_FOUND)
32
if( NOT TAGLIB_MP4_FOUND )
33
    message(FATAL_ERROR "TagLib does not have MP4 support compiled in.")
34
endif( NOT TAGLIB_MP4_FOUND ) 
35
36
set(CMAKE_REQUIRED_INCLUDES)
37
set(CMAKE_REQUIRED_LIBRARIES)
38
39
find_package(Taglib-Extras 1.0 REQUIRED)
40
if( TAGLIB-EXTRAS_FOUND )
41
    add_definitions( -DTAGLIB_EXTRAS_FOUND )
42
endif( TAGLIB-EXTRAS_FOUND )
43
44
include(CheckTagLibFileName)
45
46
check_taglib_filename(COMPLEX_TAGLIB_FILENAME)
47
48
configure_file(config-amarok.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-amarok.h )
49
50
# Needed to conditionally build tests and gui
51
if(CMAKE_BUILD_TYPE MATCHES debugfull)
52
   add_definitions(-DDEBUG)
53
endif(CMAKE_BUILD_TYPE MATCHES debugfull)
54
55
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0")
56
if (CMAKE_COMPILER_IS_GNUCXX)
57
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0")
58
    if( NOT WIN32 AND NOT APPLE )
59
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--as-needed")
60
    endif( NOT WIN32 AND NOT APPLE )
61
endif (CMAKE_COMPILER_IS_GNUCXX)
62
63
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/shared )
64
65
if( WITH_PLAYER )
66
#We depend on kde4.2 now.. I believe this is the easiest way to do it.
67
    set(KDE_MIN_VERSION "4.2.0")
68
    find_package( KDE4 REQUIRED )
69
    include (KDE4Defaults)
70
    include (MacroLibrary)
71
72
    include(MacroBoolTo01)
73
    include(MacroLogFeature)
74
75
    macro_log_feature( KDE4_FOUND "kdelibs" "The toolkit Amarok uses to build" "http://www.kde.org" TRUE "4.2.0" "" )
76
77
    find_package( QtScriptQtBindings REQUIRED )
78
    macro_log_feature( QTSCRIPTQTBINDINGS_FOUND "qtscript-qt" "QtScript Qt Bindings" "http://code.google.com/p/qtscriptgenerator/" TRUE "" "" )
79
80
    add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
81
82
    find_package(MySQLAmarok REQUIRED)
83
    macro_log_feature( MYSQL_EMBEDDED_FOUND "mysqld" "Embedded MySQL" "http://www.mysql.com" TRUE "" "" )
84
85
    # zlib is required for mysql embedded
86
    find_package(ZLIB REQUIRED)
87
    macro_log_feature( ZLIB_FOUND "zlib" "zlib" "" TRUE "" "" )
88
89
    macro_optional_find_package(Strigi)
90
    macro_log_feature( STRIGI_FOUND "strigi" "Index metadata of files" "http://strigi.sourceforge.net" TRUE "" "" )
91
92
    macro_optional_find_package(LibLastFm)
93
    macro_log_feature( LIBLASTFM_FOUND "liblastfm" "Enable Last.Fm service, including scrobbling, song submissions, and suggested song dynamic playlists" "http://cdn.last.fm/src/liblastfm-0.3.0.tar.bz2" FALSE "0.3" "" )
94
    
95
96
		
97
    if( WITH_IPOD )
98
        find_package(Ipod)
99
        if( IPOD_FOUND )
100
            macro_ensure_version("0.7.0" ${IPOD_VERSION} IPOD_FOUND)
101
        endif( IPOD_FOUND )
102
        macro_log_feature( IPOD_FOUND "libgpod" "Support Apple iPod audio devices" "http://sourceforge.net/projects/gtkpod/" FALSE "0.7.0" "" )
103
	macro_optional_find_package(Gdk)
104
	macro_log_feature( GDK_FOUND "Gdk" "Support for artwork on iPod audio devices via GdkPixbuf" "http://developer.gnome.org/arch/imaging/gdkpixbuf.html" FALSE "2.0.x" "" )
105
    endif( WITH_IPOD )
106
 
107
    macro_optional_find_package(Mtp)
108
    macro_log_feature( MTP_FOUND "libmtp" "Enable Support for portable media devices that use the media transfer protocol" "http://libmtp.sourceforge.net/" FALSE "0.3.0" "")
109
110
    if( WITH_MP3Tunes )
111
        find_package(CURL)
112
        macro_log_feature( CURL_FOUND "curl" "cURL provides the necessary network libraries required by mp3tunes." "http://curl.haxx.se" FALSE "" "" )
113
114
        find_package(LibXml2)
115
        macro_log_feature( LIBXML2_FOUND "libxml2" "LibXML2 is an XML parser required by mp3tunes." "http://www.xmlsoft.org" FALSE "" "" )
116
117
        macro_optional_find_package(OpenSSL)
118
        macro_optional_find_package(Libgcrypt)
119
        if ( OPENSSL_FOUND OR LIBGCRYPT_FOUND )
120
            set (_mp3tunes_crypto TRUE )
121
        else ( OPENSSL_FOUND OR LIBGCRYPT_FOUND )
122
            message( SEND_ERROR "Building with mp3tunes support REQUIRES either OpenSSL or GNU Libgcrypt" )
123
        endif ( OPENSSL_FOUND OR LIBGCRYPT_FOUND )
124
        macro_log_feature( _mp3tunes_crypto "openssl or libgcrypt" "OpenSSL or GNU Libgcrypt provides cryptographic functions required by mp3tunes." "http://www.openssl.org/ or http://www.gnupg.org/download/#libgcrypt" FALSE "" "" )
125
126
        find_package(GObject)
127
        macro_log_feature( GOBJECT_FOUND "gobject" "Required by mp3tunes." "http://www.gtk.org" FALSE "2.x" "" )
128
129
        find_package(Loudmouth)
130
        macro_log_feature( LOUDMOUTH_FOUND "loudmouth" "Loudmouth is the communication backend needed by mp3tunes for syncing." "http://www.loudmouth-project.org" FALSE "" "" )
131
132
        include(CheckQtGlib)
133
        macro_log_feature(QT4_GLIB_SUPPORT "Qt4 Glib support" "Qt4 must be compiled with glib support for mp3tunes" "http://www.trolltech.com" FALSE "" "")
134
    endif( WITH_MP3Tunes )
135
136
    if( WITH_IPOD OR WITH_MP3Tunes )
137
	find_package(GLIB2)
138
	macro_log_feature( GLIB2_FOUND "glib2" "Required by libgpod and mp3tunes" "http://www.gtk.org" FALSE "2.x" "")
139
    endif( WITH_IPOD OR WITH_MP3Tunes )
140
141
    #These two are currently unused
142
    #macro_optional_find_package(Soprano)
143
    #macro_log_feature( Soprano_FOUND "soprano" "Soprano is a RDF framework required by Nepomuk Collection" "http://soprano.sourceforge.net" FALSE "2.1.0" "")
144
    #macro_optional_find_package(Nepomuk)
145
    #macro_log_feature( NEPOMUK_FOUND "nepomuk" "Nepomuk Libraries required by Nepomuk Collection (part of kdelibs)" "http://www.kde.org" FALSE "4.1" "")
146
147
    macro_bool_to_01(LIBVISUAL_FOUND HAVE_LIBVISUAL)
148
149
    include_directories (${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDES} ${TAGLIB_INCLUDES})
150
151
if(CMAKE_BUILD_TYPE MATCHES debugfull)
152
    add_subdirectory( tests )
153
endif(CMAKE_BUILD_TYPE MATCHES debugfull)
154
155
    add_subdirectory( src )
156
157
    macro_display_feature_log()
158
159
    #Do not remove or modify these.  The release script substitutes in for these
160
    #comments with appropriate doc and translation directories.
161
    #PO_SUBDIR
162
    #DOC_SUBDIR
163
164
else( WITH_PLAYER )
165
166
    find_package( Qt4 REQUIRED )
167
    set( CMAKE_INCLUDE_CURRENT_DIR ON )
168
    add_definitions(${QT_DEFINITIONS})
169
    include_directories (${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${TAGLIB_INCLUDES})
170
171
endif( WITH_PLAYER )
172
173
if( WITH_UTILITIES )
174
    set(EXEC_INSTALL_PREFIX  ${CMAKE_INSTALL_PREFIX}       CACHE PATH  "Base directory for executables and libraries" FORCE)
175
    set(BIN_INSTALL_DIR          "${EXEC_INSTALL_PREFIX}/bin"    CACHE PATH "The subdirectory to the binaries prefix (default prefix/bin)" FORCE)
176
    add_subdirectory( utilities )
177
endif( WITH_UTILITIES )