mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-19 12:21:52 +02:00
Replace our custom parse arguments macro (copied from wiki) with upstream cmake_parse_arguments macro
This commit is contained in:
@@ -1,50 +1,14 @@
|
|||||||
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
|
include( CMakeParseArguments )
|
||||||
SET(DEFAULT_ARGS)
|
|
||||||
FOREACH(arg_name ${arg_names})
|
|
||||||
SET(${prefix}_${arg_name})
|
|
||||||
ENDFOREACH(arg_name)
|
|
||||||
FOREACH(option ${option_names})
|
|
||||||
SET(${prefix}_${option} FALSE)
|
|
||||||
ENDFOREACH(option)
|
|
||||||
|
|
||||||
SET(current_arg_name DEFAULT_ARGS)
|
|
||||||
SET(current_arg_list)
|
|
||||||
FOREACH(arg ${ARGN})
|
|
||||||
SET(larg_names ${arg_names})
|
|
||||||
LIST(FIND larg_names "${arg}" is_arg_name)
|
|
||||||
IF (is_arg_name GREATER -1)
|
|
||||||
SET(${prefix}_${current_arg_name} ${current_arg_list})
|
|
||||||
SET(current_arg_name ${arg})
|
|
||||||
SET(current_arg_list)
|
|
||||||
ELSE (is_arg_name GREATER -1)
|
|
||||||
SET(loption_names ${option_names})
|
|
||||||
LIST(FIND loption_names "${arg}" is_option)
|
|
||||||
IF (is_option GREATER -1)
|
|
||||||
SET(${prefix}_${arg} TRUE)
|
|
||||||
ELSE (is_option GREATER -1)
|
|
||||||
SET(current_arg_list ${current_arg_list} ${arg})
|
|
||||||
ENDIF (is_option GREATER -1)
|
|
||||||
ENDIF (is_arg_name GREATER -1)
|
|
||||||
ENDFOREACH(arg)
|
|
||||||
SET(${prefix}_${current_arg_name} ${current_arg_list})
|
|
||||||
ENDMACRO(PARSE_ARGUMENTS)
|
|
||||||
|
|
||||||
MACRO(CAR var)
|
|
||||||
SET(${var} ${ARGV1})
|
|
||||||
ENDMACRO(CAR)
|
|
||||||
|
|
||||||
MACRO(CDR var junk)
|
|
||||||
SET(${var} ${ARGN})
|
|
||||||
ENDMACRO(CDR)
|
|
||||||
|
|
||||||
|
|
||||||
macro(tomahawk_add_plugin)
|
function(tomahawk_add_plugin)
|
||||||
parse_arguments(PLUGIN
|
# parse arguments (name needs to be saved before passing ARGN into the macro)
|
||||||
"SOURCES;UI;LINK_LIBRARIES;TYPE;EXPORT_MACRO;COMPILE_DEFINITIONS"
|
set(NAME ${ARGV0})
|
||||||
"NO_INSTALL;SHARED_LIB"
|
set(options NO_INSTALL)
|
||||||
${ARGN}
|
set(oneValueArgs NAME TYPE EXPORT_MACRO)
|
||||||
)
|
set(multiValueArgs SOURCES UI LINK_LIBRARIES COMPILE_DEFINITIONS)
|
||||||
car(PLUGIN_NAME ${PLUGIN_DEFAULT_ARGS})
|
cmake_parse_arguments(PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
set(PLUGIN_NAME ${NAME})
|
||||||
|
|
||||||
# message("*** Arguments for ${PLUGIN_NAME}")
|
# message("*** Arguments for ${PLUGIN_NAME}")
|
||||||
# message("Sources: ${PLUGIN_SOURCES}")
|
# message("Sources: ${PLUGIN_SOURCES}")
|
||||||
@@ -52,6 +16,7 @@ macro(tomahawk_add_plugin)
|
|||||||
# message("UI: ${PLUGIN_UI}")
|
# message("UI: ${PLUGIN_UI}")
|
||||||
# message("TYPE: ${PLUGIN_TYPE}")
|
# message("TYPE: ${PLUGIN_TYPE}")
|
||||||
# message("EXPORT_MACRO: ${PLUGIN_EXPORT_MACRO}")
|
# message("EXPORT_MACRO: ${PLUGIN_EXPORT_MACRO}")
|
||||||
|
# message("NO_INSTALL: ${PLUGIN_NO_INSTALL}")
|
||||||
|
|
||||||
# create target name once for convenience
|
# create target name once for convenience
|
||||||
set(target "tomahawk_${PLUGIN_TYPE}_${PLUGIN_NAME}")
|
set(target "tomahawk_${PLUGIN_TYPE}_${PLUGIN_NAME}")
|
||||||
@@ -103,4 +68,4 @@ macro(tomahawk_add_plugin)
|
|||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
install(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
install(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endfunction()
|
||||||
|
Reference in New Issue
Block a user