From 1f664897550f21b9a63e147cc7d852a7c983a886 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Sun, 30 Jun 2013 15:59:29 +0200 Subject: [PATCH] Move some logic out of the tomahawk_add_plugin macro to a tomahawk_add_library macro --- CMakeLists.txt | 4 ++- TomahawkAddPlugin.cmake | 52 ++++++++++--------------------------- TomahawkUse.cmake | 1 + src/CMakeLists.txt | 19 +++++++++----- src/accounts/CMakeLists.txt | 1 - 5 files changed, 30 insertions(+), 47 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 519f36130..ec1fafae6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -345,9 +345,10 @@ file(RELATIVE_PATH CONF_REL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_CMAKEDIR}" "${CMAK configure_file(TomahawkConfig.cmake.in "${PROJECT_BINARY_DIR}/TomahawkConfig.cmake" @ONLY) configure_file(TomahawkConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/TomahawkConfigVersion.cmake" @ONLY) + file(COPY TomahawkUse.cmake DESTINATION "${PROJECT_BINARY_DIR}") file(COPY TomahawkAddPlugin.cmake DESTINATION "${PROJECT_BINARY_DIR}") - +file(COPY TomahawkAddLibrary.cmake DESTINATION "${PROJECT_BINARY_DIR}") # Install the cmake files install( @@ -356,6 +357,7 @@ install( "${PROJECT_BINARY_DIR}/TomahawkConfigVersion.cmake" "${PROJECT_BINARY_DIR}/TomahawkUse.cmake" "${PROJECT_BINARY_DIR}/TomahawkAddPlugin.cmake" + "${PROJECT_BINARY_DIR}/TomahawkAddLibrary.cmake" DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" ) diff --git a/TomahawkAddPlugin.cmake b/TomahawkAddPlugin.cmake index ab3de172e..206c9d42b 100644 --- a/TomahawkAddPlugin.cmake +++ b/TomahawkAddPlugin.cmake @@ -1,5 +1,5 @@ include( CMakeParseArguments ) - +include( ${TOMAHAWK_CMAKE_DIR}/TomahawkAddLibrary.cmake ) function(tomahawk_add_plugin) # parse arguments (name needs to be saved before passing ARGN into the macro) @@ -21,51 +21,27 @@ function(tomahawk_add_plugin) # create target name once for convenience set(target "tomahawk_${PLUGIN_TYPE}_${PLUGIN_NAME}") - # qt stuff - include_directories(${CMAKE_CURRENT_BINARY_DIR}) - if(PLUGIN_UI) - qt_wrap_ui(PLUGIN_UI_SOURCES ${PLUGIN_UI}) - list(APPEND PLUGIN_SOURCES ${PLUGIN_UI_SOURCES}) - endif() - - if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/resources.qrc") - qt_add_resources(PLUGIN_RC_SOURCES "resources.qrc") - list(APPEND PLUGIN_SOURCES ${PLUGIN_RC_SOURCES}) - unset(PLUGIN_RC_SOURCES) - endif() - - # add target + # determine target type if(NOT ${PLUGIN_SHARED_LIB}) - add_library(${target} MODULE ${PLUGIN_SOURCES}) + set(target_type "MODULE") else() - add_library(${target} SHARED ${PLUGIN_SOURCES}) + set(target_type "SHARED") endif() - # add qt modules - qt5_use_modules(${target} Core Network Widgets Sql Xml DBus) + list(APPEND tomahawk_add_library_args + "${target}" + "EXPORT_MACRO" "${PLUGIN_EXPORT_MACRO}" + "TARGET_TYPE" "${target_type}" + "SOURCES" "${PLUGIN_SOURCES}" + ) - # definitions - can this be moved into set_target_properties below? - add_definitions(${QT_DEFINITIONS}) - set_target_properties(${target} PROPERTIES AUTOMOC TRUE COMPILE_DEFINITIONS ${PLUGIN_EXPORT_MACRO}) - if(PLUGIN_COMPILE_DEFINITIONS) - # Dear CMake, i hate you! Sincerely, domme - # At least in CMake 2.8.8, you CANNOT set more than one COMPILE_DEFINITIONS value - # only takes the first one if called multiple times or bails out with wrong number of arguments - # when passing in a list, thus i redefine the export macro here in hope it won't mess up other targets - add_definitions( "-D${PLUGIN_EXPORT_MACRO}" ) - - set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS ${PLUGIN_COMPILE_DEFINITIONS}) + if(PLUGIN_UI) + list(APPEND tomahawk_add_library_args "UI" "${PLUGIN_UI}") endif() - # add link targets - target_link_libraries(${target} ${TOMAHAWK_LIBRARIES}) if(PLUGIN_LINK_LIBRARIES) - target_link_libraries(${target} ${PLUGIN_LINK_LIBRARIES}) + list(APPEND tomahawk_add_library_args "LINK_LIBRARIES" "${PLUGIN_LINK_LIBRARIES}") endif() - # make installation optional, maybe useful for dummy plugins one day - if(NOT PLUGIN_NO_INSTALL) - include(GNUInstallDirs) - install(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() + tomahawk_add_library(${tomahawk_add_library_args}) endfunction() diff --git a/TomahawkUse.cmake b/TomahawkUse.cmake index 0d59a9f9d..e1d0af4c1 100644 --- a/TomahawkUse.cmake +++ b/TomahawkUse.cmake @@ -31,4 +31,5 @@ if(NOT TOMAHAWK_CMAKE_DIR) set(TOMAHAWK_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR}) endif() +include( "${TOMAHAWK_CMAKE_DIR}/TomahawkAddLibrary.cmake" ) include( "${TOMAHAWK_CMAKE_DIR}/TomahawkAddPlugin.cmake" ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7ba4d839f..95eca61ec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,13 +1,18 @@ +include( ../TomahawkUse.cmake ) + setup_qt() include_directories( ${CMAKE_CURRENT_BINARY_DIR}/libtomahawk ) include_directories( ${CMAKE_CURRENT_LIST_DIR}/libtomahawk ) -file(GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*") +# library +add_subdirectory(libtomahawk) -foreach(SUBDIRECTORY ${SUBDIRECTORIES}) - if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt") - message(STATUS "build: " ${SUBDIRECTORY}) - add_subdirectory( ${SUBDIRECTORY} ) - endif() -endforeach() +# plugins +add_subdirectory(accounts) +add_subdirectory(infoplugins) + + +# application +add_subdirectory(tomahawk) +add_subdirectory(crashreporter) \ No newline at end of file diff --git a/src/accounts/CMakeLists.txt b/src/accounts/CMakeLists.txt index 8359bc4df..aefc56346 100644 --- a/src/accounts/CMakeLists.txt +++ b/src/accounts/CMakeLists.txt @@ -1,4 +1,3 @@ -include( ${CMAKE_CURRENT_LIST_DIR}/../../TomahawkAddPlugin.cmake ) file(GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*") foreach(SUBDIRECTORY ${SUBDIRECTORIES})