[CMake] Passing back list of files from Function

Michael Jackson mike.jackson at bluequartz.net
Fri May 11 15:58:58 EDT 2012


Thanks. Worked.
--
Mike Jackson <www.bluequartz.net>

On May 11, 2012, at 3:40 PM, Alexander Neundorf wrote:

> On Friday 11 May 2012, Michael Jackson wrote:
> > I have a function where I am generating a number of files and I need to
> > pass that list of files back to the original calling cmake
> > command/file/scope. How would I go about that?
> > 
> > 
> > 
> > function(create_files)
> >   set(options)
> >   set(multiValueArgs GENERATED_HEADERS)
> >   cmake_parse_arguments( WIG "${options}" "${oneValueArgs}"
> > "${multiValueArgs}" ${ARGN} )
> > 
> >   foreach (....)
> >      .. Generate some files
> > 
> >   endforeach()
> > 
> > 
> > ??
> > 
> > endfunction()
> > 
> > 
> > set(headers "")
> > create_files (GENERATED_HEADERS headers)
> > 
> > 
> > Could someone help me fill in the blanks? Thanks
> Give the name of a variable to create_files() which will be used to return the values:
> function(create_files)
>   set(options)
>   set(multiValueArgs GENERATED_HEADERS)
>   cmake_parse_arguments( WIG "${options}" "${oneValueArgs}"
> "${multiValueArgs}" ${ARGN} )
>  
>   foreach (....)
>      .. Generate some files
>   endforeach()
>   # the following line sets generatedFiles to file[123].x
>   set(${outVar} file1.x file2.x file3.x PARENT_SCOPE)
> endfunction()
>  
>  
> set(headers foo.h bar.h blub.h)
> set(generatedFiles )
> create_files (GENERATED_HEADERS INFILES ${headers} OUTVAR generatedFiles)
> Alex



More information about the CMake mailing list