如何从命令行设置类型列表的CMake变量 [英] How to set CMake variable of type list from command line

查看:370
本文介绍了如何从命令行设置类型列表的CMake变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试执行以下操作

I am trying to do something like this

cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_CONFIGURATION_TYPES=ReleaseDebug

但是 CMAKE_CONFIGURATION_TYPES 未设置为列表变量。我也尝试过

But the CMAKE_CONFIGURATION_TYPES is not set as a list variable. I also tried

cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_CONFIGURATION_TYPES="Release Debug"

这也不起作用。

操作方法

推荐答案

列表是CMake中特殊的字符串类型。当您编写 set(var a b c)时,它等效于 set(var a; b; c)。同样适用于您的情况。 CMake将 CMAKE_CONFIGURATION_TYPES 变量解释为列表,因此您需要编写 -DCMAKE_CONFIGURATION_TYPES = Release; Debug 才能正确设置通过命令行。

Lists are special type of strings in CMake. When you write set(var a b c) it is equivalent to set(var "a;b;c"). The same applies to your case. CMake interprets CMAKE_CONFIGURATION_TYPES variable as a list, so you need to write -DCMAKE_CONFIGURATION_TYPES="Release;Debug" to properly set it from the command line.

这篇关于如何从命令行设置类型列表的CMake变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆