mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-13 20:39:57 +01:00
Replace our custom parse arguments macro (copied from wiki) with upstream cmake_parse_arguments macro
This commit is contained in:
parent
ca1db0cd48
commit
ae13f92885
@ -1,50 +1,14 @@
|
||||
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
|
||||
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)
|
||||
include( CMakeParseArguments )
|
||||
|
||||
|
||||
macro(tomahawk_add_plugin)
|
||||
parse_arguments(PLUGIN
|
||||
"SOURCES;UI;LINK_LIBRARIES;TYPE;EXPORT_MACRO;COMPILE_DEFINITIONS"
|
||||
"NO_INSTALL;SHARED_LIB"
|
||||
${ARGN}
|
||||
)
|
||||
car(PLUGIN_NAME ${PLUGIN_DEFAULT_ARGS})
|
||||
function(tomahawk_add_plugin)
|
||||
# parse arguments (name needs to be saved before passing ARGN into the macro)
|
||||
set(NAME ${ARGV0})
|
||||
set(options NO_INSTALL)
|
||||
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})
|
||||
|
||||
# message("*** Arguments for ${PLUGIN_NAME}")
|
||||
# message("Sources: ${PLUGIN_SOURCES}")
|
||||
@ -52,6 +16,7 @@ macro(tomahawk_add_plugin)
|
||||
# message("UI: ${PLUGIN_UI}")
|
||||
# message("TYPE: ${PLUGIN_TYPE}")
|
||||
# message("EXPORT_MACRO: ${PLUGIN_EXPORT_MACRO}")
|
||||
# message("NO_INSTALL: ${PLUGIN_NO_INSTALL}")
|
||||
|
||||
# create target name once for convenience
|
||||
set(target "tomahawk_${PLUGIN_TYPE}_${PLUGIN_NAME}")
|
||||
@ -103,4 +68,4 @@ macro(tomahawk_add_plugin)
|
||||
include(GNUInstallDirs)
|
||||
install(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
Loading…
x
Reference in New Issue
Block a user