[CMake] Converting implicit makefile rules

Tyler Roscoe tyler at cryptio.net
Mon Jul 6 14:47:13 EDT 2009


On Mon, Jul 06, 2009 at 06:07:11PM +0100, Nick Davidson wrote:
> macro (MakeCustomTarget TARGET_FILE CPP XML)
>   add_custom_target(TARGET_FILE ALL          
>     COMMAND process ${TARGET_FILE} ${CPP}
>     COMMAND process ${TARGET_FILE} ${XML})
>   message(STATUS "Cannot find xgettext")       
> endmacro (MakeCustomTarget TARGET_FILE CPP XML) 
> 
> calling MakeCustomTarget("TargetFile" ${LIST1} ${LIST2}) where LIST1 and

I would definitely expect that you need to put quotes around "${LIST1}"
and "${LIST2}" to presvere their listiness.

> LIST2 are semi-colon separated lists causes the first two elements of
> whatever the LIST1 was to get passed as CPP and XML - I had to resort to
> quoting the arguments and then turning them back in to lists with a set.
> 
> macro (MakeCustomTarget TARGET_FILE CPP XML)
>   set(CPP_LIST ${CPP})
>   set(XML_LIST ${XML})
>     add_custom_target(TARGET_FILE ALL          
>     COMMAND process ${TARGET_FILE} ${CPP_LIST}
>     COMMAND process ${TARGET_FILE} ${XML_LIST})
> endmacro (MakeCustomTarget TARGET_FILE CPP XML) 
> 
> MakePot("project.pot" "${LIST1}" "${LIST2}")

I'm not so sure about this, but you may be tripping across the fact that
arguments to a macro aren't real variables but are instead like C
preprocessor #defines. Look at the docs for macro() for more details.

If you don't like your set() workaround, you might be able to use a
function() instead of a macro(), as function() behaves a little
differently.

tyler


More information about the CMake mailing list