mirror of
https://github.com/bkaradzic/bgfx.cmake.git
synced 2026-02-17 21:12:35 +01:00
Compare commits
52 Commits
v1.115.811
...
v1.118.839
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac2c644f44 | ||
|
|
4ea31fd36f | ||
|
|
4ea7d23eb2 | ||
|
|
03ae29e5bd | ||
|
|
cfc015871f | ||
|
|
54aaa9103d | ||
|
|
2d7b0296f6 | ||
|
|
a59e0a63ae | ||
|
|
671c819e85 | ||
|
|
c825dcf256 | ||
|
|
916f26e1b6 | ||
|
|
4e42ae2ae0 | ||
|
|
52feec47f5 | ||
|
|
cf77d7c6d7 | ||
|
|
33dde1a115 | ||
|
|
3e7f1fe200 | ||
|
|
866599edb0 | ||
|
|
089b388ac0 | ||
|
|
9d3bc4f326 | ||
|
|
9ee85d3c1b | ||
|
|
74a8e4dc72 | ||
|
|
99f17108ca | ||
|
|
862912e7e9 | ||
|
|
72ea9b6f29 | ||
|
|
6e23a39de6 | ||
|
|
74e4a3fad9 | ||
|
|
5c54e5f299 | ||
|
|
06b995080d | ||
|
|
f5dc53db85 | ||
|
|
2051444e25 | ||
|
|
5ba5a38762 | ||
|
|
e4e935c7ae | ||
|
|
01c90714e1 | ||
|
|
6ecce2449d | ||
|
|
c717984be0 | ||
|
|
955d692550 | ||
|
|
12b75cc0ad | ||
|
|
65dde3874d | ||
|
|
f6a9fb1687 | ||
|
|
f1eed47138 | ||
|
|
9ac6e08121 | ||
|
|
6c75503da4 | ||
|
|
3dcf049202 | ||
|
|
3ec2a51aef | ||
|
|
26a0f1e54d | ||
|
|
896ab5478c | ||
|
|
23a1dc204a | ||
|
|
5fa58aad11 | ||
|
|
8dafd0d9e4 | ||
|
|
3bac602264 | ||
|
|
1b2b921bde | ||
|
|
95af1cc54d |
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -25,11 +25,11 @@ jobs:
|
||||
- id: version
|
||||
run: |
|
||||
API_VERSION=$(grep -Eo "BGFX_API_VERSION UINT32_C\([0-9]+\)" bgfx/include/bgfx/defines.h | grep -Eo "[0-9]+" | tail -1)
|
||||
REVISION=$(cd bgfx && git rev-list HEAD --count)
|
||||
BGFX_REVISION=$(cd bgfx && git rev-list HEAD --count)
|
||||
BGFX_CMAKE_REVISION=$(git rev-list HEAD --count)
|
||||
SHA=$(cd bgfx && git rev-parse HEAD)
|
||||
SHA7="${GITHUB_SHA::7}"
|
||||
TAG="v1.${API_VERSION}.${REVISION}-${SHA7}"
|
||||
echo "::set-output name=revision::${REVISION}"
|
||||
TAG="v1.${API_VERSION}.${BGFX_REVISION}-${BGFX_CMAKE_REVISION}"
|
||||
echo "::set-output name=revision::${BGFX_REVISION}"
|
||||
echo "::set-output name=sha::${SHA}"
|
||||
echo "::set-output name=tag::${TAG}"
|
||||
|
||||
|
||||
@@ -21,20 +21,43 @@ if( APPLE AND NOT XCODE )
|
||||
set( CMAKE_CXX_FLAGS "-ObjC++" )
|
||||
endif()
|
||||
|
||||
option( BGFX_BUILD_TOOLS "Build bgfx tools." ON )
|
||||
option( BGFX_BUILD_EXAMPLES "Build bgfx examples." ON )
|
||||
option( BGFX_INSTALL "Create installation target." ON )
|
||||
option( BGFX_INSTALL_EXAMPLES "Install examples and their runtimes." OFF )
|
||||
option( BGFX_CUSTOM_TARGETS "Include convenience custom targets." ON )
|
||||
option( BGFX_AMALGAMATED "Amalgamated bgfx build for faster compilation" OFF )
|
||||
option( BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF )
|
||||
option( BGFX_CONFIG_MULTITHREADED "Build bgfx with multithreaded configuration" ON )
|
||||
option( BGFX_CONFIG_RENDERER_WEBGPU "Enables the webgpu renderer" OFF )
|
||||
if (MSVC AND (MSVC_VERSION GREATER_EQUAL 1914))
|
||||
add_compile_options("/Zc:__cplusplus")
|
||||
endif()
|
||||
|
||||
option( BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF )
|
||||
option( BX_CONFIG_DEBUG "Log debug messages (default: on in debug)" OFF )
|
||||
option( BGFX_AMALGAMATED "Amalgamated bgfx build for faster compilation" OFF )
|
||||
option( BGFX_BUILD_TOOLS "Build bgfx tools." ON )
|
||||
option( BGFX_BUILD_TOOLS_SHADER "Build bgfx shader tools." ON )
|
||||
option( BGFX_BUILD_TOOLS_GEOMETRY "Build bgfx geometry tools." ON )
|
||||
option( BGFX_BUILD_TOOLS_TEXTURE "Build bgfx texture tools." ON )
|
||||
option( BGFX_BUILD_EXAMPLES "Build bgfx examples." ON )
|
||||
option( BGFX_INSTALL "Create installation target." ON )
|
||||
option( BGFX_INSTALL_EXAMPLES "Install examples and their runtimes." OFF )
|
||||
option( BGFX_CUSTOM_TARGETS "Include convenience custom targets." ON )
|
||||
option( BGFX_CONFIG_MULTITHREADED "Build bgfx with multithreaded configuration" ON )
|
||||
option( BGFX_CONFIG_RENDERER_WEBGPU "Enable the webgpu renderer" OFF )
|
||||
option( BGFX_CONFIG_DEBUG_ANNOTATION "Enable gfx debug annotations (default: on in debug)" OFF )
|
||||
|
||||
set( BGFX_OPENGL_VERSION "" CACHE STRING "Specify minimum opengl version" )
|
||||
set( BGFX_OPENGLES_VERSION "" CACHE STRING "Specify minimum OpenGL ES version" )
|
||||
set( BGFX_LIBRARY_TYPE "STATIC" CACHE STRING "Linking type for library" )
|
||||
|
||||
set( BGFX_CONFIG_DEFAULT_MAX_ENCODERS "" CACHE STRING "Specify default maximum encoder count (multithreaded only)" )
|
||||
set( BGFX_CONFIG_MAX_DRAW_CALLS "" CACHE STRING "Specify maximum draw calls" )
|
||||
set( BGFX_CONFIG_MAX_VIEWS "" CACHE STRING "Specify maximum view count (should be a power of two)" )
|
||||
set( BGFX_CONFIG_MAX_FRAME_BUFFERS "" CACHE STRING "Specify maximum frame buffers" )
|
||||
set( BGFX_CONFIG_MAX_VERTEX_LAYOUTS "" CACHE STRING "Specify maximum vertex layouts" )
|
||||
set( BGFX_CONFIG_MAX_VERTEX_BUFFERS "" CACHE STRING "Specify maximum vertex buffer count" )
|
||||
set( BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS "" CACHE STRING "Specify maximum dynamic vertex buffer count" )
|
||||
set( BGFX_CONFIG_MAX_INDEX_BUFFERS "" CACHE STRING "Specify maximum index buffer count" )
|
||||
set( BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS "" CACHE STRING "Specify maximum dynamic index buffer count" )
|
||||
set( BGFX_CONFIG_MAX_TEXTURES "" CACHE STRING "Specify maximum texture count" )
|
||||
set( BGFX_CONFIG_MAX_TEXTURE_SAMPLERS "" CACHE STRING "Specify maximum texture samplers" )
|
||||
set( BGFX_CONFIG_MAX_SHADERS "" CACHE STRING "Specify shader count" )
|
||||
set( BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM "" CACHE STRING "Specify maximum program count as 2^(program bits)" )
|
||||
|
||||
set_property( CACHE BGFX_LIBRARY_TYPE PROPERTY STRINGS STATIC SHARED )
|
||||
|
||||
if( BGFX_LIBRARY_TYPE MATCHES "SHARED" )
|
||||
@@ -126,7 +149,7 @@ if( BGFX_INSTALL )
|
||||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
if( NOT BGFX_LIBRARY_TYPE MATCHES "SHARED" )
|
||||
install( TARGETS bimg bx astc-codec astc edtaa3 etc1 etc2 iqa squish nvtt pvrtc tinyexr
|
||||
install( TARGETS bimg bx astc-encoder edtaa3 etc1 etc2 iqa squish nvtt pvrtc tinyexr
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
@@ -155,22 +178,30 @@ if( BGFX_INSTALL )
|
||||
)
|
||||
|
||||
# install tools
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfxToolUtils.cmake
|
||||
DESTINATION "${config_install_dir}")
|
||||
if( BGFX_BUILD_TOOLS )
|
||||
install( TARGETS shaderc
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
||||
install( TARGETS geometryc
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
||||
install( TARGETS geometryv
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
||||
install( TARGETS texturec
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
||||
install( TARGETS texturev
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
||||
if (BGFX_BUILD_TOOLS_SHADER)
|
||||
install( TARGETS shaderc
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
||||
endif()
|
||||
if (BGFX_BUILD_TOOLS_GEOMETRY)
|
||||
install( TARGETS geometryc
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
||||
install( TARGETS geometryv
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
||||
endif()
|
||||
if (BGFX_BUILD_TOOLS_TEXTURE)
|
||||
install( TARGETS texturec
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
||||
install( TARGETS texturev
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# install examples
|
||||
|
||||
25
README.md
25
README.md
@@ -1,37 +1,38 @@
|
||||
bgfx.cmake
|
||||
===================
|
||||
==========
|
||||
[](https://github.com/bkaradzic/bgfx.cmake/workflows/Release/badge.svg)
|
||||
|
||||
**NOTE: This port only made to be used as C++ library, some features (such as bindings, examples) might not work! Please use original repo with GENie instead.**
|
||||
**NOTE: This port only made to be used as C++ library, some features (such as bindings) might not work! For those features, please use original repo with GENie instead.**
|
||||
|
||||
This repo contains a bunch of cmake files that can be used to build bgfx with CMake.
|
||||
This repo contains cmake configuration files that can be used to build bgfx with CMake.
|
||||
|
||||
Building
|
||||
-------------
|
||||
---
|
||||
|
||||
```bash
|
||||
git clone https://github.com/bkaradzic/bgfx.cmake.git
|
||||
cd bgfx.cmake
|
||||
git submodule init
|
||||
git submodule update
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
cmake -S. -Bcmake-build # $CMakeOptions
|
||||
cmake --build cmake-build
|
||||
```
|
||||
|
||||
If downloading via zip (instead of using git submodules) manually download bx, bimg and bgfx and copy them into the root directory, or locate them via `BX_DIR`, `BIMG_DIR` and `BGFX_DIR` CMake variables.
|
||||
|
||||
How To Use
|
||||
-------------
|
||||
This project is setup to be included a few different ways. To include bgfx source code in your project simply use add_subdirectory to include this project. To build bgfx binaries build the `INSTALL` target (or `make install`). The installed files will be in the directory specified by `CMAKE_INSTALL_PREFIX` which I recommend you set to `./install` so it will export to your build directory. Note you may want to build install on both `Release` and `Debug` configurations.
|
||||
----------
|
||||
This project is setup to be included a few different ways. To include bgfx source code in your project simply use add_subdirectory to include this project. To build bgfx binaries build the `INSTALL` target (or `make install`). The installed files will be in the directory specified by `CMAKE_INSTALL_PREFIX` which we recommend you set to `./install` so it will export to your build directory. Note you may want to build install on both `Release` and `Debug` configurations.
|
||||
|
||||
Features
|
||||
-------------
|
||||
--------
|
||||
* No outside dependencies besides bx, bimg, bgfx, and CMake.
|
||||
* Tested on Visual Studio 2015, Xcode, gcc 5.4, clang 3.8.
|
||||
* Tested on
|
||||
* Windows, OSX, Linux, Android, UWP, Emscripten (experimental)
|
||||
* VSCode, Visual Studio, Xcode, gcc, clang.
|
||||
* Compiles bgfx, tools & examples.
|
||||
* Detects shader modifications and automatically rebuilds them for all examples.
|
||||
|
||||
Does this work with latest bx/bgfx/bimg?
|
||||
-------------
|
||||
----------------------------------------
|
||||
Probably! This project needs to be updated if a dependency is added or the bgfx build system changes. The bgfx repository is very active but these types of changes are rare. New examples have to be added manually as well, but not doing so will merely result in that example not showing up and won't break anything else. If pulling latest causes issues, be sure to manually reconfigure CMake as the glob patterns may need to be refreshed (the use of glob patterns in CMake is generally discouraged but in this project it helps to ensure upwards compatibilty with newer bgfx updates).
|
||||
|
||||
2
bgfx
2
bgfx
Submodule bgfx updated: 5ae2271667...5f435ea56b
2
bimg
2
bimg
Submodule bimg updated: 663f724186...1af90543ca
2
bx
2
bx
Submodule bx updated: 88327070b9...aed1086c48
@@ -8,21 +8,23 @@
|
||||
# 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 astc-codec )
|
||||
if( TARGET astc-encoder )
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(
|
||||
GLOB
|
||||
ASTC_CODEC_SOURCES
|
||||
${BIMG_DIR}/3rdparty/astc-codec/src/decoder/*.cc
|
||||
${BIMG_DIR}/3rdparty/astc-codec/src/decoder/*.h
|
||||
ASTC_ENCODER_SOURCES
|
||||
${BIMG_DIR}/3rdparty/astc-encoder/source/*.cpp
|
||||
${BIMG_DIR}/3rdparty/astc-encoder/include/*.h
|
||||
)
|
||||
|
||||
add_library( astc-codec STATIC ${ASTC_CODEC_SOURCES} )
|
||||
target_include_directories( astc-codec
|
||||
add_library( astc-encoder STATIC ${ASTC_ENCODER_SOURCES} )
|
||||
target_include_directories( astc-encoder
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty>
|
||||
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-codec>
|
||||
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-codec/include> )
|
||||
set_target_properties( astc-codec PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-encoder>
|
||||
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-encoder/include> )
|
||||
set_target_properties( astc-encoder
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty" )
|
||||
19
cmake/3rdparty/astc.cmake
vendored
19
cmake/3rdparty/astc.cmake
vendored
@@ -1,19 +0,0 @@
|
||||
# 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 astc )
|
||||
return()
|
||||
endif()
|
||||
|
||||
file( GLOB ASTC_SOURCES ${BIMG_DIR}/3rdparty/astc/*.cpp ${BIMG_DIR}/3rdparty/astc/*.h )
|
||||
|
||||
add_library( astc STATIC ${ASTC_SOURCES} )
|
||||
target_include_directories( astc PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
|
||||
set_target_properties( astc PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
5
cmake/3rdparty/dear-imgui.cmake
vendored
5
cmake/3rdparty/dear-imgui.cmake
vendored
@@ -18,4 +18,7 @@ add_library( dear-imgui STATIC EXCLUDE_FROM_ALL ${dear_IMGUI_SOURCES} )
|
||||
target_compile_definitions( dear-imgui PRIVATE "-D_CRT_SECURE_NO_WARNINGS" "-D__STDC_FORMAT_MACROS" )
|
||||
target_include_directories( dear-imgui PUBLIC ${BGFX_DIR}/3rdparty )
|
||||
target_link_libraries( dear-imgui PUBLIC bx )
|
||||
set_target_properties( dear-imgui PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( dear-imgui
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
5
cmake/3rdparty/edtaa3.cmake
vendored
5
cmake/3rdparty/edtaa3.cmake
vendored
@@ -16,4 +16,7 @@ file( GLOB EDTAA3_SOURCES ${BIMG_DIR}/3rdparty/edtaa3/*.cpp ${BIMG_DIR}/3rdparty
|
||||
|
||||
add_library( edtaa3 STATIC ${EDTAA3_SOURCES} )
|
||||
target_include_directories( edtaa3 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
|
||||
set_target_properties( edtaa3 PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( edtaa3
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
5
cmake/3rdparty/etc1.cmake
vendored
5
cmake/3rdparty/etc1.cmake
vendored
@@ -16,4 +16,7 @@ file( GLOB ETC1_SOURCES ${BIMG_DIR}/3rdparty/etc1/*.cpp ${BIMG_DIR}/3rdparty/etc
|
||||
|
||||
add_library( etc1 STATIC ${ETC1_SOURCES} )
|
||||
target_include_directories( etc1 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
|
||||
set_target_properties( etc1 PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( etc1
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
7
cmake/3rdparty/etc2.cmake
vendored
7
cmake/3rdparty/etc2.cmake
vendored
@@ -16,5 +16,8 @@ file( GLOB ETC2_SOURCES ${BIMG_DIR}/3rdparty/etc2/*.cpp ${BIMG_DIR}/3rdparty/etc
|
||||
|
||||
add_library( etc2 STATIC ${ETC2_SOURCES} )
|
||||
target_include_directories( etc2 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
|
||||
set_target_properties( etc2 PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
target_link_libraries( etc2 PUBLIC bx )
|
||||
target_link_libraries( etc2 PUBLIC bx )
|
||||
set_target_properties( etc2
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
5
cmake/3rdparty/fcpp.cmake
vendored
5
cmake/3rdparty/fcpp.cmake
vendored
@@ -28,5 +28,8 @@ if( MSVC )
|
||||
set_target_properties( fcpp PROPERTIES COMPILE_FLAGS "/W0" )
|
||||
endif()
|
||||
|
||||
set_target_properties( fcpp PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( fcpp
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
set_source_files_properties( ${BGFX_DIR}/3rdparty/fcpp/usecpp.c PROPERTIES HEADER_FILE_ONLY ON )
|
||||
|
||||
5
cmake/3rdparty/glsl-optimizer.cmake
vendored
5
cmake/3rdparty/glsl-optimizer.cmake
vendored
@@ -84,4 +84,7 @@ elseif(APPLE)
|
||||
-Wno-deprecated-register
|
||||
)
|
||||
endif()
|
||||
set_target_properties( glsl-optimizer PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( glsl-optimizer
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
7
cmake/3rdparty/glslang.cmake
vendored
7
cmake/3rdparty/glslang.cmake
vendored
@@ -40,7 +40,10 @@ target_include_directories( glslang PUBLIC
|
||||
${BGFX_DIR}/3rdparty
|
||||
)
|
||||
|
||||
set_target_properties( glslang PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( glslang
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
if( MSVC )
|
||||
target_compile_options( glslang PRIVATE
|
||||
@@ -95,4 +98,4 @@ endif()
|
||||
target_compile_definitions( glslang PRIVATE
|
||||
ENABLE_OPT=1
|
||||
ENABLE_HLSL=1
|
||||
)
|
||||
)
|
||||
|
||||
5
cmake/3rdparty/iqa.cmake
vendored
5
cmake/3rdparty/iqa.cmake
vendored
@@ -16,4 +16,7 @@ file( GLOB IQA_SOURCES ${BIMG_DIR}/3rdparty/iqa/source/*.c ${BIMG_DIR}/3rdparty/
|
||||
|
||||
add_library( iqa STATIC ${IQA_SOURCES} )
|
||||
target_include_directories( iqa PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/iqa/include> )
|
||||
set_target_properties( iqa PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( iqa
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
5
cmake/3rdparty/libsquish.cmake
vendored
5
cmake/3rdparty/libsquish.cmake
vendored
@@ -16,4 +16,7 @@ file( GLOB SQUISH_SOURCES ${BIMG_DIR}/3rdparty/libsquish/*.cpp ${BIMG_DIR}/3rdpa
|
||||
|
||||
add_library( squish STATIC ${SQUISH_SOURCES} )
|
||||
target_include_directories( squish PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
|
||||
set_target_properties( squish PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( squish
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
5
cmake/3rdparty/meshoptimizer.cmake
vendored
5
cmake/3rdparty/meshoptimizer.cmake
vendored
@@ -16,4 +16,7 @@ file( GLOB MESHOPTIMIZER_SOURCES ${BGFX_DIR}/3rdparty/meshoptimizer/src/*.cpp ${
|
||||
|
||||
add_library( meshoptimizer STATIC ${MESHOPTIMIZER_SOURCES} )
|
||||
target_include_directories( meshoptimizer PUBLIC ${BGFX_DIR}/3rdparty )
|
||||
set_target_properties( meshoptimizer PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( meshoptimizer
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
7
cmake/3rdparty/nvtt.cmake
vendored
7
cmake/3rdparty/nvtt.cmake
vendored
@@ -32,5 +32,8 @@ target_include_directories( nvtt
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty>
|
||||
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/nvtt> )
|
||||
set_target_properties( nvtt PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
target_link_libraries( nvtt PUBLIC bx )
|
||||
target_link_libraries( nvtt PUBLIC bx )
|
||||
set_target_properties( nvtt
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
5
cmake/3rdparty/pvrtc.cmake
vendored
5
cmake/3rdparty/pvrtc.cmake
vendored
@@ -16,4 +16,7 @@ file( GLOB PVRTC_SOURCES ${BIMG_DIR}/3rdparty/pvrtc/*.cpp ${BIMG_DIR}/3rdparty/p
|
||||
|
||||
add_library( pvrtc STATIC ${PVRTC_SOURCES} )
|
||||
target_include_directories( pvrtc PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
|
||||
set_target_properties( pvrtc PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( pvrtc
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
5
cmake/3rdparty/spirv-cross.cmake
vendored
5
cmake/3rdparty/spirv-cross.cmake
vendored
@@ -35,4 +35,7 @@ if( MSVC )
|
||||
)
|
||||
endif()
|
||||
|
||||
set_target_properties( spirv-cross PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( spirv-cross
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
5
cmake/3rdparty/spirv-tools.cmake
vendored
5
cmake/3rdparty/spirv-tools.cmake
vendored
@@ -55,4 +55,7 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_target_properties( spirv-tools PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( spirv-tools
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
5
cmake/3rdparty/tinyexr.cmake
vendored
5
cmake/3rdparty/tinyexr.cmake
vendored
@@ -6,4 +6,7 @@ file( GLOB_RECURSE TINYEXR_SOURCES ${BIMG_DIR}/3rdparty/tinyexr/*.c ${BIMG_DIR}/
|
||||
|
||||
add_library( tinyexr STATIC ${TINYEXR_SOURCES} )
|
||||
target_include_directories( tinyexr PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/tinyexr/deps/miniz> )
|
||||
set_target_properties( tinyexr PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( tinyexr
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
5
cmake/3rdparty/webgpu.cmake
vendored
5
cmake/3rdparty/webgpu.cmake
vendored
@@ -28,4 +28,7 @@ target_include_directories( webgpu
|
||||
$<BUILD_INTERFACE:${BGFX_DIR}/3rdparty/webgpu/include>
|
||||
)
|
||||
|
||||
# set_target_properties( webgpu PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
set_target_properties( webgpu
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
@@ -1,4 +1,25 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
||||
get_target_property(BGFX_INCLUDE_PATH bgfx::bgfx INTERFACE_INCLUDE_DIRECTORIES)
|
||||
list(GET BGFX_INCLUDE_PATH 0 BGFX_INCLUDE_PATH_1) # bgfx::bgfx exports include directory twice?
|
||||
set(BGFX_SHADER_INCLUDE_PATH ${BGFX_INCLUDE_PATH_1}/bgfx)
|
||||
|
||||
# If cross compiling, we need a host-compatible version of shaderc to compile shaders
|
||||
if (@CMAKE_CROSSCOMPILING@ AND NOT TARGET bgfx::shaderc)
|
||||
find_program(
|
||||
shaderc_EXECUTABLE REQUIRED
|
||||
NAMES bgfx-shaderc shaderc
|
||||
PATHS /usr/bin
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-linux/tools/bgfx
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-windows/tools/bgfx
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-osx/tools/bgfx
|
||||
)
|
||||
add_executable(bgfx::shaderc IMPORTED)
|
||||
set_target_properties(
|
||||
bgfx::shaderc PROPERTIES IMPORTED_LOCATION "${shaderc_EXECUTABLE}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
||||
|
||||
@@ -44,6 +44,7 @@ if(BGFX_LIBRARY_TYPE STREQUAL STATIC)
|
||||
add_library( bgfx STATIC ${BGFX_SOURCES} )
|
||||
else()
|
||||
add_library( bgfx SHARED ${BGFX_SOURCES} )
|
||||
target_compile_definitions( bgfx PUBLIC BGFX_SHARED_LIB_BUILD=1 )
|
||||
endif()
|
||||
|
||||
if(BGFX_CONFIG_RENDERER_WEBGPU)
|
||||
@@ -56,6 +57,10 @@ if(BGFX_CONFIG_RENDERER_WEBGPU)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
target_link_options(bgfx PUBLIC "-sMAX_WEBGL_VERSION=2")
|
||||
endif()
|
||||
|
||||
if( NOT ${BGFX_OPENGL_VERSION} STREQUAL "" )
|
||||
target_compile_definitions( bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION=${BGFX_OPENGL_VERSION} )
|
||||
endif()
|
||||
@@ -64,6 +69,33 @@ if( NOT ${BGFX_OPENGLES_VERSION} STREQUAL "" )
|
||||
target_compile_definitions( bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION=${BGFX_OPENGLES_VERSION} )
|
||||
endif()
|
||||
|
||||
if( NOT ${BGFX_CONFIG_DEFAULT_MAX_ENCODERS} STREQUAL "" )
|
||||
target_compile_definitions( bgfx
|
||||
PUBLIC
|
||||
"BGFX_CONFIG_DEFAULT_MAX_ENCODERS=$<IF:$<BOOL:${BGFX_CONFIG_MULTITHREADED}>,${BGFX_CONFIG_DEFAULT_MAX_ENCODERS},1>" )
|
||||
endif()
|
||||
|
||||
set(BGFX_CONFIG_OPTIONS "")
|
||||
list(APPEND BGFX_CONFIG_OPTIONS
|
||||
"BGFX_CONFIG_MAX_DRAW_CALLS"
|
||||
"BGFX_CONFIG_MAX_VIEWS"
|
||||
"BGFX_CONFIG_MAX_FRAME_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_VERTEX_LAYOUTS"
|
||||
"BGFX_CONFIG_MAX_VERTEX_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_INDEX_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_TEXTURES"
|
||||
"BGFX_CONFIG_MAX_TEXTURE_SAMPLERS"
|
||||
"BGFX_CONFIG_MAX_SHADERS"
|
||||
"BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM"
|
||||
)
|
||||
foreach(BGFX_CONFIG_OPTION IN LISTS BGFX_CONFIG_OPTIONS)
|
||||
if( NOT ${${BGFX_CONFIG_OPTION}} STREQUAL "" )
|
||||
target_compile_definitions( bgfx PUBLIC "${BGFX_CONFIG_OPTION}=${${BGFX_CONFIG_OPTION}}" )
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Special Visual Studio Flags
|
||||
if( MSVC )
|
||||
target_compile_definitions( bgfx PRIVATE "_CRT_SECURE_NO_WARNINGS" )
|
||||
@@ -72,15 +104,29 @@ endif()
|
||||
# Add debug config required in bx headers since bx is private
|
||||
target_compile_definitions(bgfx
|
||||
PUBLIC
|
||||
"BX_CONFIG_DEBUG=$<CONFIG:Debug>"
|
||||
"BX_CONFIG_DEBUG=$<OR:$<CONFIG:Debug>,$<BOOL:${BX_CONFIG_DEBUG}>>"
|
||||
"BGFX_CONFIG_DEBUG_ANNOTATION=$<AND:$<NOT:$<STREQUAL:${CMAKE_SYSTEM_NAME},WindowsStore>>,$<OR:$<CONFIG:Debug>,$<BOOL:${BGFX_CONFIG_DEBUG_ANNOTATION}>>>"
|
||||
"BGFX_CONFIG_MULTITHREADED=$<BOOL:${BGFX_CONFIG_MULTITHREADED}>"
|
||||
)
|
||||
|
||||
# directx-headers
|
||||
set (DIRECTX_HEADERS)
|
||||
if (UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID) # Only Linux
|
||||
set (DIRECTX_HEADERS
|
||||
${BGFX_DIR}/3rdparty/directx-headers/include/directx
|
||||
${BGFX_DIR}/3rdparty/directx-headers/include
|
||||
${BGFX_DIR}/3rdparty/directx-headers/include/wsl/stubs )
|
||||
elseif (WIN32) # Only Windows
|
||||
set (DIRECTX_HEADERS
|
||||
${BGFX_DIR}/3rdparty/directx-headers/include/directx
|
||||
${BGFX_DIR}/3rdparty/directx-headers/include )
|
||||
endif()
|
||||
|
||||
# Includes
|
||||
target_include_directories( bgfx
|
||||
PRIVATE
|
||||
${DIRECTX_HEADERS}
|
||||
${BGFX_DIR}/3rdparty
|
||||
${BGFX_DIR}/3rdparty/dxsdk/include
|
||||
${BGFX_DIR}/3rdparty/khronos
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${BGFX_DIR}/include>
|
||||
|
||||
277
cmake/bgfxToolUtils.cmake
Normal file
277
cmake/bgfxToolUtils.cmake
Normal file
@@ -0,0 +1,277 @@
|
||||
# shaderc_parse(
|
||||
# FILE filename
|
||||
# OUTPUT filename
|
||||
# FRAGMENT|VERTEX|COMPUTE
|
||||
# ANDROID|ASM_JS|IOS|LINUX|NACL|OSX|WINDOWS
|
||||
# [PROFILE profile]
|
||||
# [O 0|1|2|3]
|
||||
# [VARYINGDEF filename]
|
||||
# [BIN2C filename]
|
||||
# [INCLUDES include;include]
|
||||
# [DEFINES include;include]
|
||||
# [DEPENDS]
|
||||
# [PREPROCESS]
|
||||
# [RAW]
|
||||
# [VERBOSE]
|
||||
# [DEBUG]
|
||||
# [DISASM]
|
||||
# [WERROR]
|
||||
# )
|
||||
function( shaderc_parse ARG_OUT )
|
||||
cmake_parse_arguments( ARG "DEPENDS;ANDROID;ASM_JS;IOS;LINUX;NACL;OSX;WINDOWS;PREPROCESS;RAW;FRAGMENT;VERTEX;COMPUTE;VERBOSE;DEBUG;DISASM;WERROR" "FILE;OUTPUT;VARYINGDEF;BIN2C;PROFILE;O" "INCLUDES;DEFINES" ${ARGN} )
|
||||
set( CLI "" )
|
||||
|
||||
# -f
|
||||
if( ARG_FILE )
|
||||
list( APPEND CLI "-f" "${ARG_FILE}" )
|
||||
endif()
|
||||
|
||||
# -i
|
||||
if( ARG_INCLUDES )
|
||||
foreach( INCLUDE ${ARG_INCLUDES} )
|
||||
list( APPEND CLI "-i" )
|
||||
list( APPEND CLI "${INCLUDE}" )
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# -o
|
||||
if( ARG_OUTPUT )
|
||||
list( APPEND CLI "-o" "${ARG_OUTPUT}" )
|
||||
endif()
|
||||
|
||||
# --bin2c
|
||||
if( ARG_BIN2C )
|
||||
list( APPEND CLI "--bin2c" "${ARG_BIN2C}" )
|
||||
endif()
|
||||
|
||||
# --depends
|
||||
if( ARG_DEPENDS )
|
||||
list( APPEND CLI "--depends" )
|
||||
endif()
|
||||
|
||||
# --platform
|
||||
set( PLATFORM "" )
|
||||
set( PLATFORMS "ANDROID;ASM_JS;IOS;LINUX;NACL;OSX;WINDOWS" )
|
||||
foreach( P ${PLATFORMS} )
|
||||
if( ARG_${P} )
|
||||
if( PLATFORM )
|
||||
message( SEND_ERROR "Call to shaderc_parse() cannot have both flags ${PLATFORM} and ${P}." )
|
||||
return()
|
||||
endif()
|
||||
set( PLATFORM "${P}" )
|
||||
endif()
|
||||
endforeach()
|
||||
if( "${PLATFORM}" STREQUAL "" )
|
||||
message( SEND_ERROR "Call to shaderc_parse() must have a platform flag: ${PLATFORMS}" )
|
||||
return()
|
||||
elseif( "${PLATFORM}" STREQUAL "ANDROID" )
|
||||
list( APPEND CLI "--platform" "android" )
|
||||
elseif( "${PLATFORM}" STREQUAL "ASM_JS" )
|
||||
list( APPEND CLI "--platform" "asm.js" )
|
||||
elseif( "${PLATFORM}" STREQUAL "IOS" )
|
||||
list( APPEND CLI "--platform" "ios" )
|
||||
elseif( "${PLATFORM}" STREQUAL "LINUX" )
|
||||
list( APPEND CLI "--platform" "linux" )
|
||||
elseif( "${PLATFORM}" STREQUAL "NACL" )
|
||||
list( APPEND CLI "--platform" "nacl" )
|
||||
elseif( "${PLATFORM}" STREQUAL "OSX" )
|
||||
list( APPEND CLI "--platform" "osx" )
|
||||
elseif( "${PLATFORM}" STREQUAL "WINDOWS" )
|
||||
list( APPEND CLI "--platform" "windows" )
|
||||
endif()
|
||||
|
||||
# --preprocess
|
||||
if( ARG_PREPROCESS )
|
||||
list( APPEND CLI "--preprocess" )
|
||||
endif()
|
||||
|
||||
# --define
|
||||
if( ARG_DEFINES )
|
||||
list( APPEND CLI "--defines" )
|
||||
set( DEFINES "" )
|
||||
foreach( DEFINE ${ARG_DEFINES} )
|
||||
if( NOT "${DEFINES}" STREQUAL "" )
|
||||
set( DEFINES "${DEFINES}\\\\;${DEFINE}" )
|
||||
else()
|
||||
set( DEFINES "${DEFINE}" )
|
||||
endif()
|
||||
endforeach()
|
||||
list( APPEND CLI "${DEFINES}" )
|
||||
endif()
|
||||
|
||||
# --raw
|
||||
if( ARG_RAW )
|
||||
list( APPEND CLI "--raw" )
|
||||
endif()
|
||||
|
||||
# --type
|
||||
set( TYPE "" )
|
||||
set( TYPES "FRAGMENT;VERTEX;COMPUTE" )
|
||||
foreach( T ${TYPES} )
|
||||
if( ARG_${T} )
|
||||
if( TYPE )
|
||||
message( SEND_ERROR "Call to shaderc_parse() cannot have both flags ${TYPE} and ${T}." )
|
||||
return()
|
||||
endif()
|
||||
set( TYPE "${T}" )
|
||||
endif()
|
||||
endforeach()
|
||||
if( "${TYPE}" STREQUAL "" )
|
||||
message( SEND_ERROR "Call to shaderc_parse() must have a type flag: ${TYPES}" )
|
||||
return()
|
||||
elseif( "${TYPE}" STREQUAL "FRAGMENT" )
|
||||
list( APPEND CLI "--type" "fragment" )
|
||||
elseif( "${TYPE}" STREQUAL "VERTEX" )
|
||||
list( APPEND CLI "--type" "vertex" )
|
||||
elseif( "${TYPE}" STREQUAL "COMPUTE" )
|
||||
list( APPEND CLI "--type" "compute" )
|
||||
endif()
|
||||
|
||||
# --varyingdef
|
||||
if( ARG_VARYINGDEF )
|
||||
list( APPEND CLI "--varyingdef" "${ARG_VARYINGDEF}" )
|
||||
endif()
|
||||
|
||||
# --verbose
|
||||
if( ARG_VERBOSE )
|
||||
list( APPEND CLI "--verbose" )
|
||||
endif()
|
||||
|
||||
# --debug
|
||||
if( ARG_DEBUG )
|
||||
list( APPEND CLI "--debug" )
|
||||
endif()
|
||||
|
||||
# --disasm
|
||||
if( ARG_DISASM )
|
||||
list( APPEND CLI "--disasm" )
|
||||
endif()
|
||||
|
||||
# --profile
|
||||
if( ARG_PROFILE )
|
||||
list( APPEND CLI "--profile" "${ARG_PROFILE}" )
|
||||
endif()
|
||||
|
||||
# -O
|
||||
if( ARG_O )
|
||||
list( APPEND CLI "-O" "${ARG_O}" )
|
||||
endif()
|
||||
|
||||
# --Werror
|
||||
if( ARG_WERROR )
|
||||
list( APPEND CLI "--Werror" )
|
||||
endif()
|
||||
|
||||
set( ${ARG_OUT} ${CLI} PARENT_SCOPE )
|
||||
endfunction()
|
||||
|
||||
function (_get_profile_ext PROFILE PROFILE_EXT)
|
||||
string(REPLACE 300_es essl PROFILE ${PROFILE})
|
||||
string(REPLACE 120 glsl PROFILE ${PROFILE})
|
||||
string(REPLACE spirv spv PROFILE ${PROFILE})
|
||||
string(REPLACE metal mtl PROFILE ${PROFILE})
|
||||
string(REPLACE vs_3_0 dx9 PROFILE ${PROFILE})
|
||||
string(REPLACE vs_4_0 dx10 PROFILE ${PROFILE})
|
||||
string(REPLACE vs_5_0 dx11 PROFILE ${PROFILE})
|
||||
string(REPLACE ps_3_0 dx9 PROFILE ${PROFILE})
|
||||
string(REPLACE ps_4_0 dx10 PROFILE ${PROFILE})
|
||||
string(REPLACE ps_5_0 dx11 PROFILE ${PROFILE})
|
||||
string(REPLACE cs_4_0 dx10 PROFILE ${PROFILE})
|
||||
string(REPLACE cs_5_0 dx11 PROFILE ${PROFILE})
|
||||
|
||||
set(${PROFILE_EXT}
|
||||
${PROFILE}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endfunction ()
|
||||
|
||||
# compile_shader_to_header(
|
||||
# TYPE VERTEX|FRAGMENT|COMPUTE
|
||||
# SHADERS filenames
|
||||
# VARYING_DEF filename
|
||||
# OUTPUT_DIR directory
|
||||
#)
|
||||
#
|
||||
function (compile_shader_to_header)
|
||||
set(options "")
|
||||
set(oneValueArgs TYPE VARYING_DEF OUTPUT_DIR)
|
||||
set(multiValueArgs SHADERS)
|
||||
cmake_parse_arguments(
|
||||
ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}"
|
||||
)
|
||||
|
||||
set(PROFILES 120 300_es spirv) # pssl
|
||||
if (UNIX AND NOT APPLE)
|
||||
set(PLATFORM LINUX)
|
||||
elseif (EMSCRIPTEN)
|
||||
set(PLATFORM ASM_JS)
|
||||
elseif (APPLE)
|
||||
set(PLATFORM OSX)
|
||||
list(APPEND PROFILES metal)
|
||||
elseif (
|
||||
WIN32
|
||||
OR MINGW
|
||||
OR MSYS
|
||||
OR CYGWIN
|
||||
)
|
||||
set(PLATFORM WINDOWS)
|
||||
if (ARGS_TYPE STREQUAL "VERTEX")
|
||||
list(APPEND PROFILES vs_3_0)
|
||||
list(APPEND PROFILES vs_4_0)
|
||||
list(APPEND PROFILES vs_5_0)
|
||||
elseif (ARGS_TYPE STREQUAL "FRAGMENT")
|
||||
list(APPEND PROFILES ps_3_0)
|
||||
list(APPEND PROFILES ps_4_0)
|
||||
list(APPEND PROFILES ps_5_0)
|
||||
elseif (ARGS_TYPE STREQUAL "COMPUTE")
|
||||
list(APPEND PROFILES cs_4_0)
|
||||
list(APPEND PROFILES cs_5_0)
|
||||
else ()
|
||||
message(error "shaderc: Unsupported type")
|
||||
endif ()
|
||||
else ()
|
||||
message(error "shaderc: Unsupported platform")
|
||||
endif ()
|
||||
|
||||
foreach (SHADER_FILE ${ARGS_SHADERS})
|
||||
source_group("Shaders" FILES "${SHADER}")
|
||||
get_filename_component(SHADER_FILE_BASENAME ${SHADER_FILE} NAME)
|
||||
get_filename_component(SHADER_FILE_NAME_WE ${SHADER_FILE} NAME_WE)
|
||||
get_filename_component(SHADER_FILE_ABSOLUTE ${SHADER_FILE} ABSOLUTE)
|
||||
|
||||
# Build output targets and their commands
|
||||
set(OUTPUTS "")
|
||||
set(COMMANDS "")
|
||||
foreach (PROFILE ${PROFILES})
|
||||
_get_profile_ext(${PROFILE} PROFILE_EXT)
|
||||
set(OUTPUT
|
||||
${ARGS_OUTPUT_DIR}/${SHADER_FILE_BASENAME}.${PROFILE_EXT}.bin.h
|
||||
)
|
||||
set(PLATFORM_I ${PLATFORM})
|
||||
if (PROFILE STREQUAL "spirv")
|
||||
set(PLATFORM_I LINUX)
|
||||
endif ()
|
||||
shaderc_parse(
|
||||
CLI #
|
||||
${ARGS_TYPE} ${PLATFORM_I} WERROR
|
||||
"$<$<CONFIG:debug>:DEBUG>$<$<CONFIG:relwithdebinfo>:DEBUG>"
|
||||
FILE ${SHADER_FILE_ABSOLUTE}
|
||||
OUTPUT ${OUTPUT}
|
||||
PROFILE ${PROFILE}
|
||||
O "$<$<CONFIG:debug>:0>$<$<CONFIG:release>:3>$<$<CONFIG:relwithdebinfo>:3>$<$<CONFIG:minsizerel>:3>"
|
||||
VARYINGDEF ${ARGS_VARYING_DEF}
|
||||
INCLUDES ${BGFX_SHADER_INCLUDE_PATH}
|
||||
BIN2C BIN2C ${SHADER_FILE_NAME_WE}_${PROFILE_EXT}
|
||||
)
|
||||
list(APPEND OUTPUTS ${OUTPUT})
|
||||
list(APPEND COMMANDS COMMAND bgfx::shaderc ${CLI})
|
||||
endforeach ()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${OUTPUTS}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${ARGS_OUTPUT_DIR} ${COMMANDS}
|
||||
MAIN_DEPENDENCY ${SHADER_FILE_ABSOLUTE}
|
||||
DEPENDS ${ARGS_VARYING_DEF}
|
||||
)
|
||||
endforeach ()
|
||||
endfunction ()
|
||||
@@ -9,8 +9,7 @@
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
# Third party libs
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/astc-codec.cmake )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/astc.cmake )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/astc-encoder.cmake )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/edtaa3.cmake )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/etc1.cmake )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/etc2.cmake )
|
||||
@@ -39,7 +38,7 @@ target_include_directories( bimg
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
|
||||
# bimg dependencies
|
||||
target_link_libraries( bimg PUBLIC bx PRIVATE astc-codec astc edtaa3 etc1 etc2 iqa squish nvtt pvrtc tinyexr )
|
||||
target_link_libraries( bimg PUBLIC bx PRIVATE astc-encoder edtaa3 etc1 etc2 iqa squish nvtt pvrtc tinyexr )
|
||||
|
||||
# Put in a "bgfx" folder in Visual Studio
|
||||
set_target_properties( bimg PROPERTIES FOLDER "bgfx" )
|
||||
@@ -30,6 +30,10 @@ endif()
|
||||
# Create the bx target
|
||||
add_library( bx STATIC ${BX_SOURCES} )
|
||||
|
||||
target_compile_features( bx PUBLIC cxx_std_14 )
|
||||
# (note: see bx\scripts\toolchain.lua for equivalent compiler flag)
|
||||
target_compile_options( bx PUBLIC $<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus> )
|
||||
|
||||
# Link against psapi on Windows
|
||||
if( WIN32 )
|
||||
target_link_libraries( bx PUBLIC psapi )
|
||||
@@ -55,11 +59,16 @@ elseif( WIN32 )
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${BX_DIR}/include/compat/msvc>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/msvc> )
|
||||
elseif( APPLE )
|
||||
elseif( APPLE ) # APPLE is technically UNIX... ORDERING MATTERS!
|
||||
target_include_directories( bx
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${BX_DIR}/include/compat/osx>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/osx> )
|
||||
$<BUILD_INTERFACE:${BX_DIR}/include/compat/osx>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/osx> )
|
||||
elseif ( UNIX )
|
||||
target_include_directories( bx
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${BX_DIR}/include/compat/linux>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/linux> )
|
||||
endif()
|
||||
|
||||
# All configurations
|
||||
@@ -67,7 +76,7 @@ target_compile_definitions( bx PUBLIC "__STDC_LIMIT_MACROS" )
|
||||
target_compile_definitions( bx PUBLIC "__STDC_FORMAT_MACROS" )
|
||||
target_compile_definitions( bx PUBLIC "__STDC_CONSTANT_MACROS" )
|
||||
|
||||
target_compile_definitions(bx PUBLIC "BX_CONFIG_DEBUG=$<CONFIG:Debug>")
|
||||
target_compile_definitions(bx PUBLIC "BX_CONFIG_DEBUG=$<IF:$<CONFIG:Debug>,1,$<BOOL:${BX_CONFIG_DEBUG}>>")
|
||||
|
||||
# Additional dependencies on Unix
|
||||
if (ANDROID)
|
||||
|
||||
@@ -14,6 +14,7 @@ include( ${CMAKE_CURRENT_LIST_DIR}/util/ConfigureDebugging.cmake )
|
||||
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/dear-imgui.cmake )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/meshoptimizer.cmake )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake )
|
||||
|
||||
function( add_bgfx_shader FILE FOLDER )
|
||||
get_filename_component( FILENAME "${FILE}" NAME_WE )
|
||||
@@ -179,10 +180,12 @@ function( add_example ARG_NAME )
|
||||
endif()
|
||||
|
||||
if (NOT ARG_COMMON AND EMSCRIPTEN)
|
||||
target_link_libraries(example-${ARG_NAME}
|
||||
"-s PRECISE_F32=1"
|
||||
"-s TOTAL_MEMORY=268435456"
|
||||
"--memory-init-file 1")
|
||||
set_target_properties(example-${ARG_NAME}
|
||||
PROPERTIES
|
||||
LINK_FLAGS
|
||||
"-s PRECISE_F32=1 -s TOTAL_MEMORY=268435456 -s ENVIRONMENT=web --memory-init-file 1 --emrun"
|
||||
SUFFIX ".html"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Directory name
|
||||
@@ -275,6 +278,7 @@ if( BGFX_BUILD_EXAMPLES )
|
||||
44-sss
|
||||
45-bokeh
|
||||
46-fsr
|
||||
47-pixelformats
|
||||
)
|
||||
|
||||
foreach( EXAMPLE ${BGFX_EXAMPLES} )
|
||||
|
||||
@@ -13,8 +13,16 @@ if( BGFX_CUSTOM_TARGETS )
|
||||
set_target_properties( tools PROPERTIES FOLDER "bgfx/tools" )
|
||||
endif()
|
||||
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/geometryc.cmake )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/geometryv.cmake )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/shaderc.cmake )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/texturec.cmake )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/texturev.cmake )
|
||||
if( BGFX_BUILD_TOOLS_SHADER )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/shaderc.cmake )
|
||||
endif()
|
||||
|
||||
if( BGFX_BUILD_TOOLS_GEOMETRY )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/geometryc.cmake )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/geometryv.cmake )
|
||||
endif()
|
||||
|
||||
if( BGFX_BUILD_TOOLS_TEXTURE )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/texturec.cmake )
|
||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/texturev.cmake )
|
||||
endif()
|
||||
|
||||
@@ -32,338 +32,3 @@ elseif (IOS)
|
||||
set_target_properties(shaderc PROPERTIES MACOSX_BUNDLE ON
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER shaderc)
|
||||
endif()
|
||||
|
||||
function( add_shader ARG_FILE )
|
||||
# Parse arguments
|
||||
cmake_parse_arguments( ARG "FRAGMENT;VERTEX;COMPUTE" "OUTPUT;GLSL_VERSION;DX9_MODEL;DX11_MODEL" "PLATFORMS" ${ARGN} )
|
||||
|
||||
# Get filename
|
||||
get_filename_component( FILENAME "${ARG_FILE}" NAME_WE )
|
||||
|
||||
# Determine if fragment or vertex or compute
|
||||
if( ARG_FRAGMENT AND ARG_VERTEX AND ARG_COMPUTE )
|
||||
message( SEND_ERROR "add_shader cannot be called with all FRAGMENT and VERTEX and COMPUTE." )
|
||||
return()
|
||||
elseif( ARG_FRAGMENT AND ARG_VERTEX )
|
||||
message( SEND_ERROR "add_shader cannot be called with both FRAGMENT and VERTEX." )
|
||||
return()
|
||||
elseif( ARG_FRAGMENT AND ARG_COMPUTE )
|
||||
message( SEND_ERROR "add_shader cannot be called with both FRAGMENT and COMPUTE." )
|
||||
return()
|
||||
elseif( ARG_VERTEX AND ARG_COMPUTE )
|
||||
message( SEND_ERROR "add_shader cannot be called with both VERTEX and COMPUTE." )
|
||||
return()
|
||||
endif()
|
||||
|
||||
if( ARG_FRAGMENT )
|
||||
set( TYPE "FRAGMENT" )
|
||||
set( D3D_PREFIX "ps" )
|
||||
elseif( ARG_VERTEX )
|
||||
set( TYPE "VERTEX" )
|
||||
set( D3D_PREFIX "vs" )
|
||||
elseif( ARG_COMPUTE )
|
||||
set( TYPE "COMPUTE" )
|
||||
set( D3D_PREFIX "cs" )
|
||||
else()
|
||||
message( SEND_ERROR "add_shader must be called with either FRAGMENT or VERTEX or COMPUTE." )
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Determine compatible platforms
|
||||
if( ARG_PLATFORMS )
|
||||
set( PLATFORMS ${ARG_PLATFORMS} )
|
||||
else()
|
||||
if( MSVC )
|
||||
set( PLATFORMS dx9 dx11 glsl essl asm.js spirv )
|
||||
elseif( APPLE )
|
||||
set( PLATFORMS metal glsl essl asm.js spirv )
|
||||
else()
|
||||
set( PLATFORMS glsl essl asm.js spirv )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Build options
|
||||
set( BASE_OPTIONS
|
||||
FILE ${ARG_FILE}
|
||||
${TYPE}
|
||||
INCLUDES ${BGFX_DIR}/src
|
||||
)
|
||||
|
||||
# Parse profiles
|
||||
set( DX9_PROFILE PROFILE ${D3D_PREFIX}_3_0 )
|
||||
if( ARG_DX9_MODEL )
|
||||
set( DX9_PROFILE PROFILE ${D3D_PREFIX}_${ARG_DX9_MODEL} )
|
||||
endif()
|
||||
set( DX11_PROFILE PROFILE ${D3D_PREFIX}_5_0 )
|
||||
if( ARG_DX11_MODEL )
|
||||
set( DX11_PROFILE PROFILE ${D3D_PREFIX}_${ARG_DX11_MODEL} )
|
||||
endif()
|
||||
set( GLSL_PROFILE PROFILE 120 )
|
||||
if( ARG_COMPUTE )
|
||||
set( GLSL_PROFILE PROFILE 430 )
|
||||
endif()
|
||||
if( ARG_GLSL_VERSION )
|
||||
set( GLSL_PROFILE PROFILE ${ARG_GLSL_VERSION} )
|
||||
endif()
|
||||
set( SPIRV_PROFILE PROFILE spirv )
|
||||
|
||||
# Add commands
|
||||
set( OUTPUTS "" )
|
||||
set( COMMANDS "" )
|
||||
foreach( PLATFORM ${PLATFORMS} )
|
||||
set( OPTIONS ${BASE_OPTIONS} )
|
||||
set( OUTPUT "${ARG_OUTPUT}/${PLATFORM}/${FILENAME}.bin" )
|
||||
get_filename_component( OUTPUT "${OUTPUT}" ABSOLUTE )
|
||||
|
||||
if( "${PLATFORM}" STREQUAL "dx9" )
|
||||
list( APPEND OPTIONS
|
||||
WINDOWS
|
||||
${DX9_PROFILE}
|
||||
OUTPUT ${OUTPUT}
|
||||
)
|
||||
elseif( "${PLATFORM}" STREQUAL "dx11" )
|
||||
list( APPEND OPTIONS
|
||||
WINDOWS
|
||||
${DX11_PROFILE}
|
||||
OUTPUT ${OUTPUT}
|
||||
)
|
||||
elseif( "${PLATFORM}" STREQUAL "metal" )
|
||||
list( APPEND OPTIONS
|
||||
OSX
|
||||
PROFILE metal
|
||||
OUTPUT ${OUTPUT}
|
||||
)
|
||||
elseif( "${PLATFORM}" STREQUAL "glsl" )
|
||||
list( APPEND OPTIONS
|
||||
LINUX
|
||||
${GLSL_PROFILE}
|
||||
OUTPUT ${OUTPUT}
|
||||
)
|
||||
elseif( "${PLATFORM}" STREQUAL "essl" )
|
||||
list( APPEND OPTIONS
|
||||
ANDROID
|
||||
OUTPUT ${OUTPUT}
|
||||
)
|
||||
elseif( "${PLATFORM}" STREQUAL "asm.js" )
|
||||
list( APPEND OPTIONS
|
||||
ASM_JS
|
||||
OUTPUT ${OUTPUT}
|
||||
)
|
||||
elseif( "${PLATFORM}" STREQUAL "spirv" )
|
||||
list( APPEND OPTIONS
|
||||
LINUX
|
||||
${SPIRV_PROFILE}
|
||||
OUTPUT ${OUTPUT}
|
||||
)
|
||||
else()
|
||||
message( SEND_ERROR "add_shader given bad platform: ${PLATFORM}" )
|
||||
return()
|
||||
endif()
|
||||
|
||||
list( APPEND OUTPUTS ${OUTPUT} )
|
||||
shaderc_parse( CMD ${OPTIONS} )
|
||||
list( APPEND COMMANDS COMMAND "${CMAKE_COMMAND}" -E make_directory "${ARG_OUTPUT}/${PLATFORM}" )
|
||||
list( APPEND COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${CMD} )
|
||||
endforeach()
|
||||
|
||||
# Add command
|
||||
add_custom_command(
|
||||
MAIN_DEPENDENCY
|
||||
${ARG_FILE}
|
||||
OUTPUT
|
||||
${OUTPUTS}
|
||||
${COMMANDS}
|
||||
COMMENT "Compiling shader ${ARG_FILE}"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
# Add to custom filter
|
||||
source_group( "Shader Files" FILES ${ARG_FILE} )
|
||||
endfunction()
|
||||
|
||||
# shaderc( FILE file OUTPUT file ... )
|
||||
# See shaderc_parse() below for inputs
|
||||
function( shaderc )
|
||||
cmake_parse_arguments( ARG "" "FILE;OUTPUT;LABEL" "" ${ARGN} )
|
||||
set( LABEL "" )
|
||||
if( ARG_LABEL )
|
||||
set( LABEL " (${ARG_LABEL})" )
|
||||
endif()
|
||||
shaderc_parse( CLI FILE ${ARG_FILE} OUTPUT ${ARG_OUTPUT} ${ARG_UNPARSED_ARGUMENTS} )
|
||||
get_filename_component( OUTDIR "${ARG_OUTPUT}" ABSOLUTE )
|
||||
get_filename_component( OUTDIR "${OUTDIR}" DIRECTORY )
|
||||
add_custom_command( OUTPUT ${ARG_OUTPUT}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${OUTDIR}"
|
||||
COMMAND "$<TARGET_FILE:shaderc>" ${CLI}
|
||||
MAIN_DEPENDENCY ${ARG_FILE}
|
||||
COMMENT "Compiling shader ${ARG_FILE}${LABEL}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# shaderc_parse(
|
||||
# FILE filename
|
||||
# OUTPUT filename
|
||||
# FRAGMENT|VERTEX|COMPUTE
|
||||
# ANDROID|ASM_JS|IOS|LINUX|NACL|OSX|WINDOWS
|
||||
# [PROFILE profile]
|
||||
# [O 0|1|2|3]
|
||||
# [VARYINGDEF filename]
|
||||
# [BIN2C filename]
|
||||
# [INCLUDES include;include]
|
||||
# [DEFINES include;include]
|
||||
# [DEPENDS]
|
||||
# [PREPROCESS]
|
||||
# [RAW]
|
||||
# [VERBOSE]
|
||||
# [DEBUG]
|
||||
# [DISASM]
|
||||
# [WERROR]
|
||||
# )
|
||||
function( shaderc_parse ARG_OUT )
|
||||
cmake_parse_arguments( ARG "DEPENDS;ANDROID;ASM_JS;IOS;LINUX;NACL;OSX;WINDOWS;PREPROCESS;RAW;FRAGMENT;VERTEX;COMPUTE;VERBOSE;DEBUG;DISASM;WERROR" "FILE;OUTPUT;VARYINGDEF;BIN2C;PROFILE;O" "INCLUDES;DEFINES" ${ARGN} )
|
||||
set( CLI "" )
|
||||
|
||||
# -f
|
||||
if( ARG_FILE )
|
||||
list( APPEND CLI "-f" "${ARG_FILE}" )
|
||||
endif()
|
||||
|
||||
# -i
|
||||
if( ARG_INCLUDES )
|
||||
foreach( INCLUDE ${ARG_INCLUDES} )
|
||||
list( APPEND CLI "-i" )
|
||||
list( APPEND CLI "${INCLUDE}" )
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# -o
|
||||
if( ARG_OUTPUT )
|
||||
list( APPEND CLI "-o" "${ARG_OUTPUT}" )
|
||||
endif()
|
||||
|
||||
# --bin2c
|
||||
if( ARG_BIN2C )
|
||||
list( APPEND CLI "--bin2c" "${ARG_BIN2C}" )
|
||||
endif()
|
||||
|
||||
# --depends
|
||||
if( ARG_DEPENDS )
|
||||
list( APPEND CLI "--depends" )
|
||||
endif()
|
||||
|
||||
# --platform
|
||||
set( PLATFORM "" )
|
||||
set( PLATFORMS "ANDROID;ASM_JS;IOS;LINUX;NACL;OSX;WINDOWS" )
|
||||
foreach( P ${PLATFORMS} )
|
||||
if( ARG_${P} )
|
||||
if( PLATFORM )
|
||||
message( SEND_ERROR "Call to shaderc_parse() cannot have both flags ${PLATFORM} and ${P}." )
|
||||
return()
|
||||
endif()
|
||||
set( PLATFORM "${P}" )
|
||||
endif()
|
||||
endforeach()
|
||||
if( "${PLATFORM}" STREQUAL "" )
|
||||
message( SEND_ERROR "Call to shaderc_parse() must have a platform flag: ${PLATFORMS}" )
|
||||
return()
|
||||
elseif( "${PLATFORM}" STREQUAL "ANDROID" )
|
||||
list( APPEND CLI "--platform" "android" )
|
||||
elseif( "${PLATFORM}" STREQUAL "ASM_JS" )
|
||||
list( APPEND CLI "--platform" "asm.js" )
|
||||
elseif( "${PLATFORM}" STREQUAL "IOS" )
|
||||
list( APPEND CLI "--platform" "ios" )
|
||||
elseif( "${PLATFORM}" STREQUAL "LINUX" )
|
||||
list( APPEND CLI "--platform" "linux" )
|
||||
elseif( "${PLATFORM}" STREQUAL "NACL" )
|
||||
list( APPEND CLI "--platform" "nacl" )
|
||||
elseif( "${PLATFORM}" STREQUAL "OSX" )
|
||||
list( APPEND CLI "--platform" "osx" )
|
||||
elseif( "${PLATFORM}" STREQUAL "WINDOWS" )
|
||||
list( APPEND CLI "--platform" "windows" )
|
||||
endif()
|
||||
|
||||
# --preprocess
|
||||
if( ARG_PREPROCESS )
|
||||
list( APPEND CLI "--preprocess" )
|
||||
endif()
|
||||
|
||||
# --define
|
||||
if( ARG_DEFINES )
|
||||
list( APPEND CLI "--defines" )
|
||||
set( DEFINES "" )
|
||||
foreach( DEFINE ${ARG_DEFINES} )
|
||||
if( NOT "${DEFINES}" STREQUAL "" )
|
||||
set( DEFINES "${DEFINES}\\\\;${DEFINE}" )
|
||||
else()
|
||||
set( DEFINES "${DEFINE}" )
|
||||
endif()
|
||||
endforeach()
|
||||
list( APPEND CLI "${DEFINES}" )
|
||||
endif()
|
||||
|
||||
# --raw
|
||||
if( ARG_RAW )
|
||||
list( APPEND CLI "--raw" )
|
||||
endif()
|
||||
|
||||
# --type
|
||||
set( TYPE "" )
|
||||
set( TYPES "FRAGMENT;VERTEX;COMPUTE" )
|
||||
foreach( T ${TYPES} )
|
||||
if( ARG_${T} )
|
||||
if( TYPE )
|
||||
message( SEND_ERROR "Call to shaderc_parse() cannot have both flags ${TYPE} and ${T}." )
|
||||
return()
|
||||
endif()
|
||||
set( TYPE "${T}" )
|
||||
endif()
|
||||
endforeach()
|
||||
if( "${TYPE}" STREQUAL "" )
|
||||
message( SEND_ERROR "Call to shaderc_parse() must have a type flag: ${TYPES}" )
|
||||
return()
|
||||
elseif( "${TYPE}" STREQUAL "FRAGMENT" )
|
||||
list( APPEND CLI "--type" "fragment" )
|
||||
elseif( "${TYPE}" STREQUAL "VERTEX" )
|
||||
list( APPEND CLI "--type" "vertex" )
|
||||
elseif( "${TYPE}" STREQUAL "COMPUTE" )
|
||||
list( APPEND CLI "--type" "compute" )
|
||||
endif()
|
||||
|
||||
# --varyingdef
|
||||
if( ARG_VARYINGDEF )
|
||||
list( APPEND CLI "--varyingdef" "${ARG_VARYINGDEF}" )
|
||||
endif()
|
||||
|
||||
# --verbose
|
||||
if( ARG_VERBOSE )
|
||||
list( APPEND CLI "--verbose" )
|
||||
endif()
|
||||
|
||||
# --debug
|
||||
if( ARG_DEBUG )
|
||||
list( APPEND CLI "--debug" )
|
||||
endif()
|
||||
|
||||
# --disasm
|
||||
if( ARG_DISASM )
|
||||
list( APPEND CLI "--disasm" )
|
||||
endif()
|
||||
|
||||
# --profile
|
||||
if( ARG_PROFILE )
|
||||
list( APPEND CLI "--profile" "${ARG_PROFILE}" )
|
||||
endif()
|
||||
|
||||
# -O
|
||||
if( ARG_O )
|
||||
list( APPEND CLI "-O" "${ARG_O}" )
|
||||
endif()
|
||||
|
||||
# --Werror
|
||||
if( ARG_WERROR )
|
||||
list( APPEND CLI "--Werror" )
|
||||
endif()
|
||||
|
||||
set( ${ARG_OUT} ${CLI} PARENT_SCOPE )
|
||||
endfunction()
|
||||
|
||||
Reference in New Issue
Block a user