2010-02-28 17:28:56 +00:00
cmake_minimum_required ( VERSION 2.6 )
include ( FindPkgConfig )
2010-06-08 22:39:31 +00:00
include ( cmake/Version.cmake )
2010-02-28 17:28:56 +00:00
2010-03-02 20:46:46 +00:00
if ( CMAKE_FIND_ROOT_PATH )
# Help find the Qt headers if we're cross compiling (since we can't run qmake.exe)
# CMAKE_FIND_ROOT_PATH should get set by your cmake toolchain file
set ( QT_HEADERS_DIR ${ CMAKE_FIND_ROOT_PATH } /include )
set ( QT_LIBRARY_DIR ${ CMAKE_FIND_ROOT_PATH } /lib )
endif ( CMAKE_FIND_ROOT_PATH )
2010-04-15 12:39:34 +00:00
find_package ( Qt4 REQUIRED QtCore QtGui QtOpenGL QtSql QtNetwork QtXml )
2010-03-22 14:27:54 +00:00
if ( UNIX AND NOT APPLE )
2010-04-15 12:39:34 +00:00
find_package ( Qt4 REQUIRED QtDbus )
2010-03-22 14:27:54 +00:00
endif ( UNIX AND NOT APPLE )
2010-04-15 12:39:34 +00:00
find_package ( Qt4 COMPONENTS Phonon )
2010-02-28 17:28:56 +00:00
2010-04-21 11:03:30 +00:00
# Find Qt's lconvert binary. Try qt's binary dir first, fall back to looking in PATH
find_program ( QT_LCONVERT_EXECUTABLE NAMES lconvert lconvert-qt4 PATHS ${ QT_BINARY_DIR } NO_DEFAULT_PATH )
find_program ( QT_LCONVERT_EXECUTABLE NAMES lconvert lconvert-qt4 )
2010-04-19 09:42:30 +00:00
if ( APPLE )
if ( NOT QT_MAC_USE_COCOA )
message ( FATAL_ERROR "Cocoa support is required" )
endif ( NOT QT_MAC_USE_COCOA )
endif ( APPLE )
2010-02-28 17:28:56 +00:00
find_package ( OpenGL REQUIRED )
find_package ( Boost REQUIRED )
2010-04-06 19:18:14 +00:00
find_package ( Gettext REQUIRED )
2010-02-28 17:28:56 +00:00
2010-03-02 20:46:46 +00:00
if ( WIN32 )
find_library ( TAGLIB_LIBRARIES tag )
2010-04-06 16:57:02 +00:00
find_path ( GLIB_INCLUDE_DIRS glib.h
P A T H _ S U F F I X E S g l i b g l i b - 2 . 0 )
find_path ( GLIBCONFIG_INCLUDE_DIRS glibconfig.h
P A T H _ S U F F I X E S . . / l i b / g l i b / i n c l u d e . . / l i b / g l i b - 2 . 0 / i n c l u d e )
find_path ( LIBXML_INCLUDE_DIRS libxml/parser.h
P A T H _ S U F F I X E S l i b x m l l i b x m l 2 )
2010-04-19 20:37:21 +00:00
find_path ( GSTREAMER_INCLUDE_DIRS gst/gst.h
P A T H _ S U F F I X E S g s t r e a m e r - 0 . 1 0 )
2010-04-06 16:57:02 +00:00
find_library ( GSTREAMER_LIBRARIES gstreamer-0.10 )
2010-04-07 16:26:04 +00:00
find_library ( GSTREAMER_BASE_LIBRARIES gstbase-0.10 )
2010-04-06 16:57:02 +00:00
find_library ( GLIB_LIBRARIES glib-2.0 )
find_library ( GOBJECT_LIBRARIES gobject-2.0 )
2010-03-02 20:46:46 +00:00
else ( WIN32 )
2010-04-15 12:39:34 +00:00
pkg_check_modules ( TAGLIB REQUIRED taglib>=1.6 )
2010-04-06 16:57:02 +00:00
pkg_check_modules ( GSTREAMER gstreamer-0.10 )
2010-04-07 16:26:04 +00:00
pkg_check_modules ( GSTREAMER_BASE gstreamer-base-0.10 )
2010-04-16 14:39:55 +00:00
pkg_check_modules ( LIBVLC libvlc )
pkg_check_modules ( LIBXINE libxine )
2010-06-17 14:45:31 +00:00
pkg_check_modules ( GLIB glib-2.0 )
pkg_check_modules ( LIBXML libxml-2.0 )
pkg_check_modules ( GOBJECT gobject-2.0 )
2010-07-04 20:52:45 +00:00
pkg_check_modules ( LIBGPOD libgpod-1.0 )
2010-07-17 14:22:07 +00:00
pkg_check_modules ( GIO gio-2.0 )
2010-07-30 21:10:34 +00:00
pkg_check_modules ( IMOBILEDEVICE libimobiledevice-1.0 )
pkg_check_modules ( PLIST libplist )
2010-08-02 12:42:59 +00:00
pkg_check_modules ( USBMUXD libusbmuxd )
2010-03-02 20:46:46 +00:00
endif ( WIN32 )
2010-02-28 17:28:56 +00:00
2010-06-06 21:08:52 +00:00
find_library ( LASTFM_LIBRARIES lastfm )
2010-02-28 17:28:56 +00:00
find_path ( LASTFM_INCLUDE_DIRS lastfm/ws.h )
2010-03-01 12:13:11 +00:00
if ( APPLE )
find_library ( GROWL Growl )
2010-04-15 15:23:12 +00:00
find_library ( SPARKLE Sparkle )
2010-06-18 11:13:44 +00:00
# Uses Darwin kernel version.
# 9.8.0 -> 10.5/Leopard
# 10.4.0 -> 10.6/Snow Leopard
string ( REGEX MATCH "[0-9]+" DARWIN_VERSION ${ CMAKE_HOST_SYSTEM_VERSION } )
if ( DARWIN_VERSION GREATER 9 )
SET ( SNOW_LEOPARD 1 )
elseif ( DARWIN_VERSION GREATER 8 )
SET ( LEOPARD 1 )
endif ( DARWIN_VERSION GREATER 9 )
2010-03-01 12:13:11 +00:00
endif ( APPLE )
2010-02-28 17:28:56 +00:00
if ( ${ CMAKE_BUILD_TYPE } MATCHES "Release" )
add_definitions ( -DNDEBUG )
add_definitions ( -DQT_NO_DEBUG_OUTPUT )
endif ( ${ CMAKE_BUILD_TYPE } MATCHES "Release" )
# Set up definitions and paths
add_definitions ( ${ QT_DEFINITIONS } )
link_directories ( ${ TAGLIB_LIBRARY_DIRS } )
2010-04-06 16:57:02 +00:00
link_directories ( ${ GSTREAMER_LIBRARY_DIRS } )
2010-02-28 17:28:56 +00:00
2010-04-30 11:27:27 +00:00
# Don't try to use Phonon if its include directory couldn't be found.
# For some reason this works differently to the rest of Qt...
if ( NOT ${ QT_PHONON_INCLUDE_DIR } )
set ( QT_USE_PHONON 0 )
endif ( NOT ${ QT_PHONON_INCLUDE_DIR } )
2010-02-28 17:28:56 +00:00
include ( ${ QT_USE_FILE } )
include_directories ( ${ Boost_INCLUDE_DIRS } )
include_directories ( ${ TAGLIB_INCLUDE_DIRS } )
2010-04-06 16:57:02 +00:00
include_directories ( ${ GSTREAMER_INCLUDE_DIRS } )
include_directories ( ${ GLIB_INCLUDE_DIRS } )
include_directories ( ${ GLIBCONFIG_INCLUDE_DIRS } )
include_directories ( ${ LIBXML_INCLUDE_DIRS } )
2010-02-28 17:28:56 +00:00
include_directories ( ${ LASTFM_INCLUDE_DIRS } )
2010-03-23 13:54:17 +00:00
include_directories ( "3rdparty/qsqlite" )
2010-04-29 13:16:46 +00:00
include_directories ( "3rdparty/universalchardet" )
2010-02-28 17:28:56 +00:00
2010-03-02 20:46:46 +00:00
# Remove GLU and GL from the link line - they're not really required
# and don't exist on my mingw toolchain
list ( REMOVE_ITEM QT_LIBRARIES "-lGLU -lGL" )
2010-03-02 22:02:43 +00:00
if ( WIN32 )
# RC compiler
string ( REPLACE "gcc" "windres" CMAKE_RC_COMPILER_INIT ${ CMAKE_C_COMPILER } )
2010-03-04 16:50:27 +00:00
enable_language ( RC )
2010-03-31 02:55:05 +00:00
SET ( CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -o <OBJECT> <SOURCE> -I../../dist/windows" )
2010-03-02 22:02:43 +00:00
endif ( WIN32 )
2010-05-23 15:35:28 +00:00
add_definitions ( -DQT_NO_CAST_TO_ASCII )
2010-03-25 22:37:00 +00:00
2010-04-06 19:18:14 +00:00
# Translations stuff
find_program ( GETTEXT_XGETTEXT_EXECUTABLE xgettext )
2010-05-07 13:10:21 +00:00
if ( NOT GETTEXT_XGETTEXT_EXECUTABLE )
message ( FATAL_ERROR "Could not find xgettext executable" )
endif ( NOT GETTEXT_XGETTEXT_EXECUTABLE )
2010-04-06 19:18:14 +00:00
2010-06-10 22:48:23 +00:00
# Optional bits
option ( ENABLE_VISUALISATIONS "Use libprojectm visualisations" ON )
2010-06-10 23:01:22 +00:00
option ( BUNDLE_PROJECTM_PRESETS "Install Clementine's own copies of libprojectm presets - disable this if you want to use a system package instead" ON )
2010-06-10 22:48:23 +00:00
if ( ENABLE_VISUALISATIONS )
2010-07-10 20:21:06 +00:00
# When/if upstream accepts our patches then these options can be used to link
2010-07-10 20:33:28 +00:00
# to system installed projectM instead.
2010-07-10 20:21:06 +00:00
option ( USE_SYSTEM_PROJECTM "Don't set this option unless your system projectM library has been compiled with the Clementine patches in 3rdparty" OFF )
if ( USE_SYSTEM_PROJECTM )
2010-07-17 11:56:33 +00:00
pkg_check_modules ( LIBPROJECTM libprojectM )
2010-07-10 20:21:06 +00:00
else ( USE_SYSTEM_PROJECTM )
add_subdirectory ( 3rdparty/libprojectm )
set ( LIBPROJECTM_INCLUDE_DIRS ${ CMAKE_CURRENT_SOURCE_DIR } /3rdparty/libprojectm )
set ( LIBPROJECTM_LIBRARIES projectM )
endif ( USE_SYSTEM_PROJECTM )
2010-06-10 22:48:23 +00:00
endif ( ENABLE_VISUALISATIONS )
2010-06-30 19:55:46 +00:00
# Test whether libsqlite3 is available and if FTS3 is enabled in it
if ( WIN32 OR APPLE )
option ( STATIC_SQLITE "Compile and use a static sqlite3 library" ON )
else ( WIN32 OR APPLE )
try_run ( FTS_TEST_RUN FTS_TEST_COMPILE
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / s q l i t e 3 _ f t s _ t e s t
$ { C M A K E _ S O U R C E _ D I R } / c m a k e / s q l i t e 3 _ f t s _ t e s t . c p p
C M A K E _ F L A G S " - D L I N K _ L I B R A R I E S : S T R I N G = s q l i t e 3 " )
if ( NOT FTS_TEST_COMPILE OR FTS_TEST_RUN EQUAL 1 OR FTS_TEST_RUN STREQUAL "FAILED_TO_RUN" )
option ( STATIC_SQLITE "Compile and use a static sqlite3 library" ON )
else ( NOT FTS_TEST_COMPILE OR FTS_TEST_RUN EQUAL 1 OR FTS_TEST_RUN STREQUAL "FAILED_TO_RUN" )
option ( STATIC_SQLITE "Compile and use a static sqlite3 library" OFF )
endif ( NOT FTS_TEST_COMPILE OR FTS_TEST_RUN EQUAL 1 OR FTS_TEST_RUN STREQUAL "FAILED_TO_RUN" )
endif ( WIN32 OR APPLE )
set ( HAVE_STATIC_SQLITE ${ STATIC_SQLITE } )
if ( STATIC_SQLITE )
message ( STATUS "Building static qsqlite plugin" )
add_definitions ( -DQT_STATICPLUGIN )
add_subdirectory ( 3rdparty/qsqlite )
endif ( STATIC_SQLITE )
2010-07-10 20:33:28 +00:00
# When/if upstream accepts our patches then these options can be used to link
# to system installed qtsingleapplication instead.
option ( USE_SYSTEM_QTSINGLEAPPLICATION "Don't set this option unless your system QtSingleApplication library has been compiled with the Clementine patches in 3rdparty" OFF )
if ( USE_SYSTEM_QTSINGLEAPPLICATION )
find_path ( QTSINGLEAPPLICATION_INCLUDE_DIRS qtsingleapplication.h PATH_SUFFIXES QtSolutions )
find_library ( QTSINGLEAPPLICATION_LIBRARIES QtSolutions_SingleApplication-2.6 )
else ( USE_SYSTEM_QTSINGLEAPPLICATION )
add_subdirectory ( 3rdparty/qtsingleapplication )
set ( QTSINGLEAPPLICATION_INCLUDE_DIRS ${ CMAKE_CURRENT_SOURCE_DIR } /3rdparty/qtsingleapplication )
set ( QTSINGLEAPPLICATION_LIBRARIES qtsingleapplication )
endif ( USE_SYSTEM_QTSINGLEAPPLICATION )
2010-07-11 12:02:30 +00:00
# QtIoCompressor isn't patched, so we can use a system version if it's
# available
find_path ( QTIOCOMPRESSOR_INCLUDE_DIRS qtiocompressor.h PATH_SUFFIXES QtSolutions )
find_library ( QTIOCOMPRESSOR_LIBRARIES QtSolutions_IOCompressor-2.3 )
if ( NOT QTIOCOMPRESSOR_INCLUDE_DIRS OR NOT QTIOCOMPRESSOR_LIBRARIES )
add_subdirectory ( 3rdparty/qtiocompressor )
set ( QTIOCOMPRESSOR_INCLUDE_DIRS ${ CMAKE_CURRENT_SOURCE_DIR } /3rdparty/qtiocompressor )
set ( QTIOCOMPRESSOR_LIBRARIES qtiocompressor )
endif ( NOT QTIOCOMPRESSOR_INCLUDE_DIRS OR NOT QTIOCOMPRESSOR_LIBRARIES )
2010-07-10 20:33:28 +00:00
2010-07-24 12:35:21 +00:00
# When/if upstream accepts our or reimplement our patches then these options can be
# used to link to system installed qxt instead.
option ( USE_SYSTEM_QXT "Don't set this option unless your system Qxt library has been compiled with the Clementine patches in 3rdparty" OFF )
if ( USE_SYSTEM_QXT )
find_path ( QXTCORE_INCLUDE_DIRS qxtglobal.h PATH_SUFFIXES QxtCore )
find_path ( QXTGUI_INCLUDE_DIRS qxtglobalshortcut.h PATH_SUFFIXES QxtGui )
set ( QXT_INCLUDE_DIRS ${ QXTCORE_INCLUDE_DIRS } ${ QXTGUI_INCLUDE_DIRS } )
# We only need its header. We don't need to link to QxtCore.
find_library ( QXT_LIBRARIES QxtGui )
else ( USE_SYSTEM_QXT )
2010-07-24 12:46:48 +00:00
add_definitions ( -DQXT_STATIC -DBUILD_QXT_GUI -DBUILD_QXT_CORE )
2010-07-24 15:22:15 +00:00
set ( QXT_INCLUDE_DIRS ${ CMAKE_CURRENT_SOURCE_DIR } /3rdparty/qxt )
set ( QXT_LIBRARIES qxt )
2010-07-24 12:35:21 +00:00
if ( NOT APPLE )
add_subdirectory ( 3rdparty/qxt )
endif ( NOT APPLE )
endif ( USE_SYSTEM_QXT )
2010-07-11 12:02:30 +00:00
# Subdirectories
2010-02-28 17:28:56 +00:00
add_subdirectory ( src )
2010-07-07 23:03:35 +00:00
add_subdirectory ( 3rdparty/qtwin )
2010-04-29 13:16:46 +00:00
add_subdirectory ( 3rdparty/universalchardet )
2010-03-01 01:47:50 +00:00
add_subdirectory ( tests )
2010-05-03 13:58:41 +00:00
add_subdirectory ( dist )
2010-06-24 22:07:04 +00:00
add_subdirectory ( debian )
2010-03-04 16:41:14 +00:00
2010-08-01 16:37:38 +00:00
if ( IMOBILEDEVICE_FOUND AND PLIST_FOUND )
add_subdirectory ( gstafcsrc )
endif ( IMOBILEDEVICE_FOUND AND PLIST_FOUND )
2010-03-04 16:41:14 +00:00
# Uninstall support
2010-03-04 16:50:27 +00:00
configure_file (
2010-03-04 16:41:14 +00:00
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e _ u n i n s t a l l . c m a k e . i n "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e "
I M M E D I A T E @ O N L Y )
2010-03-04 16:50:27 +00:00
add_custom_target ( uninstall
2010-03-04 16:41:14 +00:00
" $ { C M A K E _ C O M M A N D } " - P " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e " )