PageRenderTime 26ms CodeModel.GetById 9ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 1ms

/CMakeLists.txt

Relevant Search: With Applications for Solr and Elasticsearch

For more in depth reading about search, ranking and generally everything you could ever want to know about how lucene, elasticsearch or solr work under the hood I highly suggest this book. Easily one of the most interesting technical books I have read in a long time. If you are tasked with solving search relevance problems even if not in Solr or Elasticsearch it should be your first reference. Amazon Affiliate Link
http://github.com/tomahawk-player/tomahawk
CMake | 392 lines | 259 code | 81 blank | 52 comment | 35 complexity | af4f400167dc3000d21a3cf73a615c8d MD5 | raw file
  1PROJECT( tomahawk )
  2CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 )
  3CMAKE_POLICY(SET CMP0017 NEW)
  4CMAKE_POLICY(SET CMP0022 NEW)
  5IF(POLICY CMP0075)
  6    CMAKE_POLICY(SET CMP0075 NEW)
  7ENDIF()
  8
  9# TODO:
 10# Update to NEW and fix things up
 11CMAKE_POLICY(SET CMP0023 NEW)
 12
 13# Let AUTOMOC and AUTOUIC process generated files
 14IF(POLICY CMP0071)
 15    CMAKE_POLICY(SET CMP0071 NEW)
 16ENDIF()
 17
 18# TODO:
 19# Disable automatic qtmain linking
 20CMAKE_POLICY(SET CMP0020 OLD)
 21
 22find_package(ECM 1.7.0 REQUIRED NO_MODULE)
 23set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules" )
 24
 25
 26
 27INCLUDE(CMakeDependentOption)
 28
 29###
 30### Tomahawk application info
 31###
 32SET( TOMAHAWK_ORGANIZATION_NAME "Tomahawk" )
 33SET( TOMAHAWK_ORGANIZATION_DOMAIN "tomahawk-player.org" )
 34SET( TOMAHAWK_APPLICATION_NAME  "Tomahawk" )
 35SET( TOMAHAWK_DESCRIPTION_SUMMARY "The social media player" )
 36SET( TOMAHAWK_APPLICATION_PACKAGE_NAME "org.tomahawk-player.Tomahawk")
 37IF(APPLE)
 38    SET( TOMAHAWK_TARGET_NAME "Tomahawk" )
 39ELSE()
 40    SET( TOMAHAWK_TARGET_NAME "tomahawk" )
 41ENDIF()
 42
 43STRING(TOLOWER "${TOMAHAWK_TARGET_NAME}" TOMAHAWK_BASE_TARGET_NAME)
 44
 45IF( WIN32 )
 46    SET( TOMAHAWK_SYSTEM "Windows" )
 47ELSEIF( APPLE )
 48    SET( TOMAHAWK_SYSTEM "OS X" )
 49ELSEIF( UNIX )
 50    SET( TOMAHAWK_SYSTEM "Linux")
 51ELSE()
 52    SET( TOMAHAWK_SYSTEM "Uknown Platform, please let the Tomahawk team know, this actually happened" )
 53ENDIF()
 54
 55SET( TOMAHAWK_VERSION_MAJOR 0 )
 56SET( TOMAHAWK_VERSION_MINOR 8 )
 57SET( TOMAHAWK_VERSION_PATCH 99 )
 58SET( TOMAHAWK_VERSION_RC 0 )
 59
 60SET( TOMAHAWK_TRANSLATION_LANGUAGES ar bg bn_IN ca cs da de en el es es_419 fi fr hi_IN hu gl id it ja lt nl pl pt_BR pt_PT ro ru sq sv th tr uk vi zh_CN zh_TW )
 61
 62# add_definitions is only in the scope of this directory and all directories
 63# below it. Tomahawk Libraries and plugins that are built with Tomahawk are
 64# not included in out-of-source build so we need to re-add_definitions there.
 65macro(tomahawk_add_definitions DEFINITION)
 66    add_definitions( ${DEFINITION} )
 67    set( TOMAHAWK_DEFINITIONS "${TOMAHAWK_DEFINITIONS} ${DEFINITION}")
 68endmacro()
 69
 70macro(tomahawk_add_cxx_flags FLAGS)
 71    set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS}")
 72    set( TOMAHAWK_CXX_FLAGS "${TOMAHAWK_CXX_FLAGS} ${FLAGS}")
 73endmacro()
 74
 75macro(tomahawk_add_c_flags FLAGS)
 76    set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
 77    set( TOMAHAWK_C_FLAGS "${TOMAHAWK_C_FLAGS} ${FLAGS}")
 78endmacro()
 79
 80if(NOT WIN32)
 81    # enforce proper symbol exporting on all platforms but Windows
 82    tomahawk_add_cxx_flags( "-fvisibility=hidden" )
 83    tomahawk_add_c_flags( "-fvisibility=hidden" )
 84endif()
 85
 86# enforce using constBegin, constEnd for const-iterators
 87tomahawk_add_definitions( "-DQT_STRICT_ITERATORS" )
 88
 89# build options
 90option(BUILD_RELEASE "Generate TOMAHAWK_VERSION without GIT info" OFF)
 91if(BUILD_RELEASE)
 92    set(BUILD_NO_RELEASE OFF)
 93else()
 94    set(BUILD_NO_RELEASE ON)
 95endif()
 96
 97option(BUILD_GUI "Build Tomahawk with GUI" ON)
 98option(BUILD_TESTS "Build Tomahawk with unit tests" ${BUILD_NO_RELEASE})
 99option(BUILD_TOOLS "Build Tomahawk helper tools" ${BUILD_NO_RELEASE})
100option(BUILD_HATCHET "Build the Hatchet plugin" OFF)
101
102if(UNIX AND NOT APPLE)
103       set(CRASHREPORTER_ENABLED_BY_DEFAULT OFF)
104else()
105       set(CRASHREPORTER_ENABLED_BY_DEFAULT ON)
106endif()
107option(WITH_CRASHREPORTER "Build with CrashReporter" ${CRASHREPORTER_ENABLED_BY_DEFAULT})
108option(WITH_BINARY_ATTICA "Enable support for downloading binary resolvers automatically" ON)
109
110# build options for development purposes
111option(SANITIZE_ADDRESS "Enable Address Sanitizer for memory error detection" OFF)
112option(TOMAHAWK_FINEGRAINED_MESSAGES "Enable even more verbose logging (will hurt performance significantly" OFF)
113
114CMAKE_DEPENDENT_OPTION(WITH_UPOWER "Build with support for UPower events" ON
115       "UNIX;NOT APPLE" OFF)
116CMAKE_DEPENDENT_OPTION(WITH_GNOMESHORTCUTHANDLER "Build with shortcut handler for GNOME" ON
117       "UNIX;NOT APPLE" OFF)
118
119IF( CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/libcrashreporter-qt/CMakeLists.txt")
120    message(STATUS "Build of crashreporter disabled.")
121    SET(WITH_CRASHREPORTER OFF)
122ENDIF()
123
124# generate version string
125
126# base string used in release and unstable builds
127SET( TOMAHAWK_VERSION_TMP "${TOMAHAWK_VERSION_MAJOR}.${TOMAHAWK_VERSION_MINOR}.${TOMAHAWK_VERSION_PATCH}")
128SET( TOMAHAWK_VERSION_SHORT "${TOMAHAWK_VERSION_TMP}" )
129IF( TOMAHAWK_VERSION_RC )
130  SET( TOMAHAWK_VERSION_TMP "${TOMAHAWK_VERSION_TMP}rc${TOMAHAWK_VERSION_RC}")
131ENDIF()
132
133# additional info for non-release builds
134IF( NOT BUILD_RELEASE AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/" )
135    INCLUDE( CMakeDateStamp )
136    SET( TOMAHAWK_VERSION_DATE "${CMAKE_DATESTAMP_YEAR}${CMAKE_DATESTAMP_MONTH}${CMAKE_DATESTAMP_DAY}" )
137    IF( TOMAHAWK_VERSION_DATE GREATER 0 )
138        SET( TOMAHAWK_VERSION_TMP ${TOMAHAWK_VERSION_TMP}.${TOMAHAWK_VERSION_DATE} )
139    ENDIF()
140
141    INCLUDE( CMakeVersionSource )
142    IF( CMAKE_VERSION_SOURCE )
143        SET( TOMAHAWK_VERSION_TMP ${TOMAHAWK_VERSION_TMP}-${CMAKE_VERSION_SOURCE} )
144    ENDIF()
145ENDIF()
146
147# write Tomahawk version to cache
148SET(TOMAHAWK_VERSION "${TOMAHAWK_VERSION_TMP}" CACHE STRING "Tomahawk Version")
149
150
151# set paths
152SET( THIRDPARTY_DIR "${CMAKE_SOURCE_DIR}/thirdparty" )
153SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
154SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
155SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
156
157# make predefined install dirs available everywhere
158INCLUDE( GNUInstallDirs )
159
160# installer creation
161INCLUDE( TomahawkCPack.cmake )
162
163# deps
164INCLUDE( MacroOptionalFindPackage )
165INCLUDE( MacroLogFeature )
166
167message( STATUS "Building Tomahawk ${TOMAHAWK_VERSION} ***" )
168
169find_package(Qt5Core REQUIRED)
170find_package(Qt5Concurrent REQUIRED)
171find_package(Qt5Gui REQUIRED)
172find_package(Qt5Network REQUIRED)
173find_package(Qt5Sql REQUIRED)
174find_package(Qt5Svg REQUIRED)
175find_package(Qt5UiTools REQUIRED)
176find_package(Qt5WebKitWidgets REQUIRED)
177find_package(Qt5Widgets REQUIRED)
178find_package(Qt5Xml REQUIRED)
179find_package(Qt5X11Extras NO_MODULE QUIET)
180
181if(Qt5X11Extras_FOUND)
182    set(HAVE_X11 TRUE)
183else()
184    set(HAVE_X11 FALSE)
185endif()
186
187if( UNIX AND NOT APPLE )
188    # We need this to find the paths to qdbusxml2cpp and co
189    find_package(Qt5DBus REQUIRED)
190endif()
191
192if(APPLE)
193    find_package(Qt5MacExtras REQUIRED)
194endif()
195
196if(WIN32)
197    find_package(Qt5WinExtras REQUIRED)
198endif()
199
200find_package(Qt5LinguistTools REQUIRED)
201
202set(QT_RCC_EXECUTABLE "${Qt5Core_RCC_EXECUTABLE}")
203# FIXME: CrashReporter depends on deprecated QHttp
204
205set(CMAKE_CXX_STANDARD 11)
206set(CMAKE_CXX_STANDARD_REQUIRED ON)
207set(CMAKE_CXX_EXTENSIONS OFF)
208
209find_package(Boost REQUIRED COMPONENTS filesystem system)
210macro_log_feature(Boost_FOUND "Boost" "Provides free peer-reviewed portable C++ source libraries" "http://www.boost.org" TRUE "" "") #FIXME: give useful explanation
211
212macro_optional_find_package(Lucene++ 3.0.0)
213macro_log_feature(LUCENEPP_FOUND "Lucene++" "The open-source, C++ search engine" "https://github.com/luceneplusplus/LucenePlusPlus/" TRUE "" "Lucene++ is used for indexing the collection")
214
215macro_optional_find_package(Taglib 1.8.0)
216macro_log_feature(TAGLIB_FOUND "TagLib" "Audio Meta-Data Library" "http://developer.kde.org/~wheeler/taglib.html" TRUE "" "taglib is needed for reading meta data from audio files")
217include( CheckTagLibFileName )
218check_taglib_filename( COMPLEX_TAGLIB_FILENAME )
219
220macro_optional_find_package(Sparsehash)
221macro_log_feature(SPARSEHASH_FOUND "Sparsehash"
222    "An extremely memory-efficient hash_map implementation."
223    "https://code.google.com/p/sparsehash/" TRUE ""
224    "Sparsehash is needed for reading metadata of mediastreams and fast
225    forward/backward seeking in HTTP streams")
226
227macro_optional_find_package(GnuTLS)
228macro_log_feature(GNUTLS_FOUND "GnuTLS"
229    "GnuTLS is a secure communications library implementing the SSL, TLS and DTLS protocols and technologies around them."
230    "http://gnutls.org/" TRUE ""
231    "GnuTLS is needed for serving the Playdar/HTTP API via TLS")
232
233macro_optional_find_package(Qca-qt5)
234if(Qca-qt5_DIR)
235    set(QCA2_FOUND ON CACHE BOOL "QCA2 was found")
236    set(QCA2_LIBRARIES "qca-qt5" CACHE STRING "QCA2 Qt5 target")
237endif()
238macro_log_feature(QCA2_FOUND "QCA2" "Provides encryption and signing functions necessary for some resolvers and accounts" "http://delta.affinix.com/qca/" TRUE "" "")
239
240macro_optional_find_package(KF5Attica 1.0.0)
241set(LIBATTICA_FOUND ${KF5Attica_FOUND})
242macro_log_feature(LIBATTICA_FOUND "libattica" "Provides support for installation of resolvers from the Tomahawk website" "http://download.kde.org/stable/attica/" TRUE "" "")
243
244macro_optional_find_package(QuaZip)
245macro_log_feature(QUAZIP_FOUND "QuaZip" "Provides support for extracting downloaded resolvers automatically." "http://quazip.sourceforge.net/" TRUE "" "")
246
247macro_optional_find_package(Jreen 1.0.5)
248macro_log_feature(JREEN_FOUND "Jreen" "Qt XMPP Library" "http://qutim.org/jreen / https://github.com/euroelessar/jreen" FALSE "" "Jreen is needed for the Jabber SIP plugin.\n")
249if( PC_JREEN_VERSION STREQUAL "1.1.0" )
250    message(FATAL_ERROR "Jreen 1.1.0 has a very annoying bug that breaks accepting auth requests in Tomahawk. Please upgrade to 1.1.1 or downgrade to 1.0.5.")
251endif()
252
253macro_optional_find_package(LibLastFm 1.0.0)
254macro_log_feature(LIBLASTFM_FOUND "liblastfm" "Qt library for the Last.fm webservices" "https://github.com/lastfm/liblastfm" TRUE "" "liblastfm is needed for scrobbling tracks to Last.fm and fetching cover artwork")
255
256if( NOT APPLE )
257macro_optional_find_package(Qt5Keychain 0.1.0)
258macro_log_feature(Qt5Keychain_FOUND "QtKeychain" "Provides support for secure credentials storage" "https://github.com/frankosterfeld/qtkeychain" TRUE "" "")
259endif()
260
261if( UNIX AND NOT APPLE )
262    macro_optional_find_package(TelepathyQt 0.9.3)
263    macro_log_feature(TelepathyQt5_FOUND "Telepathy-Qt" "Telepathy-Qt is a Qt high-level binding for Telepathy, a D-Bus framework for unifying real time communication." FALSE "" "Telepathy-Qt is needed for sharing Jabber/GTalk accounts with Telepathy.\n")
264endif()
265
266# we need pthreads too
267macro_optional_find_package(Threads)
268macro_log_feature(THREADS_FOUND "Threads" "Threading Library" "" TRUE "" "Platform specific library for threading")
269
270### QtSparkle
271if( WIN32 )
272    macro_optional_find_package(QtSparkle)
273    macro_log_feature(QTSPARKLE_FOUND "qtsparkle" "Library for creating auto updaters written in Qt" "https://github.com/davidsansome/qtsparkle" FALSE "" "")
274endif( WIN32 )
275
276if( WIN32 OR APPLE )
277    macro_optional_find_package(LibsnoreQt5 0.6.0 QUIET)
278    macro_log_feature(LibsnoreQt5_FOUND "Libsnore" "Library for notifications" "https://projects.kde.org/projects/playground/libs/snorenotify" FALSE "" "")
279endif()
280
281find_package(LIBVLC REQUIRED 2.1.0)
282macro_log_feature(LIBVLC_FOUND "LibVLC" "Provides audio output" "https://www.videolan.org/vlc/"  TRUE "" "")
283
284set(QXTWEB_FOUND TRUE)
285set(QXTWEB_LIBRARIES qxtweb-standalone)
286set(QXTWEB_INCLUDE_DIRS ${THIRDPARTY_DIR}/qxt/qxtweb-standalone/web ${THIRDPARTY_DIR}/qxt/qxtweb-standalone/network ${THIRDPARTY_DIR}/qxt/qxtweb-standalone/core ${CMAKE_CURRENT_BINARY_DIR})
287
288### libportfwd
289set(LIBPORTFWD_INCLUDE_DIR ${THIRDPARTY_DIR}/libportfwd/include)
290set(LIBPORTFWD_LIBRARY tomahawk_portfwd)
291set(LIBPORTFWD_LIBRARIES ${LIBPORTFWD_LIBRARY})
292add_subdirectory(${THIRDPARTY_DIR}/libportfwd)
293
294#### submodules start
295# automatically init submodules here, don't delete this code we may add submodules again
296
297# this installs headers and such and should really be handled in a separate package by packagers
298
299# IF( FALSE )
300#     IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules)
301#         EXECUTE_PROCESS(COMMAND git submodule init WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
302#         EXECUTE_PROCESS(COMMAND git submodule update WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
303#     ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.gitmodules)
304# ENDIF()
305
306#### submodules end
307
308SET( CLEAN_C_FLAGS ${CMAKE_C_FLAGS} )
309
310#show dep log
311macro_display_feature_log()
312
313SET( INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" )
314
315# make uninstall support
316CONFIGURE_FILE(
317  "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
318  "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
319  IMMEDIATE @ONLY)
320
321IF( ( NOT APPLE ) AND ( NOT SANITIZE_ADDRESS ))
322    # Make linking as strict on linux as it is on osx. Then we don't break linking on mac so often
323    #
324    # On using Address Sanitizer, we cannot link to the ASAN lib, so
325    # --no-undefined would break the build.
326    SET( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" )
327    SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined" )
328ENDIF()
329
330IF ( SANITIZE_ADDRESS )
331    SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS}   -fsanitize=address -fno-omit-frame-pointer")
332    SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}   -fsanitize=address -fno-omit-frame-pointer")
333ENDIF()
334
335# Early configure these files as we need them later on
336configure_file(TomahawkUse.cmake.in "${PROJECT_BINARY_DIR}/TomahawkUse.cmake" @ONLY)
337file(COPY TomahawkAddPlugin.cmake DESTINATION "${PROJECT_BINARY_DIR}")
338file(COPY TomahawkAddLibrary.cmake DESTINATION "${PROJECT_BINARY_DIR}")
339
340SET( TOMAHAWK_LIBRARY ${TOMAHAWK_BASE_TARGET_NAME}lib )
341SET( TOMAHAWK_LIBRARIES ${TOMAHAWK_LIBRARY} )
342SET( TOMAHAWK_WIDGETS_LIBRARIES ${TOMAHAWK_BASE_TARGET_NAME}-widgets )
343SET( TOMAHAWK_PLAYDARAPI_LIBRARIES ${TOMAHAWK_BASE_TARGET_NAME}-playdarapi )
344
345ADD_SUBDIRECTORY( thirdparty )
346ADD_SUBDIRECTORY( src )
347ADD_SUBDIRECTORY( admin )
348
349IF(BUILD_TESTS)
350  find_package(Qt5Test REQUIRED)
351  enable_testing()
352  ADD_SUBDIRECTORY( src/tests )
353ENDIF()
354
355# Add all targets to the build-tree export set
356set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/Tomahawk" CACHE PATH  "Installation directory for CMake files")
357set(CMAKE_INSTALL_FULL_CMAKEDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}")
358export(TARGETS ${TOMAHAWK_LIBRARY}
359  FILE "${PROJECT_BINARY_DIR}/TomahawkLibraryDepends.cmake")
360
361# Export the package for use from the build-tree
362# (this registers the build-tree with a global CMake-registry)
363export(PACKAGE Tomahawk)
364
365# Create a TomahawkBuildTreeSettings.cmake file for the use from the build tree
366configure_file(TomahawkBuildTreeSettings.cmake.in "${PROJECT_BINARY_DIR}/TomahawkBuildTreeSettings.cmake" @ONLY)
367
368# Create the TomahawkConfig.cmake and TomahawkConfigVersion files
369file(RELATIVE_PATH CONF_REL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_CMAKEDIR}" "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
370
371configure_file(TomahawkConfig.cmake.in "${PROJECT_BINARY_DIR}/TomahawkConfig.cmake" @ONLY)
372configure_file(TomahawkConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/TomahawkConfigVersion.cmake" @ONLY)
373
374# Install the cmake files
375install(
376    FILES
377        "${PROJECT_BINARY_DIR}/TomahawkConfig.cmake"
378        "${PROJECT_BINARY_DIR}/TomahawkConfigVersion.cmake"
379        "${PROJECT_BINARY_DIR}/TomahawkUse.cmake"
380        "${PROJECT_BINARY_DIR}/TomahawkAddPlugin.cmake"
381        "${PROJECT_BINARY_DIR}/TomahawkAddLibrary.cmake"
382    DESTINATION
383        "${CMAKE_INSTALL_CMAKEDIR}"
384)
385
386# Install the export set for use with the install-tree
387install(
388    EXPORT
389        TomahawkLibraryDepends
390    DESTINATION
391        "${CMAKE_INSTALL_CMAKEDIR}"
392)