Skip to content

Commit

Permalink
Add support for vcpkg
Browse files Browse the repository at this point in the history
Added the --vcpkg flag which enables vcpkg support and optionally allows to specify path to vcpkg.cmake
  • Loading branch information
pentatonick committed Oct 1, 2024
1 parent 584755c commit e653160
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions bin/polly.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ def PositiveInt(string):
help="Print the corresponding CMake command and quit"
)

vcpkg_cmake_relative_path = 'scripts/buildsystems/vcpkg.cmake'
vcpkg_cmake_pwd = '{}/vcpkg/{}'.format(os.environ['PWD'], vcpkg_cmake_relative_path)
vcpkg_cmake_env_vcpkg_root = '{}/{}'.format(os.environ['VCPKG_ROOT'], vcpkg_cmake_relative_path)
vcpkg_cmake_path = vcpkg_cmake_pwd if os.path.exists(vcpkg_cmake_pwd) else vcpkg_cmake_env_vcpkg_root

parser.add_argument(
'--vcpkg',
nargs='?',
const=vcpkg_cmake_path,
help='Enables vcpkg using on ${PWD}/vcpkg, if exists, or $VCPKG_ROOT followed by /scripts/buildsystems/vcpkg.cmake or given argument'
)

args = parser.parse_args()

polly_toolchain = detail.toolchain_name.get(args.toolchain)
Expand Down Expand Up @@ -296,7 +308,6 @@ def PositiveInt(string):
toolchain_path = os.path.join(polly_root, "{}.cmake".format(polly_toolchain))
if not os.path.exists(toolchain_path):
sys.exit("Toolchain file not found: {}".format(toolchain_path))
toolchain_option = "-DCMAKE_TOOLCHAIN_FILE={}".format(toolchain_path)

if args.output:
if not os.path.isdir(args.output):
Expand All @@ -318,7 +329,6 @@ def PositiveInt(string):

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

install_dir = os.path.join(cdir, '_install', polly_toolchain)
local_install = args.install or args.strip or args.framework or args.framework_device or args.archive
Expand Down Expand Up @@ -385,9 +395,13 @@ def PositiveInt(string):
generate_command = [
cmake_bin,
'-H{}'.format(home),
build_dir_option
'-B{}'.format(build_dir),
'-DCMAKE_TOOLCHAIN_FILE={}'.format(args.vcpkg if args.vcpkg else toolchain_path)
]

if args.vcpkg:
generate_command.append('-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE={}'.format(toolchain_path))

if args.cache:
if not os.path.isfile(args.cache):
sys.exit("Specified cache file does not exist: {}".format(args.cache))
Expand All @@ -408,9 +422,6 @@ def PositiveInt(string):
toolset = 'v{}0_xp'.format(toolchain_entry.vs_version)
generate_command.append('-T{}'.format(toolset))

if toolchain_option:
generate_command.append(toolchain_option)

if args.verbosity == 'full':
generate_command.append('-DCMAKE_VERBOSE_MAKEFILE=ON')
generate_command.append('-DPOLLY_STATUS_DEBUG=ON')
Expand Down

0 comments on commit e653160

Please sign in to comment.