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:
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
Update1 : When I change generator line to the
'-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. Be sure the one used in your Python script is greater than or equal to CMake version 3.14. The Visual Studio 16 2019
generator is not available in earlier CMake versions.
You can test your CMake version used by the Python script by adding:
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. 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:
subprocess.call(['cmake', '-G"Visual Studio 16 2019"']) # Fails
subprocess.call(['cmake', '-GVisual Studio 16 2019']) # Succeeds
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.