Allow --cmake_generator to work on macOS (#4278)

This commit is contained in:
Aaron Bockover 2020-06-24 19:30:33 -04:00 committed by GitHub
parent 15c07c75f8
commit 64264c3846
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -314,7 +314,7 @@ def parse_arguments():
parser.add_argument(
"--cmake_generator",
choices=['Visual Studio 15 2017', 'Visual Studio 16 2019', 'Ninja'],
default='Visual Studio 15 2017',
default='Visual Studio 15 2017' if is_windows() else None,
help="Specify the generator that CMake invokes. "
"This is only supported on Windows")
parser.add_argument(
@ -692,8 +692,11 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home
"-DANDROID_ABI=" + str(args.android_abi)
]
if is_macOS() and args.use_xcode:
cmake_args += ["-GXcode"]
if is_macOS():
if args.use_xcode:
cmake_args += ['-G', 'Xcode']
elif args.cmake_generator is not None:
cmake_args += ['-G', args.cmake_generator]
if args.ios:
if is_macOS():
@ -1513,8 +1516,11 @@ def build_protoc_for_host(cmake_path, source_dir, build_dir, args):
if not is_ninja:
cmd_args += ['-T', 'host=x64']
cmd_args += ['-G', args.cmake_generator]
elif is_macOS() and args.use_xcode:
cmd_args += ['-G', 'Xcode']
elif is_macOS():
if args.use_xcode:
cmd_args += ['-G', 'Xcode']
elif args.cmake_generator is not None:
cmd_args += ['-G', args.cmake_generator]
run_subprocess(cmd_args, cwd=protoc_build_dir)
# Build step