Skip to content

Commit 4eb2df1

Browse files
committed
Add support for vcpkg
Added the --vcpkg flag which enables vcpkg support and optionally allows to specify path to vcpkg.cmake
1 parent e1aa148 commit 4eb2df1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

bin/polly.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ def PositiveInt(string):
238238
help="Print the corresponding CMake command and quit"
239239
)
240240

241+
parser.add_argument(
242+
'--vcpkg',
243+
nargs='?',
244+
const='{}/scripts/buildsystems/vcpkg.cmake'.format(os.environ['VCPKG_ROOT']),
245+
help='Enables vcpkg using $VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake or given argument'
246+
)
247+
241248
args = parser.parse_args()
242249

243250
polly_toolchain = detail.toolchain_name.get(args.toolchain)
@@ -296,7 +303,6 @@ def PositiveInt(string):
296303
toolchain_path = os.path.join(polly_root, "{}.cmake".format(polly_toolchain))
297304
if not os.path.exists(toolchain_path):
298305
sys.exit("Toolchain file not found: {}".format(toolchain_path))
299-
toolchain_option = "-DCMAKE_TOOLCHAIN_FILE={}".format(toolchain_path)
300306

301307
if args.output:
302308
if not os.path.isdir(args.output):
@@ -309,7 +315,6 @@ def PositiveInt(string):
309315

310316
build_dir = os.path.join(cdir, '_builds', build_tag)
311317
print("Build dir: {}".format(build_dir))
312-
build_dir_option = "-B{}".format(build_dir)
313318

314319
install_dir = os.path.join(cdir, '_install', polly_toolchain)
315320
local_install = args.install or args.strip or args.framework or args.framework_device or args.archive
@@ -380,9 +385,13 @@ def PositiveInt(string):
380385
generate_command = [
381386
cmake_bin,
382387
'-H{}'.format(home),
383-
build_dir_option
388+
'-B{}'.format(build_dir),
389+
'-DCMAKE_TOOLCHAIN_FILE={}'.format(args.vcpkg if args.vcpkg else toolchain_path)
384390
]
385391

392+
if args.vcpkg:
393+
generate_command.append('-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE={}'.format(toolchain_path))
394+
386395
if args.cache:
387396
if not os.path.isfile(args.cache):
388397
sys.exit("Specified cache file does not exist: {}".format(args.cache))
@@ -403,9 +412,6 @@ def PositiveInt(string):
403412
toolset = 'v{}0_xp'.format(toolchain_entry.vs_version)
404413
generate_command.append('-T{}'.format(toolset))
405414

406-
if toolchain_option:
407-
generate_command.append(toolchain_option)
408-
409415
if args.verbosity == 'full':
410416
generate_command.append('-DCMAKE_VERBOSE_MAKEFILE=ON')
411417
generate_command.append('-DPOLLY_STATUS_DEBUG=ON')

0 commit comments

Comments
 (0)