Skip to content

Commit

Permalink
Externals: Add glslang from Vulkan SDK v1.0.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Aug 11, 2016
1 parent 49e57df commit 951fc44
Show file tree
Hide file tree
Showing 135 changed files with 74,837 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,8 @@ endif()
add_subdirectory(Externals/Bochs_disasm)
include_directories(Externals/Bochs_disasm)

add_subdirectory(Externals/glslang)

if(USE_SHARED_ENET)
check_lib(ENET libenet enet enet/enet.h QUIET)
include(CheckSymbolExists)
Expand Down
40 changes: 40 additions & 0 deletions Externals/glslang/.appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Windows Build Configuration for AppVeyor
# http://www.appveyor.com/docs/appveyor-yml

# build version format
version: "{build}"

os: Visual Studio 2013

platform:
- Any CPU

configuration:
- Debug
- Release

branches:
only:
- master

clone_depth: 5

matrix:
fast_finish: true # Show final status immediately if a test fails.

# scripts that run after cloning repository
install:
- git clone https://github.com/google/googletest.git External/googletest

build:
parallel: true # enable MSBuild parallel builds
verbosity: minimal

build_script:
- mkdir build && cd build
- cmake .. -DCMAKE_INSTALL_PREFIX=install
- cmake --build . --config %CONFIGURATION% --target install

test_script:
- ctest -C %CONFIGURATION% --output-on-failure
- cd ../Test && bash runtests
12 changes: 12 additions & 0 deletions Externals/glslang/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Language: Cpp
IndentWidth: 4
BreakBeforeBraces: Custom
BraceWrapping: { AfterFunction: true, AfterControlStatement: true }
IndentCaseLabels: false
ReflowComments: false
ColumnLimit: 120
AccessModifierOffset: -4
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
60 changes: 60 additions & 0 deletions Externals/glslang/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Linux and Mac Build Configuration for Travis

language: cpp

os:
- linux
- osx

# Use Ubuntu 14.04 LTS (Trusty) as the Linux testing environment.
sudo: required
dist: trusty

env:
- GLSLANG_BUILD_TYPE=Release
- GLSLANG_BUILD_TYPE=Debug

compiler:
- clang
- gcc

matrix:
fast_finish: true # Show final status immediately if a test fails.
exclude:
# Skip GCC builds on Mac OS X.
- os: osx
compiler: gcc

cache:
apt: true

branches:
only:
- master

addons:
apt:
packages:
- clang-3.6
- ninja-build

install:
# Install ninja on Mac OS X.
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update && brew install ninja; fi
# Make sure that clang-3.6 is selected.
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CC" == "clang" ]]; then
export CC=clang-3.6 CXX=clang++-3.6;
fi

before_script:
- git clone https://github.com/google/googletest.git External/googletest

script:
- mkdir build && cd build
# We need to install the compiled binaries so the paths in the runtests script can resolve correctly.
- cmake -GNinja -DCMAKE_BUILD_TYPE=${GLSLANG_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=`pwd`/install ..
- ninja install
# Run Google-Test-based tests.
- ctest --output-on-failure
# Run runtests-based tests.
- cd ../Test && ./runtests
58 changes: 58 additions & 0 deletions Externals/glslang/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
set(SRCS
glslang/GenericCodeGen/CodeGen.cpp
glslang/GenericCodeGen/Link.cpp
glslang/MachineIndependent/Constant.cpp
glslang/MachineIndependent/glslang_tab.cpp
glslang/MachineIndependent/InfoSink.cpp
glslang/MachineIndependent/Initialize.cpp
glslang/MachineIndependent/Intermediate.cpp
glslang/MachineIndependent/intermOut.cpp
glslang/MachineIndependent/IntermTraverse.cpp
glslang/MachineIndependent/limits.cpp
glslang/MachineIndependent/linkValidate.cpp
glslang/MachineIndependent/parseConst.cpp
glslang/MachineIndependent/ParseHelper.cpp
glslang/MachineIndependent/PoolAlloc.cpp
glslang/MachineIndependent/preprocessor/Pp.cpp
glslang/MachineIndependent/preprocessor/PpAtom.cpp
glslang/MachineIndependent/preprocessor/PpContext.cpp
glslang/MachineIndependent/preprocessor/PpMemory.cpp
glslang/MachineIndependent/preprocessor/PpScanner.cpp
glslang/MachineIndependent/preprocessor/PpSymbols.cpp
glslang/MachineIndependent/preprocessor/PpTokens.cpp
glslang/MachineIndependent/propagateNoContraction.cpp
glslang/MachineIndependent/reflection.cpp
glslang/MachineIndependent/RemoveTree.cpp
glslang/MachineIndependent/Scan.cpp
glslang/MachineIndependent/ShaderLang.cpp
glslang/MachineIndependent/SymbolTable.cpp
glslang/MachineIndependent/Versions.cpp
glslang/OSDependent/Unix/ossource.cpp
hlsl/hlslGrammar.cpp
hlsl/hlslOpMap.cpp
hlsl/hlslParseables.cpp
hlsl/hlslParseHelper.cpp
hlsl/hlslScanContext.cpp
hlsl/hlslTokenStream.cpp
OGLCompilersDLL/InitializeDll.cpp
SPIRV/disassemble.cpp
SPIRV/doc.cpp
SPIRV/GlslangToSpv.cpp
SPIRV/InReadableOrder.cpp
SPIRV/Logger.cpp
SPIRV/SpvBuilder.cpp
SPIRV/SPVRemapper.cpp
)

# glslang requires C++11 at a minimum to compile.
add_definitions(-std=c++11)

# Silence some warnings that occur frequently to reduce noise in build logs.
add_definitions(-Wno-shadow)
add_definitions(-Wno-reorder)
add_definitions(-Wno-sign-compare)
add_definitions(-Wno-parentheses)
add_definitions(-Wno-unused-variable)

add_library(glslang STATIC ${SRCS})

46 changes: 46 additions & 0 deletions Externals/glslang/CMakeLists.txt.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
cmake_minimum_required(VERSION 2.8.12)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

enable_testing()

set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "prefix")

project(glslang)

if(WIN32)
set(CMAKE_DEBUG_POSTFIX "d")
include(ChooseMSVCCRT.cmake)
add_definitions(-DGLSLANG_OSINCLUDE_WIN32)
elseif(UNIX)
add_definitions(-fPIC)
add_definitions(-DGLSLANG_OSINCLUDE_UNIX)
else(WIN32)
message("unknown platform")
endif(WIN32)

if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-std=c++11)
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
add_definitions(-std=c++11)
endif()

function(glslang_set_link_args TARGET)
# For MinGW compiles, statically link against the GCC and C++ runtimes.
# This avoids the need to ship those runtimes as DLLs.
if(WIN32)
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
set_target_properties(${TARGET} PROPERTIES
LINK_FLAGS "-static -static-libgcc -static-libstdc++")
endif()
endif(WIN32)
endfunction(glslang_set_link_args)

# We depend on these for later projects, so they should come first.
add_subdirectory(External)

add_subdirectory(glslang)
add_subdirectory(OGLCompilersDLL)
add_subdirectory(StandAlone)
add_subdirectory(SPIRV)
add_subdirectory(hlsl)
add_subdirectory(gtests)
105 changes: 105 additions & 0 deletions Externals/glslang/ChooseMSVCCRT.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# The macro choose_msvc_crt() takes a list of possible
# C runtimes to choose from, in the form of compiler flags,
# to present to the user. (MTd for /MTd, etc)
#
# The macro is invoked at the end of the file.
#
# CMake already sets CRT flags in the CMAKE_CXX_FLAGS_* and
# CMAKE_C_FLAGS_* variables by default. To let the user
# override that for each build type:
# 1. Detect which CRT is already selected, and reflect this in
# LLVM_USE_CRT_* so the user can have a better idea of what
# changes they're making.
# 2. Replace the flags in both variables with the new flag via a regex.
# 3. set() the variables back into the cache so the changes
# are user-visible.

### Helper macros: ###
macro(make_crt_regex regex crts)
set(${regex} "")
foreach(crt ${${crts}})
# Trying to match the beginning or end of the string with stuff
# like [ ^]+ didn't work, so use a bunch of parentheses instead.
set(${regex} "${${regex}}|(^| +)/${crt}($| +)")
endforeach(crt)
string(REGEX REPLACE "^\\|" "" ${regex} "${${regex}}")
endmacro(make_crt_regex)

macro(get_current_crt crt_current regex flagsvar)
# Find the selected-by-CMake CRT for each build type, if any.
# Strip off the leading slash and any whitespace.
string(REGEX MATCH "${${regex}}" ${crt_current} "${${flagsvar}}")
string(REPLACE "/" " " ${crt_current} "${${crt_current}}")
string(STRIP "${${crt_current}}" ${crt_current})
endmacro(get_current_crt)

# Replaces or adds a flag to a variable.
# Expects 'flag' to be padded with spaces.
macro(set_flag_in_var flagsvar regex flag)
string(REGEX MATCH "${${regex}}" current_flag "${${flagsvar}}")
if("${current_flag}" STREQUAL "")
set(${flagsvar} "${${flagsvar}}${${flag}}")
else()
string(REGEX REPLACE "${${regex}}" "${${flag}}" ${flagsvar} "${${flagsvar}}")
endif()
string(STRIP "${${flagsvar}}" ${flagsvar})
# Make sure this change gets reflected in the cache/gui.
# CMake requires the docstring parameter whenever set() touches the cache,
# so get the existing docstring and re-use that.
get_property(flagsvar_docs CACHE ${flagsvar} PROPERTY HELPSTRING)
set(${flagsvar} "${${flagsvar}}" CACHE STRING "${flagsvar_docs}" FORCE)
endmacro(set_flag_in_var)


macro(choose_msvc_crt MSVC_CRT)
if(LLVM_USE_CRT)
message(FATAL_ERROR
"LLVM_USE_CRT is deprecated. Use the CMAKE_BUILD_TYPE-specific
variables (LLVM_USE_CRT_DEBUG, etc) instead.")
endif()

make_crt_regex(MSVC_CRT_REGEX ${MSVC_CRT})

foreach(build_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE})
string(TOUPPER "${build_type}" build)
if (NOT LLVM_USE_CRT_${build})
get_current_crt(LLVM_USE_CRT_${build}
MSVC_CRT_REGEX
CMAKE_CXX_FLAGS_${build})
set(LLVM_USE_CRT_${build}
"${LLVM_USE_CRT_${build}}"
CACHE STRING "Specify VC++ CRT to use for ${build_type} configurations."
FORCE)
set_property(CACHE LLVM_USE_CRT_${build}
PROPERTY STRINGS ;${${MSVC_CRT}})
endif(NOT LLVM_USE_CRT_${build})
endforeach(build_type)

foreach(build_type ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE})
string(TOUPPER "${build_type}" build)
if ("${LLVM_USE_CRT_${build}}" STREQUAL "")
set(flag_string " ")
else()
set(flag_string " /${LLVM_USE_CRT_${build}} ")
list(FIND ${MSVC_CRT} ${LLVM_USE_CRT_${build}} idx)
if (idx LESS 0)
message(FATAL_ERROR
"Invalid value for LLVM_USE_CRT_${build}: ${LLVM_USE_CRT_${build}}. Valid options are one of: ${${MSVC_CRT}}")
endif (idx LESS 0)
message(STATUS "Using ${build_type} VC++ CRT: ${LLVM_USE_CRT_${build}}")
endif()
foreach(lang C CXX)
set_flag_in_var(CMAKE_${lang}_FLAGS_${build} MSVC_CRT_REGEX flag_string)
endforeach(lang)
endforeach(build_type)
endmacro(choose_msvc_crt MSVC_CRT)


# List of valid CRTs for MSVC
set(MSVC_CRT
MD
MDd
MT
MTd)

choose_msvc_crt(MSVC_CRT)
34 changes: 34 additions & 0 deletions Externals/glslang/External/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Suppress all warnings from external projects.
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS -w)

if (TARGET gmock)
message(STATUS "Google Mock already configured - use it")
elseif(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
# We need to make sure Google Test does not mess up with the
# global CRT settings on Windows.
if(WIN32)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif(WIN32)
add_subdirectory(googletest)
set(GTEST_TARGETS
gtest
gtest_main
gmock
gmock_main
)
foreach(target ${GTEST_TARGETS})
set_property(TARGET ${target} PROPERTY FOLDER gtest)
endforeach()
mark_as_advanced(gmock_build_tests
BUILD_GMOCK
BUILD_GTEST
BUILD_SHARED_LIBS
gtest_build_samples
gtest_build_tests
gtest_disable_pthreads
gtest_force_shared_crt
gtest_hide_internal_symbols)
else()
message(STATUS
"Google Mock was not found - tests based on that will not build")
endif()
11 changes: 11 additions & 0 deletions Externals/glslang/OGLCompilersDLL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(SOURCES InitializeDll.cpp InitializeDll.h)

add_library(OGLCompiler STATIC ${SOURCES})
set_property(TARGET OGLCompiler PROPERTY FOLDER glslang)

if(WIN32)
source_group("Source" FILES ${SOURCES})
endif(WIN32)

install(TARGETS OGLCompiler
ARCHIVE DESTINATION lib)
Loading

0 comments on commit 951fc44

Please sign in to comment.