windows buildbot 和 cmake 无法创建 vs2010 生成器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4852669/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:06:20  来源:igfitidea点击:

buildbot and cmake cannot create vs2010 generator

windowscmakebuildbot

提问by kinnou02

i mount a continious integration plateform with buildbot, the project use cmake for generate a visual studio 2010 solution.

我使用 buildbot 安装了一个连续的集成平台,该项目使用 cmake 来生成一个 Visual Studio 2010 解决方案。

for test purpose i use my windows dev vm for the buildslave, cmake die with a strange error

出于测试目的,我将我的 windows dev vm 用于 buildslave,cmake 出现一个奇怪的错误

CMake Error: Could not create named generator "Visual Studio 10"

CMake 错误:无法创建命名生成器“Visual Studio 10”

but if i do the cmake manualy, it's work fine

但是如果我手动执行 cmake,它就可以正常工作

cmake -G "Visual Studio 10" source

cmake -G "Visual Studio 10" 源代码

the config of this buildslave:

这个 buildslave 的配置:

factoryWin = BuildFactory()
factoryWin.addStep(SVN(svnurl=repo_url, mode='copy', username=svn_user, password=svn_passwd))
factoryWin.addStep(ShellCommand(command=['cmake', '-G"Visual Studio 10"', 'source']))


c['builders'].append(
BuilderConfig(name="runtests-win",
slavenames=["win-slave"],
factory=factoryWin)

are you have an idea?

你有什么想法吗?

回答by Vladislav Vaintroub

Make sure you're not using cygwin's cmake by accident (in case you happened to install cygwin)

确保您没有意外使用 cygwin 的 cmake(以防您碰巧安装了 cygwin)

This one cannot build VS.

这个不能建立VS。

回答by Hugh

For my situation I had to resolve this problem with the use of an environment variable. The command then becomes:

对于我的情况,我不得不使用环境变量来解决这个问题。然后命令变为:

factoryWin.addStep(ShellCommand(command=['cmake', '-G%CMAKEGENERATOR%', 'source'],
     env={"CMAKEGENERATOR": "\"Visual Studio 10\""}))

This I think stops the twisted runprocess from manipulating the string. In my case I also wanted to set up the Visual Studio command environment so my command is:

我认为这会阻止扭曲的运行过程操作字符串。就我而言,我还想设置 Visual Studio 命令环境,因此我的命令是:

factoryWin.addStep(ShellCommand(command=["c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat", "x86",
     "&&", "cmake", "-G%CMAKEGENERATOR%", "..\src"],
     env={"CMAKEGENERATOR": "\"Visual Studio 10\""}))

Obviously I have my relative path between my build directory and src directory different but the outcome is the same, namely a Visual Studio solution generated by cmake.

显然,我的构建目录和 src 目录之间的相对路径不同,但结果是相同的,即由 cmake 生成的 Visual Studio 解决方案。

回答by james

In your case I THINK that your issue is that the array should read

在你的情况下,我认为你的问题是数组应该读取

['cmake', '-G', "Visual Studio 10", 'source']

rather than

而不是

['cmake', '-G"Visual Studio 10"', 'source']

The quotes in the error you are seeing are part of the string and are not a wrapper.

您看到的错误中的引号是字符串的一部分,而不是包装器。

回答by KymikoLoco

I don't think the environment variable answer should necessarily be considered the 'best' answer. It's a simple issue of not using the correct format for the string.

我认为环境变量答案不一定被视为“最佳”答案。这是一个不使用正确格式的字符串的简单问题。

This syntax can also be used. ['cmake', '-GVisual Studio 10', 'source']

也可以使用此语法。 ['cmake', '-GVisual Studio 10', 'source']

I wrote a CMakeCommand class that inherits from ShellCommand, that allows keywords to specify the generator and the sourceDir. It's a stripped version that only specifies the generator and source dir, but it can be extended to include CMake flags, etc.

我编写了一个继承自 ShellCommand 的 CMakeCommand 类,它允许关键字指定生成器和 sourceDir。它是一个剥离版本,仅指定生成器和源目录,但可以扩展以包含 CMake 标志等。

class CMakeCommand(ShellCommand):

    name = "generate"
    description = "generating"
    descriptionDone = "generate"

    generator="Visual Studio 10"
    sourceDir = "../"

    def __init__( self, 
                  generator="Visual Studio 10",
                  sourceDir = "../",
                  **kwargs ):

        self.generator = generator
        self.sourceDir = sourceDir

        # always upcall!
        ShellCommand.__init__(self, **kwargs)

        self.addFactoryArguments(
            generator = generator,
            sourceDir = sourceDir,
        )
    def start(self):

        tempCommand = ["cmake", "-G", self.generator ]
        # Add any flags here
        # tempCommand.append( "-DBUILDNAME=buildbot" )
        tempCommand.append( self.sourceDir )
        self.setCommand( tempCommand )

        return ShellCommand.start( self )

Example step usage:

示例步骤用法:

factoryWin.addStep(
    CMakeCommand(
        generator="Visual Studio 10",
        sourceDir = "../SVN_CO", # Top level CMakeLists.txt
        workdir="vc100", # where the build tree will be placed. Automatically created.
    )
)