[CMake] Converting implicit makefile rules

Marcel Loose loose at astron.nl
Tue Jul 7 03:22:03 EDT 2009


Hi Nick, Tyler,

Another option is to pass the names of the lists to the macro (one for
the CPP files, one for the XML files), instead of their contents. You
would then need a ${${...}} construct to get their values. 

The (only) downside to that solution is that you cannot pass literal
string arguments anymore.

Best regards,
Marcel Loose.

On Mon, 2009-07-06 at 11:47 -0700, Tyler Roscoe wrote:
> 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
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list