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?

1
  • 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. Commented Oct 20, 2015 at 18:34

1 Answer 1

17

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' ... 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.