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
|
|
|
|
set(target "tomahawk_${PLUGIN_TYPE}_${PLUGIN_NAME}")
|
|
|
|
|
2013-06-30 15:59:29 +02:00
|
|
|
# determine target type
|
2012-11-11 00:04:13 +01:00
|
|
|
if(NOT ${PLUGIN_SHARED_LIB})
|
2013-06-30 15:59:29 +02:00
|
|
|
set(target_type "MODULE")
|
2012-11-11 00:04:13 +01:00
|
|
|
else()
|
2013-06-30 15:59:29 +02:00
|
|
|
set(target_type "SHARED")
|
2012-11-11 00:04:13 +01:00
|
|
|
endif()
|
2012-05-14 02:41:02 +02:00
|
|
|
|
2013-06-30 15:59:29 +02:00
|
|
|
list(APPEND tomahawk_add_library_args
|
|
|
|
"${target}"
|
|
|
|
"EXPORT_MACRO" "${PLUGIN_EXPORT_MACRO}"
|
|
|
|
"TARGET_TYPE" "${target_type}"
|
|
|
|
"SOURCES" "${PLUGIN_SOURCES}"
|
|
|
|
)
|
2012-05-17 18:37:34 +02:00
|
|
|
|
2013-06-30 15:59:29 +02:00
|
|
|
if(PLUGIN_UI)
|
|
|
|
list(APPEND tomahawk_add_library_args "UI" "${PLUGIN_UI}")
|
2012-05-14 03:16:03 +02:00
|
|
|
endif()
|
2012-05-14 02:41:02 +02:00
|
|
|
|
|
|
|
if(PLUGIN_LINK_LIBRARIES)
|
2013-06-30 15:59:29 +02:00
|
|
|
list(APPEND tomahawk_add_library_args "LINK_LIBRARIES" "${PLUGIN_LINK_LIBRARIES}")
|
2012-05-14 02:41:02 +02:00
|
|
|
endif()
|
|
|
|
|
2013-07-01 13:11:57 +02:00
|
|
|
if(PLUGIN_COMPILE_DEFINITIONS)
|
|
|
|
list(APPEND tomahawk_add_library_args "COMPILE_DEFINITIONS" ${PLUGIN_COMPILE_DEFINITIONS})
|
|
|
|
endif()
|
|
|
|
|
2013-06-30 22:06:55 +02:00
|
|
|
list(APPEND tomahawk_add_library_args "NO_VERSION")
|
|
|
|
|
2013-07-23 22:29:06 +02:00
|
|
|
list(APPEND tomahawk_add_library_args "INSTALL_BINDIR" "${CMAKE_INSTALL_LIBDIR}")
|
|
|
|
|
2013-06-30 15:59:29 +02:00
|
|
|
tomahawk_add_library(${tomahawk_add_library_args})
|
2013-06-30 15:10:53 +02:00
|
|
|
endfunction()
|