1

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

出于测试目的,我使用我的 windows dev vm 作为 buildslave,cmake 死了一个奇怪的错误

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

但如果我手动进行cmake,它工作正常

cmake -G "Visual Studio 10" 源码

这个 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)

你有想法吗?

4

4 回答 4

6

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

这个不能建立VS。

于 2011-02-06T02:01:52.233 回答
5

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

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

我认为这可以阻止扭曲的运行过程操纵字符串。就我而言,我还想设置 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\""}))

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

于 2012-10-10T02:34:32.107 回答
2

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

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

而不是

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

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

于 2012-08-10T14:55:19.550 回答
1

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

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

我写了一个继承自 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 )

示例步骤用法:

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.
    )
)
于 2013-10-15T16:10:18.367 回答