[CMake] Removing the first element from a list

Sylvain Benner benner at virtools.com
Thu Oct 11 11:40:28 EDT 2007


> But this doesn't?
>
> 	MACRO(SHIFT RESULT LISTVAR)
>     	LIST(GET LISTVAR 1 RESULT)
>     	LIST(REMOVE_AT LISTVAR 1)
> 	ENDMACRO(SHIFT)
>
> 	MACRO(TEST)
>         SET(Q ${ARGN})
>         WHILE(${Q})
>                 # Get the command
>                 SHIFT(CMD Q)
>                 MESSAGE("Command was ${CMD}")
>         ENDWHILE(Q)
> 	ENDMACRO(TEST)
>
> 	TEST(NOT A B NOT C D CLEAR)
>   
correction:

	MACRO(SHIFT RESULT LISTVAR)
    	LIST(GET ${LISTVAR} 1 ${RESULT})
    	LIST(REMOVE_AT ${LISTVAR} 1)
	ENDMACRO(SHIFT)

rule:

Dereferencing a macro variable gives you the variable name. Dereferencing twice gives you the value of the passed variable.

The other way is to call your original macro like this :
SHIFT(${CMD} ${Q})


--Sylvain



More information about the CMake mailing list