From b63d1cf9f183a61e52c3e16d2b9d09feefba836e Mon Sep 17 00:00:00 2001 From: David Sansome Date: Tue, 28 Aug 2012 19:19:29 +0100 Subject: [PATCH] Show which packages are required to satisfy failed dependencies when running CMake. --- CMakeLists.txt | 178 +++++++++++++++++++------------------------- cmake/Summary.cmake | 60 +++++++++++++++ 2 files changed, 136 insertions(+), 102 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf0c879d0..a5410708f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 2.6) +cmake_policy(SET CMP0011 OLD) include(CheckCXXCompilerFlag) include(FindPkgConfig) @@ -15,20 +16,6 @@ if (UNIX AND NOT APPLE) endif (UNIX AND NOT APPLE) find_package(Qt4 4.5.0 REQUIRED QtCore QtGui QtOpenGL QtSql QtNetwork QtXml) -if (LINUX) - option(ENABLE_DBUS "Enable D-Bus, MPRIS and native notifications. Required for DeviceKit and Wii remote support" ON) - if(ENABLE_DBUS) - find_package(Qt4 REQUIRED QtDbus) - set(HAVE_DBUS ON) - - option(ENABLE_DEVICEKIT "DeviceKit backend" ON) - if(ENABLE_DEVICEKIT) - set(HAVE_DEVICEKIT ON) - endif(ENABLE_DEVICEKIT) - - option(ENABLE_WIIMOTEDEV "Enable Wii remote support in Clementine" ON) - endif(ENABLE_DBUS) -endif (LINUX) if(NOT APPLE) find_package(Qt4 COMPONENTS QtWebKit) @@ -92,12 +79,7 @@ endif() if (APPLE) find_library(GROWL Growl) - - option(ENABLE_SPARKLE "Sparkle updating" ON) find_library(SPARKLE Sparkle) - if (ENABLE_SPARKLE AND SPARKLE) - set(HAVE_SPARKLE ON) - endif (ENABLE_SPARKLE AND SPARKLE) find_library(SPOTIFY libspotify) if (SPOTIFY) @@ -151,7 +133,6 @@ if (NOT QT_QTWEBKIT_INCLUDE_DIR) set (QT_USE_QTWEBKIT 0) endif (NOT QT_QTWEBKIT_INCLUDE_DIR) -include(${QT_USE_FILE}) include_directories(${Boost_INCLUDE_DIRS}) include_directories(${TAGLIB_INCLUDE_DIRS}) include_directories(${QJSON_INCLUDE_DIRS}) @@ -161,10 +142,6 @@ include_directories(${GLIBCONFIG_INCLUDE_DIRS}) include_directories(${LIBXML_INCLUDE_DIRS}) include_directories("3rdparty/universalchardet") -# 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") - if (WIN32) # RC compiler string(REPLACE "gcc" "windres" CMAKE_RC_COMPILER_INIT ${CMAKE_C_COMPILER}) @@ -189,21 +166,6 @@ if(NOT GETTEXT_MSGFMT_EXECUTABLE) endif(NOT GETTEXT_MSGFMT_EXECUTABLE) # Optional bits -option(ENABLE_LIBGPOD "iPod classic support" ON) -option(ENABLE_IMOBILEDEVICE "iPod Touch, iPhone, iPad support" ON) -option(ENABLE_LIBMTP "MTP support" ON) -option(ENABLE_GIO "GIO backend" ON) -option(ENABLE_AUDIOCD "Audio CD support" ON) -option(ENABLE_VISUALISATIONS "Use libprojectm visualisations" ON) -option(BUNDLE_PROJECTM_PRESETS "Install Clementine's own copies of libprojectm presets - disable this if you want to use a system package instead" ON) -option(ENABLE_SOUNDMENU "Add Clementine to the Gnome sound menu" ON) -option(ENABLE_LIBLASTFM "Use liblastfm for fetching song info, scrobbling and radio streams" ON) -option(ENABLE_BREAKPAD "Enable crash reporting" OFF) -option(ENABLE_SPOTIFY_BLOB "Build the spotify non-GPL binary" ON) -option(ENABLE_SPOTIFY "Enable spotify support" ON) -option(ENABLE_MOODBAR "Enable moodbar" ON) -option(ENABLE_GOOGLE_DRIVE "Enable Google Drive support" ON) - if(WIN32) option(ENABLE_WIN32_CONSOLE "Show the windows console even outside Debug mode" OFF) if(SAC_SHIM_LIBRARIES) @@ -211,68 +173,97 @@ if(WIN32) endif(SAC_SHIM_LIBRARIES) endif(WIN32) -if(ENABLE_LIBGPOD AND LIBGPOD_FOUND) - set(HAVE_LIBGPOD ON) -endif(ENABLE_LIBGPOD AND LIBGPOD_FOUND) +optional_component(BREAKPAD OFF "Crash reporting") -if(ENABLE_GIO AND GIO_FOUND AND NOT APPLE) - set(HAVE_GIO ON) -endif(ENABLE_GIO AND GIO_FOUND AND NOT APPLE) +optional_component(GOOGLE_DRIVE ON "Google Drive support" + DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS + DEPENDS "Taglib 1.8 beta" "TAGLIB_VERSION VERSION_GREATER 1.7.999" +) -if(ENABLE_AUDIOCD AND CDIO_FOUND) - set(HAVE_AUDIOCD ON) -endif(ENABLE_AUDIOCD AND CDIO_FOUND) +optional_component(AUDIOCD ON "Devices: Audio CD support" + DEPENDS "libcdio" CDIO_FOUND +) -if(ENABLE_IMOBILEDEVICE AND IMOBILEDEVICE_FOUND AND PLIST_FOUND AND HAVE_LIBGPOD AND USBMUXD_FOUND) - set(HAVE_IMOBILEDEVICE ON) -endif(ENABLE_IMOBILEDEVICE AND IMOBILEDEVICE_FOUND AND PLIST_FOUND AND HAVE_LIBGPOD AND USBMUXD_FOUND) +optional_component(LIBGPOD ON "Devices: iPod classic support" + DEPENDS "libgpod" LIBGPOD_FOUND +) -if(ENABLE_LIBMTP AND LIBMTP_FOUND) - set(HAVE_LIBMTP ON) -endif(ENABLE_LIBMTP AND LIBMTP_FOUND) +optional_component(GIO ON "Devices: GIO device backend" + DEPENDS "libgio" GIO_FOUND + DEPENDS "Linux or Windows" "NOT APPLE" +) -if(ENABLE_SOUNDMENU AND INDICATEQT_FOUND) - set(HAVE_LIBINDICATE ON) -endif(ENABLE_SOUNDMENU AND INDICATEQT_FOUND) +optional_component(IMOBILEDEVICE ON "Devices: iPod Touch, iPhone, iPad support" + DEPENDS "libimobiledevice" IMOBILEDEVICE_FOUND + DEPENDS "libplist" PLIST_FOUND + DEPENDS "libusbmuxd" USBMUXD_FOUND + DEPENDS "iPod classic support" HAVE_LIBGPOD +) -if(ENABLE_LIBLASTFM AND LASTFM_LIBRARIES AND LASTFM_INCLUDE_DIRS) - set(HAVE_LIBLASTFM ON) -endif(ENABLE_LIBLASTFM AND LASTFM_LIBRARIES AND LASTFM_INCLUDE_DIRS) +optional_component(LIBMTP ON "Devices: MTP support" + DEPENDS "libmtp" LIBMTP_FOUND +) -if(ENABLE_WIIMOTEDEV AND HAVE_DBUS) - set(HAVE_WIIMOTEDEV ON) -endif(ENABLE_WIIMOTEDEV AND HAVE_DBUS) +optional_component(SOUNDMENU ON "Gnome sound menu integration" + DEPENDS "indicate-qt" INDICATEQT_FOUND +) -if(ENABLE_BREAKPAD) - set(HAVE_BREAKPAD ON) -endif(ENABLE_BREAKPAD) +optional_component(LIBLASTFM ON "Last.fm support" + DEPENDS "liblastfm" LASTFM_LIBRARIES LASTFM_INCLUDE_DIRS +) -if(ENABLE_SPOTIFY AND PROTOBUF_FOUND AND PROTOBUF_PROTOC_EXECUTABLE) - set(HAVE_SPOTIFY ON) -endif(ENABLE_SPOTIFY AND PROTOBUF_FOUND AND PROTOBUF_PROTOC_EXECUTABLE) +optional_component(DBUS ON "D-Bus support" + DEPENDS "Linux" LINUX +) -if(ENABLE_SPOTIFY_BLOB AND PROTOBUF_FOUND AND PROTOBUF_PROTOC_EXECUTABLE AND SPOTIFY_FOUND) - set(HAVE_SPOTIFY_BLOB ON) -endif(ENABLE_SPOTIFY_BLOB AND PROTOBUF_FOUND AND PROTOBUF_PROTOC_EXECUTABLE AND SPOTIFY_FOUND) +optional_component(WIIMOTEDEV ON "Wiimote support" + DEPENDS "D-Bus support" HAVE_DBUS +) -if((NOT HAVE_SPOTIFY_BLOB) AND (NOT QCA_FOUND)) - # If we're not bundling the spotify blob then we must ensure QCA is available - # so we can verify the blob we download at runtime. - unset(HAVE_SPOTIFY) -endif((NOT HAVE_SPOTIFY_BLOB) AND (NOT QCA_FOUND)) +optional_component(DEVICEKIT ON "Devices: DeviceKit backend" + DEPENDS "D-Bus support" HAVE_DBUS +) -if(QCA_FOUND AND HAVE_SPOTIFY) +optional_component(SPOTIFY_BLOB ON "Spotify support: non-GPL binary helper" + DEPENDS "protobuf" PROTOBUF_FOUND PROTOBUF_PROTOC_EXECUTABLE + DEPENDS "libspotify" SPOTIFY_FOUND +) + +# If we're building the spotify blob then we don't need qca2 for the core code +if(HAVE_SPOTIFY_BLOB) + set(QCA_FOUND ON) +elseif(QCA_FOUND) set(HAVE_QCA ON) -endif(QCA_FOUND AND HAVE_SPOTIFY) - -if(ENABLE_MOODBAR AND FFTW3_FOUND) - set(HAVE_MOODBAR ON) endif() -if(ENABLE_GOOGLE_DRIVE AND SPARSEHASH_INCLUDE_DIRS AND TAGLIB_VERSION VERSION_GREATER 1.7.999) - set(HAVE_GOOGLE_DRIVE ON) -endif() +optional_component(SPOTIFY ON "Spotify support: core code" + DEPENDS "protobuf" PROTOBUF_FOUND PROTOBUF_PROTOC_EXECUTABLE + DEPENDS "qca2" QCA_FOUND +) +optional_component(MOODBAR ON "Moodbar support" + DEPENDS "fftw3" FFTW3_FOUND +) + +optional_component(SPARKLE ON "Sparkle integration" + DEPENDS "Mac OS X" APPLE + DEPENDS "Sparkle" SPARKLE +) + +optional_component(VISUALISATIONS ON "Visualisations") + + +# Find DBus if it's enabled +if (HAVE_DBUS) + find_package(Qt4 REQUIRED QtDbus) +endif () + +# We can include the Qt definitions now +include(${QT_USE_FILE}) + +# 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") if(ENABLE_VISUALISATIONS) # When/if upstream accepts our patches then these options can be used to link @@ -437,21 +428,4 @@ add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") # Show a summary of what we have enabled -summary_add("Crash reporting" HAVE_BREAKPAD) -summary_add("D-Bus support" HAVE_DBUS) -summary_add("Devices: Audio CD support" HAVE_AUDIOCD) -summary_add("Devices: DeviceKit backend" HAVE_DEVICEKIT) -summary_add("Devices: iPod classic support" HAVE_LIBGPOD) -summary_add("Devices: iPod Touch, iPhone, iPad support" HAVE_IMOBILEDEVICE) -summary_add("Devices: MTP support" HAVE_LIBMTP) -summary_add("Devices: GIO backend" HAVE_GIO) -summary_add("Gnome sound menu integration" HAVE_LIBINDICATE) -summary_add("Google Drive support" HAVE_GOOGLE_DRIVE) -summary_add("Last.fm support" HAVE_LIBLASTFM) -summary_add("Moodbar support" HAVE_MOODBAR) -summary_add("Spotify support: core code" HAVE_SPOTIFY) -summary_add("Spotify support: non-GPL binary helper" HAVE_SPOTIFY_BLOB) -summary_add("Visualisations" ENABLE_VISUALISATIONS) -summary_add("Wiimote support" HAVE_WIIMOTEDEV) -summary_add("(Mac OS X) Sparkle integration" HAVE_SPARKLE) summary_show() diff --git a/cmake/Summary.cmake b/cmake/Summary.cmake index 2a43735d6..55e511e98 100644 --- a/cmake/Summary.cmake +++ b/cmake/Summary.cmake @@ -1,3 +1,5 @@ +cmake_policy(SET CMP0012 NEW) + set(summary_willbuild "") set(summary_willnotbuild "") @@ -21,7 +23,65 @@ macro(summary_show_part variable title) endmacro(summary_show_part) macro(summary_show) + list(SORT summary_willbuild) + list(SORT summary_willnotbuild) summary_show_part(summary_willbuild "The following components will be built:") summary_show_part(summary_willnotbuild "The following components WILL NOT be built:") message("") endmacro(summary_show) + +function(optional_component name default description) + set(option_variable "ENABLE_${name}") + set(have_variable "HAVE_${name}") + set(${have_variable} OFF) + + # Create the option + option(${option_variable} "${description}" ${default}) + + # Was the option set? + if(NOT ${option_variable}) + set(summary_willnotbuild "${summary_willnotbuild};${description} (disabled in CMake config)" PARENT_SCOPE) + return() + endif() + + # Check each of the dependencies + set(next_arg_is_dep_name FALSE) + set(testing_deps TRUE) + set(current_dep_name) + set(missing_deps) + + foreach(arg ${ARGN}) + if(${next_arg_is_dep_name}) + set(current_dep_name "${arg}") + set(next_arg_is_dep_name FALSE) + elseif(arg STREQUAL "DEPENDS") + set(next_arg_is_dep_name TRUE) + set(testing_deps TRUE) + elseif(${testing_deps}) + string(REPLACE " " ";" arglist "${arg}") + if(${arglist}) + # We have to do this instead of if(NOT ${arg}) so that tests may contain + # "NOT" themselves. + else() + list(APPEND missing_deps "${current_dep_name}") + set(testing_deps FALSE) + endif() + endif() + endforeach() + + if(missing_deps) + foreach(dep ${missing_deps}) + if(deplist_text) + set(deplist_text "${deplist_text}, ${dep}") + else() + set(deplist_text "${dep}") + endif() + endforeach() + set(text "${description} (missing ${deplist_text})") + + set(summary_willnotbuild "${summary_willnotbuild};${text}" PARENT_SCOPE) + else() + set(${have_variable} ON PARENT_SCOPE) + set(summary_willbuild "${summary_willbuild};${description}" PARENT_SCOPE) + endif() +endfunction()