i mount a continious integration plateform with buildbot, the project use cmake for generate a 开发者_运维技巧visual studio 2010 solution.
for test purpose i use my windows dev vm for the buildslave, cmake die with a strange error
CMake Error: Could not create named generator "Visual Studio 10"
but if i do the cmake manualy, it's work fine
cmake -G "Visual Studio 10" source
the config of this 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?
Make sure you're not using cygwin's cmake by accident (in case you happened to install cygwin)
This one cannot build VS.
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:
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.
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.
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']
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.
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.
)
)
精彩评论