[CMake] append command

Michael Wild themiwi at gmail.com
Thu Aug 11 14:34:58 EDT 2011


On 08/11/2011 07:39 PM, Alan W. Irwin wrote:
> On 2011-08-11 17:20+0200 Michael Wild wrote:
> 
>> How about
>>
>> string(APPEND " /newstuff" xyz)
>>
>> It is not satisfactory in that it doesn't follow the semantics of all
>> the other string(...) commands which never modify their input.
> 
> I like that idea, but I would generalize it as
> 
> string(APPEND <string> <output_variable> <input> [<input>...])
> 
> to make it similar to other string commands.
> 
> BUT if no input is given take it from "${output_variable}" just as
> for your suggestion.
> 
> I would also make that same change for all other string commands of
> the same form, i.e., the various REGEX and REPLACE commands.  For those, I
> find the input string is often "${output_variable}" so I believe this
> generalization would be a useful convenience for all users of those
> string subcommands.  Furthermore, even though this generalization of
> REGEX et all is a major change, IIRC you get a wrong number
> of arguments now for, e.g.,
> 
> string(REGEX REPLACE <regular_expression> <replace_expression> <output
> variable>)
> 
> so I believe this generalization would be backwards compatible.
> 
> Alan

Making the <string> argument optional is not possible, since there is no
reliable way of determining whether it has been provided or not. Take

string(APPEND foo bar baz)

What is the intention here? Should the result be equivalent to

set(bar "foobaz")

or

set(foo "${foo}barbaz")

?

Michael


More information about the CMake mailing list