[CMake] append command

Glenn Coombs glenn.coombs at gmail.com
Thu Aug 11 07:29:03 EDT 2011


The problem is that we currently already have 2 parallel systems.  Some of
the variables like CMAKE_EXE_LINKER_FLAGS are passed through as-is to the
compiler or linker.  So, by definition, these variables are space separated
lists of options.  Attempting to use list(APPEND) on them adds semicolon
characters which causes breakage unless you manually remove them.

Using list(APPEND), followed by string(REGEX REPLACE) is even more verbose
than just using the set(foo "${foo} ...") approach.  I see an append()
command as just the equivalent of the += operator in C/C++ and don't think
that adding it would necessarily require adding any more space separated
list functionality.  And I agree that you wouldn't really want

An alternative approach (but harder to implement) would be to abandon space
separated lists altogether.  Variables like CMAKE_EXE_LINKER_FLAGS would be
stored as lists and then cmake would format them internally as space
separated strings before passing them to the native build tools.  You might
have to change the way cmake internally represents lists if you ever wanted
to be able to pass options with semicolons through to the build tools.

--
Glenn


On 9 August 2011 20:34, 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
> __________________________
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110811/c4bb95be/attachment-0001.htm>


More information about the CMake mailing list