[CMake] append command

Alan W. Irwin irwin at beluga.phys.uvic.ca
Tue Aug 9 15:34:15 EDT 2011


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
__________________________


More information about the CMake mailing list