命令行上的CMake传递列表 [英] CMake Passing Lists on Command Line
本文介绍了命令行上的CMake传递列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
作为cmake构建系统的一部分,我需要运行swig.我希望用户能够指定要传递给swig的语言列表,并在命令行上指定它们.
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>
cmake是否有内置方法来处理此问题?
Is there a built in way for cmake to handle this?
推荐答案
您可以使用分号来分隔列表项.由于分号是类Unix外壳中的特殊字符,因此您需要对其进行转义或使用引号.以下任何命令均可工作:
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' ...
这篇关于命令行上的CMake传递列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文