[英]Python script: how to fix CMake Error: Could not create named generator?
When I use command line I can generate build with following line当我使用命令行时,我可以使用以下行生成构建
cmake -B "D:\Builds" -S "D:\src" -G "Visual Studio 16 2019" -A "x64"
When I use followed Pytnon script:当我使用以下 Pytnon 脚本时:
subprocess.call([
'...\cmake.exe',
'-B "D:\Builds"',
'-S "D:\src"',
'-G "Visual Studio 16 2019"',
'-A "x64"'
])
I receive an error:我收到一个错误:
CMake Error: Could not create named generator "Visual Studio 16 2019"
Why it happens and how to fix it?为什么会发生以及如何解决?
PS: this is not duplicate of any questions, this is new PS:这不是任何问题的重复,这是新的
Update1 : When I change generator line to the Update1 :当我将发电机线更改为
'-G Visual Studio 16 2019'
I see the followed error:我看到以下错误:
CMake Error: Could not create named generator Visual Studio 16 2019
So I think it is not doublequotes fall所以我认为这不是双引号下降
It looks like you may have two versions of CMake installed.看起来您可能安装了两个版本的 CMake。 Be sure the one used in your Python script is greater than or equal to CMake version 3.14.
确保 Python 脚本中使用的版本大于或等于 CMake 3.14 版。 The
Visual Studio 16 2019
generator is not available in earlier CMake versions. Visual Studio 16 2019
生成器在早期 CMake 版本中不可用。
You can test your CMake version used by the Python script by adding:您可以通过添加以下内容来测试 Python 脚本使用的 CMake 版本:
subprocess.call([
'...\cmake.exe',
'--version'
])
For me, a similar problem was resolved by removing the quotes within the quotes in Python, as hinted at in @Tsyvarev's comment above.对我来说,通过删除 Python 中引号中的引号解决了类似的问题,正如上面@Tsyvarev 的评论中所暗示的那样。 IOW:
爱荷华州:
subprocess.call(['cmake', '-G', '"Visual Studio 16 2019"']) # Fails
subprocess.call(['cmake', '-G', 'Visual Studio 16 2019']) # Succeeds
Or if you want one generator arg:或者,如果您想要一个生成器 arg:
subprocess.call(['cmake', '-G"Visual Studio 16 2019"']) # Fails
subprocess.call(['cmake', '-GVisual Studio 16 2019']) # Succeeds
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.