Skip to content

Commit

Permalink
Shaderc from hunter
Browse files Browse the repository at this point in the history
  • Loading branch information
mean-ui-thread authored Sep 29, 2019
1 parent 0381722 commit 329c229
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 136 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@
[submodule "third_party/markupsafe"]
path = third_party/markupsafe
url = https://chromium.googlesource.com/chromium/src/third_party/markupsafe
[submodule "third_party/shaderc"]
path = third_party/shaderc
url = https://github.com/google/shaderc
44 changes: 13 additions & 31 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@ git:
submodules: true
depth: 1

language: minimal

cache:
timeout: 900
directories:
- $HOME/.hunter
- $HOME/.linuxbrew

notifications:
email: false
Expand All @@ -40,53 +35,39 @@ matrix:

# - os: linux
# dist: bionic
# language: minimal
# compiler: clang
# env: DAWN_BUILD=linux-bionic-clang
# cache:
# directories:
# - $HOME/.hunter
# addons:
# apt:
# packages:
# - libgl1-mesa-dev
# - libvulkan-dev
# - mesa-common-dev
# - python2.7
# - python3
# before_install:
# - test -f $HOME/.linuxbrew/bin/brew || git clone https://github.com/Homebrew/brew.git $HOME/.linuxbrew
# - PATH="$HOME/.linuxbrew/bin:$PATH"
# - echo 'export PATH="$HOME/.linuxbrew/bin:$PATH"' >>~/.bash_profile
# - export MANPATH="$(brew --prefix)/share/man:$MANPATH"
# - export INFOPATH="$(brew --prefix)/share/info:$INFOPATH"
# - brew update
# install:
# - brew install cmake
# - brew cleanup
# before_script:
# - cmake -B.build -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) -DCMAKE_INSTALL_PREFIX=$(pwd)/.install
# script:
# - cmake --build .build --target install -- -j$(grep -c ^processor /proc/cpuinfo)

- os: linux
dist: bionic
language: minimal
compiler: gcc
env: DAWN_BUILD=linux-bionic-gcc
cache:
directories:
- $HOME/.hunter
addons:
apt:
packages:
- libgl1-mesa-dev
- libvulkan-dev
- mesa-common-dev
- python2.7
- python3
before_install:
- test -f $HOME/.linuxbrew/bin/brew || git clone https://github.com/Homebrew/brew.git $HOME/.linuxbrew
- PATH="$HOME/.linuxbrew/bin:$PATH"
- echo 'export PATH="$HOME/.linuxbrew/bin:$PATH"' >>~/.bash_profile
- export MANPATH="$(brew --prefix)/share/man:$MANPATH"
- export INFOPATH="$(brew --prefix)/share/info:$INFOPATH"
- brew update
install:
- brew install cmake
- brew cleanup
before_script:
- cmake -B.build -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=$(which gcc) -DCMAKE_CXX_COMPILER=$(which g++) -DCMAKE_INSTALL_PREFIX=$(pwd)/.install
script:
Expand All @@ -96,12 +77,13 @@ matrix:
language: cpp
env:
- PATH=/c/Python37:/c/Python37/Scripts:/c/Python27:$PATH
- HUNTER_ROOT=/c/.hunter
cache:
directories:
- /c/.hunter
install:
- choco install cmake python python2
- choco install python python2
before_script:
- cmake -G "Visual Studio 15 2017" -A x64 -B.build -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(pwd)/.install
script:
- cmake --build .build --target install
cache:
directories:
- $HOME/.hunter
124 changes: 25 additions & 99 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0076 OLD)
cmake_minimum_required(VERSION 3.2)
if(NOT CMAKE_VERSION VERSION_LESS "3.13")
cmake_policy(SET CMP0076 OLD)
endif()

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_CXX_STANDARD 14)
Expand All @@ -36,8 +38,8 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
endif()

HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.23.214.tar.gz"
SHA1 "e14bc153a7f16d6a5eeec845fb0283c8fad8c358"
URL "https://github.com/cpp-pm/hunter/archive/v0.23.216.tar.gz"
SHA1 "a492a1879bee60c29f7af17ef56b45f0d7766241"
LOCAL
)

Expand All @@ -52,12 +54,16 @@ find_package(OpenGL QUIET)
find_package(X11 QUIET)
find_package(Vulkan QUIET)
find_package(Python3 QUIET REQUIRED)
find_package(Git QUIET REQUIRED)

# https://docs.hunter.sh/en/latest/packages/pkg/glfw.html
hunter_add_package(glfw)
find_package(glfw3 CONFIG REQUIRED)

hunter_add_package(mattc_glslang)
hunter_add_package(mattc_SPIRV-Cross)
hunter_add_package(shaderc)
find_package(shaderc CONFIG REQUIRED)

if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
option(DAWN_ENABLE_ASSERTS "Enable assert" ON)
else()
Expand All @@ -73,16 +79,6 @@ option(DAWN_BUILD_SAMPLES "Builds Samples" ON)

set(dawn_root ${PROJECT_SOURCE_DIR}/dawn)

execute_process(
COMMAND Git::Git submodule update --init --recursive
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)

execute_process(
COMMAND ${Python3_EXECUTABLE} utils/git-sync-deps
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/third_party/shaderc
)

################################################################################
# Compiler flags
################################################################################
Expand All @@ -99,22 +95,6 @@ endif()
# Third-party dependencies needed by dawn_native
###############################################################################

# shaderc (includes glslang, SPIRV-Headers, SPIRV-Cross and SPIRV-Tools)
if (CMAKE_C_FLAGS_${_BUILD_TYPE} MATCHES "/MD")
set(SHADERC_ENABLE_SHARED_CRT ON CACHE BOOL "Use the shared CRT instead of the static CRT" FORCE)
else()
set(SHADERC_ENABLE_SHARED_CRT OFF CACHE BOOL "Use the shared CRT instead of the static CRT" FORCE)
endif()
set(SHADERC_ENABLE_SPVC ON CACHE BOOL "Enable libshaderc_spvc" FORCE) # for SPIRV-Cross
option(SHADERC_SKIP_INSTALL "Skip installation" ON)
option(SHADERC_SKIP_TESTS "Skip building tests" ON)
option(SPIRV_CROSS_ENABLE_TESTS "Enable SPIRV-Cross tests." OFF)
option(SPIRV_CROSS_SKIP_INSTALL "Skips installation targets." ON)
option(SPIRV_SKIP_EXECUTABLES "Skip building the executable and tests along with the library" ON)
option(SPIRV_SKIP_TESTS "Skip building SPIRV-Tools tests" ON)
option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" OFF)
add_subdirectory(third_party/shaderc)

# Empty targets to add the include dirs and list the sources of Khronos headers for header inclusion check.
add_library(khronos_headers_public INTERFACE)
target_include_directories(khronos_headers_public INTERFACE
Expand All @@ -126,7 +106,9 @@ target_include_directories(vulkan_headers_config INTERFACE
${dawn_root}/third_party/khronos
)
target_compile_definitions(vulkan_headers_config INTERFACE
$<$<PLATFORM_ID:Cygwin,MinGW,Windows>:VK_USE_PLATFORM_WIN32_KHR>
$<$<PLATFORM_ID:Cygwin>:VK_USE_PLATFORM_WIN32_KHR>
$<$<PLATFORM_ID:MinGW>:VK_USE_PLATFORM_WIN32_KHR>
$<$<PLATFORM_ID:Windows>:VK_USE_PLATFORM_WIN32_KHR>
$<$<PLATFORM_ID:Linux>:VK_USE_PLATFORM_XCB_KHR>
$<$<PLATFORM_ID:Android>:VK_USE_PLATFORM_ANDROID_KHR>
)
Expand Down Expand Up @@ -172,8 +154,9 @@ target_compile_definitions(dawn_internal INTERFACE
$<$<BOOL:${DAWN_ENABLE_BACKEND_OPENGL}>:DAWN_ENABLE_BACKEND_OPENGL>
$<$<BOOL:${DAWN_ENABLE_BACKEND_VULKAN}>:DAWN_ENABLE_BACKEND_VULKAN>
$<$<BOOL:${X11_FOUND}>:DAWN_USE_X11>
$<$<PLATFORM_ID:Cygwin,MinGW,Windows>:NOMINMAX>
$<$<PLATFORM_ID:Cygwin,MinGW,Windows>:_CRT_SECURE_NO_WARNINGS>
$<$<PLATFORM_ID:Cygwin>:NOMINMAX _CRT_SECURE_NO_WARNINGS>
$<$<PLATFORM_ID:MinGW>:NOMINMAX _CRT_SECURE_NO_WARNINGS>
$<$<PLATFORM_ID:Windows>:NOMINMAX _CRT_SECURE_NO_WARNINGS>
)

###############################################################################
Expand Down Expand Up @@ -679,10 +662,10 @@ add_library(dawn_native
target_link_libraries(dawn_native
PUBLIC
dawn_common
SPIRV-Tools
spirv-cross-glsl
spirv-cross-hlsl
spirv-cross-msl
SPIRV-Tools::SPIRV-Tools
SPIRV-Cross::spirv-cross-glsl
SPIRV-Cross::spirv-cross-hlsl
SPIRV-Cross::spirv-cross-msl
PRIVATE
$<BUILD_INTERFACE:dawn_native_headers>
$<BUILD_INTERFACE:dawn_native_sources>
Expand Down Expand Up @@ -778,7 +761,9 @@ add_library(dawn_utils STATIC
dawn/src/utils/TerribleCommandBuffer.cpp
dawn/src/utils/TerribleCommandBuffer.h
dawn/src/utils/Timer.h
$<$<PLATFORM_ID:Cygwin,MinGW,Windows>:dawn/src/utils/WindowsTimer.cpp>
$<$<PLATFORM_ID:Cygwin>:dawn/src/utils/WindowsTimer.cpp>
$<$<PLATFORM_ID:MinGW>:dawn/src/utils/WindowsTimer.cpp>
$<$<PLATFORM_ID:Windows>:dawn/src/utils/WindowsTimer.cpp>
$<$<PLATFORM_ID:Darwin>:dawn/src/utils/OSXTimer.cpp>
$<$<PLATFORM_ID:Linux>:dawn/src/utils/PosixTimer.cpp>
)
Expand All @@ -787,7 +772,7 @@ target_link_libraries(dawn_utils PUBLIC
dawn_native
dawn_wire
dawn_common
shaderc
shaderc::shaderc
)

add_library(dawn_bindings STATIC
Expand Down Expand Up @@ -868,52 +853,6 @@ configure_package_config_file(
INSTALL_DESTINATION ${config_install_dir}
)

##
# Some targets from shaderc and dependents have absolute build paths in their
# INTERFACE_INCLUDE_DIRECTORIES. So let's fix that by hiding them from the
# install package by marking them as BUILD_INTERFACE. This will need to be fixed
# upstream in :
# https://github.com/google/shaderc
# https://github.com/KhronosGroup/glslang
##
get_property(shaderc_include_directory TARGET shaderc PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
set_property(TARGET shaderc PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${shaderc_include_directory}>)
get_property(glslang_include_directory TARGET glslang PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
set_property(TARGET glslang PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${glslang_include_directory}>)
get_property(shaderc_util_include_directory TARGET shaderc_util PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
set_property(TARGET shaderc_util PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${shaderc_util_include_directory}>)
get_property(spirv_include_directory TARGET SPIRV PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
set_property(TARGET SPIRV PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${spirv_include_directory}>)

##
# Another mistake found in SPIRV-Tools, where their
# INTERFACE_INCLUDE_DIRECTORIES points to nonexistant
# ${_IMPORT_PREFIX}/include/include. Because we're not using SPIRV-Tools headers
# directly (dawn uses it, but users of dawn most likely won't). This will need
# to be fixed upstream in :
# https://github.com/KhronosGroup/SPIRV-Tools
##
get_property(SPIRV-Tools_include_directory TARGET SPIRV-Tools PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
set_property(TARGET SPIRV-Tools PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${SPIRV-Tools_include_directory}>)
get_property(SPIRV-Tools-opt_include_directory TARGET SPIRV-Tools-opt PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
set_property(TARGET SPIRV-Tools-opt PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${SPIRV-Tools-opt_include_directory}>)

##
# Similar thing in SPIRV-Cross... INTERFACE_INCLUDE_DIRECTORIES points to
# nonexistant ${_IMPORT_PREFIX}/include/spirv-cross, most likely happening
# because we are enabling SPIRV_CROSS_SKIP_INSTALL because it seems to be
# broken right now. Either way, this will need to be fixed upstream in :
# https://github.com/KhronosGroup/SPIRV-Cross
##
get_property(spirv-cross-hlsl_include_directory TARGET spirv-cross-hlsl PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
set_property(TARGET spirv-cross-hlsl PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${spirv-cross-hlsl_include_directory}>)
get_property(spirv-cross-msl_include_directory TARGET spirv-cross-msl PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
set_property(TARGET spirv-cross-msl PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${spirv-cross-msl_include_directory}>)
get_property(spirv-cross-glsl_include_directory TARGET spirv-cross-glsl PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
set_property(TARGET spirv-cross-glsl PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${spirv-cross-glsl_include_directory}>)
get_property(spirv-cross-core_include_directory TARGET spirv-cross-core PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
set_property(TARGET spirv-cross-core PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<BUILD_INTERFACE:${spirv-cross-core_include_directory}>)

install(
TARGETS
dawn
Expand All @@ -923,19 +862,6 @@ install(
dawn_native
dawn_wire
dawn_common
shaderc
glslang
OSDependent
OGLCompiler
shaderc_util
SPIRV
SPIRV-Tools
SPIRV-Tools-opt
HLSL
spirv-cross-hlsl
spirv-cross-msl
spirv-cross-glsl
spirv-cross-core
${dawn_samples}
EXPORT ${TARGETS_EXPORT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Google Dawn cmake build scripts with no ties to GN and depot_tools.

## Build dependencies
- [cmake 3.13+](https://cmake.org/)
- [cmake 3.2+](https://cmake.org/)
- [Python 2.7+](https://python.org/)
- [Python 3.6+](https://python.org/)

Expand Down
45 changes: 44 additions & 1 deletion cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
hunter_config(glfw VERSION 3.3.0-f9923e9-p0 CMAKE_ARGS OpenGL_GL_PREFERENCE=GLVND)
hunter_config(glfw
VERSION 3.3.0-f9923e9-p0
CMAKE_ARGS OpenGL_GL_PREFERENCE=GLVND
)

hunter_config(glm
VERSION 0.9.9.2
CMAKE_ARGS GLM_TEST_ENABLE=OFF BUILD_SHARED_LIBS=OFF BUILD_STATIC_LIBS=OFF
)

hunter_config(SPIRV-Headers
VERSION 1.5.1
URL https://github.com/KhronosGroup/SPIRV-Headers/archive/1.5.1.tar.gz
SHA1 77018bfe6cb1eceaf824e401dbd206660a25bf66
CMAKE_ARGS SPIRV_HEADERS_SKIP_EXAMPLES=ON
)

hunter_config(SPIRV-Tools
VERSION v2019.4-p0
URL https://github.com/mchiasson/SPIRV-Tools/archive/v2019.4-p0.tar.gz
SHA1 fde8521fd5c99166de934d7d7d65800940dfba93
CMAKE_ARGS BUILD_TESTING=OFF SPIRV_SKIP_EXECUTABLES=ON SPIRV_SKIP_TESTS=ON
)

hunter_config(mattc_glslang
VERSION v7.12.3352-p1
URL https://github.com/mchiasson/glslang/archive/v7.12.3352-p1.tar.gz
SHA1 d25c10c725f71cc6b7eb5fa2140b9b4d7c06f74c
CMAKE_ARGS BUILD_TESTING=OFF ENABLE_GLSLANG_BINARIES=OFF ENABLE_HLSL=ON
)

hunter_config(mattc_SPIRV-Cross
VERSION v2019.09.06-p2
URL https://github.com/mchiasson/SPIRV-Cross/archive/v2019.09.06-p2.tar.gz
SHA1 fd82bceef9be48903b604166346984102a4eb1c0
CMAKE_ARGS BUILD_TESTING=OFF SPIRV_CROSS_CLI=OFF SPIRV_CROSS_ENABLE_TESTS=OFF SPIRV_CROSS_FORCE_PIC=ON
)

hunter_config(shaderc
VERSION v2019.0-p5
URL https://github.com/mchiasson/shaderc/archive/v2019.0-p5.tar.gz
SHA1 e63f63e89bce234767e671f6d14ca94a1ecaa0d9
CMAKE_ARGS BUILD_TESTING=OFF SHADERC_ENABLE_SPVC=ON SHADERC_SKIP_TESTS=ON
)
1 change: 1 addition & 0 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ find_package(OpenGL QUIET)
find_package(X11 QUIET)
find_package(Vulkan QUIET)
find_package(glfw3 CONFIG REQUIRED)
find_package(shaderc CONFIG REQUIRED)

include(${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake)
check_required_components("@PROJECT_NAME@")
1 change: 0 additions & 1 deletion third_party/shaderc
Submodule shaderc deleted from e849e6

0 comments on commit 329c229

Please sign in to comment.