2013-06-30 15:10:53 +02:00
|
|
|
include( CMakeParseArguments )
|
2013-06-30 15:59:29 +02:00
|
|
|
include( ${TOMAHAWK_CMAKE_DIR}/TomahawkAddLibrary.cmake )
|
2012-05-14 02:41:02 +02:00
|
|
|
|
2013-06-30 15:10:53 +02:00
|
|
|
function(tomahawk_add_plugin)
|
|
|
|
# parse arguments (name needs to be saved before passing ARGN into the macro)
|
|
|
|
set(NAME ${ARGV0})
|
2013-07-01 12:23:19 +02:00
|
|
|
set(options NO_INSTALL SHARED_LIB)
|
2013-06-30 15:10:53 +02:00
|
|
|
set(oneValueArgs NAME TYPE EXPORT_MACRO)
|
|
|
|
set(multiValueArgs SOURCES UI LINK_LIBRARIES COMPILE_DEFINITIONS)
|
|
|
|
cmake_parse_arguments(PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
set(PLUGIN_NAME ${NAME})
|
2012-05-14 02:41:02 +02:00
|
|
|
|
|
|
|
# message("*** Arguments for ${PLUGIN_NAME}")
|
|
|
|
# message("Sources: ${PLUGIN_SOURCES}")
|
|
|
|
# message("Link libraries: ${PLUGIN_LINK_LIBRARIES}")
|
|
|
|
# message("UI: ${PLUGIN_UI}")
|
|
|
|
# message("TYPE: ${PLUGIN_TYPE}")
|
|
|
|
# message("EXPORT_MACRO: ${PLUGIN_EXPORT_MACRO}")
|
2013-06-30 15:10:53 +02:00
|
|
|
# message("NO_INSTALL: ${PLUGIN_NO_INSTALL}")
|
2012-05-14 02:41:02 +02:00
|
|
|
|
|
|
|
# create target name once for convenience
|
2015-10-11 00:00:40 +02:00
|
|
|
set(target "${TOMAHAWK_BASE_TARGET_NAME}_${PLUGIN_TYPE}_${PLUGIN_NAME}")
|
2012-05-14 02:41:02 +02:00
|
|
|
|
2015-09-06 20:37:16 +02:00
|
|
|
# create option to disable plugins
|
|
|
|
string(TOUPPER "${PLUGIN_TYPE}" PLUGIN_TYPE_UPPER)
|
|
|
|
string(TOUPPER "${PLUGIN_NAME}" PLUGIN_NAME_UPPER)
|
|
|
|
set(PLUGIN_OPTION "BUILD_${PLUGIN_TYPE_UPPER}_${PLUGIN_NAME_UPPER}")
|
|
|
|
|
|
|
|
if(NOT DEFINED ${PLUGIN_OPTION})
|
|
|
|
set(${PLUGIN_OPTION} ON)
|
2012-11-11 00:04:13 +01:00
|
|
|
endif()
|
2012-05-14 02:41:02 +02:00
|
|
|
|
2015-09-06 20:37:16 +02:00
|
|
|
option(${PLUGIN_OPTION} "Build Tomahawk with the ${PLUGIN_NAME} ${PLUGIN_TYPE}" ${${PLUGIN_OPTION}})
|
2012-05-17 18:37:34 +02:00
|
|
|
|
2015-09-06 20:37:16 +02:00
|
|
|
if(${PLUGIN_OPTION})
|
|
|
|
# determine target type
|
|
|
|
if(NOT ${PLUGIN_SHARED_LIB})
|
|
|
|
set(target_type "MODULE")
|
|
|
|
else()
|
|
|
|
set(target_type "SHARED")
|
|
|
|
endif()
|
2012-05-14 02:41:02 +02:00
|
|
|
|
2015-09-06 20:37:16 +02:00
|
|
|
list(APPEND tomahawk_add_library_args
|
|
|
|
"${target}"
|
|
|
|
"EXPORT_MACRO" "${PLUGIN_EXPORT_MACRO}"
|
|
|
|
"TARGET_TYPE" "${target_type}"
|
|
|
|
"SOURCES" "${PLUGIN_SOURCES}"
|
|
|
|
)
|
2012-05-14 02:41:02 +02:00
|
|
|
|
2015-09-06 20:37:16 +02:00
|
|
|
if(PLUGIN_UI)
|
|
|
|
list(APPEND tomahawk_add_library_args "UI" "${PLUGIN_UI}")
|
|
|
|
endif()
|
2013-07-01 13:11:57 +02:00
|
|
|
|
2015-09-06 20:37:16 +02:00
|
|
|
if(PLUGIN_LINK_LIBRARIES)
|
|
|
|
list(APPEND tomahawk_add_library_args "LINK_LIBRARIES" "${PLUGIN_LINK_LIBRARIES}")
|
|
|
|
endif()
|
2013-06-30 22:06:55 +02:00
|
|
|
|
2015-09-06 20:37:16 +02:00
|
|
|
if(PLUGIN_COMPILE_DEFINITIONS)
|
|
|
|
list(APPEND tomahawk_add_library_args "COMPILE_DEFINITIONS" ${PLUGIN_COMPILE_DEFINITIONS})
|
|
|
|
endif()
|
2013-07-23 22:29:06 +02:00
|
|
|
|
2015-09-06 20:37:16 +02:00
|
|
|
list(APPEND tomahawk_add_library_args "NO_VERSION")
|
|
|
|
|
|
|
|
list(APPEND tomahawk_add_library_args "INSTALL_BINDIR" "${CMAKE_INSTALL_LIBDIR}")
|
|
|
|
|
|
|
|
tomahawk_add_library(${tomahawk_add_library_args})
|
|
|
|
endif()
|
2013-06-30 15:10:53 +02:00
|
|
|
endfunction()
|