[CMake] how to write a cmake function with 2 or 3 arguments?

Arnaud GELAS arnaud_gelas at hms.harvard.edu
Tue Mar 1 15:45:10 EST 2011


That was exactly what I needed!

Thanks,
Arnaud

On 03/01/2011 03:12 PM, David Cole wrote:
> The mandatory function arguments are the ones that you name. Optional
> ones go after the named args and are referenced via ARGV0, ARGV1,
> ARGV2, ... or the ARGV and ARGN variables.
>
> See function documentation for more info:
> http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:function
>
> Typically I use ARGN as a list of, for example, filenames:
>
> function(do_stuff arg1 arg2)
>    foreach(f ${ARGN})
>      # do something interesting with file 'f'
>      message("f='${f}' arg1='${arg1}' arg2='${arg2}'")
>    endforeach()
>    message("f='${f}' arg1='${arg1}' arg2='${arg2}' ARGV2='${ARGV2}'")
> endfunction()
>
>
> HTH,
> David
>
>
> On Tue, Mar 1, 2011 at 3:04 PM, Arnaud GELAS
> <arnaud_gelas at hms.harvard.edu>  wrote:
>> Hi all,
>>
>> I would like to write a cmake function with one optional 3rd argument, the two first are mandatory.
>> How to proceed?
>>
>> Let's take the following example:
>>
>> function( add_sikuli_test arg1 arg2 arg3 )
>>     ...
>> endfunction( add_sikuli_test )
>>
>>
>> Thanks,
>> Arnaud
>>
>>
>>
>>
>>
>> _______________________________________________
>> 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