[CMake] Batch converting several files

Martin Fischer m_fischer at users.sf.net
Sun Mar 16 11:31:09 EDT 2008


On 11.03.2008 21:24 Andy Lego wrote:

Hi Andy,

so I tried the following

SET( SOURCEFILES
      file1
      file2
      file3 )
	

FOREACH( FILE ${SOURCEFILES})
	SET( EXECUTE
	     ${EXECUTE}
	     ${tool_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.in 
${CMAKE_CURRENT_BINARY_DIR}/${FILE}.out )
ENDFOREACH( FILE )


ADD_CUSTOM_TARGET( carfiles
		   DEPENDS SOURCEFILES tool
		   COMMAND ${EXECUTE}	
		  )
	 	
It looks like the variable EXCUTE is initialized as expected but is 
considered as one command and not a sequence. Where am I going wrong?

Regards
Martin

> Hello Martin,
> 
> You cannot nest commands and constructs. Move the FOREACH before the
> custom target and set a variable in it. Then use the result in the
> custom target.
> 
> Andy
> 
> On Tue, Mar 11, 2008 at 12:44 PM, Martin Fischer <m_fischer at users.sf.net> wrote:
>> > Hi,
>> >
>> >  for a project I'm working on I need to do the following build steps:
>> >
>> >  - compile an executable from source
>> >  - run this executable to convert several files
>> >  - for each input file in source directory there will be one output file
>> >  in build directory.
>> >
>> >  I tried several variants of he following but didn't come up with a good
>> >  solution.



More information about the CMake mailing list