mirror of
https://github.com/bkaradzic/bgfx.cmake.git
synced 2026-02-17 21:12:35 +01:00
3rd party: Add webgpu cmake file (#84)
This commit is contained in:
@@ -33,6 +33,7 @@ option( BGFX_USE_OVR "Build with OVR support." OF
|
||||
option( BGFX_AMALGAMATED "Amalgamated bgfx build for faster compilation" OFF )
|
||||
option( BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF )
|
||||
option( BGFX_CONFIG_DEBUG "Enables debug configuration on all builds" OFF )
|
||||
option( BGFX_CONFIG_RENDERER_WEBGPU "Enables the webgpu renderer" OFF )
|
||||
set( BGFX_OPENGL_VERSION "" CACHE STRING "Specify minimum OpenGL version" )
|
||||
set( BGFX_OPENGLES_VERSION "" CACHE STRING "Specify minimum OpenGL ES version" )
|
||||
|
||||
@@ -108,7 +109,7 @@ if( BGFX_INSTALL )
|
||||
install(FILES ${BGFX_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||
install(FILES readme.md DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||
|
||||
install( TARGETS bgfx bimg bx astc-codec astc edtaa3 etc1 etc2 iqa squish nvtt pvrtc
|
||||
install( TARGETS bgfx bimg bx astc-codec astc edtaa3 etc1 etc2 iqa squish nvtt pvrtc webgpu
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
|
||||
2
bgfx
2
bgfx
Submodule bgfx updated: eaab1be079...e08de6dd2c
2
bx
2
bx
Submodule bx updated: 39711f53df...b1a707fac8
1
cmake/3rdparty/spirv-cross.cmake
vendored
1
cmake/3rdparty/spirv-cross.cmake
vendored
@@ -24,7 +24,6 @@ target_compile_definitions( spirv-cross PRIVATE SPIRV_CROSS_EXCEPTIONS_TO_ASSERT
|
||||
target_include_directories( spirv-cross PUBLIC
|
||||
${BGFX_DIR}/3rdparty/spirv-cross
|
||||
${BGFX_DIR}/3rdparty/spirv-cross/include
|
||||
${BGFX_DIR}/3rdparty/webgpu/include
|
||||
)
|
||||
|
||||
if( MSVC )
|
||||
|
||||
31
cmake/3rdparty/webgpu.cmake
vendored
Normal file
31
cmake/3rdparty/webgpu.cmake
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# 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 webgpu )
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(
|
||||
GLOB
|
||||
WEBGPU_SOURCES
|
||||
${BGFX_DIR}/3rdparty/webgpu/include/webgpu/*.h
|
||||
# ${BGFX_DIR}/3rdparty/webgpu/webgpu_cpp.cpp # requires dawn to be installed
|
||||
)
|
||||
|
||||
# Library without sources is interface
|
||||
#add_library( webgpu STATIC ${WEBGPU_SOURCES} )
|
||||
add_library(webgpu INTERFACE)
|
||||
target_include_directories( webgpu
|
||||
# PUBLIC
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${BGFX_DIR}/3rdparty/webgpu/include>
|
||||
)
|
||||
|
||||
# set_target_properties( webgpu PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
@@ -42,6 +42,16 @@ endif()
|
||||
# Create the bgfx target
|
||||
add_library( bgfx ${BGFX_SOURCES} )
|
||||
|
||||
if(BGFX_CONFIG_RENDERER_WEBGPU)
|
||||
include(cmake/3rdparty/webgpu.cmake)
|
||||
target_compile_definitions( bgfx PRIVATE BGFX_CONFIG_RENDERER_WEBGPU=1)
|
||||
if (EMSCRIPTEN)
|
||||
target_link_options(bgfx PRIVATE "-s USE_WEBGPU=1")
|
||||
else()
|
||||
target_link_libraries(bgfx PRIVATE webgpu)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Enable BGFX_CONFIG_DEBUG in Debug configuration
|
||||
target_compile_definitions( bgfx PRIVATE "$<$<CONFIG:Debug>:BGFX_CONFIG_DEBUG=1>" )
|
||||
if(BGFX_CONFIG_DEBUG)
|
||||
@@ -120,4 +130,4 @@ set_target_properties( bgfx PROPERTIES FOLDER "bgfx" )
|
||||
# in Xcode we need to specify this file as objective-c++ (instead of renaming to .mm)
|
||||
if (XCODE)
|
||||
set_source_files_properties(${BGFX_DIR}/src/renderer_vk.cpp PROPERTIES LANGUAGE OBJCXX XCODE_EXPLICIT_FILE_TYPE sourcecode.cpp.objcpp)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -15,18 +15,19 @@ include( cmake/3rdparty/glsl-optimizer.cmake )
|
||||
include( cmake/3rdparty/glslang.cmake )
|
||||
include( cmake/3rdparty/spirv-cross.cmake )
|
||||
include( cmake/3rdparty/spirv-tools.cmake )
|
||||
include( cmake/3rdparty/webgpu.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 ${BGFX_DIR}/tools/shaderc/shaderc_metal.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-vertexlayout bgfx-shader-spirv fcpp glsl-optimizer glslang spirv-cross spirv-tools )
|
||||
target_link_libraries(shaderc PRIVATE bx bimg bgfx-vertexlayout bgfx-shader-spirv fcpp glsl-optimizer glslang spirv-cross spirv-tools webgpu)
|
||||
|
||||
if( BGFX_CUSTOM_TARGETS )
|
||||
add_dependencies( tools shaderc )
|
||||
endif()
|
||||
|
||||
if (ANDROID)
|
||||
target_link_libraries( shaderc log )
|
||||
target_link_libraries(shaderc PRIVATE log)
|
||||
elseif (IOS)
|
||||
set_target_properties(shaderc PROPERTIES MACOSX_BUNDLE ON
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER shaderc)
|
||||
|
||||
Reference in New Issue
Block a user