cmake: Cleanup CMake

Pulling in latest changes from VVL

Use BUILD_TESTS instead of VUL_TESTS. While it's good practice to
prefix variable names it makes updating this code more difficult.
Also since tests can only ever be enabled if the project is top
level, it doesn't affect add_subdirectory users.

Other misc. CMake cleanup
This commit is contained in:
Juan Ramos 2023-06-20 14:32:16 -06:00 committed by Juan Ramos
parent 4e5efb844c
commit 8d23122189
7 changed files with 99 additions and 60 deletions

View file

@ -3,6 +3,7 @@
# Copyright 2017 The Glslang Authors. All rights reserved.
# Copyright (c) 2018-2023 Valve Corporation
# Copyright (c) 2018-2023 LunarG, Inc.
# Copyright (c) 2023-2023 RasterGrid Kft.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -31,11 +32,6 @@ this home repository depend on. It also checks out each dependent
repository at a "known-good" commit in order to provide stability in
the dependent repositories.
Python Compatibility
--------------------
This program can be used with Python 2.7 and Python 3.
Known-Good JSON Database
------------------------
@ -117,6 +113,10 @@ examples of all of these elements.
The name of the dependent repository. This field can be referenced
by the "deps.repo_name" structure to record a dependency.
- api
The name of the API the dependency is specific to (e.g. "vulkan").
- url
Specifies the URL of the repository.
@ -233,8 +233,6 @@ option can be a relative or absolute path.
"""
from __future__ import print_function
import argparse
import json
import os.path
@ -264,7 +262,7 @@ DEVNULL = open(os.devnull, 'wb')
def on_rm_error( func, path, exc_info):
"""Error handler for recursively removing a directory. The
shutil.rmtree function can fail on Windows due to read-only files.
This handler will change the permissions for tha file and continue.
This handler will change the permissions for the file and continue.
"""
os.chmod( path, stat.S_IWRITE )
os.unlink( path )
@ -335,6 +333,7 @@ class GoodRepo(object):
self.build_step = json['build_step'] if ('build_step' in json) else 'build'
self.build_platforms = json['build_platforms'] if ('build_platforms' in json) else []
self.optional = set(json.get('optional', []))
self.api = json['api'] if ('api' in json) else None
# Absolute paths for a repo's directories
dir_top = os.path.abspath(args.dir)
self.repo_dir = os.path.join(dir_top, self.sub_dir)
@ -425,9 +424,11 @@ class GoodRepo(object):
def CMakeConfig(self, repos):
"""Build CMake command for the configuration phase and execute it"""
if self._args.do_clean_build:
shutil.rmtree(self.build_dir)
if os.path.isdir(self.build_dir):
shutil.rmtree(self.build_dir, onerror=on_rm_error)
if self._args.do_clean_install:
shutil.rmtree(self.install_dir)
if os.path.isdir(self.install_dir):
shutil.rmtree(self.install_dir, onerror=on_rm_error)
# Create and change to build directory
make_or_exist_dirs(self.build_dir)
@ -579,6 +580,10 @@ def CreateHelper(args, repos, filename):
install_names = GetInstallNames(args)
with open(filename, 'w') as helper_file:
for repo in repos:
# If the repo has an API tag and that does not match
# the target API then skip it
if repo.api is not None and repo.api != args.api:
continue
if install_names and repo.name in install_names and repo.on_build_platform:
helper_file.write('set({var} "{dir}" CACHE STRING "" FORCE)\n'
.format(
@ -654,6 +659,12 @@ def main():
type=str.lower,
help="Set build files configuration",
default='debug')
parser.add_argument(
'--api',
dest='api',
default='vulkan',
choices=['vulkan'],
help="Target API")
parser.add_argument(
'--generator',
dest='generator',
@ -685,6 +696,11 @@ def main():
print('Starting builds in {d}'.format(d=abs_top_dir))
for repo in repos:
# If the repo has an API tag and that does not match
# the target API then skip it
if repo.api is not None and repo.api != args.api:
continue
# If the repo has a platform whitelist, skip the repo
# unless we are building on a whitelisted platform.
if not repo.on_build_platform: