2010-02-28 10:04:35 +01:00
|
|
|
MACRO(SPLIT_ARGN_KEYWORDS SAK_RESULT)
|
|
|
|
SET(SAK_FIRST TRUE)
|
|
|
|
SET(SAK_FINISHED FALSE)
|
|
|
|
|
|
|
|
FOREACH(SAK_ITEM ${ARGN})
|
|
|
|
IF(NOT SAK_FINISHED)
|
|
|
|
IF(${SAK_ITEM} STREQUAL ARGUMENTS)
|
|
|
|
SET(SAK_FINISHED TRUE)
|
|
|
|
ELSE(${SAK_ITEM} STREQUAL ARGUMENTS)
|
|
|
|
STRING(REPLACE "," ";" SAK_ITEMLIST ${SAK_ITEM})
|
|
|
|
LIST(GET SAK_ITEMLIST 0 SAK_KEYWORD)
|
|
|
|
IF(SAK_FIRST)
|
|
|
|
SET(${SAK_RESULT} ${SAK_KEYWORD})
|
|
|
|
SET(SAK_FIRST FALSE)
|
|
|
|
ELSE(SAK_FIRST)
|
|
|
|
SET(${SAK_RESULT} ${${SAK_RESULT}} ${SAK_KEYWORD})
|
|
|
|
ENDIF(SAK_FIRST)
|
|
|
|
ENDIF(${SAK_ITEM} STREQUAL ARGUMENTS)
|
|
|
|
ENDIF(NOT SAK_FINISHED)
|
|
|
|
ENDFOREACH(SAK_ITEM ${ARGN})
|
|
|
|
ENDMACRO(SPLIT_ARGN_KEYWORDS SAK_RESULT)
|
|
|
|
|
|
|
|
MACRO(SPLIT_ARGN_CLEAN_ISVARS)
|
|
|
|
SET(SACI_FINISHED FALSE)
|
|
|
|
|
|
|
|
FOREACH(SACI_ITEM ${ARGN})
|
|
|
|
IF(NOT SACI_FINISHED)
|
|
|
|
IF(${SACI_ITEM} STREQUAL ARGUMENTS)
|
|
|
|
SET(SACI_FINISHED TRUE)
|
|
|
|
ELSE(${SACI_ITEM} STREQUAL ARGUMENTS)
|
|
|
|
STRING(REPLACE "," ";" SACI_ITEMLIST ${SACI_ITEM})
|
|
|
|
LIST(GET SACI_ITEMLIST 3 SACI_ISVARNAME)
|
|
|
|
IF(NOT "${SACI_ISVARNAME}" STREQUAL "_")
|
|
|
|
SET(${SACI_ISVARNAME} FALSE)
|
|
|
|
ENDIF(NOT "${SACI_ISVARNAME}" STREQUAL "_")
|
|
|
|
ENDIF(${SACI_ITEM} STREQUAL ARGUMENTS)
|
|
|
|
ENDIF(NOT SACI_FINISHED)
|
|
|
|
ENDFOREACH(SACI_ITEM ${ARGN})
|
|
|
|
ENDMACRO(SPLIT_ARGN_CLEAN_ISVARS)
|
|
|
|
|
|
|
|
MACRO(SPLIT_ARGN_GET_KEYWORD SAG_KEYWORD SAG_FOUND SAG_KEYWORDNAME SAG_MINCOUNT SAG_MAXCOUNT SAG_ISVARNAME SAG_VARNAME)
|
|
|
|
SET(${SAG_FOUND} FALSE)
|
|
|
|
SET(SAG_FINISHED FALSE)
|
|
|
|
|
|
|
|
FOREACH(SAG_ITEM ${ARGN})
|
|
|
|
IF(NOT SAG_FINISHED)
|
|
|
|
IF(${SAG_ITEM} STREQUAL ARGUMENTS)
|
|
|
|
SET(SAG_FINISHED TRUE)
|
|
|
|
ELSE(${SAG_ITEM} STREQUAL ARGUMENTS)
|
|
|
|
STRING(REPLACE "," ";" SAG_ITEMLIST ${SAG_ITEM})
|
|
|
|
LIST(GET SAG_ITEMLIST 0 SAG_ITEMKEYWORD)
|
|
|
|
IF(${SAG_KEYWORD} STREQUAL ${SAG_ITEMKEYWORD})
|
|
|
|
SET(${SAG_FOUND} TRUE)
|
|
|
|
IF(NOT "${SAG_KEYWORDNAME}" STREQUAL "_")
|
|
|
|
LIST(GET SAG_ITEMLIST 0 ${SAG_KEYWORDNAME})
|
|
|
|
ENDIF(NOT "${SAG_KEYWORDNAME}" STREQUAL "_")
|
|
|
|
IF(NOT "${SAG_MINCOUNT}" STREQUAL "_")
|
|
|
|
LIST(GET SAG_ITEMLIST 1 ${SAG_MINCOUNT})
|
|
|
|
ENDIF(NOT "${SAG_MINCOUNT}" STREQUAL "_")
|
|
|
|
IF(NOT "${SAG_MAXCOUNT}" STREQUAL "_")
|
|
|
|
LIST(GET SAG_ITEMLIST 2 ${SAG_MAXCOUNT})
|
|
|
|
ENDIF(NOT "${SAG_MAXCOUNT}" STREQUAL "_")
|
|
|
|
IF(NOT "${SAG_ISVARNAME}" STREQUAL "_")
|
|
|
|
LIST(GET SAG_ITEMLIST 3 ${SAG_ISVARNAME})
|
|
|
|
ENDIF(NOT "${SAG_ISVARNAME}" STREQUAL "_")
|
|
|
|
IF(NOT "${SAG_VARNAME}" STREQUAL "_")
|
|
|
|
LIST(GET SAG_ITEMLIST 4 ${SAG_VARNAME})
|
|
|
|
ENDIF(NOT "${SAG_VARNAME}" STREQUAL "_")
|
|
|
|
ENDIF(${SAG_KEYWORD} STREQUAL ${SAG_ITEMKEYWORD})
|
|
|
|
ENDIF(${SAG_ITEM} STREQUAL ARGUMENTS)
|
|
|
|
ENDIF(NOT SAG_FINISHED)
|
|
|
|
ENDFOREACH(SAG_ITEM ${ARGN})
|
|
|
|
ENDMACRO(SPLIT_ARGN_GET_KEYWORD SAG_KEYWORD SAG_FOUND SAG_KEYWORDNAME SAG_MINCOUNT SAG_MAXCOUNT SAG_ISVARNAME SAG_VARNAME)
|
|
|
|
|
|
|
|
MACRO(SPLIT_ARGN_IS_KEYWORD SAG_KEYWORDS SAG_ITEM SAG_RESULT)
|
|
|
|
LIST(FIND ${SAG_KEYWORDS} ${SAG_ITEM} SAG_FIND)
|
|
|
|
IF(${SAG_FIND} LESS 0)
|
|
|
|
SET(${SAG_RESULT} FALSE)
|
|
|
|
ELSE(${SAG_FIND} LESS 0)
|
|
|
|
SET(${SAG_RESULT} TRUE)
|
|
|
|
ENDIF(${SAG_FIND} LESS 0)
|
|
|
|
ENDMACRO(SPLIT_ARGN_IS_KEYWORD SAG_KEYWORDS SAG_ITEM)
|
|
|
|
|
|
|
|
MACRO(SPLIT_ARGN)
|
|
|
|
SPLIT_ARGN_KEYWORDS(SA_KEYWORDS ${ARGN})
|
2010-10-24 15:42:25 +02:00
|
|
|
#IF(__DEBUG__)
|
|
|
|
# MESSAGE(STATUS "KEYWORDS: ${SA_KEYWORDS}")
|
|
|
|
#ENDIF()
|
2010-02-28 10:04:35 +01:00
|
|
|
SPLIT_ARGN_CLEAN_ISVARS(${ARGN})
|
|
|
|
SET(SA_EXPECT_KEYWORD TRUE)
|
|
|
|
SET(SA_EXPECT_VALUE FALSE)
|
|
|
|
SET(SA_START FALSE)
|
|
|
|
|
|
|
|
#Loop through list
|
|
|
|
FOREACH(SA_ITEM ${ARGN})
|
|
|
|
IF(NOT SA_START)
|
|
|
|
IF(${SA_ITEM} STREQUAL ARGUMENTS)
|
|
|
|
SET(SA_START TRUE)
|
|
|
|
ENDIF(${SA_ITEM} STREQUAL ARGUMENTS)
|
|
|
|
ELSE(NOT SA_START)
|
|
|
|
#Check if the current item is a keyword
|
|
|
|
SPLIT_ARGN_IS_KEYWORD(SA_KEYWORDS ${SA_ITEM} SA_ISKEYWORD)
|
2010-10-24 15:42:25 +02:00
|
|
|
#IF(__DEBUG__)
|
|
|
|
# MESSAGE(STATUS "ITEM=${SA_ITEM} KEYWORD=${SA_ISKEYWORD}")
|
|
|
|
#ENDIF()
|
2010-02-28 10:04:35 +01:00
|
|
|
|
|
|
|
IF(SA_ISKEYWORD)
|
|
|
|
#Check if it is what we expect
|
|
|
|
IF(NOT SA_EXPECT_KEYWORD)
|
|
|
|
MESSAGE(ERROR "Unexpected keyword in SPLIT_ARGN, got \"${SA_ITEM}\".")
|
|
|
|
ELSE(NOT SA_EXPECT_KEYWORD)
|
|
|
|
#Save information about the keyword
|
|
|
|
SPLIT_ARGN_GET_KEYWORD(${SA_ITEM} SA_KEYWORD_FOUND SA_CUR_KEYWORD SA_CUR_MINCOUNT SA_CUR_MAXCOUNT SA_CUR_ISVARNAME SA_CUR_VARNAME ${ARGN})
|
2010-10-24 15:42:25 +02:00
|
|
|
#IF(__DEBUG__)
|
|
|
|
# MESSAGE(STATUS "KEYWORD: FOUND=${SA_KEYWORD_FOUND} KEYW=${SA_CUR_KEYWORD} MIN=${SA_CUR_MINCOUNT} MAX=${SA_CUR_MAXCOUNT} ISVAR=${SA_CUR_ISVARNAME} VARNAME=${SA_CUR_VARNAME}")
|
|
|
|
#ENDIF()
|
2010-02-28 10:04:35 +01:00
|
|
|
IF(SA_KEYWORD_FOUND)
|
|
|
|
SET(SA_CUR_INDEX 0)
|
|
|
|
IF(NOT "${SA_CUR_VARNAME}" STREQUAL "_")
|
|
|
|
SET(${SA_CUR_VARNAME})
|
|
|
|
ENDIF(NOT "${SA_CUR_VARNAME}" STREQUAL "_")
|
|
|
|
IF(NOT "${SA_CUR_ISVARNAME}" STREQUAL "_")
|
|
|
|
SET(${SA_CUR_ISVARNAME} FALSE)
|
|
|
|
ENDIF(NOT "${SA_CUR_ISVARNAME}" STREQUAL "_")
|
|
|
|
ELSE(SA_KEYWORD_FOUND)
|
|
|
|
MESSAGE(ERROR "Got keyword, but didn't found information about \"${SA_ITEM}\"")
|
|
|
|
ENDIF(SA_KEYWORD_FOUND)
|
|
|
|
ENDIF(NOT SA_EXPECT_KEYWORD)
|
|
|
|
ELSE(SA_ISKEYWORD)
|
|
|
|
#Check if it is what we expect
|
|
|
|
IF(NOT SA_EXPECT_VALUE)
|
|
|
|
MESSAGE(ERROR "Unexpected value in SPLIT_ARGN, got \"${SA_ITEM}\".")
|
|
|
|
ELSE(NOT SA_EXPECT_VALUE)
|
|
|
|
#Save this item to the list
|
|
|
|
IF(NOT "${SA_CUR_VARNAME}" STREQUAL "_")
|
|
|
|
SET(${SA_CUR_VARNAME} ${${SA_CUR_VARNAME}} ${SA_ITEM})
|
|
|
|
ENDIF(NOT "${SA_CUR_VARNAME}" STREQUAL "_")
|
|
|
|
|
|
|
|
#Increase index
|
|
|
|
MATH(EXPR SA_CUR_INDEX_TMP "${SA_CUR_INDEX}+1")
|
|
|
|
SET(SA_CUR_INDEX ${SA_CUR_INDEX_TMP})
|
|
|
|
ENDIF(NOT SA_EXPECT_VALUE)
|
|
|
|
ENDIF(SA_ISKEYWORD)
|
|
|
|
|
|
|
|
#Check what to expect from the next element
|
|
|
|
IF(${SA_CUR_INDEX} LESS ${SA_CUR_MINCOUNT})
|
|
|
|
SET(SA_EXPECT_KEYWORD FALSE)
|
|
|
|
SET(SA_EXPECT_VALUE TRUE)
|
|
|
|
ELSE(${SA_CUR_INDEX} LESS ${SA_CUR_MINCOUNT})
|
|
|
|
SET(${SA_CUR_ISVARNAME} TRUE)
|
|
|
|
SET(SA_EXPECT_KEYWORD TRUE)
|
|
|
|
|
|
|
|
IF(${SA_CUR_INDEX} LESS ${SA_CUR_MAXCOUNT} OR ${SA_CUR_MAXCOUNT} LESS 0)
|
|
|
|
SET(SA_EXPECT_VALUE TRUE)
|
|
|
|
ELSE(${SA_CUR_INDEX} LESS ${SA_CUR_MAXCOUNT} OR ${SA_CUR_MAXCOUNT} LESS 0)
|
|
|
|
SET(SA_EXPECT_VALUE FALSE)
|
|
|
|
ENDIF(${SA_CUR_INDEX} LESS ${SA_CUR_MAXCOUNT} OR ${SA_CUR_MAXCOUNT} LESS 0)
|
|
|
|
ENDIF(${SA_CUR_INDEX} LESS ${SA_CUR_MINCOUNT})
|
|
|
|
ENDIF(NOT SA_START)
|
|
|
|
ENDFOREACH(SA_ITEM ${ARGN})
|
|
|
|
|
|
|
|
IF(SA_START AND NOT SA_EXPECT_KEYWORD)
|
|
|
|
#Didn't get all the expected values of the last keyword
|
|
|
|
MESSAGE(ERROR "Missing values at the end in SPLIT_ARGN.")
|
|
|
|
ENDIF(SA_START AND NOT SA_EXPECT_KEYWORD)
|
|
|
|
ENDMACRO(SPLIT_ARGN)
|
|
|
|
|