${CMAKE_CURRENT_BINARY_DIR}/..
)
+find_package(PythonInterp 3 REQUIRED)
+set(PYTHON_CMD ${PYTHON_EXECUTABLE})
+
+set(SCRIPTS_DIR "${PROJECT_SOURCE_DIR}/scripts")
+
if(NOT DEFINED GLSLANG_REPO_ROOT)
+ set(GLSLANG_VALIDATOR_NAME "glslangValidator")
message(STATUS "Using cmake find_program to look for glslangValidator")
- find_program(GLSLANG_VALIDATOR NAMES glslangValidator
- HINTS "$ENV{VULKAN_SDK}/bin"
+ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ execute_process(COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/fetch_glslangvalidator.py glslang-master-windows-x64-Release.zip)
+ set(GLSLANG_VALIDATOR_NAME "glslangValidator.exe")
+ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ execute_process(COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/fetch_glslangvalidator.py glslang-master-linux-Release.zip)
+ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ execute_process(COMMAND ${PYTHON_CMD} ${SCRIPTS_DIR}/fetch_glslangvalidator.py glslang-master-osx-Release.zip)
+ endif()
+ find_program(GLSLANG_VALIDATOR NAMES ${GLSLANG_VALIDATOR_NAME}
+ HINTS "${PROJECT_SOURCE_DIR}/glslang/bin"
)
else()
message(STATUS "Using glslang_repo_root to look for glslangValidator")
--- /dev/null
+#!/usr/bin/env python3
+#
+# Copyright (c) 2018 The Khronos Group Inc.
+# Copyright (c) 2018 Valve Corporation
+# Copyright (c) 2018 LunarG, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Author: Mark Lobodzinski <mark@lunarg.com>
+
+
+# This script will download the latest glslang release binary and extract the
+# glslangValidator binary needed by the cube and cubepp applications.
+#
+# It takes as its lone argument the filname (no path) describing the release
+# binary name from the glslang github releases page.
+
+import sys
+import os
+import subprocess
+import urllib.request
+import zipfile
+
+REPO_DIR = os.path.join(os.getcwd(), "..")
+GLSLANG_URL = "https://github.com/KhronosGroup/glslang/releases/download/master-tot"
+
+if __name__ == '__main__':
+ if len(sys.argv) != 2:
+ print("ERROR -- must include a single glslang release zipfile name argument")
+ sys.exit();
+
+ GLSLANG_FILENAME = sys.argv[1]
+ GLSLANG_COMPLETE_URL = GLSLANG_URL + "/" + GLSLANG_FILENAME
+ GLSLANG_OUTFILENAME = os.path.join(REPO_DIR, "glslang", GLSLANG_FILENAME)
+ GLSLANG_VALIDATOR_PATH = os.path.join(REPO_DIR, "glslang", "bin")
+ GLSLANG_VALIDATOR_FULL_PATH = os.path.join(REPO_DIR, "glslang", "bin", "glslangValidator")
+ GLSLANG_DIR = os.path.join(REPO_DIR, "glslang")
+
+ if os.path.isdir(GLSLANG_DIR):
+ if os.path.isdir(GLSLANG_VALIDATOR_PATH):
+ dir_contents = os.listdir(GLSLANG_VALIDATOR_PATH)
+ for afile in dir_contents:
+ if "glslangValidator" in afile:
+ print(" Using glslangValidator at %s" % GLSLANG_VALIDATOR_PATH)
+ sys.exit();
+ else:
+ os.mkdir(GLSLANG_DIR)
+ print(" Downloading glslangValidator binary from glslang releases dir")
+ sys.stdout.flush()
+
+ # Download release zip file from glslang github releases site
+ urllib.request.urlretrieve(GLSLANG_COMPLETE_URL, GLSLANG_OUTFILENAME)
+ # Unzip the glslang binary archive
+ zipped_file = zipfile.ZipFile(GLSLANG_OUTFILENAME, 'r')
+ namelist = zipped_file.namelist()
+ for afile in namelist:
+ if "glslangValidator" in afile:
+ EXE_FILE_PATH = os.path.join(GLSLANG_DIR, afile)
+ zipped_file.extract(afile, GLSLANG_DIR)
+ os.chmod(EXE_FILE_PATH, 0o775)
+ break
+ zipped_file.close()
+ sys.exit();