[CMake] append command

David Cole david.cole at kitware.com
Wed Aug 10 09:56:15 EDT 2011


On Tue, Aug 9, 2011 at 3:34 PM, Alan W. Irwin <irwin at beluga.phys.uvic.ca> wrote:
> On 2011-08-09 17:19+0100 Glenn Coombs wrote:
>
>> Probably too late now and there isn't a bug filed so far as I know, but
>> one thing I would love to see added to cmake is an append command
>> so that lines like this:
>>
>>     set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}
>> /INCREMENTAL:NO")
>>
>> become shorter and easier to understand:
>>
>>     append(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO")
>>
>> The existing syntax for the set command is just ugly when appending.  I
>> know you can define a macro or function to do this but I just
>> feel that it should be supported out of the box as it would make
>> CMakeLists.txt files more readable.
>>
>
> Hi Glenn:
>
> I am changing the subject line to keep discussion out of the
> bugfix thread as requested by Dave.
>
> It appears what you want is the list APPEND command for
> blank-delimited strings.  But then later someone will want to add
> other parts of the list functionality to blank-delimited strings as
> well such as removing items from the blank-delimited list.  Until you
> have two parallel list systems, one for blank delimited strings and
> one for semicolon-delimited strings (i.e., the current lists).
>
> I think most would reject the idea of having two parallel list systems
> with different delimiters so here is one possibility.
>
> For now just stick to list functionality, e.g.,
>
> list(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO")
>
> and then change the semicolon delimiters to blanks using
>
> strings(REGEX REPLACE ...)
>
> once you have the list completely assembled.  Of course, that will not
> work for the corner case where the strings contain semicolons. So in
> the long term, the right thing to do with lists might be to allow a
> choice of delimiter if you could do that in such a way as to preserve
> backwards compatibility.
>
> Alan
> __________________________
> Alan W. Irwin
>
> Astronomical research affiliation with Department of Physics and Astronomy,
> University of Victoria (astrowww.phys.uvic.ca).
>
> Programming affiliations with the FreeEOS equation-of-state implementation
> for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
> package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
> Linux Links project (loll.sf.net); and the Linux Brochure Project
> (lbproject.sf.net).
> __________________________
>
> Linux-powered Science
> __________________________
>

The APPEND_STRING arg was recently added to the CMake command
set_property, because of a similar complaint about the APPEND arg with
properties that are typically space separated.

I'm not sure if an APPEND_STRING arg belongs in the "set" command, though...

I understand that a line like this:

    set(CMAKE_EXE_LINKER_FLAGS_RELEASE
"${CMAKE_EXE_LINKER_FLAGS_RELEASE} /INCREMENTAL:NO")

is visually "too long" because we use verbose variable naming, but it
is clear what it's doing, and it does work in all prior CMake
versions...

I tend toward keeping things as they are unless there's a strong
consensus that an addition like this would really improve things for
most CMake users.

Anybody else listening in here have an opinion?


Thanks,
David


More information about the CMake mailing list