如何从命令行设置类型列表的 CMake 变量 [英] How to set CMake variable of type list from command line
问题描述
我正在尝试做这样的事情
I am trying to do something like this
cmake .. -G "Visual Studio 15 2017 Win64" -DCMAKE_CONFIGURATION_TYPES=ReleaseDebug
但是 CMAKE_CONFIGURATION_TYPES
未设置为 list
变量.我也试过
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"
也没有用.
如何以正确的方式做到这一点?
How to do it the right way?
推荐答案
列表是 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屋!