[CMake] NSIS template variable substitution.

Anders Lindgren andlind at gmail.com
Thu Jun 5 02:59:42 EDT 2014


Hi!

You can do something like:

---------------------------
set(my_list alpha beta gamma)

message(STATUS "my_list: ${my_list}")

# This converts a list into a newline-separated string.
set(res "")
foreach(x ${my_list})
  set(res "${res}${x}\n")
endforeach()

message(STATUS "res:\n${res}")
---------------------------

One nice feature of this solution is that it does not rely on the fact that
a list is a semicolon-separated string.

When executing this using cmake -P nameOfScript.cmake, you will get the
following output:

---------------------------
-- my_list: alpha;beta;gamma
-- res:
alpha
beta
gamma
---------------------------

Sincerely,
    Anders Lindgren



On Wed, Jun 4, 2014 at 9:17 PM, Rick McGuire <object.rexx at gmail.com> wrote:

> I'm working on a custom NSIS template where I wish to accumulate a set of
> NSIS commands in a list and then insert those commands into the template
> file using a variable.
>
> I'm able to get the variable substituted, but unfortunately, the list is
> getting inserted as a single line with semicolons inserted between the list
> elements.  I need to have this inserted as a series of lines rather than a
> single line.  Is there someway to control this substitution? Or as an
> alternative, is it possible to convert a list of strings into a single
> string with inserted newlines?
>
> Rick
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140605/393e47f1/attachment-0001.html>


More information about the CMake mailing list