[CMake] Passing back list of files from Function
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 --- Mike Jackson www.bluequartz.net -- 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
Re: [CMake] Passing back list of files from Function
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 -- 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
Re: [CMake] Passing back list of files from Function
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 -- 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