我的CMakeLists.txt文件中有一些选项可以在命令行中使用-D进行选择,如下所示:
# Set some options the user may choose
OPTION(USE_MPI "Use the MPI library for parallelization" OFF)
OPTION(USE_OPENMP "Use OpenMP for parallelization" OFF)
OPTION(TESTING "Enable testing of both Fortran and Python code" OFF)
OPTION(PYTHON_TOOLS "Build the python helper tools" OFF)
OPTION(BUILD_DOCS "Build the documentation; turns on PYTHON_TOOLS" OFF)我可以用这样的方法激活其中一个
$ cmake . -DUSE_MPI=ON有时我会忘记我所选择的选择。如果我可以使用某种-h标志来自动显示命令行上的标记(以python的argparse风格),那就太好了。
是否有一种自动方式为特定的CMakeLists.txt生成帮助文档,以及/或使用某种-h或--help标志调用帮助?我在寻找能给我这种行为的东西:
$ cmake . --help
USE_MPI - Use the MPI library for parallelization (Default: OFF)
USE_OPENMP - Use OpenMP for parallelization (Default: OFF)
TESTING - Enable testing of both Fortran and Python code (Default: OFF)
PYTHON_TOOLS - Build the python helper tools (Default: OFF)
BUILD_DOCS - Build the documentation; turns on PYTHON_TOOLS (Default: OFF)如果没有自动方式,那么是否至少有一种简单的方法可以将--help或-h传递给CMakeLists.txt,以便我可以手动编写帮助消息?
发布于 2013-12-12 04:56:13
我认为最接近您要寻找的是-L命令行arg。运行cmake . -LH应该配置项目,然后输出所有缓存的、非高级变量以及它们的帮助字符串。
i arg还允许您查看option的当前值,但实际上它在命令行“向导模式”中运行cmake --它配置项目,要求您一次设置/更新每个变量。
https://stackoverflow.com/questions/20535189
复制相似问题