10

I need to run swig as part of my cmake build system. I want the user to be able to specify a list of languages to pass to swig and specify them on the command line.

$ cmake -DSWIG_LANGUAGES=java,scala <path to cmake_source_dir>

Is there a built-in-way for cmake to handle this?

Matthew Hoggan
  • 7,402
  • 16
  • 75
  • 140
  • 1
    Lists are handled in CMake with semicolon. If you use `-DSWIG_LANGUAGES=java;scala;haskell` you can for example iterate over the list with a for loop. – usr1234567 Oct 20 '15 at 18:34

1 Answers1

16

You can use semicolons to separate list items. Since semicolon is a special character in unix-like shells, you need to escape it or use quotes. Any of the following commands work:

cmake -DSWIG_LANGUAGES=java\;scala ...
cmake "-DSWIG_LANGUAGES=java;scala" ...
cmake '-DSWIG_LANGUAGES=java;scala' ...
tamas.kenez
  • 7,301
  • 4
  • 24
  • 34