Add spirv-tools and spirv-cross

This commit is contained in:
Robert D. Blanchet Jr
2019-04-06 14:24:09 -07:00
committed by Joshua Brookover
parent 834ec251e7
commit ffbe1dff0b
4 changed files with 108 additions and 2 deletions

View File

@@ -28,7 +28,14 @@ else()
endif()
add_library( glslang STATIC EXCLUDE_FROM_ALL ${GLSLANG_SOURCES} )
target_include_directories( glslang PUBLIC ${BGFX_DIR}/3rdparty/glslang ${BGFX_DIR}/3rdparty/glslang/glslang/Include ${BGFX_DIR}/3rdparty/glslang/glslang/Public )
target_include_directories( glslang PUBLIC
${BGFX_DIR}/3rdparty/spirv-tools/include
${BGFX_DIR}/3rdparty/spirv-tools/source
${BGFX_DIR}/3rdparty/glslang
${BGFX_DIR}/3rdparty/glslang/glslang/Include
${BGFX_DIR}/3rdparty/glslang/glslang/Public
)
set_target_properties( glslang PROPERTIES FOLDER "bgfx/3rdparty" )
if( MSVC )
@@ -73,5 +80,6 @@ if( UNIX AND NOT APPLE )
endif()
target_compile_definitions( glslang PRIVATE
"ENABLE_OPT=1"
"ENABLE_HLSL=1"
)

38
cmake/3rdparty/spirv-cross.cmake vendored Normal file
View File

@@ -0,0 +1,38 @@
# bgfx.cmake - bgfx building in cmake
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along with
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
if( TARGET spirv-cross )
return()
endif()
file(
GLOB
SPIRV_CROSS_SOURCES
${BGFX_DIR}/3rdparty/spirv-cross/*.cpp
${BGFX_DIR}/3rdparty/spirv-cross/*.h
)
add_library( spirv-cross STATIC ${SPIRV_CROSS_SOURCES} )
target_compile_definitions( spirv-cross PRIVATE SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS )
target_include_directories( spirv-cross PUBLIC
${BGFX_DIR}/3rdparty/spirv-cross
${BGFX_DIR}/3rdparty/spirv-cross/include
)
if( MSVC )
target_compile_options( spirv-cross PRIVATE
"/wd4018"
"/wd4245"
"/wd4706"
"/wd4715"
)
endif()
set_target_properties( spirv-cross PROPERTIES FOLDER "bgfx/3rdparty" )

58
cmake/3rdparty/spirv-tools.cmake vendored Normal file
View File

@@ -0,0 +1,58 @@
# bgfx.cmake - bgfx building in cmake
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along with
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
if( TARGET spirv-tools )
return()
endif()
file(
GLOB
SPIRV_TOOLS_SOURCES
${BGFX_DIR}/3rdparty/spirv-tools/source/*.cpp
${BGFX_DIR}/3rdparty/spirv-tools/source/*.h
${BGFX_DIR}/3rdparty/spirv-tools/source/opt/*.cpp
${BGFX_DIR}/3rdparty/spirv-tools/source/opt/*.h
${BGFX_DIR}/3rdparty/spirv-tools/source/reduce/*.cpp
${BGFX_DIR}/3rdparty/spirv-tools/source/reduce/*.h
${BGFX_DIR}/3rdparty/spirv-tools/source/util/*.cpp
${BGFX_DIR}/3rdparty/spirv-tools/source/util/*.h
${BGFX_DIR}/3rdparty/spirv-tools/source/val/*.cpp
${BGFX_DIR}/3rdparty/spirv-tools/source/val/*.h
)
add_library( spirv-tools STATIC ${SPIRV_TOOLS_SOURCES} )
target_include_directories( spirv-tools PUBLIC
${BGFX_DIR}/3rdparty/spirv-headers/include
${BGFX_DIR}/3rdparty/spirv-tools
${BGFX_DIR}/3rdparty/spirv-tools/include
${BGFX_DIR}/3rdparty/spirv-tools/include/generated
${BGFX_DIR}/3rdparty/spirv-tools/source
)
if( MSVC )
target_compile_options( spirv-tools PRIVATE
"/wd4127"
"/wd4389"
"/wd4702"
"/wd4706"
)
else()
target_compile_options( spirv-tools PRIVATE
"-Wno-switch"
)
if(MINGW OR ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
target_compile_options( spirv-tools PRIVATE
"-Wno-misleading-indentation"
)
endif()
endif()
set_target_properties( spirv-tools PROPERTIES FOLDER "bgfx/3rdparty" )

View File

@@ -13,11 +13,13 @@ include( CMakeParseArguments )
include( cmake/3rdparty/fcpp.cmake )
include( cmake/3rdparty/glsl-optimizer.cmake )
include( cmake/3rdparty/glslang.cmake )
include( cmake/3rdparty/spirv-cross.cmake )
include( cmake/3rdparty/spirv-tools.cmake )
add_executable( shaderc ${BGFX_DIR}/tools/shaderc/shaderc.cpp ${BGFX_DIR}/tools/shaderc/shaderc.h ${BGFX_DIR}/tools/shaderc/shaderc_glsl.cpp ${BGFX_DIR}/tools/shaderc/shaderc_hlsl.cpp ${BGFX_DIR}/tools/shaderc/shaderc_pssl.cpp ${BGFX_DIR}/tools/shaderc/shaderc_spirv.cpp )
target_compile_definitions( shaderc PRIVATE "-D_CRT_SECURE_NO_WARNINGS" )
set_target_properties( shaderc PROPERTIES FOLDER "bgfx/tools" )
target_link_libraries( shaderc bx bimg bgfx-vertexdecl bgfx-shader-spirv fcpp glsl-optimizer glslang )
target_link_libraries( shaderc bx bimg bgfx-vertexdecl bgfx-shader-spirv fcpp glsl-optimizer glslang spirv-cross spirv-tools )
if( BGFX_CUSTOM_TARGETS )
add_dependencies( tools shaderc )
endif()