diff --git a/CMakeLists.txt b/CMakeLists.txt index 4007ce216..743024768 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,7 @@ macro_log_feature(LIBJREEN_FOUND "Jreen" "Qt XMPP Library" "http://gitorious.org # we need pthreads too find_package(Threads) +find_package(KDE4Installed) find_package(KDE4) IF(KDE4_FOUND) #KDE4 adds and removes some compiler flags that we don't like diff --git a/CMakeModules/FindKDE4Installed.cmake b/CMakeModules/FindKDE4Installed.cmake new file mode 100644 index 000000000..d61e57a40 --- /dev/null +++ b/CMakeModules/FindKDE4Installed.cmake @@ -0,0 +1,20 @@ +# Simple hack to detect wether KDE4 is *installed* -- not anything about the development environment! + +FILE(TO_CMAKE_PATH "$ENV{KDEDIRS}" _KDEDIRS) + +# For KDE4 kde-config has been renamed to kde4-config +FIND_PROGRAM(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config + # the suffix must be used since KDEDIRS can be a list of directories which don't have bin/ appended + PATH_SUFFIXES bin + HINTS + ${CMAKE_INSTALL_PREFIX} + ${_KDEDIRS} + /opt/kde4 + ONLY_CMAKE_FIND_ROOT_PATH + ) + +IF (KDE4_KDECONFIG_EXECUTABLE) + SET (KDE4_INSTALLED TRUE) + message(STATUS "KDE4 is installed, will install protocol file") +ENDIF (KDE4_KDECONFIG_EXECUTABLE) + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 42ea6e0fe..301ac0ca8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -243,14 +243,19 @@ ENDIF( APPLE ) INSTALL( TARGETS tomahawk BUNDLE DESTINATION . RUNTIME DESTINATION bin ) -IF(KDE4_FOUND) #install protocol file - FILE(READ ${CMAKE_SOURCE_DIR}/admin/unix/tomahawk.protocol protocol) +IF( UNIX AND NOT APPLE AND KDE4_INSTALLED ) #install protocol file + FILE( READ ${CMAKE_SOURCE_DIR}/admin/unix/tomahawk.protocol protocol ) STRING( REPLACE "/path/to/binary" # match this "${CMAKE_INSTALL_PREFIX}/bin/tomahawk" # this is linux (kde) so pretty safe I think edited_protocol # save in this variable "${protocol}" # from the contents of this var ) FILE( WRITE ${CMAKE_BINARY_DIR}/tomahawk.protocol "${edited_protocol}" ) - INSTALL( FILES ${CMAKE_BINARY_DIR}/tomahawk.protocol DESTINATION ${SERVICES_INSTALL_DIR} ) + IF( ${SERVICES_INSTALL_DIR} ) + SET( PROTOCOL_INSTALL_DIR ${SERVICES_INSTALL_DIR} ) + ELSE() + SET( PROTOCOL_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/kde4/services" ) + ENDIF() + INSTALL( FILES ${CMAKE_BINARY_DIR}/tomahawk.protocol DESTINATION ${PROTOCOL_INSTALL_DIR} ) ENDIF() #INCLUDE( "CPack.txt" )