@@ -238,6 +238,18 @@ def PositiveInt(string):
238238 help = "Print the corresponding CMake command and quit"
239239)
240240
241+ vcpkg_cmake_relative_path = 'scripts/buildsystems/vcpkg.cmake'
242+ vcpkg_cmake_pwd = '{}/vcpkg/{}' .format (os .environ ['PWD' ], vcpkg_cmake_relative_path )
243+ vcpkg_cmake_env_vcpkg_root = '{}/{}' .format (os .environ ['VCPKG_ROOT' ], vcpkg_cmake_relative_path )
244+ vcpkg_cmake_path = vcpkg_cmake_pwd if os .path .exists (vcpkg_cmake_pwd ) else vcpkg_cmake_env_vcpkg_root
245+
246+ parser .add_argument (
247+ '--vcpkg' ,
248+ nargs = '?' ,
249+ const = vcpkg_cmake_path ,
250+ help = 'Enables vcpkg using on ${PWD}/vcpkg, if exists, or $VCPKG_ROOT followed by /scripts/buildsystems/vcpkg.cmake or given argument'
251+ )
252+
241253args = parser .parse_args ()
242254
243255polly_toolchain = detail .toolchain_name .get (args .toolchain )
@@ -296,7 +308,6 @@ def PositiveInt(string):
296308toolchain_path = os .path .join (polly_root , "{}.cmake" .format (polly_toolchain ))
297309if not os .path .exists (toolchain_path ):
298310 sys .exit ("Toolchain file not found: {}" .format (toolchain_path ))
299- toolchain_option = "-DCMAKE_TOOLCHAIN_FILE={}" .format (toolchain_path )
300311
301312if args .output :
302313 if not os .path .isdir (args .output ):
@@ -318,7 +329,6 @@ def PositiveInt(string):
318329
319330build_dir = os .path .join (cdir , '_builds' , build_tag )
320331print ("Build dir: {}" .format (build_dir ))
321- build_dir_option = "-B{}" .format (build_dir )
322332
323333install_dir = os .path .join (cdir , '_install' , polly_toolchain )
324334local_install = args .install or args .strip or args .framework or args .framework_device or args .archive
@@ -385,9 +395,13 @@ def PositiveInt(string):
385395generate_command = [
386396 cmake_bin ,
387397 '-H{}' .format (home ),
388- build_dir_option
398+ '-B{}' .format (build_dir ),
399+ '-DCMAKE_TOOLCHAIN_FILE={}' .format (args .vcpkg if args .vcpkg else toolchain_path )
389400]
390401
402+ if args .vcpkg :
403+ generate_command .append ('-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE={}' .format (toolchain_path ))
404+
391405if args .cache :
392406 if not os .path .isfile (args .cache ):
393407 sys .exit ("Specified cache file does not exist: {}" .format (args .cache ))
@@ -408,9 +422,6 @@ def PositiveInt(string):
408422 toolset = 'v{}0_xp' .format (toolchain_entry .vs_version )
409423 generate_command .append ('-T{}' .format (toolset ))
410424
411- if toolchain_option :
412- generate_command .append (toolchain_option )
413-
414425if args .verbosity == 'full' :
415426 generate_command .append ('-DCMAKE_VERBOSE_MAKEFILE=ON' )
416427 generate_command .append ('-DPOLLY_STATUS_DEBUG=ON' )
0 commit comments