Compare commits

...

195 Commits

Author SHA1 Message Date
dependabot[bot]
688224d5f0 build(deps): bump the submodules group with 2 updates
Bumps the submodules group with 2 updates: [bgfx](https://github.com/bkaradzic/bgfx) and [bx](https://github.com/bkaradzic/bx).


Updates `bgfx` from `e7e75e4` to `e2c5b1d`
- [Commits](e7e75e4bff...e2c5b1d3e1)

Updates `bx` from `7ac95d5` to `96748d9`
- [Commits](7ac95d5131...96748d9a58)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
  dependency-group: submodules
- dependency-name: bx
  dependency-type: direct:production
  dependency-group: submodules
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-06 21:26:04 -04:00
Sandy Carter
3c1f8bac82 add @bwrsandman as default reviewer 2023-07-06 20:26:35 -04:00
Sandy Carter
ec52497189 dependabot: Add groups, a beta feature 2023-07-06 20:15:50 -04:00
Sandy Carter
1925f436e7 dependabot: Add groups, a beta feature 2023-07-06 20:14:42 -04:00
Sandy Carter
b208d0c37b release: Fix typo in file directory 2023-06-11 09:09:45 -04:00
Sandy Carter
b5041def8e release: Isolate source from binaries 2023-06-11 08:29:30 -04:00
Sandy Carter
29b62260f6 Improve release archive names and structure 2023-06-11 08:11:49 -04:00
Sandy Carter
4cfb204f26 Use commas to separate artefacts 2023-06-11 07:25:09 -04:00
Sandy Carter
715b2a2c67 Debug artifact location 2023-06-11 06:26:34 -04:00
Sandy Carter
9d8213645b Fix artifact grepping 2023-06-11 05:40:26 -04:00
Sandy Carter
376cdd9205 fix typo in linux 2023-06-11 05:00:01 -04:00
Sandy Carter
9ad4a8a69a Compress repo folder 2023-06-11 04:19:43 -04:00
Sandy Carter
398b09ef17 Fix tar exclusion 2023-06-10 22:27:17 -04:00
Sandy Carter
0fc04361c8 fix directory 2023-06-10 21:46:04 -04:00
Sandy Carter
f5afee9379 Add built binaries to assets 2023-06-10 21:45:02 -04:00
Sandy Carter
16ae1476f0 Zip submodules 2023-06-10 20:55:21 -04:00
Sandy Carter
c2eb5368fa Auto generate release notes 2023-06-10 20:39:51 -04:00
Sandy Carter
86fa198254 Fix set output deprecation 2023-06-10 20:04:57 -04:00
Sandy Carter
84f51c4f0f update checkout action 2023-06-10 20:01:12 -04:00
Sandy Carter
fab7c74fa9 Release using submodules 2023-06-10 19:56:13 -04:00
Sandy Carter
b520b4686c Use ncipollo/release-action to release version
actions/create-release is no longer maintained
2023-06-10 19:16:59 -04:00
dependabot[bot]
dd8b8db87b build(deps): bump bgfx from 2902951 to e7e75e4 (#203) 2023-06-09 21:13:16 +00:00
dependabot[bot]
cbb7c340ba build(deps): bump bx from c5593ad to 7ac95d5
Bumps [bx](https://github.com/bkaradzic/bx) from `c5593ad` to `7ac95d5`.
- [Commits](c5593ad749...7ac95d5131)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-09 16:36:09 -04:00
dependabot[bot]
2a53415f03 build(deps): bump bgfx from 538c9a0 to 2902951 (#196) 2023-05-12 16:44:15 +00:00
Hristo Stamenov
7d89f8ee50 Fix setting the outputs correctly after the for loop since it was overriding the value for each shader. 2023-05-12 12:00:45 -04:00
Hristo Stamenov
487fa0c63b Refactored the conditions a bit 2023-05-02 00:55:01 -04:00
Hristo Iliev
9670cf4f43 Improvments on the shader compiler utility
The custom command didn't recognize bgfx::shaderc and the generator expression seems bettter. I also added an include option since it might be important to be able to define those.

Added changes to each of the cmake files to make sure bgfx:: is defined

Also add an output variable name parameter.

Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-05-02 00:55:01 -04:00
dependabot[bot]
0ab856a9dc build(deps): bump bgfx from 6f36b4f to 538c9a0
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `6f36b4f` to `538c9a0`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](6f36b4fb3a...538c9a05eb)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-27 21:59:34 -04:00
dependabot[bot]
73a2b12c5e build(deps): bump bx from fa1411e to 4e67e34
Bumps [bx](https://github.com/bkaradzic/bx) from `fa1411e` to `4e67e34`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](fa1411e4aa...4e67e34c4b)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-27 21:59:24 -04:00
Sandy Carter
4e42ca1ef5 Bump up minimum cmake version to 3.10.2 2023-02-19 09:04:28 -05:00
Sandy Carter
aaf627f912 cmake: test minimum cmake version 2023-02-19 09:04:28 -05:00
Sandy Carter
13fda4c089 install: Move install(TARGET) calls to target scope
CMake prior to 3.13 require  to be done in the same directory they were created
2023-02-19 09:04:28 -05:00
Sandy Carter
a6e266e326 Fix uses of sourceless exe/lib declarations
The feature to add targets without sources was added in cmake 3.11, in order to
be compatible with 3.6 and 3.11, target_sources call was removed
2023-02-19 09:04:28 -05:00
Sandy Carter
d671412cca webgpu: remove folder property 2023-02-19 09:04:28 -05:00
Sandy Carter
907dc5fbd7 Export bimg_encode and bimg_decode 2023-02-11 09:44:45 -05:00
Sandy Carter
a0f928864f version: remove newline from version number 2023-02-11 09:44:28 -05:00
Francis Hart
fad617f66f Ensure BX_DIR is converted to cmake style path
When using the BX_DIR, BIMG_DIR, and BGFX_DIR options to cmake, the
pathnames need to be converted to cmake style path. This ensures the
paths do not have mixed directory separators later on in the build,
which can cause build failures.
2023-02-11 09:44:13 -05:00
dependabot[bot]
fba0379121 build(deps): bump bgfx from bea82a1 to 6f36b4f
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `bea82a1` to `6f36b4f`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](bea82a1343...6f36b4fb3a)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-09 19:58:33 -05:00
Jamil Halabi
a6cfe968a5 Updated to the latest bgfx 2023-01-22 09:31:31 -05:00
Sandy Carter
0479a929a7 example: Fix for android 2023-01-22 08:38:49 -05:00
Sandy Carter
e5fea62b02 tests: Enable tools tests on android 2023-01-22 08:38:49 -05:00
Sandy Carter
0a11910c2a actions: Add android cross compile test 2023-01-22 08:38:49 -05:00
Sandy Carter
1c31493614 Set -fPIC always 2023-01-21 22:43:28 -05:00
Sandy Carter
fb50e78e49 examples: Only copy assets once 2023-01-21 18:16:45 -05:00
Sandy Carter
cf8b57e65c Fix -fPIC for static 2023-01-21 18:16:45 -05:00
Sandy Carter
38d11732c7 ci: test building examples 2023-01-21 18:16:45 -05:00
Sandy Carter
b6c4027d20 examples: Bump gssl version to 140 for vs and fs 2023-01-21 18:16:45 -05:00
npnp
086fccf3a8 Removed D3D_PREFIX and changed profile values to match the current version of shaderc 2023-01-21 18:16:45 -05:00
Sandy Carter
034462fd2a Add option to prefix tool names to avoid conflicts
For example the shaderc is used by dawn and an installation might want to
prefix bgfx's shaderc with bgfx-shaderc
2023-01-21 16:05:46 -05:00
Sandy Carter
7da3b0ed77 tools: Use dependent options 2023-01-15 22:08:41 -05:00
Sandy Carter
b89e3acb3b bgfx: move shared 2023-01-15 22:08:41 -05:00
Sandy Carter
ba2948e099 bgfx: Move shaderc to bgfx with 3rdparties 2023-01-15 22:08:41 -05:00
Sandy Carter
10501b78f4 bgfx: Move example to bgfx and split off imgui 2023-01-15 22:08:41 -05:00
Sandy Carter
8d130b923d bgfx: Move geometryc and add cmake macro 2023-01-15 22:08:41 -05:00
Sandy Carter
eb5a7d5f07 bgfx: Move geometryv config to bgfx dir 2023-01-15 22:08:41 -05:00
Sandy Carter
1e2f0ce9aa bgfx: Move texturev config to bgfx dir 2023-01-15 22:08:41 -05:00
Sandy Carter
052734d07a bgfx: Move bgfx config to its own directory 2023-01-15 22:08:41 -05:00
Sandy Carter
95a0a20a01 bimg: Add texturec and cmake macro 2023-01-14 22:10:06 -05:00
Sandy Carter
c1640a666b Move edtaa to file 2023-01-14 22:10:06 -05:00
Sandy Carter
850c227403 Move etc1 to file 2023-01-14 22:10:06 -05:00
Sandy Carter
2f2b00cc05 Move etc2 to file 2023-01-14 22:10:06 -05:00
Sandy Carter
6f741542d9 Move nvtt to file 2023-01-14 22:10:06 -05:00
Sandy Carter
e2c9bd0254 Move pvrtc to file 2023-01-14 22:10:06 -05:00
Sandy Carter
edb0b19c6f Move iqa sources to file 2023-01-14 22:10:06 -05:00
Sandy Carter
32508a2289 Add loadpng sources to file 2023-01-14 22:10:06 -05:00
Sandy Carter
4f4e484333 Move astc-encode to file 2023-01-14 22:10:06 -05:00
Sandy Carter
067672c661 Move tinyexr definitions to file 2023-01-14 22:10:06 -05:00
Sandy Carter
4a1f7581a6 Move libsquish definitions to file 2023-01-14 22:10:06 -05:00
Sandy Carter
03b690a4ab Move miniz definitions to file 2023-01-14 22:10:06 -05:00
Sandy Carter
1c7ef2d48f Add option to add user script
Useful for packagers like pacman and vcpkg to add custom cmake logic
instead of patching code.
2023-01-14 22:10:06 -05:00
Sandy Carter
03951e805c bimg: Restructure bimg*.cmake to be more like bimg*.lua 2023-01-14 22:10:06 -05:00
Sandy Carter
422e7cf0f8 bimg: Move bimg config to its own directory 2023-01-14 22:10:06 -05:00
Sandy Carter
9c1607365f fix list syntax 2023-01-14 18:57:19 -05:00
Sandy Carter
576c2b9694 bx: Add bx.test and bx.bench 2023-01-13 09:12:03 -05:00
Sandy Carter
99537daccd bx: Add bin2c and cmake macro 2023-01-13 09:12:03 -05:00
Sandy Carter
e9b0bb3b6c bx: Restructure bx.cmake to be more like bx.lua 2023-01-13 09:12:03 -05:00
Sandy Carter
d50eec41c1 config: Factor out crosscompile tool search
Add search for shaderc, texturec, texturev and geometryv
2023-01-13 09:12:03 -05:00
Sandy Carter
34d0f372b1 bx: Move bx config to its own directory 2023-01-13 09:12:03 -05:00
Sandy Carter
87180e3b7e gitignore: Add common project metafiles 2023-01-13 09:12:03 -05:00
Sandy Carter
ef8234966e Fix warnings related to CMP0054
The LINUX variable is only available in 3.25+
2023-01-07 22:08:47 -05:00
Sandy Carter
c85f396456 fix formatting for all cmake files 2023-01-07 09:54:59 -05:00
Sandy Carter
c9e4e20b02 fix format action syntax 2023-01-07 09:27:39 -05:00
Sandy Carter
471da90712 Add cmake-format config
Improve formatting.
Use Tabs.
Make copyright one whole comment block.
Remove spaces inside of functions and after if.
Remove excessive whitespace.
Add github action to validate formatting.
2023-01-07 09:25:21 -05:00
Sandy Carter
c53792d472 Fix the shader compile cmake utility to use the new profiles 2023-01-04 18:22:27 -05:00
dependabot[bot]
ac2c644f44 build(deps): bump bgfx from 66de825 to 5f435ea
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `66de825` to `5f435ea`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](66de825e6f...5f435ea56b)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-03 21:09:33 -05:00
dependabot[bot]
4ea31fd36f build(deps): bump bimg from 85109d7 to 1af9054
Bumps [bimg](https://github.com/bkaradzic/bimg) from `85109d7` to `1af9054`.
- [Release notes](https://github.com/bkaradzic/bimg/releases)
- [Commits](85109d7cdb...1af90543ca)

---
updated-dependencies:
- dependency-name: bimg
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-03 21:09:18 -05:00
Sandy Carter
4ea7d23eb2 3rdparty: prefix bgfx- to lib names to avoid conflicts 2023-01-03 21:09:01 -05:00
Sandy
03ae29e5bd Update README.md 2022-12-03 13:59:33 -05:00
Sandy Carter
cfc015871f Properly export when making shared library
Fixes using a dll in windows
2022-12-03 13:59:15 -05:00
Sandy Carter
54aaa9103d Add BGFX_CONFIG_DEBUG_ANNOTATION option
Disable for WindowsStore (UWP)
2022-12-03 13:59:05 -05:00
Sandy
2d7b0296f6 Use commit count for tag
In the case where the cmake package has been updated but bgfx submodules
haven't it is more informative to have the commit count than the sha.
2022-12-03 13:58:25 -05:00
dependabot[bot]
a59e0a63ae build(deps): bump bx from 20efa22 to aed1086
Bumps [bx](https://github.com/bkaradzic/bx) from `20efa22` to `aed1086`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](20efa22f18...aed1086c48)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-02 17:35:52 -05:00
dependabot[bot]
671c819e85 build(deps): bump bgfx from 6a03a1e to 66de825
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `6a03a1e` to `66de825`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](6a03a1ec5e...66de825e6f)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-02 17:35:46 -05:00
dependabot[bot]
c825dcf256 build(deps): bump bimg from 225dad7 to 85109d7
Bumps [bimg](https://github.com/bkaradzic/bimg) from `225dad7` to `85109d7`.
- [Release notes](https://github.com/bkaradzic/bimg/releases)
- [Commits](225dad7441...85109d7cdb)

---
updated-dependencies:
- dependency-name: bimg
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-02 17:35:38 -05:00
loanselot
916f26e1b6 Merge pull request #160 from Hyreos/patch-1
Prevent the script from trying to install tools that have been disabled
2022-11-28 16:18:22 +03:00
Hyreos
4e42ae2ae0 Prevent the script from trying to install tools that have been disabled
This commit fixes the issue of install failing if you disable any of the tools due to missing targets.
2022-11-20 17:23:21 -03:00
Johannes Schäufele
52feec47f5 bgfx: Add bgfx limits config options 2022-11-04 17:30:48 -04:00
loanselot
cf77d7c6d7 Merge pull request #159 from bkaradzic/dependabot/submodules/bgfx-6a03a1e
build(deps): bump bgfx from `f6a1289` to `6a03a1e`
2022-11-02 00:48:54 +03:00
loanselot
33dde1a115 Merge pull request #158 from bkaradzic/dependabot/submodules/bimg-225dad7
build(deps): bump bimg from `1955d8f` to `225dad7`
2022-11-02 00:48:44 +03:00
dependabot[bot]
3e7f1fe200 build(deps): bump bgfx from f6a1289 to 6a03a1e
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `f6a1289` to `6a03a1e`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](f6a1289dbc...6a03a1ec5e)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-01 16:03:17 +00:00
dependabot[bot]
866599edb0 build(deps): bump bimg from 1955d8f to 225dad7
Bumps [bimg](https://github.com/bkaradzic/bimg) from `1955d8f` to `225dad7`.
- [Release notes](https://github.com/bkaradzic/bimg/releases)
- [Commits](1955d8f99a...225dad7441)

---
updated-dependencies:
- dependency-name: bimg
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-01 16:03:13 +00:00
loanselot
089b388ac0 Merge pull request #156 from bkaradzic/temp
Update Submodules
2022-10-28 23:00:25 +03:00
e-erdal
9d3bc4f326 Update bgfx submodule 2022-10-28 22:21:19 +03:00
e-erdal
9ee85d3c1b Fix directx-headers 2022-10-28 21:48:50 +03:00
e-erdal
74a8e4dc72 ordering matters 2022-10-28 21:35:02 +03:00
e-erdal
99f17108ca Add linux compat for bx 2022-10-28 21:25:03 +03:00
e-erdal
862912e7e9 Fix WSL Include 2022-10-28 21:18:47 +03:00
e-erdal
72ea9b6f29 Add other DX Headers 2022-10-28 21:00:43 +03:00
e-erdal
6e23a39de6 Update submodules 2022-10-28 20:36:16 +03:00
loanselot
74e4a3fad9 Merge pull request #151 from SamHellawell/master
Allow to specify which tools to compile
2022-10-28 20:08:06 +03:00
Samuel Hellawell
5c54e5f299 Allow to specify which tools to compile
Signed-off-by: Samuel Hellawell <sshellawell@gmail.com>
2022-09-23 04:36:01 +01:00
Sandy Carter
06b995080d update submodules to dbafa14, 90ac47d, 8e94c8c 2022-08-26 10:29:01 -04:00
Sandy Carter
f5dc53db85 Find shaderc when cross-compiling 2022-08-24 11:56:03 -04:00
Sandy Carter
2051444e25 Install bgfxToolUtils even if not building tools
Fixes corner case of cross compiling with tools from host platform
2022-08-24 11:56:03 -04:00
Sandy Carter
5ba5a38762 add new 47-pixelformats example 2022-08-23 07:20:31 -04:00
Sandy Carter
e4e935c7ae ToolUtils: Add helper to compile shader to header 2022-08-22 08:57:50 -04:00
Sandy Carter
01c90714e1 export cmake function for shaderc_compiling
Remove unused add_shader and shaderc
Example usage:
```
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}
)
```
2022-08-22 08:57:50 -04:00
Sandy Carter
6ecce2449d emscripten: Set examples as htmls 2022-08-22 08:57:15 -04:00
Sandy Carter
c717984be0 emscripten: specify webgl2
Fix `undefined symbol emscripten_webgl2_get_proc_address` linker error
2022-08-22 08:57:15 -04:00
Sandy
955d692550 Dependabot unblock (#144)
* build(deps): bump bx from `aa5090b` to `13ae212`

Bumps [bx](https://github.com/bkaradzic/bx) from `aa5090b` to `13ae212`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](aa5090bbd8...13ae21207d)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): bump bgfx from `db44d56` to `8461f34`

Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `db44d56` to `8461f34`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](db44d5675f...8461f3406e)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-19 08:56:45 -07:00
Sandy Carter
12b75cc0ad config: Add option to turn on debug output on release 2022-08-07 08:33:26 -04:00
loanselot
65dde3874d Merge pull request #137 from pr0g/master
update bx to require c++14 and add compiler flag for bx when using MSVC
2022-07-19 00:42:56 +03:00
Tom Hulton-Harrop
f6a9fb1687 update from upstream - update bgfx submodule 2022-07-17 22:39:38 +01:00
Tom Hulton-Harrop
f1eed47138 Merge remote-tracking branch 'upstream/master' 2022-07-17 22:38:36 +01:00
loanselot
9ac6e08121 Merge pull request #138 from bkaradzic/dependabot/submodules/bx-aa5090b
build(deps): bump bx from `6332fb0` to `aa5090b`
2022-07-17 18:16:53 +03:00
loanselot
6c75503da4 Merge pull request #139 from bkaradzic/dependabot/submodules/bgfx-b38389f
build(deps): bump bgfx from `9204a53` to `b38389f`
2022-07-17 18:16:45 +03:00
dependabot[bot]
3dcf049202 build(deps): bump bgfx from 9204a53 to b38389f
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `9204a53` to `b38389f`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](9204a536dd...b38389f04e)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-01 16:03:21 +00:00
dependabot[bot]
3ec2a51aef build(deps): bump bx from 6332fb0 to aa5090b
Bumps [bx](https://github.com/bkaradzic/bx) from `6332fb0` to `aa5090b`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](6332fb0305...aa5090bbd8)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-01 16:03:20 +00:00
e-erdal
26a0f1e54d update bx to require c++14 and add compiler flag for bx when using MSVC 2022-06-26 17:22:23 +01:00
e-erdal
896ab5478c Add __cplusplus for MSVC 2022-06-24 11:42:25 +03:00
loanselot
23a1dc204a Merge pull request #135 from bkaradzic/dependabot/submodules/bx-6332fb0
build(deps): bump bx from `8832707` to `6332fb0`
2022-06-24 11:36:57 +03:00
loanselot
5fa58aad11 Merge pull request #136 from bkaradzic/dependabot/submodules/bgfx-9204a53
build(deps): bump bgfx from `379fc70` to `9204a53`
2022-06-24 11:36:49 +03:00
dependabot[bot]
8dafd0d9e4 build(deps): bump bgfx from 379fc70 to 9204a53
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `379fc70` to `9204a53`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](379fc707ff...9204a536dd)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-01 16:03:24 +00:00
dependabot[bot]
3bac602264 build(deps): bump bx from 8832707 to 6332fb0
Bumps [bx](https://github.com/bkaradzic/bx) from `8832707` to `6332fb0`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](88327070b9...6332fb0305)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-01 16:03:20 +00:00
loanselot
1b2b921bde Merge pull request #134 from bkaradzic/dependabot/submodules/bgfx-379fc70
build(deps): bump bgfx from `5ae2271` to `379fc70`
2022-05-04 12:26:41 +03:00
loanselot
374dcbba70 Merge pull request #133 from bkaradzic/dependabot/submodules/bx-8832707
build(deps): bump bx from `ad018d4` to `8832707`
2022-05-04 12:26:26 +03:00
dependabot[bot]
95af1cc54d build(deps): bump bgfx from 5ae2271 to 379fc70
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `5ae2271` to `379fc70`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](5ae2271667...379fc707ff)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-01 16:01:28 +00:00
dependabot[bot]
e85f8c0f3c build(deps): bump bx from ad018d4 to 8832707
Bumps [bx](https://github.com/bkaradzic/bx) from `ad018d4` to `8832707`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](ad018d47c6...88327070b9)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-01 16:01:26 +00:00
loanselot
9ecbe9ee51 Merge pull request #131 from bkaradzic/dependabot/submodules/bgfx-5ae2271
Bump bgfx from `ae7aeba` to `5ae2271`
2022-04-12 02:24:53 +03:00
Sandy Carter
d725e78f86 bgfx: Add BGFX_MULTITHREADED option 2022-04-10 22:30:07 -04:00
dependabot[bot]
93de01a1af Bump bgfx from ae7aeba to 5ae2271
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `ae7aeba` to `5ae2271`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](ae7aeba72c...5ae2271667)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-01 16:02:10 +00:00
Sandy Carter
dd2017c332 examples: Don't build on android by default 2022-03-30 17:09:46 -04:00
Sandy Carter
ead887f59b bx: Link with android log library 2022-03-30 17:09:46 -04:00
Sandy Carter
f184835827 glsl-optimizer: set libraries as STATIC explicitly 2022-03-30 17:09:31 -04:00
Tom Hulton-Harrop
a7ac0aa3ae add additional space around parens 2022-03-21 20:52:06 -04:00
Tom Hulton-Harrop
163661a07e update to have bgfx.cmake work with emscripten 2022-03-21 20:52:06 -04:00
loanselot
99b9c1e852 Merge pull request #126 from bkaradzic/dependabot/submodules/bx-ad018d4
Bump bx from `c969169` to `ad018d4`
2022-03-08 13:51:21 +03:00
loanselot
28ea11be6d Merge pull request #125 from bkaradzic/dependabot/submodules/bimg-663f724
Bump bimg from `9d6af16` to `663f724`
2022-03-08 13:51:14 +03:00
loanselot
0006784f70 Merge pull request #124 from bkaradzic/dependabot/submodules/bgfx-ae7aeba
Bump bgfx from `e79f92a` to `ae7aeba`
2022-03-08 13:51:07 +03:00
dependabot[bot]
819719a4f9 Bump bx from c969169 to ad018d4
Bumps [bx](https://github.com/bkaradzic/bx) from `c969169` to `ad018d4`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](c969169fc1...ad018d47c6)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-01 16:02:16 +00:00
dependabot[bot]
5b34c97f4c Bump bimg from 9d6af16 to 663f724
Bumps [bimg](https://github.com/bkaradzic/bimg) from `9d6af16` to `663f724`.
- [Release notes](https://github.com/bkaradzic/bimg/releases)
- [Commits](9d6af16116...663f724186)

---
updated-dependencies:
- dependency-name: bimg
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-01 16:02:13 +00:00
dependabot[bot]
4846036666 Bump bgfx from e79f92a to ae7aeba
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `e79f92a` to `ae7aeba`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](e79f92a241...ae7aeba72c)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-01 16:02:11 +00:00
loanselot
3168a4660e Merge pull request #103 from Ravbug/bx_debug_fix
BX_CONFIG_DEBUG via generator expression
2022-02-03 13:05:49 +03:00
Ravbug
b5879646bb Incorporate MrRobust's suggestion 2022-02-02 16:30:21 -05:00
loanselot
9426a2f44f Update dependabot.yml 2022-02-02 15:44:32 +03:00
loanselot
3cf48b42d1 Merge pull request #122 from bkaradzic/dependabot/submodules/bgfx-e79f92a
Bump bgfx from `9f04292` to `e79f92a`
2022-02-02 15:42:15 +03:00
dependabot[bot]
b5192910f9 Bump bgfx from 9f04292 to e79f92a
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `9f04292` to `e79f92a`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](9f04292f40...e79f92a241)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-01 16:13:45 +00:00
loanselot
b44793b740 Merge pull request #114 from recisio/cmake_include_paths
CMake more precise includes path
2022-01-31 21:26:30 +03:00
loanselot
1b74840891 Merge pull request #120 from bkaradzic/dependabot/submodules/bgfx-9f04292
Bump bgfx from `cd2030c` to `9f04292`
2022-01-31 20:56:20 +03:00
dependabot[bot]
b193a31651 Bump bgfx from cd2030c to 9f04292
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `cd2030c` to `9f04292`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](cd2030cc11...9f04292f40)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-31 17:16:26 +00:00
loanselot
146a9f43b0 Merge pull request #121 from bkaradzic/ci-fix-2
Add IOKit for Metal backend
2022-01-31 20:15:14 +03:00
e-erdal
9f3943b829 Link IOKit + CoreFoundation 2022-01-31 19:38:44 +03:00
e-erdal
f81d8ee146 Add IOKit for Metal backend 2022-01-31 19:16:08 +03:00
e-erdal
d65bbd523e Merge branches 'dependabot/submodules/bimg-9d6af16', 'dependabot/submodules/bgfx-cd2030c' and 'dependabot/submodules/bx-c969169' of https://github.com/bkaradzic/bgfx.cmake 2022-01-31 18:44:22 +03:00
dependabot[bot]
d3449c2f68 Bump bimg from 9e4d2b1 to 9d6af16
Bumps [bimg](https://github.com/bkaradzic/bimg) from `9e4d2b1` to `9d6af16`.
- [Release notes](https://github.com/bkaradzic/bimg/releases)
- [Commits](9e4d2b167f...9d6af16116)

---
updated-dependencies:
- dependency-name: bimg
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-17 16:14:11 +00:00
dependabot[bot]
0745f23a13 Bump bgfx from 932d2f2 to cd2030c
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `932d2f2` to `cd2030c`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](932d2f21e7...cd2030cc11)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-17 16:14:10 +00:00
dependabot[bot]
0424ae3763 Bump bx from 51c3264 to c969169
Bumps [bx](https://github.com/bkaradzic/bx) from `51c3264` to `c969169`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](51c3264846...c969169fc1)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-17 16:14:07 +00:00
alexandrebeaudet
72bc1cf167 CMake more precise includes path (in order to use some functions externally) 2022-01-07 10:57:18 +01:00
Sandy Carter
7e7a6795a1 Use string compare for library type 2021-12-23 13:52:18 -05:00
Ravbug
93c9e73a42 Add checked & profile 2021-12-19 12:12:00 -08:00
Ravbug
0f1a5a91e6 Change BGFX_CONFIG_DEBUG to generator expression 2021-12-19 11:44:52 -08:00
Sandy Carter
a01e8e043f bgfx: Add debug config required in bx headers since bx is private 2021-10-30 10:14:58 -04:00
loanselot
5205429de2 Merge pull request #79 from bkaradzic/ci-fix
Add definition type
2021-10-28 12:00:14 +03:00
e-erdal
25f2107994 Add definition type 2021-10-28 11:16:14 +03:00
loanselot
75b9076904 Merge pull request #78 from bkaradzic/dependabot/submodules/bgfx-932d2f2
Bump bgfx from `6573fc4` to `932d2f2`
2021-10-28 11:06:55 +03:00
loanselot
de4c88ac51 Merge pull request #76 from bkaradzic/dependabot/submodules/bimg-9e4d2b1
Bump bimg from `6693de0` to `9e4d2b1`
2021-10-28 11:06:48 +03:00
loanselot
d575656458 Merge pull request #75 from bkaradzic/dependabot/submodules/bx-51c3264
Bump bx from `11c3c5e` to `51c3264`
2021-10-28 11:06:41 +03:00
e-erdal
d3260f172c Add definition for BX_CONFIG_DEBUG 2021-10-28 11:06:14 +03:00
dependabot[bot]
f290d91828 Bump bgfx from 6573fc4 to 932d2f2
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `6573fc4` to `932d2f2`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](6573fc44a8...932d2f21e7)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-27 16:12:45 +00:00
dependabot[bot]
23577764fe Bump bimg from 6693de0 to 9e4d2b1
Bumps [bimg](https://github.com/bkaradzic/bimg) from `6693de0` to `9e4d2b1`.
- [Release notes](https://github.com/bkaradzic/bimg/releases)
- [Commits](6693de0e50...9e4d2b167f)

---
updated-dependencies:
- dependency-name: bimg
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-26 16:15:23 +00:00
dependabot[bot]
ec90e950f1 Bump bx from 11c3c5e to 51c3264
Bumps [bx](https://github.com/bkaradzic/bx) from `11c3c5e` to `51c3264`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](11c3c5e615...51c3264846)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-26 16:15:21 +00:00
loanselot
8a301010d7 Merge pull request #73 from bkaradzic/dependabot/submodules/bx-11c3c5e
Bump bx from `f324ffa` to `11c3c5e`
2021-10-23 07:15:32 +03:00
loanselot
29888bfb88 Merge pull request #72 from bkaradzic/dependabot/submodules/bgfx-6573fc4
Bump bgfx from `ffeba57` to `6573fc4`
2021-10-23 07:15:25 +03:00
e-erdal
0133fc5cca Remove bounds 2021-10-23 06:39:13 +03:00
dependabot[bot]
8a1d4fe3b1 Bump bx from f324ffa to 11c3c5e
Bumps [bx](https://github.com/bkaradzic/bx) from `f324ffa` to `11c3c5e`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](f324ffad46...11c3c5e615)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-22 16:11:49 +00:00
dependabot[bot]
3dc17e4d12 Bump bgfx from ffeba57 to 6573fc4
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `ffeba57` to `6573fc4`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](ffeba57b8a...6573fc44a8)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-21 14:19:10 +00:00
loanselot
83e5c829c1 Merge pull request #71 from bkaradzic/dependabot/submodules/bx-f324ffa
Bump bx from `ce8f0ec` to `f324ffa`
2021-10-21 17:18:30 +03:00
dependabot[bot]
b64b46c01b Bump bx from ce8f0ec to f324ffa
Bumps [bx](https://github.com/bkaradzic/bx) from `ce8f0ec` to `f324ffa`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](ce8f0ec49b...f324ffad46)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-18 16:16:08 +00:00
loanselot
b455d69ebc Merge pull request #69 from bkaradzic/dependabot/submodules/bgfx-ffeba57
Bump bgfx from `f99a6b4` to `ffeba57`
2021-10-18 10:27:03 +03:00
loanselot
4702973847 Merge pull request #70 from bkaradzic/dependabot/submodules/bx-ce8f0ec
Bump bx from `c7fc7b4` to `ce8f0ec`
2021-10-18 10:26:55 +03:00
e-erdal
7f96ef20a7 Add example "fsr" 2021-10-18 10:26:07 +03:00
dependabot[bot]
06ea813ee0 Bump bx from c7fc7b4 to ce8f0ec
Bumps [bx](https://github.com/bkaradzic/bx) from `c7fc7b4` to `ce8f0ec`.
- [Release notes](https://github.com/bkaradzic/bx/releases)
- [Commits](c7fc7b4ac6...ce8f0ec49b)

---
updated-dependencies:
- dependency-name: bx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-15 16:12:43 +00:00
dependabot[bot]
813fd9be03 Bump bgfx from f99a6b4 to ffeba57
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `f99a6b4` to `ffeba57`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](f99a6b4246...ffeba57b8a)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-15 16:12:40 +00:00
loanselot
417f8b82ef Merge pull request #59 from bkaradzic/dependabot/submodules/bgfx-f99a6b4
Bump bgfx from `73db386` to `f99a6b4`
2021-10-05 01:03:15 +03:00
dependabot[bot]
8ee2f954a2 Bump bgfx from 73db386 to f99a6b4
Bumps [bgfx](https://github.com/bkaradzic/bgfx) from `73db386` to `f99a6b4`.
- [Release notes](https://github.com/bkaradzic/bgfx/releases)
- [Commits](73db386165...f99a6b4246)

---
updated-dependencies:
- dependency-name: bgfx
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-04 21:15:49 +00:00
76 changed files with 3874 additions and 1984 deletions

315
.cmake-format.py Normal file
View File

@@ -0,0 +1,315 @@
# ----------------------------------
# Options affecting listfile parsing
# ----------------------------------
with section("parse"):
# Specify structure for custom cmake functions
additional_commands = { '_bgfx_bin2c_parse': { 'kwargs': { 'ARRAY_NAME': 1,
'INPUT_FILE': 1,
'OUTPUT_FILE': 1},
'pargs': {'flags': [], 'nargs': '*'}},
'_bgfx_get_profile_ext': {'pargs': {'nargs': 2}},
'_bgfx_shaderc_parse': { 'kwargs': { 'BIN2C': 1,
'DEFINES': '+',
'FILE': 1,
'INCLUDES': '+',
'O': 1,
'OUTPUT': 1,
'PROFILE': 1,
'VARYINGDEF': 1},
'pargs': { 'flags': [ 'DEPENDS',
'ANDROID',
'ASM_JS',
'IOS',
'LINUX',
'NACL',
'OSX',
'WINDOWS',
'PREPROCESS',
'RAW',
'FRAGMENT',
'VERTEX',
'COMPUTE',
'VERBOSE',
'DEBUG',
'DISASM',
'WERROR'],
'nargs': '1+'}},
'_bgfx_texturec_parse': { 'kwargs': { 'AS': 1,
'FILE': 1,
'FORMAT': 1,
'MAX': 1,
'MIPSKIP': 1,
'OUTPUT': 1,
'QUALITY': 1,
'RADIANCE': 1,
'REF': 1},
'pargs': { 'flags': [ 'MIPS',
'NORMALMAP',
'EQUIRECT',
'STRIP',
'SDF',
'IQA',
'PMA',
'LINEAR'],
'nargs': '*'}},
'bgfx_compile_binary_to_header': { 'kwargs': { 'ARRAY_NAME': 1,
'INPUT_FILE': 1,
'OUTPUT_FILE': 1},
'pargs': {'flags': [], 'nargs': '*'}},
'bgfx_compile_shader_to_header': { 'kwargs': { 'OUTPUT_DIR': 1,
'SHADERS': '+',
'TYPE': 1,
'VARYING_DEF': 1},
'pargs': {'flags': [], 'nargs': '*'}},
'bgfx_compile_texture': { 'kwargs': { 'AS': 1,
'FILE': 1,
'FORMAT': 1,
'MAX': 1,
'MIPSKIP': 1,
'OUTPUT': 1,
'QUALITY': 1,
'RADIANCE': 1,
'REF': 1},
'pargs': { 'flags': [ 'MIPS',
'NORMALMAP',
'EQUIRECT',
'STRIP',
'SDF',
'IQA',
'PMA',
'LINEAR'],
'nargs': '*'}}}
# Override configurations per-command where available
override_spec = {}
# Specify variable tags.
vartags = []
# Specify property tags.
proptags = []
# -----------------------------
# Options affecting formatting.
# -----------------------------
with section("format"):
# Disable formatting entirely, making cmake-format a no-op
disable = False
# How wide to allow formatted cmake files
line_width = 120
# How many spaces to tab for indent
tab_size = 4
# If true, lines are indented using tab characters (utf-8 0x09) instead of
# <tab_size> space characters (utf-8 0x20). In cases where the layout would
# require a fractional tab character, the behavior of the fractional
# indentation is governed by <fractional_tab_policy>
use_tabchars = True
# If <use_tabchars> is True, then the value of this variable indicates how
# fractional indentions are handled during whitespace replacement. If set to
# 'use-space', fractional indentation is left as spaces (utf-8 0x20). If set
# to `round-up` fractional indentation is replaced with a single tab character
# (utf-8 0x09) effectively shifting the column to the next tabstop
fractional_tab_policy = 'use-space'
# If an argument group contains more than this many sub-groups (parg or kwarg
# groups) then force it to a vertical layout.
max_subgroups_hwrap = 3
# If a positional argument group contains more than this many arguments, then
# force it to a vertical layout.
max_pargs_hwrap = 6
# If a cmdline positional group consumes more than this many lines without
# nesting, then invalidate the layout (and nest)
max_rows_cmdline = 2
# If true, separate flow control names from their parentheses with a space
separate_ctrl_name_with_space = False
# If true, separate function names from parentheses with a space
separate_fn_name_with_space = False
# If a statement is wrapped to more than one line, than dangle the closing
# parenthesis on its own line.
dangle_parens = True
# If the trailing parenthesis must be 'dangled' on its on line, then align it
# to this reference: `prefix`: the start of the statement, `prefix-indent`:
# the start of the statement, plus one indentation level, `child`: align to
# the column of the arguments
dangle_align = 'prefix'
# If the statement spelling length (including space and parenthesis) is
# smaller than this amount, then force reject nested layouts.
min_prefix_chars = 4
# If the statement spelling length (including space and parenthesis) is larger
# than the tab width by more than this amount, then force reject un-nested
# layouts.
max_prefix_chars = 10
# If a candidate layout is wrapped horizontally but it exceeds this many
# lines, then reject the layout.
max_lines_hwrap = 2
# What style line endings to use in the output.
line_ending = 'unix'
# Format command names consistently as 'lower' or 'upper' case
command_case = 'canonical'
# Format keywords consistently as 'lower' or 'upper' case
keyword_case = 'canonical'
# A list of command names which should always be wrapped
always_wrap = []
# If true, the argument lists which are known to be sortable will be sorted
# lexicographicall
enable_sort = True
# If true, the parsers may infer whether or not an argument list is sortable
# (without annotation).
autosort = False
# By default, if cmake-format cannot successfully fit everything into the
# desired linewidth it will apply the last, most agressive attempt that it
# made. If this flag is True, however, cmake-format will print error, exit
# with non-zero status code, and write-out nothing
require_valid_layout = False
# A dictionary mapping layout nodes to a list of wrap decisions. See the
# documentation for more information.
layout_passes = {}
# ------------------------------------------------
# Options affecting comment reflow and formatting.
# ------------------------------------------------
with section("markup"):
# What character to use for bulleted lists
bullet_char = '*'
# What character to use as punctuation after numerals in an enumerated list
enum_char = '.'
# If comment markup is enabled, don't reflow the first comment block in each
# listfile. Use this to preserve formatting of your copyright/license
# statements.
first_comment_is_literal = False
# If comment markup is enabled, don't reflow any comment block which matches
# this (regex) pattern. Default is `None` (disabled).
literal_comment_pattern = None
# Regular expression to match preformat fences in comments default=
# ``r'^\s*([`~]{3}[`~]*)(.*)$'``
fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
# Regular expression to match rulers in comments default=
# ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``
ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
# If a comment line matches starts with this pattern then it is explicitly a
# trailing comment for the preceeding argument. Default is '#<'
explicit_trailing_pattern = '#<'
# If a comment line starts with at least this many consecutive hash
# characters, then don't lstrip() them off. This allows for lazy hash rulers
# where the first hash char is not separated by space
hashruler_min_length = 10
# If true, then insert a space between the first hash char and remaining hash
# chars in a hash ruler, and normalize its length to fill the column
canonicalize_hashrulers = True
# enable comment markup parsing and reflow
enable_markup = False
# ----------------------------
# Options affecting the linter
# ----------------------------
with section("lint"):
# a list of lint codes to disable
disabled_codes = []
# regular expression pattern describing valid function names
function_pattern = '[0-9a-z_]+'
# regular expression pattern describing valid macro names
macro_pattern = '[0-9A-Z_]+'
# regular expression pattern describing valid names for variables with global
# (cache) scope
global_var_pattern = '[A-Z][0-9A-Z_]+'
# regular expression pattern describing valid names for variables with global
# scope (but internal semantic)
internal_var_pattern = '_[A-Z][0-9A-Z_]+'
# regular expression pattern describing valid names for variables with local
# scope
local_var_pattern = '[a-z][a-z0-9_]+'
# regular expression pattern describing valid names for privatedirectory
# variables
private_var_pattern = '_[0-9a-z_]+'
# regular expression pattern describing valid names for public directory
# variables
public_var_pattern = '[A-Z][0-9A-Z_]+'
# regular expression pattern describing valid names for function/macro
# arguments and loop variables.
argument_var_pattern = '[a-z][a-z0-9_]+'
# regular expression pattern describing valid names for keywords used in
# functions or macros
keyword_pattern = '[A-Z][0-9A-Z_]+'
# In the heuristic for C0201, how many conditionals to match within a loop in
# before considering the loop a parser.
max_conditionals_custom_parser = 2
# Require at least this many newlines between statements
min_statement_spacing = 1
# Require no more than this many newlines between statements
max_statement_spacing = 2
max_returns = 6
max_branches = 12
max_arguments = 5
max_localvars = 15
max_statements = 50
# -------------------------------
# Options affecting file encoding
# -------------------------------
with section("encode"):
# If true, emit the unicode byte-order mark (BOM) at the start of the file
emit_byteorder_mark = False
# Specify the encoding of the input file. Defaults to utf-8
input_encoding = 'utf-8'
# Specify the encoding of the output file. Defaults to utf-8. Note that cmake
# only claims to support utf-8 so be careful when using anything else
output_encoding = 'utf-8'
# -------------------------------------
# Miscellaneous configurations options.
# -------------------------------------
with section("misc"):
# A dictionary containing any per-command configuration overrides. Currently
# only `command_case` is supported.
per_command = {}

1
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1 @@
* @bwrsandman

View File

@@ -3,4 +3,9 @@ updates:
- package-ecosystem: "gitsubmodule"
directory: "/"
schedule:
interval: "daily"
interval: "monthly"
groups:
# Name of the group
submodules:
patterns:
- "*"

View File

@@ -1,4 +1,3 @@
# https://github.com/openblack/bgfx.cmake/blob/master/.github/workflows/ci.yml
name: CI
on:
@@ -7,10 +6,41 @@ on:
pull_request:
branches: [ master ]
env:
# Indicates the CMake build directory where project files and binaries are being produced.
CMAKE_BUILD_DIR: ${{ github.workspace }}/build/
jobs:
job:
minimum-cmake-version:
name: Check compatibility with minimum cmake version
runs-on: ubuntu-latest
env:
CMAKE_VERSION: 3.10.2
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt install -y libgl1-mesa-dev
- uses: lukka/get-cmake@latest
with:
cmakeVersion: ${{ env.CMAKE_VERSION }}
- name: Check cmake version
run: |
cmake --version | grep ${{ env.CMAKE_VERSION }}
- name: Test config
# old way of configuring a build directory
run: |
mkdir -p "${{ env.CMAKE_BUILD_DIR }}"
cd "${{ env.CMAKE_BUILD_DIR }}"
cmake ${{ github.workspace }} -GNinja -DCMAKE_BUILD_TYPE=Release
native:
name: ${{ matrix.os }} ${{ matrix.cc }}
runs-on: ${{ matrix.os }}
needs: minimum-cmake-version
strategy:
fail-fast: false
matrix:
@@ -23,18 +53,13 @@ jobs:
cc: clang
cxx: clang++
- os: macos-latest
env:
# Indicates the CMake build directory where project files and binaries are being produced.
CMAKE_BUILD_DIR: ${{ github.workspace }}/build/
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
submodules: recursive
- name: Install Linux dependencies
run: |
sudo apt-get update
@@ -55,4 +80,46 @@ jobs:
# Build the whole project with Ninja (which is spawn by CMake).
- name: Build
run: |
cmake --build "${{ env.CMAKE_BUILD_DIR }}"
cmake --build "${{ env.CMAKE_BUILD_DIR }}"
# Build the examples which are excluded from all
- name: Build examples
run: |
cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target examples
cross-android:
name: cross-android
runs-on: ubuntu-latest
needs: minimum-cmake-version
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt install -y libgl1-mesa-dev
if: matrix.os == 'ubuntu-latest'
# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.
- uses: lukka/get-cmake@latest
# On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly. As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK.
- uses: ilammy/msvc-dev-cmd@v1
# Run CMake to generate Ninja project files
- name: Generate project files
run: |
cmake -B "${{ env.CMAKE_BUILD_DIR }}" -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake
# Build the whole project with Ninja (which is spawn by CMake).
- name: Build
run: |
cmake --build "${{ env.CMAKE_BUILD_DIR }}"
# Build the examples which are excluded from all
- name: Build examples
run: |
cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target examples

54
.github/workflows/format.yml vendored Normal file
View File

@@ -0,0 +1,54 @@
# https://github.com/openblack/bgfx.cmake/blob/master/.github/workflows/format.yml
name: Format
on:
push:
branches: [ master ]
pull_request_target:
branches: [ master ]
jobs:
cmake-format-check:
name: cmake-format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Add base repo to git config
run: git remote add upstream ${{ github.event.pull_request.base.repo.html_url }}
if: startsWith(github.event_name, 'pull_request')
- name: Format CMake files
id: cmake-format
uses: PuneetMatharu/cmake-format-lint-action@main
with:
args: --config-files .cmake-format.py --check
# Run only if a PR and cmake-format has failed
cmake-format-action-suggester:
name: cmake-format fix suggester
runs-on: ubuntu-latest
needs: cmake-format-check
if: always() && startsWith(github.event_name, 'pull_request') && needs.cmake-format-check.result == 'failure'
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Add base repo to git config
run: git remote add upstream ${{ github.event.pull_request.base.repo.html_url }}
if: startsWith(github.event_name, 'pull_request')
- name: Format CMake files
id: cmake-format
uses: PuneetMatharu/cmake-format-lint-action@v1.0.0
with:
args: --config-files .cmake-format.py --in-place
- run: |
git diff > cmake-format.patch
- uses: actions/upload-artifact@v2
with:
name: formatting-fix-${{github.sha}}
path: cmake-format.patch
- uses: reviewdog/action-suggester@v1
with:
tool_name: cmake-format

View File

@@ -18,20 +18,20 @@ jobs:
sha: ${{ steps.version.outputs.sha }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- 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}"
echo "::set-output name=sha::${SHA}"
echo "::set-output name=tag::${TAG}"
TAG="v1.${API_VERSION}.${BGFX_REVISION}-${BGFX_CMAKE_REVISION}"
echo "revision=${BGFX_REVISION}" >> $GITHUB_OUTPUT
echo "sha=${SHA}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
build:
name: ${{ matrix.os }}
@@ -51,7 +51,7 @@ jobs:
CMAKE_INSTALL_DIR: ${{ github.workspace }}/install/
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install Linux dependencies
@@ -75,13 +75,12 @@ jobs:
# Run CMake to generate project files
- name: Generate project files
run: |
cmake -B "${{ env.CMAKE_BUILD_DIR }}" -DCMAKE_INSTALL_PREFIX="${{ env.CMAKE_INSTALL_DIR }}" -DCMAKE_DEBUG_POSTFIX=d -DBGFX_BUILD_EXAMPLES=OFF -DBGFX_BUILD_TOOLS=ON -DBGFX_INSTALL=ON -DBGFX_AMALGAMATED=ON
cmake -B "${{ env.CMAKE_BUILD_DIR }}" "-DCMAKE_INSTALL_PREFIX=${{ env.CMAKE_INSTALL_DIR }}" -DCMAKE_DEBUG_POSTFIX=d -DBGFX_BUILD_EXAMPLES=OFF -DBGFX_BUILD_TOOLS=ON -DBGFX_INSTALL=ON -DBGFX_AMALGAMATED=ON -DCMAKE_BUILD_TYPE=Release
# Build the install targets
- name: Build
run: |
cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target install --config Debug
cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target install --config Release
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}
path: ${{ github.workspace }}/install/
@@ -91,11 +90,89 @@ jobs:
runs-on: ubuntu-latest
needs: [ version, build ]
if: github.repository == 'bkaradzic/bgfx.cmake' && github.event_name == 'push'
permissions:
contents: write
steps:
- name: Create Release
uses: actions/create-release@v1
- uses: actions/checkout@v3
with:
tag_name: ${{ needs.version.outputs.tag }}
release_name: ${{ needs.version.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
submodules: recursive
fetch-depth: 0
path: src/bgfx.cmake
- run: |
find src/bgfx.cmake -name ".git*" -exec rm -rf {} +
find src/bgfx.cmake -name ".editorconfig" -delete
rm src/bgfx.cmake/.cmake-format.py
- uses: actions/download-artifact@v3
with:
name: windows-latest
path: ${{ github.workspace }}/install/windows/bgfx.cmake
- uses: actions/download-artifact@v3
with:
name: ubuntu-latest
path: ${{ github.workspace }}/install/linux/bgfx.cmake
- uses: actions/download-artifact@v3
with:
name: macos-latest
path: ${{ github.workspace }}/install/macos/bgfx.cmake
- name: Create Source Zip
uses: thedoctor0/zip-release@0.7.1
with:
type: 'zip'
filename: 'bgfx.cmake.${{ needs.version.outputs.tag }}.zip'
directory: 'src'
path: 'bgfx.cmake'
- name: Create Source Tar
uses: thedoctor0/zip-release@0.7.1
with:
type: 'tar'
filename: 'bgfx.cmake.${{ needs.version.outputs.tag }}.tar.gz'
directory: 'src'
path: 'bgfx.cmake'
- name: Create Windows Zip
uses: thedoctor0/zip-release@0.7.1
with:
type: 'zip'
filename: 'bgfx.cmake.binary.windows.${{ needs.version.outputs.tag }}.zip'
directory: 'install/windows'
path: 'bgfx.cmake'
- name: Create Windows Tar
uses: thedoctor0/zip-release@0.7.1
with:
type: 'tar'
filename: 'bgfx.cmake.binary.windows.${{ needs.version.outputs.tag }}.tar.gz'
directory: 'install/windows'
path: 'bgfx.cmake'
- name: Create Linux Zip
uses: thedoctor0/zip-release@0.7.1
with:
type: 'zip'
filename: 'bgfx.cmake.binary.linux.${{ needs.version.outputs.tag }}.zip'
directory: 'install/linux'
path: 'bgfx.cmake'
- name: Create Linux Tar
uses: thedoctor0/zip-release@0.7.1
with:
type: 'tar'
filename: 'bgfx.cmake.binary.linux.${{ needs.version.outputs.tag }}.tar.gz'
directory: 'install/linux'
path: 'bgfx.cmake'
- name: Create MacOS Zip
uses: thedoctor0/zip-release@0.7.1
with:
type: 'zip'
filename: 'bgfx.cmake.binary.macos.${{ needs.version.outputs.tag }}.zip'
directory: 'install/macos'
path: 'bgfx.cmake'
- name: Create MacOS Tar
uses: thedoctor0/zip-release@0.7.1
with:
type: 'tar'
filename: 'bgfx.cmake.binary.macos.${{ needs.version.outputs.tag }}.tar.gz'
directory: 'install/macos'
path: 'bgfx.cmake'
- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.version.outputs.tag }}
artifacts: "src/bgfx.cmake.${{ needs.version.outputs.tag }}.zip,src/bgfx.cmake.${{ needs.version.outputs.tag }}.tar.gz,install/*/*.${{ needs.version.outputs.tag }}.zip,install/*/*.${{ needs.version.outputs.tag }}.tar.gz"
generateReleaseNotes: true

6
.gitignore vendored
View File

@@ -13,3 +13,9 @@ install_manifest.txt
generated/*
!generated/*.in
cmake_install.cmake
.cache/
.vscode/
.idea/
Makefile
install*/
cmake-build-*/

View File

@@ -1,199 +1,189 @@
# 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/>.
cmake_minimum_required( VERSION 3.0 )
project(bgfx)
set_property( GLOBAL PROPERTY USE_FOLDERS ON )
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Makefile generators on apple need this flag to compile mixed objective/c++
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_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" )
set( BGFX_LIBRARY_TYPE "STATIC" CACHE STRING "Linking type for library" )
set_property( CACHE BGFX_LIBRARY_TYPE PROPERTY STRINGS STATIC SHARED )
if( BGFX_LIBRARY_TYPE MATCHES "SHARED" )
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
if( NOT BX_DIR )
set( BX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bx" CACHE STRING "Location of bx." )
elseif( NOT IS_ABSOLUTE "${BX_DIR}")
get_filename_component(BX_DIR "${BX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
if( NOT BIMG_DIR )
set( BIMG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bimg" CACHE STRING "Location of bimg." )
elseif( NOT IS_ABSOLUTE "${BIMG_DIR}")
get_filename_component(BIMG_DIR "${BIMG_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
if( NOT BGFX_DIR )
set( BGFX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bgfx" CACHE STRING "Location of bgfx." )
elseif( NOT IS_ABSOLUTE "${BGFX_DIR}")
get_filename_component(BGFX_DIR "${BGFX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
# sets project version from api ver / git rev
include( cmake/version.cmake )
include( cmake/shared.cmake )
include( cmake/bx.cmake )
include( cmake/bimg.cmake )
include( cmake/bgfx.cmake )
if( BGFX_BUILD_TOOLS )
include( cmake/tools.cmake )
endif()
if( BGFX_BUILD_TOOLS OR BGFX_BUILD_EXAMPLES )
include( cmake/examples.cmake )
endif()
if( BGFX_INSTALL )
include(GNUInstallDirs)
# Layout. This works for all platforms:
# * <prefix>/lib*/cmake/<PROJECT-NAME>
# * <prefix>/lib*/
# * <prefix>/include/
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
# Configuration
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")
# Include module with fuction 'write_basic_package_version_file'
include(CMakePackageConfigHelpers)
# Configure '<PROJECT-NAME>ConfigVersion.cmake'
# Use:
# * PROJECT_VERSION
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
set(BGFX_COMPATIBILITY SameMajorVersion)
else()
set(BGFX_COMPATIBILITY SameMinorVersion)
endif()
write_basic_package_version_file(
"${version_config}"
VERSION ${PROJECT_VERSION}
COMPATIBILITY ${BGFX_COMPATIBILITY}
)
# Configure '<PROJECT-NAME>Config.cmake'
# Use variables:
# * TARGETS_EXPORT_NAME
# * PROJECT_NAME
configure_package_config_file(
"cmake/Config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${config_install_dir}"
)
install(FILES ${BGFX_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/licences/${PROJECT_NAME})
install( TARGETS bgfx
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
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
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()
if (BGFX_CONFIG_RENDERER_WEBGPU)
install( TARGETS webgpu
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()
# install headers (this should be done as a target probably... ^)
install( DIRECTORY ${BX_DIR}/include/bx ${BX_DIR}/include/compat ${BX_DIR}/include/tinystl DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install( DIRECTORY ${BIMG_DIR}/include/bimg DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install( DIRECTORY ${BGFX_DIR}/include/bgfx DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
# header required for shader compilation
install( FILES ${BGFX_DIR}/src/bgfx_shader.sh ${BGFX_DIR}/src/bgfx_compute.sh
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bgfx"
)
# install tools
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}" )
endif()
# install examples
if( BGFX_BUILD_EXAMPLES AND BGFX_INSTALL_EXAMPLES )
install( DIRECTORY ${BGFX_DIR}/examples/runtime/ DESTINATION examples )
foreach( EXAMPLE ${BGFX_EXAMPLES} )
install( TARGETS example-${EXAMPLE} DESTINATION examples )
endforeach()
endif()
# Config
# * <prefix>/lib/cmake/bgfx/bgfxConfig.cmake
# * <prefix>/lib/cmake/bgfx/bgfxConfigVersion.cmake
install(
FILES "${project_config}" "${version_config}"
DESTINATION "${config_install_dir}"
)
# Config
# * <prefix>/lib/cmake/bgfx/bgfxTargets.cmake
install(
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
)
endif()
# 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/>.
cmake_minimum_required(VERSION 3.10.2) # version supported by android studio
project(bgfx)
cmake_policy(SET CMP0054 NEW)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Makefile generators on apple need this flag to compile mixed objective/c++
if(APPLE AND NOT XCODE)
set(CMAKE_CXX_FLAGS "-ObjC++")
endif()
if(MSVC AND (MSVC_VERSION GREATER_EQUAL 1914))
add_compile_options("/Zc:__cplusplus")
endif()
include(CMakeDependentOption)
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)
cmake_dependent_option(BGFX_BUILD_TOOLS_BIN2C "Build bx binary to c converter." ON BGFX_BUILD_TOOLS OFF)
cmake_dependent_option(BGFX_BUILD_TOOLS_SHADER "Build bgfx shader tools." ON BGFX_BUILD_TOOLS OFF)
cmake_dependent_option(BGFX_BUILD_TOOLS_GEOMETRY "Build bgfx geometry tools." ON BGFX_BUILD_TOOLS OFF)
cmake_dependent_option(BGFX_BUILD_TOOLS_TEXTURE "Build bgfx texture tools." ON BGFX_BUILD_TOOLS OFF)
set(BGFX_TOOLS_PREFIX "" CACHE STRING "Prefix name to add to name of tools (to avoid clashes)")
option(BGFX_BUILD_EXAMPLES "Build bgfx examples." ON)
option(BGFX_BUILD_TESTS "Build bgfx tests." OFF)
option(BGFX_INSTALL "Create installation target." ON)
cmake_dependent_option(
BGFX_INSTALL_EXAMPLES "Install examples and their runtimes." OFF "BGFX_INSTALL;BGFX_BUILD_EXAMPLES" 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_property(CACHE BGFX_LIBRARY_TYPE PROPERTY STRINGS "STATIC" "SHARED")
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(BGFX_CMAKE_USER_SCRIPT "" CACHE STRING "Path to custom cmake script to include")
if(BGFX_CMAKE_USER_SCRIPT)
include(${BGFX_CMAKE_USER_SCRIPT})
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(BGFX_BUILD_TESTS)
enable_testing()
endif()
if(NOT BX_DIR)
set(BX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bx" CACHE STRING "Location of bx.")
elseif(NOT IS_ABSOLUTE "${BX_DIR}")
get_filename_component(BX_DIR "${BX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
if(NOT BIMG_DIR)
set(BIMG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bimg" CACHE STRING "Location of bimg.")
elseif(NOT IS_ABSOLUTE "${BIMG_DIR}")
get_filename_component(BIMG_DIR "${BIMG_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
if(NOT BGFX_DIR)
set(BGFX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bgfx" CACHE STRING "Location of bgfx.")
elseif(NOT IS_ABSOLUTE "${BGFX_DIR}")
get_filename_component(BGFX_DIR "${BGFX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
file(TO_CMAKE_PATH "${BX_DIR}" BX_DIR)
file(TO_CMAKE_PATH "${BIMG_DIR}" BIMG_DIR)
file(TO_CMAKE_PATH "${BGFX_DIR}" BGFX_DIR)
# sets project version from api ver / git rev
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.cmake)
if(BGFX_BUILD_TOOLS AND BGFX_CUSTOM_TARGETS)
add_custom_target(tools)
set_target_properties(tools PROPERTIES FOLDER "bgfx/tools")
endif()
if(BGFX_INSTALL)
include(GNUInstallDirs)
# Layout. This works for all platforms:
# * <prefix>/lib*/cmake/<PROJECT-NAME>
# * <prefix>/lib*/
# * <prefix>/include/
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
# Configuration
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")
endif()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bx)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bimg)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfx)
if(BGFX_INSTALL)
# Include module with fuction 'write_basic_package_version_file'
include(CMakePackageConfigHelpers)
# Configure '<PROJECT-NAME>ConfigVersion.cmake'
# Use:
# * PROJECT_VERSION
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
set(BGFX_COMPATIBILITY SameMajorVersion)
else()
set(BGFX_COMPATIBILITY SameMinorVersion)
endif()
write_basic_package_version_file("${version_config}" VERSION ${PROJECT_VERSION} COMPATIBILITY ${BGFX_COMPATIBILITY})
# Configure '<PROJECT-NAME>Config.cmake'
# Use variables:
# * TARGETS_EXPORT_NAME
# * PROJECT_NAME
# * BGFX_CMAKE_USER_SCRIPT_PRESENT
# * BGFX_CMAKE_USER_SCRIPT_INSTALL_NAME
if(BGFX_CMAKE_USER_SCRIPT STREQUAL "")
set(BGFX_CMAKE_USER_SCRIPT_PRESENT OFF)
set(BGFX_CMAKE_USER_SCRIPT_INSTALL_NAME "NOT-USED")
else()
set(BGFX_CMAKE_USER_SCRIPT_PRESENT ON)
get_filename_component(BGFX_CMAKE_USER_SCRIPT_INSTALL_NAME ${BGFX_CMAKE_USER_SCRIPT} NAME)
endif()
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in" "${project_config}"
INSTALL_DESTINATION "${config_install_dir}"
)
install(FILES ${BGFX_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/licences/${PROJECT_NAME})
# install headers (this should be done as a target probably... ^)
install(DIRECTORY ${BX_DIR}/include/bx ${BX_DIR}/include/compat ${BX_DIR}/include/tinystl
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(DIRECTORY ${BIMG_DIR}/include/bimg DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(DIRECTORY ${BGFX_DIR}/include/bgfx DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
# header required for shader compilation
install(FILES ${BGFX_DIR}/src/bgfx_shader.sh ${BGFX_DIR}/src/bgfx_compute.sh
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bgfx"
)
# install tools
if(BGFX_CMAKE_USER_SCRIPT)
install(FILES ${BGFX_CMAKE_USER_SCRIPT} DESTINATION "${config_install_dir}")
endif()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfxToolUtils.cmake DESTINATION "${config_install_dir}")
# Config
# * <prefix>/lib/cmake/bgfx/bgfxConfig.cmake
# * <prefix>/lib/cmake/bgfx/bgfxConfigVersion.cmake
install(FILES "${project_config}" "${version_config}" DESTINATION "${config_install_dir}")
# Config
# * <prefix>/lib/cmake/bgfx/bgfxTargets.cmake
install(EXPORT "${TARGETS_EXPORT_NAME}" NAMESPACE "${namespace}" DESTINATION "${config_install_dir}")
endif()

143
README.md
View File

@@ -1,37 +1,146 @@
bgfx.cmake
===================
# bgfx.cmake
[![Build Status](https://github.com/bkaradzic/bgfx.cmake/workflows/Release/badge.svg)](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
-------------
## 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.
## 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 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
-------------
## 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?
-------------
## Added cmake commands
bgfx.cmake will install `bgfxToolUtils.cmake` which has useful cmake functions for using bgfx's tools:
### `bgfx_compile_binary_to_header`
Add a build rule for a binary file to the generated build system using bin2c.
```cmake
bgfx_compile_binary_to_header(
INPUT_FILE filename
OUTPUT_FILE filename
ARRAY_NAME name
)
```
This defines a bin2c command to generate a specified `OUTPUT_FILE` header with an array `ARRAY_NAME` with the binary representation of a `INPUT_FILE` file.
Adding these `INPUT_FILE` as source files to a target will run `bin2c` at build time and they will rebuild if either the contents of the `INPUT_FILE` change.
#### Examples: Generating an image as a header
```cmake
bgfx_compile_binary_to_header(
INPUT_FILE image.png
OUTPUT_FILE ${CMAKE_BINARY_DIR}/include/generated/images/image.png.h
)
add_library(myLib image.png)
target_include_directories(myLib ${CMAKE_BINARY_DIR}/include/generated/images)
```
```cpp
// main.cpp
#include <image.png.h>
```
### `bgfx_compile_texture`
Add a build rule for a texture to the generated build system be compiled using texturec.
```cmake
bgfx_compile_texture(
FILE filename
OUTPUT filename
[FORMAT format]
[QUALITY default|fastest|highest]
[MIPS]
[MIPSKIP N]
[NORMALMAP]
[EQUIRECT]
[STRIP]
[SDF]
[REF alpha]
[IQA]
[PMA]
[LINEAR]
[MAX max size]
[RADIANCE model]
[AS extension]
)
```
### `bgfx_compile_shader_to_header`
Add a build rule for a `*.sc` shader to the generated build system using shaderc.
```cmake
bgfx_compile_shader_to_header(
TYPE VERTEX|FRAGMENT|COMPUTE
SHADERS filenames
VARYING_DEF filename
OUTPUT_DIR directory
)
```
This defines a shaderc command to generate headers for a number of `TYPE` shaders with `SHADERS` files and `VARYING_DEF` file in the `OUTPUT_DIR` directory. There will be one generated shader for each supported rendering API on this current platform according to the `BGFX_EMBEDDED_SHADER` macro in `bgfx/embedded_shader.h`.
The generated headers will have names in the format of `${SHADERS}.${RENDERING_API}.bin.h` where `RENDERING_API` can be `glsl`, `essl`, `spv`, `dx9`, `dx11` and `mtl` depending on the availability of the platform.
Adding these `SHADERS` as source files to a target will run `shaderc` at build time and they will rebuild if either the contents of the `SHADERS` or the `VARYING_DEF` change.
#### Examples: Generating shaders as headers
```cmake
bgfx_compile_shader_to_header(
TYPE VERTEX
SHADERS vs.sc
VARYING_DEF varying.def.sc
OUTPUT_DIR ${CMAKE_BINARY_DIR}/include/generated/shaders
)
bgfx_compile_shader_to_header(
TYPE FRAGMENT
SHADERS fs.sc
VARYING_DEF ${CMAKE_SOURCE_DIR}/varying.def.sc
OUTPUT_DIR ${CMAKE_BINARY_DIR}/include/generated/shaders
)
add_library(myLib main.cpp vs.sc fs.sc)
target_include_directories(myLib ${CMAKE_BINARY_DIR}/include/generated/shaders)
```
```cpp
// main.cpp
#include <vs.sc.glsl.bin.h>
#include <vs.sc.essl.bin.h>
#include <vs.sc.spv.bin.h>
#include <fs.sc.glsl.bin.h>
#include <fs.sc.essl.bin.h>
#include <fs.sc.spv.bin.h>
#if defined(_WIN32)
#include <vs.sc.dx9.bin.h>
#include <vs.sc.dx11.bin.h>
#include <fs.sc.dx9.bin.h>
#include <fs.sc.dx11.bin.h>
#endif // defined(_WIN32)
#if __APPLE__
#include <vs.sc.mtl.bin.h>
#include <fs.sc.mtl.bin.h>
#endif // __APPLE__
const bgfx::EmbeddedShader k_vs = BGFX_EMBEDDED_SHADER(vs);
const bgfx::EmbeddedShader k_fs = BGFX_EMBEDDED_SHADER(fs);
```
## 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

Submodule bgfx updated: 73db386165...e2c5b1d3e1

2
bimg

Submodule bimg updated: 6693de0e50...ec02df824a

2
bx

Submodule bx updated: c7fc7b4ac6...96748d9a58

View File

@@ -1,28 +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-codec )
return()
endif()
file(
GLOB
ASTC_CODEC_SOURCES
${BIMG_DIR}/3rdparty/astc-codec/src/decoder/*.cc
${BIMG_DIR}/3rdparty/astc-codec/src/decoder/*.h
)
add_library( astc-codec STATIC ${ASTC_CODEC_SOURCES} )
target_include_directories( astc-codec
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" )

View File

@@ -1,21 +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 dear-imgui )
return()
endif()
file( GLOB dear_IMGUI_SOURCES ${BGFX_DIR}/3rdparty/dear-imgui/*.cpp ${BGFX_DIR}/3rdparty/dear-imgui/*.h ${BGFX_DIR}/3rdparty/dear-imgui/*.inl )
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" )

View File

@@ -1,32 +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 fcpp )
return()
endif()
file( GLOB FCPP_SOURCES ${BGFX_DIR}/3rdparty/fcpp/*.c ${BGFX_DIR}/3rdparty/fcpp/*.h )
add_library( fcpp STATIC ${FCPP_SOURCES} )
target_include_directories( fcpp PUBLIC ${BGFX_DIR}/3rdparty/fcpp )
target_compile_definitions( fcpp
PRIVATE
NINCLUDE=64
NWORK=65536
NBUFF=65536
OLD_PREPROCESSOR=0
)
if( MSVC )
set_target_properties( fcpp PROPERTIES COMPILE_FLAGS "/W0" )
endif()
set_target_properties( fcpp PROPERTIES FOLDER "bgfx/3rdparty" )
set_source_files_properties( ${BGFX_DIR}/3rdparty/fcpp/usecpp.c PROPERTIES HEADER_FILE_ONLY ON )

View File

@@ -1,85 +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 glsl-optimizer )
return()
endif()
set( GLSL-OPTIMIZER_INCLUDES
${BGFX_DIR}/3rdparty/glsl-optimizer/include
${BGFX_DIR}/3rdparty/glsl-optimizer/src/mesa
${BGFX_DIR}/3rdparty/glsl-optimizer/src/mapi
${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl
${BGFX_DIR}/3rdparty/glsl-optimizer/src
)
# glsl-optimizer makes UBSan segfault for whatever reason
# We already know that it's full of UB anyway... so just don't build it with UBSan
string(REPLACE "-fsanitize=undefined" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" )
string(REPLACE "-fsanitize=undefined" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
# glcpp
file( GLOB GLCPP_SOURCES ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/glcpp/*.c ${BGFX_DIR}/3rdparty/glsl-optimizer/src/util/*.c )
add_library( glcpp ${GLCPP_SOURCES} )
target_include_directories( glcpp PUBLIC ${GLSL-OPTIMIZER_INCLUDES} )
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
target_compile_options( glcpp PRIVATE "-fno-strict-aliasing")
endif()
if( MSVC )
set_target_properties( glcpp PROPERTIES COMPILE_FLAGS "/W0" )
endif()
set_target_properties( glcpp PROPERTIES FOLDER "bgfx/3rdparty" )
# mesa
file( GLOB MESA_SOURCES ${BGFX_DIR}/3rdparty/glsl-optimizer/src/mesa/program/*.c ${BGFX_DIR}/3rdparty/glsl-optimizer/src/mesa/main/*.c )
add_library( mesa ${MESA_SOURCES} )
target_include_directories( mesa PUBLIC ${GLSL-OPTIMIZER_INCLUDES} )
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
target_compile_options( mesa PRIVATE "-fno-strict-aliasing")
endif()
if( MSVC )
set_target_properties( mesa PROPERTIES COMPILE_FLAGS "/W0" )
endif()
set_target_properties( mesa PROPERTIES FOLDER "bgfx/3rdparty" )
# glsl-optimizer
file( GLOB GLSL-OPTIMIZER_SOURCES ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/*.cpp ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/*.c )
file( GLOB GLSL-OPTIMIZER_SOURCES_REMOVE ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/main.cpp ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/builtin_stubs.cpp )
list( REMOVE_ITEM GLSL-OPTIMIZER_SOURCES ${GLSL-OPTIMIZER_SOURCES_REMOVE} )
add_library( glsl-optimizer ${GLSL-OPTIMIZER_SOURCES} )
target_link_libraries( glsl-optimizer glcpp mesa )
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options( glsl-optimizer
PRIVATE
-fno-strict-aliasing
-Wno-implicit-fallthrough
-Wno-parentheses
-Wno-sign-compare
-Wno-unused-function
-Wno-unused-parameter
)
endif()
if( MSVC )
set_target_properties( glsl-optimizer PROPERTIES COMPILE_FLAGS "/W0" )
target_compile_definitions( glsl-optimizer
PRIVATE
__STDC__
__STDC_VERSION__=199901L
strdup=_strdup
alloca=_alloca
isascii=__isascii
)
elseif(APPLE)
target_compile_options( glsl-optimizer
PRIVATE
-Wno-deprecated-register
)
endif()
set_target_properties( glsl-optimizer PROPERTIES FOLDER "bgfx/3rdparty" )

View File

@@ -1,98 +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 glslang )
return()
endif()
file( GLOB GLSLANG_SOURCES
${BGFX_DIR}/3rdparty/glslang/glslang/GenericCodeGen/*.cpp
${BGFX_DIR}/3rdparty/glslang/glslang/MachineIndependent/*.cpp
${BGFX_DIR}/3rdparty/glslang/glslang/MachineIndependent/preprocessor/*.cpp
${BGFX_DIR}/3rdparty/glslang/glslang/HLSL/*.cpp
${BGFX_DIR}/3rdparty/glslang/hlsl/*.cpp
${BGFX_DIR}/3rdparty/glslang/SPIRV/*.cpp
${BGFX_DIR}/3rdparty/glslang/OGLCompilersDLL/*.cpp
)
if( WIN32 )
list( APPEND GLSLANG_SOURCES ${BGFX_DIR}/3rdparty/glslang/glslang/OSDependent/Windows/ossource.cpp )
else()
list( APPEND GLSLANG_SOURCES ${BGFX_DIR}/3rdparty/glslang/glslang/OSDependent/Unix/ossource.cpp )
endif()
add_library( glslang STATIC EXCLUDE_FROM_ALL ${GLSLANG_SOURCES} )
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
PRIVATE
${BGFX_DIR}/3rdparty
)
set_target_properties( glslang PROPERTIES FOLDER "bgfx/3rdparty" )
if( MSVC )
target_compile_options( glslang PRIVATE
"/wd4005"
"/wd4065"
"/wd4100"
"/wd4127"
"/wd4189"
"/wd4244"
"/wd4310"
"/wd4389"
"/wd4456"
"/wd4457"
"/wd4458"
"/wd4702"
"/wd4715"
"/wd4838"
)
else()
target_compile_options( glslang PRIVATE
"-Wno-ignored-qualifiers"
"-Wno-implicit-fallthrough"
"-Wno-missing-field-initializers"
"-Wno-reorder"
"-Wno-return-type"
"-Wno-shadow"
"-Wno-sign-compare"
"-Wno-switch"
"-Wno-undef"
"-Wno-unknown-pragmas"
"-Wno-unused-function"
"-Wno-unused-parameter"
"-Wno-unused-variable"
"-fno-strict-aliasing"
)
endif()
if( APPLE )
target_compile_options( glslang PRIVATE
"-Wno-c++11-extensions"
"-Wno-unused-const-variable"
"-Wno-deprecated-register"
)
endif()
if( UNIX AND NOT APPLE )
target_compile_options( glslang PRIVATE
"-Wno-unused-but-set-variable"
)
endif()
target_compile_definitions( glslang PRIVATE
ENABLE_OPT=1
ENABLE_HLSL=1
)

View File

@@ -1,36 +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 nvtt )
return()
endif()
file(
GLOB
NVTT_SOURCES
${BIMG_DIR}/3rdparty/nvtt/bc6h/*.cpp
${BIMG_DIR}/3rdparty/nvtt/bc6h/*.h
${BIMG_DIR}/3rdparty/nvtt/bc7/*.cpp
${BIMG_DIR}/3rdparty/nvtt/bc7/*.h
${BIMG_DIR}/3rdparty/nvtt/nvcore/*.h
${BIMG_DIR}/3rdparty/nvtt/nvcore/*.inl
${BIMG_DIR}/3rdparty/nvtt/nvmath/*.cpp
${BIMG_DIR}/3rdparty/nvtt/nvmath/*.h
${BIMG_DIR}/3rdparty/nvtt/*.cpp
${BIMG_DIR}/3rdparty/nvtt/*.h
)
add_library( nvtt STATIC ${NVTT_SOURCES} )
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 )

View File

@@ -1,38 +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 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" )

View File

@@ -1,58 +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 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

@@ -1,9 +0,0 @@
if( TARGET tinyexr )
return()
endif()
file( GLOB_RECURSE TINYEXR_SOURCES ${BIMG_DIR}/3rdparty/tinyexr/*.c ${BIMG_DIR}/3rdparty/tinyexr/*.h )
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" )

View File

@@ -1,31 +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 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" )

View File

@@ -1,4 +1,36 @@
@PACKAGE_INIT@
if(@BGFX_CMAKE_USER_SCRIPT_PRESENT@)
include("${CMAKE_CURRENT_LIST_DIR}/@BGFX_CMAKE_USER_SCRIPT_INSTALL_NAME@")
endif()
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@)
macro(_bgfx_crosscompile_use_host_tool TOOL_NAME)
if(NOT TARGET bgfx::${TOOL_NAME})
find_program(
${TOOL_NAME}_EXECUTABLE REQUIRED
NAMES bgfx-${TOOL_NAME} ${TOOL_NAME}
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::${TOOL_NAME} IMPORTED)
set_target_properties(bgfx::${TOOL_NAME} PROPERTIES IMPORTED_LOCATION "${${TOOL_NAME}_EXECUTABLE}")
endif()
endmacro()
_bgfx_crosscompile_use_host_tool(bin2c)
_bgfx_crosscompile_use_host_tool(texturec)
_bgfx_crosscompile_use_host_tool(shaderc)
_bgfx_crosscompile_use_host_tool(texturev)
_bgfx_crosscompile_use_host_tool(geometryv)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake")
check_required_components("@PROJECT_NAME@")

View File

@@ -1,128 +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/>.
# To prevent this warning: https://cmake.org/cmake/help/git-stage/policy/CMP0072.html
if(POLICY CMP0072)
cmake_policy(SET CMP0072 NEW)
endif()
# Ensure the directory exists
if( NOT IS_DIRECTORY ${BGFX_DIR} )
message( SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}" )
return()
endif()
if(NOT APPLE)
set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.cpp)
else()
set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.mm)
endif()
# Grab the bgfx source files
file( GLOB BGFX_SOURCES ${BGFX_DIR}/src/*.cpp ${BGFX_DIR}/src/*.mm ${BGFX_DIR}/src/*.h ${BGFX_DIR}/include/bgfx/*.h ${BGFX_DIR}/include/bgfx/c99/*.h )
if(BGFX_AMALGAMATED)
set(BGFX_NOBUILD ${BGFX_SOURCES})
list(REMOVE_ITEM BGFX_NOBUILD ${BGFX_AMALGAMATED_SOURCE})
foreach(BGFX_SRC ${BGFX_NOBUILD})
set_source_files_properties( ${BGFX_SRC} PROPERTIES HEADER_FILE_ONLY ON )
endforeach()
else()
# Do not build using amalgamated sources
set_source_files_properties( ${BGFX_DIR}/src/amalgamated.cpp PROPERTIES HEADER_FILE_ONLY ON )
set_source_files_properties( ${BGFX_DIR}/src/amalgamated.mm PROPERTIES HEADER_FILE_ONLY ON )
endif()
# Create the bgfx target
add_library( bgfx ${BGFX_LIBRARY_TYPE} ${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)
target_compile_definitions( bgfx PRIVATE BGFX_CONFIG_DEBUG=1)
endif()
if( NOT ${BGFX_OPENGL_VERSION} STREQUAL "" )
target_compile_definitions( bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION=${BGFX_OPENGL_VERSION} )
endif()
if( NOT ${BGFX_OPENGLES_VERSION} STREQUAL "" )
target_compile_definitions( bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION=${BGFX_OPENGLES_VERSION} )
endif()
# Special Visual Studio Flags
if( MSVC )
target_compile_definitions( bgfx PRIVATE "_CRT_SECURE_NO_WARNINGS" )
endif()
# Includes
target_include_directories( bgfx
PRIVATE
${BGFX_DIR}/3rdparty
${BGFX_DIR}/3rdparty/dxsdk/include
${BGFX_DIR}/3rdparty/khronos
PUBLIC
$<BUILD_INTERFACE:${BGFX_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
# bgfx depends on bx and bimg
target_link_libraries( bgfx PRIVATE bx bimg )
# Frameworks required on iOS, tvOS and macOS
if( ${CMAKE_SYSTEM_NAME} MATCHES iOS|tvOS )
target_link_libraries (bgfx PUBLIC "-framework OpenGLES -framework Metal -framework UIKit -framework CoreGraphics -framework QuartzCore")
elseif( APPLE )
find_library( COCOA_LIBRARY Cocoa )
find_library( METAL_LIBRARY Metal )
find_library( QUARTZCORE_LIBRARY QuartzCore )
mark_as_advanced( COCOA_LIBRARY )
mark_as_advanced( METAL_LIBRARY )
mark_as_advanced( QUARTZCORE_LIBRARY )
target_link_libraries( bgfx PUBLIC ${COCOA_LIBRARY} ${METAL_LIBRARY} ${QUARTZCORE_LIBRARY} )
endif()
if( UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID )
find_package(X11 REQUIRED)
find_package(OpenGL REQUIRED)
#The following commented libraries are linked by bx
#find_package(Threads REQUIRED)
#find_library(LIBRT_LIBRARIES rt)
#find_library(LIBDL_LIBRARIES dl)
target_link_libraries( bgfx PUBLIC ${X11_LIBRARIES} ${OPENGL_LIBRARIES})
endif()
# Exclude mm files if not on OS X
if( NOT APPLE )
set_source_files_properties( ${BGFX_DIR}/src/glcontext_eagl.mm PROPERTIES HEADER_FILE_ONLY ON )
set_source_files_properties( ${BGFX_DIR}/src/glcontext_nsgl.mm PROPERTIES HEADER_FILE_ONLY ON )
set_source_files_properties( ${BGFX_DIR}/src/renderer_mtl.mm PROPERTIES HEADER_FILE_ONLY ON )
endif()
# Exclude glx context on non-unix
if( NOT UNIX OR APPLE )
set_source_files_properties( ${BGFX_DIR}/src/glcontext_glx.cpp PROPERTIES HEADER_FILE_ONLY ON )
endif()
# Put in a "bgfx" folder in Visual Studio
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()

26
cmake/bgfx/3rdparty/dear-imgui.cmake vendored Normal file
View File

@@ -0,0 +1,26 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BGFX_DIR})
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
return()
endif()
if(NOT DEAR_IMGUI_LIBRARIES)
file(
GLOB #
DEAR_IMGUI_SOURCES #
${BGFX_DIR}/3rdparty/dear-imgui/*.cpp #
${BGFX_DIR}/3rdparty/dear-imgui/*.h #
${BGFX_DIR}/3rdparty/dear-imgui/*.inl #
)
set(DEAR_IMGUI_INCLUDE_DIR ${BGFX_DIR}/3rdparty)
endif()

64
cmake/bgfx/3rdparty/fcpp.cmake vendored Normal file
View File

@@ -0,0 +1,64 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BGFX_DIR})
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
return()
endif()
set(FCPP_DIR ${BGFX_DIR}/3rdparty/fcpp)
file(
GLOB
FCPP_SOURCES
${FCPP_DIR}/*.h
${FCPP_DIR}/cpp1.c
${FCPP_DIR}/cpp2.c
${FCPP_DIR}/cpp3.c
${FCPP_DIR}/cpp4.c
${FCPP_DIR}/cpp5.c
${FCPP_DIR}/cpp6.c
${FCPP_DIR}/cpp6.c
)
add_library(fcpp STATIC ${FCPP_SOURCES})
target_compile_definitions(
fcpp
PRIVATE "NINCLUDE=64" #
"NWORK=65536" #
"NBUFF=65536" #
"OLD_PREPROCESSOR=0" #
# "MSG_PREFIX=\"Preprocessor: \"" #
)
# Put in a "bgfx" folder in Visual Studio
set_target_properties(fcpp PROPERTIES FOLDER "bgfx")
target_include_directories(fcpp PUBLIC ${FCPP_DIR})
if(MSVC)
target_compile_options(
fcpp
PRIVATE
"/wd4055" # warning C4055: 'type cast': from data pointer 'void *' to function pointer 'void (__cdecl *)(char *,void *)'
"/wd4244" # warning C4244: '=': conversion from 'const flex_int32_t' to 'YY_CHAR', possible loss of data
"/wd4701" # warning C4701: potentially uninitialized local variable 'lower' used
"/wd4706" # warning C4706: assignment within conditional expression
)
else()
target_compile_options(
fcpp
PRIVATE -Wno-implicit-fallthrough #
-Wno-incompatible-pointer-types #
-Wno-parentheses-equality #
)
endif()

246
cmake/bgfx/3rdparty/glsl-optimizer.cmake vendored Normal file
View File

@@ -0,0 +1,246 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BGFX_DIR})
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
return()
endif()
set(GLSL_OPTIMIZER ${BGFX_DIR}/3rdparty/glsl-optimizer)
file(
GLOB
GLSL_OPTIMIZER_SOURCES
${GLSL_OPTIMIZER}/src/glsl/glcpp/glcpp.h
${GLSL_OPTIMIZER}/src/glsl/glcpp/glcpp-lex.c
${GLSL_OPTIMIZER}/src/glsl/glcpp/glcpp-parse.c
${GLSL_OPTIMIZER}/src/glsl/glcpp/glcpp-parse.h
${GLSL_OPTIMIZER}/src/glsl/glcpp/pp.c
${GLSL_OPTIMIZER}/src/glsl/ast.h
${GLSL_OPTIMIZER}/src/glsl/ast_array_index.cpp
${GLSL_OPTIMIZER}/src/glsl/ast_expr.cpp
${GLSL_OPTIMIZER}/src/glsl/ast_function.cpp
${GLSL_OPTIMIZER}/src/glsl/ast_to_hir.cpp
${GLSL_OPTIMIZER}/src/glsl/ast_type.cpp
${GLSL_OPTIMIZER}/src/glsl/builtin_functions.cpp
${GLSL_OPTIMIZER}/src/glsl/builtin_type_macros.h
${GLSL_OPTIMIZER}/src/glsl/builtin_types.cpp
${GLSL_OPTIMIZER}/src/glsl/builtin_variables.cpp
${GLSL_OPTIMIZER}/src/glsl/glsl_lexer.cpp
${GLSL_OPTIMIZER}/src/glsl/glsl_optimizer.cpp
${GLSL_OPTIMIZER}/src/glsl/glsl_optimizer.h
${GLSL_OPTIMIZER}/src/glsl/glsl_parser.cpp
${GLSL_OPTIMIZER}/src/glsl/glsl_parser.h
${GLSL_OPTIMIZER}/src/glsl/glsl_parser_extras.cpp
${GLSL_OPTIMIZER}/src/glsl/glsl_parser_extras.h
${GLSL_OPTIMIZER}/src/glsl/glsl_symbol_table.cpp
${GLSL_OPTIMIZER}/src/glsl/glsl_symbol_table.h
${GLSL_OPTIMIZER}/src/glsl/glsl_types.cpp
${GLSL_OPTIMIZER}/src/glsl/glsl_types.h
${GLSL_OPTIMIZER}/src/glsl/hir_field_selection.cpp
${GLSL_OPTIMIZER}/src/glsl/ir.cpp
${GLSL_OPTIMIZER}/src/glsl/ir.h
${GLSL_OPTIMIZER}/src/glsl/ir_basic_block.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_basic_block.h
${GLSL_OPTIMIZER}/src/glsl/ir_builder.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_builder.h
${GLSL_OPTIMIZER}/src/glsl/ir_clone.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_constant_expression.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_equals.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_expression_flattening.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_expression_flattening.h
${GLSL_OPTIMIZER}/src/glsl/ir_function.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_function_can_inline.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_function_detect_recursion.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_function_inlining.h
${GLSL_OPTIMIZER}/src/glsl/ir_hierarchical_visitor.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_hierarchical_visitor.h
${GLSL_OPTIMIZER}/src/glsl/ir_hv_accept.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_import_prototypes.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_optimization.h
${GLSL_OPTIMIZER}/src/glsl/ir_print_glsl_visitor.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_print_glsl_visitor.h
${GLSL_OPTIMIZER}/src/glsl/ir_print_metal_visitor.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_print_metal_visitor.h
${GLSL_OPTIMIZER}/src/glsl/ir_print_visitor.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_print_visitor.h
${GLSL_OPTIMIZER}/src/glsl/ir_rvalue_visitor.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_rvalue_visitor.h
${GLSL_OPTIMIZER}/src/glsl/ir_stats.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_stats.h
${GLSL_OPTIMIZER}/src/glsl/ir_uniform.h
${GLSL_OPTIMIZER}/src/glsl/ir_unused_structs.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_unused_structs.h
${GLSL_OPTIMIZER}/src/glsl/ir_validate.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_variable_refcount.cpp
${GLSL_OPTIMIZER}/src/glsl/ir_variable_refcount.h
${GLSL_OPTIMIZER}/src/glsl/ir_visitor.h
${GLSL_OPTIMIZER}/src/glsl/link_atomics.cpp
${GLSL_OPTIMIZER}/src/glsl/link_functions.cpp
${GLSL_OPTIMIZER}/src/glsl/link_interface_blocks.cpp
${GLSL_OPTIMIZER}/src/glsl/link_uniform_block_active_visitor.cpp
${GLSL_OPTIMIZER}/src/glsl/link_uniform_block_active_visitor.h
${GLSL_OPTIMIZER}/src/glsl/link_uniform_blocks.cpp
${GLSL_OPTIMIZER}/src/glsl/link_uniform_initializers.cpp
${GLSL_OPTIMIZER}/src/glsl/link_uniforms.cpp
${GLSL_OPTIMIZER}/src/glsl/link_varyings.cpp
${GLSL_OPTIMIZER}/src/glsl/link_varyings.h
${GLSL_OPTIMIZER}/src/glsl/linker.cpp
${GLSL_OPTIMIZER}/src/glsl/linker.h
${GLSL_OPTIMIZER}/src/glsl/list.h
${GLSL_OPTIMIZER}/src/glsl/loop_analysis.cpp
${GLSL_OPTIMIZER}/src/glsl/loop_analysis.h
${GLSL_OPTIMIZER}/src/glsl/loop_controls.cpp
${GLSL_OPTIMIZER}/src/glsl/loop_unroll.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_clip_distance.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_discard.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_discard_flow.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_if_to_cond_assign.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_instructions.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_jumps.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_mat_op_to_vec.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_named_interface_blocks.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_noise.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_offset_array.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_output_reads.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_packed_varyings.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_packing_builtins.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_ubo_reference.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_variable_index_to_cond_assign.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_vec_index_to_cond_assign.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_vec_index_to_swizzle.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_vector.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_vector_insert.cpp
${GLSL_OPTIMIZER}/src/glsl/lower_vertex_id.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_algebraic.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_array_splitting.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_constant_folding.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_constant_propagation.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_constant_variable.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_copy_propagation.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_copy_propagation_elements.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_cse.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_dead_builtin_variables.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_dead_builtin_varyings.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_dead_code.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_dead_code_local.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_dead_functions.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_flatten_nested_if_blocks.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_flip_matrices.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_function_inlining.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_if_simplification.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_minmax.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_noop_swizzle.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_rebalance_tree.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_redundant_jumps.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_structure_splitting.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_swizzle_swizzle.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_tree_grafting.cpp
${GLSL_OPTIMIZER}/src/glsl/opt_vectorize.cpp
${GLSL_OPTIMIZER}/src/glsl/program.h
${GLSL_OPTIMIZER}/src/glsl/s_expression.cpp
${GLSL_OPTIMIZER}/src/glsl/s_expression.h
${GLSL_OPTIMIZER}/src/glsl/standalone_scaffolding.cpp
${GLSL_OPTIMIZER}/src/glsl/standalone_scaffolding.h
${GLSL_OPTIMIZER}/src/glsl/strtod.c
${GLSL_OPTIMIZER}/src/glsl/strtod.h
${GLSL_OPTIMIZER}/src/mesa/main/compiler.h
${GLSL_OPTIMIZER}/src/mesa/main/config.h
${GLSL_OPTIMIZER}/src/mesa/main/context.h
${GLSL_OPTIMIZER}/src/mesa/main/core.h
${GLSL_OPTIMIZER}/src/mesa/main/dd.h
${GLSL_OPTIMIZER}/src/mesa/main/errors.h
${GLSL_OPTIMIZER}/src/mesa/main/glheader.h
${GLSL_OPTIMIZER}/src/mesa/main/glminimal.h
${GLSL_OPTIMIZER}/src/mesa/main/imports.c
${GLSL_OPTIMIZER}/src/mesa/main/imports.h
${GLSL_OPTIMIZER}/src/mesa/main/macros.h
${GLSL_OPTIMIZER}/src/mesa/main/mtypes.h
${GLSL_OPTIMIZER}/src/mesa/main/simple_list.h
${GLSL_OPTIMIZER}/src/mesa/program/hash_table.h
${GLSL_OPTIMIZER}/src/mesa/program/prog_hash_table.c
${GLSL_OPTIMIZER}/src/mesa/program/prog_instruction.h
${GLSL_OPTIMIZER}/src/mesa/program/prog_parameter.h
${GLSL_OPTIMIZER}/src/mesa/program/prog_statevars.h
${GLSL_OPTIMIZER}/src/mesa/program/symbol_table.c
${GLSL_OPTIMIZER}/src/mesa/program/symbol_table.h
${GLSL_OPTIMIZER}/src/util/hash_table.c
${GLSL_OPTIMIZER}/src/util/hash_table.h
${GLSL_OPTIMIZER}/src/util/macros.h
${GLSL_OPTIMIZER}/src/util/ralloc.c
${GLSL_OPTIMIZER}/src/util/ralloc.h
)
add_library(glsl-optimizer STATIC ${GLSL_OPTIMIZER_SOURCES})
# Put in a "bgfx" folder in Visual Studio
set_target_properties(glsl-optimizer PROPERTIES FOLDER "bgfx")
target_include_directories(
glsl-optimizer
PUBLIC ${GLSL_OPTIMIZER}/include #
${GLSL_OPTIMIZER}/src/glsl #
PRIVATE ${GLSL_OPTIMIZER}/src #
${GLSL_OPTIMIZER}/src/mesa #
${GLSL_OPTIMIZER}/src/mapi #
)
if(MSVC)
target_compile_definitions(
glsl-optimizer
PRIVATE "__STDC__" #
"__STDC_VERSION__=199901L" #
"strdup=_strdup" #
"alloca=_alloca" #
"isascii=__isascii" #
)
target_compile_options(
glsl-optimizer
PRIVATE
"/wd4100" # error C4100: '' : unreferenced formal parameter
"/wd4127" # warning C4127: conditional expression is constant
"/wd4132" # warning C4132: 'deleted_key_value': const object should be initialized
"/wd4189" # warning C4189: 'interface_type': local variable is initialized but not referenced
"/wd4204" # warning C4204: nonstandard extension used: non-constant aggregate initializer
"/wd4244" # warning C4244: '=': conversion from 'const flex_int32_t' to 'YY_CHAR', possible loss of data
"/wd4389" # warning C4389: '!=': signed/unsigned mismatch
"/wd4245" # warning C4245: 'return': conversion from 'int' to 'unsigned int', signed/unsigned mismatch
"/wd4701" # warning C4701: potentially uninitialized local variable 'lower' used
"/wd4702" # warning C4702: unreachable code
"/wd4706" # warning C4706: assignment within conditional expression
"/wd4996" # warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup.
)
else()
target_compile_options(
glsl-optimizer
PRIVATE "-fno-strict-aliasing" # glsl-optimizer has bugs if strict aliasing is used.
#
"-Wno-implicit-fallthrough" #
"-Wno-parentheses" #
"-Wno-sign-compare" #
"-Wno-unused-function" #
"-Wno-unused-parameter" #
)
endif()
if(XCODE)
target_compile_options(
glsl-optimizer PRIVATE #
"-Wno-deprecated-register" #
)
endif()
if(MINGW)
target_compile_options(
glsl-optimizer PRIVATE #
"-Wno-misleading-indentation" #
)
endif()

63
cmake/bgfx/3rdparty/glslang.cmake vendored Normal file
View File

@@ -0,0 +1,63 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BGFX_DIR})
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
return()
endif()
set(GLSLANG ${BGFX_DIR}/3rdparty/glslang)
set(SPIRV_TOOLS ${BGFX_DIR}/3rdparty/spirv-tools)
file(
GLOB_RECURSE
GLSLANG_SOURCES
${GLSLANG}/glslang/*.cpp
${GLSLANG}/glslang/*.h
#
${GLSLANG}/hlsl/*.cpp
${GLSLANG}/hlsl/*.h
#
${GLSLANG}/SPIRV/*.cpp
${GLSLANG}/SPIRV/*.h
#
${GLSLANG}/OGLCompilersDLL/*.cpp
${GLSLANG}/OGLCompilersDLL/*.h
)
if(WIN32)
list(FILTER GLSLANG_SOURCES EXCLUDE REGEX "glslang/OSDependent/Unix/.*.cpp")
list(FILTER GLSLANG_SOURCES EXCLUDE REGEX "glslang/OSDependent/Unix/.*.h")
else()
list(FILTER GLSLANG_SOURCES EXCLUDE REGEX "glslang/OSDependent/Windows/.*.cpp")
list(FILTER GLSLANG_SOURCES EXCLUDE REGEX "glslang/OSDependent/Windows/.*.h")
endif()
add_library(glslang STATIC ${GLSLANG_SOURCES})
target_compile_definitions(
glslang
PRIVATE #
ENABLE_OPT=1 # spriv-tools
ENABLE_HLSL=1 #
)
# Put in a "bgfx" folder in Visual Studio
set_target_properties(glslang PROPERTIES FOLDER "bgfx")
target_include_directories(
glslang
PUBLIC ${GLSLANG} #
${GLSLANG}/glslang/Public #
PRIVATE ${GLSLANG}/.. #
${SPIRV_TOOLS}/include #
${SPIRV_TOOLS}/source #
)

View File

@@ -1,19 +1,25 @@
# 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 meshoptimizer )
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BGFX_DIR})
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
return()
endif()
file( GLOB MESHOPTIMIZER_SOURCES ${BGFX_DIR}/3rdparty/meshoptimizer/src/*.cpp ${BGFX_DIR}/3rdparty/meshoptimizer/src/*.h )
add_library( meshoptimizer STATIC ${MESHOPTIMIZER_SOURCES} )
target_include_directories( meshoptimizer PUBLIC ${BGFX_DIR}/3rdparty )
set_target_properties( meshoptimizer PROPERTIES FOLDER "bgfx/3rdparty" )
if(NOT MESHOPTIMIZER_LIBRARIES)
file(
GLOB #
MESHOPTIMIZER_SOURCES #
${BGFX_DIR}/3rdparty/meshoptimizer/src/*.cpp #
${BGFX_DIR}/3rdparty/meshoptimizer/src/*.h #
)
set(MESHOPTIMIZER_INCLUDE_DIR ${BGFX_DIR}/3rdparty)
endif()

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

@@ -0,0 +1,60 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BGFX_DIR})
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
return()
endif()
set(SPIRV_CROSS ${BGFX_DIR}/3rdparty/spirv-cross)
file(
GLOB
SPIRV_CROSS_SOURCES
#
${SPIRV_CROSS}/spirv.hpp
${SPIRV_CROSS}/spirv_cfg.cpp
${SPIRV_CROSS}/spirv_cfg.hpp
${SPIRV_CROSS}/spirv_common.hpp
${SPIRV_CROSS}/spirv_cpp.cpp
${SPIRV_CROSS}/spirv_cpp.hpp
${SPIRV_CROSS}/spirv_cross.cpp
${SPIRV_CROSS}/spirv_cross.hpp
${SPIRV_CROSS}/spirv_cross_parsed_ir.cpp
${SPIRV_CROSS}/spirv_cross_parsed_ir.hpp
${SPIRV_CROSS}/spirv_cross_util.cpp
${SPIRV_CROSS}/spirv_cross_util.hpp
${SPIRV_CROSS}/spirv_glsl.cpp
${SPIRV_CROSS}/spirv_glsl.hpp
${SPIRV_CROSS}/spirv_hlsl.cpp
${SPIRV_CROSS}/spirv_hlsl.hpp
${SPIRV_CROSS}/spirv_msl.cpp
${SPIRV_CROSS}/spirv_msl.hpp
${SPIRV_CROSS}/spirv_parser.cpp
${SPIRV_CROSS}/spirv_parser.hpp
${SPIRV_CROSS}/spirv_reflect.cpp
${SPIRV_CROSS}/spirv_reflect.hpp
)
add_library(spirv-cross STATIC ${SPIRV_CROSS_SOURCES})
target_compile_definitions(spirv-cross PRIVATE SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
# Put in a "bgfx" folder in Visual Studio
set_target_properties(spirv-cross PROPERTIES FOLDER "bgfx")
target_include_directories(
spirv-cross #
PUBLIC #
${SPIRV_CROSS} #
PRIVATE #
${SPIRV_CROSS}/include #
)

146
cmake/bgfx/3rdparty/spirv-opt.cmake vendored Normal file
View File

@@ -0,0 +1,146 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BGFX_DIR})
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
return()
endif()
set(SPIRV_HEADERS ${BGFX_DIR}/3rdparty/spirv-headers)
set(SPIRV_TOOLS ${BGFX_DIR}/3rdparty/spirv-tools)
file(
GLOB
SPIRV_OPT_SOURCES
# libspirv
${SPIRV_TOOLS}/source/opt/*.cpp
${SPIRV_TOOLS}/source/opt/*.h
${SPIRV_TOOLS}/source/reduce/*.cpp
${SPIRV_TOOLS}/source/reduce/*.h
${SPIRV_TOOLS}/source/assembly_grammar.cpp
${SPIRV_TOOLS}/source/assembly_grammar.h
${SPIRV_TOOLS}/source/binary.cpp
${SPIRV_TOOLS}/source/binary.h
${SPIRV_TOOLS}/source/cfa.h
${SPIRV_TOOLS}/source/diagnostic.cpp
${SPIRV_TOOLS}/source/diagnostic.h
${SPIRV_TOOLS}/source/disassemble.cpp
${SPIRV_TOOLS}/source/disassemble.h
${SPIRV_TOOLS}/source/enum_set.h
${SPIRV_TOOLS}/source/enum_string_mapping.cpp
${SPIRV_TOOLS}/source/enum_string_mapping.h
${SPIRV_TOOLS}/source/ext_inst.cpp
${SPIRV_TOOLS}/source/ext_inst.h
${SPIRV_TOOLS}/source/extensions.cpp
${SPIRV_TOOLS}/source/extensions.h
${SPIRV_TOOLS}/source/instruction.h
${SPIRV_TOOLS}/source/latest_version_glsl_std_450_header.h
${SPIRV_TOOLS}/source/latest_version_opencl_std_header.h
${SPIRV_TOOLS}/source/latest_version_spirv_header.h
${SPIRV_TOOLS}/source/libspirv.cpp
${SPIRV_TOOLS}/source/macro.h
${SPIRV_TOOLS}/source/name_mapper.cpp
${SPIRV_TOOLS}/source/name_mapper.h
${SPIRV_TOOLS}/source/opcode.cpp
${SPIRV_TOOLS}/source/opcode.h
${SPIRV_TOOLS}/source/operand.cpp
${SPIRV_TOOLS}/source/operand.h
${SPIRV_TOOLS}/source/parsed_operand.cpp
${SPIRV_TOOLS}/source/parsed_operand.h
${SPIRV_TOOLS}/source/print.cpp
${SPIRV_TOOLS}/source/print.h
${SPIRV_TOOLS}/source/software_version.cpp
${SPIRV_TOOLS}/source/spirv_constant.h
${SPIRV_TOOLS}/source/spirv_definition.h
${SPIRV_TOOLS}/source/spirv_endian.cpp
${SPIRV_TOOLS}/source/spirv_endian.h
${SPIRV_TOOLS}/source/spirv_optimizer_options.cpp
${SPIRV_TOOLS}/source/spirv_reducer_options.cpp
${SPIRV_TOOLS}/source/spirv_target_env.cpp
${SPIRV_TOOLS}/source/spirv_target_env.h
${SPIRV_TOOLS}/source/spirv_validator_options.cpp
${SPIRV_TOOLS}/source/spirv_validator_options.h
${SPIRV_TOOLS}/source/table.cpp
${SPIRV_TOOLS}/source/table.h
${SPIRV_TOOLS}/source/text.cpp
${SPIRV_TOOLS}/source/text.h
${SPIRV_TOOLS}/source/text_handler.cpp
${SPIRV_TOOLS}/source/text_handler.h
${SPIRV_TOOLS}/source/util/bit_vector.cpp
${SPIRV_TOOLS}/source/util/bit_vector.h
${SPIRV_TOOLS}/source/util/bitutils.h
${SPIRV_TOOLS}/source/util/hex_float.h
${SPIRV_TOOLS}/source/util/parse_number.cpp
${SPIRV_TOOLS}/source/util/parse_number.h
${SPIRV_TOOLS}/source/util/string_utils.cpp
${SPIRV_TOOLS}/source/util/string_utils.h
${SPIRV_TOOLS}/source/util/timer.h
${SPIRV_TOOLS}/source/val/basic_block.cpp
${SPIRV_TOOLS}/source/val/construct.cpp
${SPIRV_TOOLS}/source/val/decoration.h
${SPIRV_TOOLS}/source/val/function.cpp
${SPIRV_TOOLS}/source/val/instruction.cpp
${SPIRV_TOOLS}/source/val/validate.cpp
${SPIRV_TOOLS}/source/val/validate.h
${SPIRV_TOOLS}/source/val/validate_adjacency.cpp
${SPIRV_TOOLS}/source/val/validate_annotation.cpp
${SPIRV_TOOLS}/source/val/validate_arithmetics.cpp
${SPIRV_TOOLS}/source/val/validate_atomics.cpp
${SPIRV_TOOLS}/source/val/validate_barriers.cpp
${SPIRV_TOOLS}/source/val/validate_bitwise.cpp
${SPIRV_TOOLS}/source/val/validate_builtins.cpp
${SPIRV_TOOLS}/source/val/validate_capability.cpp
${SPIRV_TOOLS}/source/val/validate_cfg.cpp
${SPIRV_TOOLS}/source/val/validate_composites.cpp
${SPIRV_TOOLS}/source/val/validate_constants.cpp
${SPIRV_TOOLS}/source/val/validate_conversion.cpp
${SPIRV_TOOLS}/source/val/validate_debug.cpp
${SPIRV_TOOLS}/source/val/validate_decorations.cpp
${SPIRV_TOOLS}/source/val/validate_derivatives.cpp
${SPIRV_TOOLS}/source/val/validate_execution_limitations.cpp
${SPIRV_TOOLS}/source/val/validate_extensions.cpp
${SPIRV_TOOLS}/source/val/validate_function.cpp
${SPIRV_TOOLS}/source/val/validate_id.cpp
${SPIRV_TOOLS}/source/val/validate_image.cpp
${SPIRV_TOOLS}/source/val/validate_instruction.cpp
${SPIRV_TOOLS}/source/val/validate_interfaces.cpp
${SPIRV_TOOLS}/source/val/validate_layout.cpp
${SPIRV_TOOLS}/source/val/validate_literals.cpp
${SPIRV_TOOLS}/source/val/validate_logicals.cpp
${SPIRV_TOOLS}/source/val/validate_memory.cpp
${SPIRV_TOOLS}/source/val/validate_memory_semantics.cpp
${SPIRV_TOOLS}/source/val/validate_mesh_shading.cpp
${SPIRV_TOOLS}/source/val/validate_misc.cpp
${SPIRV_TOOLS}/source/val/validate_mode_setting.cpp
${SPIRV_TOOLS}/source/val/validate_non_uniform.cpp
${SPIRV_TOOLS}/source/val/validate_primitives.cpp
${SPIRV_TOOLS}/source/val/validate_ray_query.cpp
${SPIRV_TOOLS}/source/val/validate_ray_tracing.cpp
${SPIRV_TOOLS}/source/val/validate_ray_tracing_reorder.cpp
${SPIRV_TOOLS}/source/val/validate_scopes.cpp
${SPIRV_TOOLS}/source/val/validate_small_type_uses.cpp
${SPIRV_TOOLS}/source/val/validate_type.cpp
${SPIRV_TOOLS}/source/val/validation_state.cpp
)
add_library(spirv-opt STATIC ${SPIRV_OPT_SOURCES})
# Put in a "bgfx" folder in Visual Studio
set_target_properties(spirv-opt PROPERTIES FOLDER "bgfx")
target_include_directories(
spirv-opt
PUBLIC ${SPIRV_TOOLS}/include #
PRIVATE ${SPIRV_TOOLS} #
${SPIRV_TOOLS}/include/generated #
${SPIRV_TOOLS}/source #
${SPIRV_HEADERS}/include #
)

40
cmake/bgfx/3rdparty/webgpu.cmake vendored Normal file
View File

@@ -0,0 +1,40 @@
# 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>
)
# These properties are not allowed on interface
# set_target_properties(webgpu PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
if(BGFX_INSTALL AND BGFX_CONFIG_RENDERER_WEBGPU)
install(
TARGETS webgpu
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()

33
cmake/bgfx/CMakeLists.txt Normal file
View File

@@ -0,0 +1,33 @@
# 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/>.
include(bgfx.cmake)
include(3rdparty/meshoptimizer.cmake)
include(3rdparty/dear-imgui.cmake)
include(shared.cmake)
include(examples.cmake)
if(BGFX_BUILD_TOOLS_TEXTURE)
include(texturev.cmake)
endif()
if(BGFX_BUILD_TOOLS_GEOMETRY)
include(geometryc.cmake)
include(geometryv.cmake)
endif()
if(BGFX_BUILD_TOOLS_SHADER)
include(3rdparty/spirv-opt.cmake)
include(3rdparty/spirv-cross.cmake)
include(3rdparty/glslang.cmake)
include(3rdparty/glsl-optimizer.cmake)
include(3rdparty/fcpp.cmake)
include(3rdparty/webgpu.cmake)
include(shaderc.cmake)
endif()

220
cmake/bgfx/bgfx.cmake Executable file
View File

@@ -0,0 +1,220 @@
# 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/>.
# To prevent this warning: https://cmake.org/cmake/help/git-stage/policy/CMP0072.html
if(POLICY CMP0072)
cmake_policy(SET CMP0072 NEW)
endif()
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BGFX_DIR})
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
return()
endif()
if(NOT APPLE)
set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.cpp)
else()
set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.mm)
endif()
# Grab the bgfx source files
file(
GLOB
BGFX_SOURCES
${BGFX_DIR}/src/*.cpp
${BGFX_DIR}/src/*.mm
${BGFX_DIR}/src/*.h
${BGFX_DIR}/include/bgfx/*.h
${BGFX_DIR}/include/bgfx/c99/*.h
)
if(BGFX_AMALGAMATED)
set(BGFX_NOBUILD ${BGFX_SOURCES})
list(REMOVE_ITEM BGFX_NOBUILD ${BGFX_AMALGAMATED_SOURCE})
foreach(BGFX_SRC ${BGFX_NOBUILD})
set_source_files_properties(${BGFX_SRC} PROPERTIES HEADER_FILE_ONLY ON)
endforeach()
else()
# Do not build using amalgamated sources
set_source_files_properties(${BGFX_DIR}/src/amalgamated.cpp PROPERTIES HEADER_FILE_ONLY ON)
set_source_files_properties(${BGFX_DIR}/src/amalgamated.mm PROPERTIES HEADER_FILE_ONLY ON)
endif()
# Create the bgfx target
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)
include(${CMAKE_CURRENT_LIST_DIR}/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()
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()
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")
endif()
# Add debug config required in bx headers since bx is private
target_compile_definitions(
bgfx
PUBLIC
"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/khronos
PUBLIC $<BUILD_INTERFACE:${BGFX_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
# bgfx depends on bx and bimg
target_link_libraries(bgfx PRIVATE bx bimg)
# Frameworks required on iOS, tvOS and macOS
if(${CMAKE_SYSTEM_NAME} MATCHES iOS|tvOS)
target_link_libraries(
bgfx
PUBLIC
"-framework OpenGLES -framework Metal -framework UIKit -framework CoreGraphics -framework QuartzCore -framework IOKit -framework CoreFoundation"
)
elseif(APPLE)
find_library(COCOA_LIBRARY Cocoa)
find_library(METAL_LIBRARY Metal)
find_library(QUARTZCORE_LIBRARY QuartzCore)
find_library(IOKIT_LIBRARY IOKit)
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
mark_as_advanced(COCOA_LIBRARY)
mark_as_advanced(METAL_LIBRARY)
mark_as_advanced(QUARTZCORE_LIBRARY)
mark_as_advanced(IOKIT_LIBRARY)
mark_as_advanced(COREFOUNDATION_LIBRARY)
target_link_libraries(
bgfx PUBLIC ${COCOA_LIBRARY} ${METAL_LIBRARY} ${QUARTZCORE_LIBRARY} ${IOKIT_LIBRARY} ${COREFOUNDATION_LIBRARY}
)
endif()
if(UNIX
AND NOT APPLE
AND NOT EMSCRIPTEN
AND NOT ANDROID
)
find_package(X11 REQUIRED)
find_package(OpenGL REQUIRED)
#The following commented libraries are linked by bx
#find_package(Threads REQUIRED)
#find_library(LIBRT_LIBRARIES rt)
#find_library(LIBDL_LIBRARIES dl)
target_link_libraries(bgfx PUBLIC ${X11_LIBRARIES} ${OPENGL_LIBRARIES})
endif()
# Exclude mm files if not on OS X
if(NOT APPLE)
set_source_files_properties(${BGFX_DIR}/src/glcontext_eagl.mm PROPERTIES HEADER_FILE_ONLY ON)
set_source_files_properties(${BGFX_DIR}/src/glcontext_nsgl.mm PROPERTIES HEADER_FILE_ONLY ON)
set_source_files_properties(${BGFX_DIR}/src/renderer_mtl.mm PROPERTIES HEADER_FILE_ONLY ON)
endif()
# Exclude glx context on non-unix
if(NOT UNIX OR APPLE)
set_source_files_properties(${BGFX_DIR}/src/glcontext_glx.cpp PROPERTIES HEADER_FILE_ONLY ON)
endif()
# Put in a "bgfx" folder in Visual Studio
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()
if(BGFX_INSTALL)
install(
TARGETS bgfx
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()

355
cmake/bgfx/examples.cmake Executable file
View File

@@ -0,0 +1,355 @@
# 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/>.
include(CMakeParseArguments)
include(${CMAKE_CURRENT_LIST_DIR}/util/ConfigureDebugging.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../bgfxToolUtils.cmake)
function(add_bgfx_shader FILE FOLDER)
get_filename_component(FILENAME "${FILE}" NAME_WE)
string(SUBSTRING "${FILENAME}" 0 2 TYPE)
if("${TYPE}" STREQUAL "fs")
set(TYPE "FRAGMENT")
elseif("${TYPE}" STREQUAL "vs")
set(TYPE "VERTEX")
elseif("${TYPE}" STREQUAL "cs")
set(TYPE "COMPUTE")
else()
set(TYPE "")
endif()
if(NOT "${TYPE}" STREQUAL "")
set(COMMON FILE ${FILE} ${TYPE} INCLUDES ${BGFX_DIR}/src)
set(OUTPUTS "")
set(OUTPUTS_PRETTY "")
if(WIN32)
# dx9
if(NOT "${TYPE}" STREQUAL "COMPUTE")
set(DX9_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/dx9/${FILENAME}.bin)
_bgfx_shaderc_parse(
DX9 ${COMMON} WINDOWS
PROFILE s_3_0
O 3
OUTPUT ${DX9_OUTPUT}
)
list(APPEND OUTPUTS "DX9")
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX9, ")
endif()
# dx11
set(DX11_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/dx11/${FILENAME}.bin)
if(NOT "${TYPE}" STREQUAL "COMPUTE")
_bgfx_shaderc_parse(
DX11 ${COMMON} WINDOWS
PROFILE s_5_0
O 3
OUTPUT ${DX11_OUTPUT}
)
else()
_bgfx_shaderc_parse(
DX11 ${COMMON} WINDOWS
PROFILE s_5_0
O 1
OUTPUT ${DX11_OUTPUT}
)
endif()
list(APPEND OUTPUTS "DX11")
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX11, ")
endif()
if(APPLE)
# metal
set(METAL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/metal/${FILENAME}.bin)
_bgfx_shaderc_parse(METAL ${COMMON} OSX PROFILE metal OUTPUT ${METAL_OUTPUT})
list(APPEND OUTPUTS "METAL")
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}Metal, ")
endif()
# essl
if(NOT "${TYPE}" STREQUAL "COMPUTE")
set(ESSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/essl/${FILENAME}.bin)
_bgfx_shaderc_parse(ESSL ${COMMON} ANDROID OUTPUT ${ESSL_OUTPUT})
list(APPEND OUTPUTS "ESSL")
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}ESSL, ")
endif()
# glsl
set(GLSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/glsl/${FILENAME}.bin)
if(NOT "${TYPE}" STREQUAL "COMPUTE")
_bgfx_shaderc_parse(GLSL ${COMMON} LINUX PROFILE 140 OUTPUT ${GLSL_OUTPUT})
else()
_bgfx_shaderc_parse(GLSL ${COMMON} LINUX PROFILE 430 OUTPUT ${GLSL_OUTPUT})
endif()
list(APPEND OUTPUTS "GLSL")
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}GLSL, ")
# spirv
if(NOT "${TYPE}" STREQUAL "COMPUTE")
set(SPIRV_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/spirv/${FILENAME}.bin)
_bgfx_shaderc_parse(SPIRV ${COMMON} LINUX PROFILE spirv OUTPUT ${SPIRV_OUTPUT})
list(APPEND OUTPUTS "SPIRV")
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}SPIRV")
set(OUTPUT_FILES "")
set(COMMANDS "")
endif()
foreach(OUT ${OUTPUTS})
list(APPEND OUTPUT_FILES ${${OUT}_OUTPUT})
list(APPEND COMMANDS COMMAND "bgfx::shaderc" ${${OUT}})
get_filename_component(OUT_DIR ${${OUT}_OUTPUT} DIRECTORY)
file(MAKE_DIRECTORY ${OUT_DIR})
endforeach()
file(RELATIVE_PATH PRINT_NAME ${BGFX_DIR}/examples ${FILE})
add_custom_command(
MAIN_DEPENDENCY ${FILE} OUTPUT ${OUTPUT_FILES} ${COMMANDS}
COMMENT "Compiling shader ${PRINT_NAME} for ${OUTPUTS_PRETTY}"
)
endif()
endfunction()
function(add_example ARG_NAME)
# Parse arguments
cmake_parse_arguments(ARG "COMMON" "" "DIRECTORIES;SOURCES" ${ARGN})
# Get all source files
list(APPEND ARG_DIRECTORIES "${BGFX_DIR}/examples/${ARG_NAME}")
set(SOURCES "")
set(SHADERS "")
foreach(DIR ${ARG_DIRECTORIES})
if(APPLE)
file(GLOB GLOB_SOURCES ${DIR}/*.mm)
list(APPEND SOURCES ${GLOB_SOURCES})
endif()
file(GLOB GLOB_SOURCES ${DIR}/*.c ${DIR}/*.cpp ${DIR}/*.h ${DIR}/*.sc)
list(APPEND SOURCES ${GLOB_SOURCES})
file(GLOB GLOB_SHADERS ${DIR}/*.sc)
list(APPEND SHADERS ${GLOB_SHADERS})
endforeach()
# Add target
if(ARG_COMMON)
add_library(
example-${ARG_NAME} STATIC EXCLUDE_FROM_ALL ${SOURCES} ${DEAR_IMGUI_SOURCES} ${MESHOPTIMIZER_SOURCES}
)
target_include_directories(
example-${ARG_NAME} PUBLIC ${BGFX_DIR}/examples/common ${DEAR_IMGUI_INCLUDE_DIR}
${MESHOPTIMIZER_INCLUDE_DIR}
)
target_link_libraries(
example-${ARG_NAME} PUBLIC bgfx bx bimg bimg_decode ${DEAR_IMGUI_LIBRARIES} ${MESHOPTIMIZER_LIBRARIES}
)
if(BGFX_WITH_GLFW)
find_package(glfw3 REQUIRED)
target_link_libraries(example-${ARG_NAME} PUBLIC glfw)
target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_GLFW)
elseif(BGFX_WITH_SDL)
find_package(SDL2 REQUIRED)
target_link_libraries(example-${ARG_NAME} PUBLIC ${SDL2_LIBRARIES})
target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_SDL)
elseif(UNIX AND NOT APPLE AND NOT ANDROID)
target_link_libraries(example-${ARG_NAME} PUBLIC X11)
endif()
if(ANDROID)
target_include_directories(example-${ARG_NAME} PRIVATE ${BGFX_DIR}/3rdparty/native_app_glue)
target_link_libraries(example-${ARG_NAME} INTERFACE android EGL GLESv2)
endif()
if(BGFX_BUILD_EXAMPLES)
if(IOS OR WIN32)
# on iOS we need to build a bundle so have to copy the data rather than symlink
# and on windows we can't create symlinks
add_custom_command(
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E copy_directory ${BGFX_DIR}/examples/runtime/
$<TARGET_FILE_DIR:example-${ARG_NAME}>
)
else()
# For everything else symlink some folders into our output directory
add_custom_command(
TARGET example-${ARG_NAME}
COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/font
$<TARGET_FILE_DIR:example-${ARG_NAME}>/font
)
add_custom_command(
TARGET example-${ARG_NAME}
COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/images
$<TARGET_FILE_DIR:example-${ARG_NAME}>/images
)
add_custom_command(
TARGET example-${ARG_NAME}
COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/meshes
$<TARGET_FILE_DIR:example-${ARG_NAME}>/meshes
)
add_custom_command(
TARGET example-${ARG_NAME}
COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/shaders
$<TARGET_FILE_DIR:example-${ARG_NAME}>/shaders
)
add_custom_command(
TARGET example-${ARG_NAME}
COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/text
$<TARGET_FILE_DIR:example-${ARG_NAME}>/text
)
add_custom_command(
TARGET example-${ARG_NAME}
COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/textures
$<TARGET_FILE_DIR:example-${ARG_NAME}>/textures
)
endif()
endif()
else()
if(ANDROID)
add_library(example-${ARG_NAME} SHARED ${SOURCES})
else()
add_executable(example-${ARG_NAME} WIN32 ${SOURCES})
endif()
if(NOT BGFX_INSTALL_EXAMPLES)
set_property(TARGET example-${ARG_NAME} PROPERTY EXCLUDE_FROM_ALL ON)
endif()
target_link_libraries(example-${ARG_NAME} PUBLIC example-common)
configure_debugging(example-${ARG_NAME} WORKING_DIR ${BGFX_DIR}/examples/runtime)
if(MSVC)
set_target_properties(example-${ARG_NAME} PROPERTIES LINK_FLAGS "/ENTRY:\"mainCRTStartup\"")
endif()
if(BGFX_CUSTOM_TARGETS)
add_dependencies(examples example-${ARG_NAME})
endif()
if(IOS)
set_target_properties(
example-${ARG_NAME}
PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER example-${ARG_NAME}
MACOSX_BUNDLE_BUNDLE_VERSION 0
MACOSX_BUNDLE_SHORT_VERSION_STRING 0
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
)
endif()
endif()
target_compile_definitions(
example-${ARG_NAME}
PRIVATE "-D_CRT_SECURE_NO_WARNINGS" #
"-D__STDC_FORMAT_MACROS" #
"-DENTRY_CONFIG_IMPLEMENT_MAIN=1" #
)
# Configure shaders
if(NOT ARG_COMMON
AND NOT IOS
AND NOT EMSCRIPTEN
AND NOT ANDROID
)
foreach(SHADER ${SHADERS})
add_bgfx_shader(${SHADER} ${ARG_NAME})
endforeach()
source_group("Shader Files" FILES ${SHADERS})
endif()
if(NOT ARG_COMMON AND EMSCRIPTEN)
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
set_target_properties(example-${ARG_NAME} PROPERTIES FOLDER "bgfx/examples")
endfunction()
# Build all examples target
if(BGFX_CUSTOM_TARGETS)
add_custom_target(examples)
set_target_properties(examples PROPERTIES FOLDER "bgfx/examples")
endif()
# Add common library for examples
add_example(
common
COMMON
DIRECTORIES
${BGFX_DIR}/examples/common/debugdraw
${BGFX_DIR}/examples/common/entry
${BGFX_DIR}/examples/common/font
${BGFX_DIR}/examples/common/imgui
${BGFX_DIR}/examples/common/nanovg
${BGFX_DIR}/examples/common/ps
)
# Only add examples if set, otherwise we still need exmaples common for tools
if(BGFX_BUILD_EXAMPLES)
# Add examples
set(BGFX_EXAMPLES
00-helloworld
01-cubes
02-metaballs
03-raymarch
04-mesh
05-instancing
06-bump
07-callback
08-update
09-hdr
10-font
11-fontsdf
12-lod
13-stencil
14-shadowvolumes
15-shadowmaps-simple
16-shadowmaps
17-drawstress
18-ibl
19-oit
20-nanovg
# 21-deferred
22-windows
23-vectordisplay
24-nbody
25-c99
26-occlusion
27-terrain
28-wireframe
29-debugdraw
30-picking
31-rsm
32-particles
33-pom
34-mvs
35-dynamic
36-sky
# 37-gpudrivenrendering
38-bloom
39-assao
40-svt
# 41-tess
42-bunnylod
43-denoise
44-sss
45-bokeh
46-fsr
47-pixelformats
)
foreach(EXAMPLE ${BGFX_EXAMPLES})
add_example(${EXAMPLE})
endforeach()
if(BGFX_INSTALL_EXAMPLES)
install(DIRECTORY ${BGFX_DIR}/examples/runtime/ DESTINATION examples)
foreach(EXAMPLE ${BGFX_EXAMPLES})
install(TARGETS example-${EXAMPLE} DESTINATION examples)
endforeach()
endif()
endif()

View File

@@ -0,0 +1,43 @@
# 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/>.
# Grab the geometryc source files
file(
GLOB_RECURSE
GEOMETRYC_SOURCES #
${BGFX_DIR}/tools/geometryc/*.cpp #
${BGFX_DIR}/tools/geometryc/*.h #
#
${MESHOPTIMIZER_SOURCES}
)
add_executable(geometryc ${GEOMETRYC_SOURCES})
target_include_directories(geometryc PRIVATE ${MESHOPTIMIZER_INCLUDE_DIR})
target_link_libraries(geometryc PRIVATE bx bgfx-vertexlayout ${MESHOPTIMIZER_LIBRARIES})
target_compile_definitions(geometryc PRIVATE "-D_CRT_SECURE_NO_WARNINGS")
set_target_properties(
geometryc PROPERTIES FOLDER "bgfx/tools" #
OUTPUT_NAME ${BGFX_TOOLS_PREFIX}geometryc #
)
if(BGFX_BUILD_TOOLS_GEOMETRY)
add_executable(bgfx::geometryc ALIAS geometryc)
if(BGFX_CUSTOM_TARGETS)
add_dependencies(tools geometryc)
endif()
endif()
if(IOS)
set_target_properties(geometryc PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER geometryc)
endif()
if(BGFX_INSTALL)
install(TARGETS geometryc EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()

View File

@@ -0,0 +1,42 @@
# 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/>.
# Grab the geometryv source files
file(GLOB_RECURSE GEOMETRYV_SOURCES #
${BGFX_DIR}/tools/geometryv/*
)
if(ANDROID)
add_library(geometryv SHARED ${GEOMETRYV_SOURCES})
else()
add_executable(geometryv ${GEOMETRYV_SOURCES})
endif()
target_link_libraries(geometryv PRIVATE example-common)
set_target_properties(
geometryv PROPERTIES FOLDER "bgfx/tools" #
OUTPUT_NAME ${BGFX_TOOLS_PREFIX}geometryv #
)
if(BGFX_BUILD_TOOLS_GEOMETRY AND BGFX_CUSTOM_TARGETS)
add_dependencies(tools geometryv)
endif()
if(ANDROID)
set_property(TARGET geometryv PROPERTY PREFIX "")
elseif(EMSCRIPTEN)
target_link_options(geometryv PRIVATE -sMAX_WEBGL_VERSION=2)
elseif(IOS)
set_target_properties(geometryv PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER geometryv)
endif()
if(BGFX_INSTALL)
install(TARGETS geometryv EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()

68
cmake/bgfx/shaderc.cmake Normal file
View File

@@ -0,0 +1,68 @@
# 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/>.
# Grab the shaderc source files
file(
GLOB
SHADERC_SOURCES #
${BGFX_DIR}/tools/shaderc/*.cpp #
${BGFX_DIR}/tools/shaderc/*.h #
${BGFX_DIR}/src/shader* #
)
add_executable(shaderc ${SHADERC_SOURCES})
target_link_libraries(
shaderc
PRIVATE bx
bgfx-vertexlayout
fcpp
glslang
glsl-optimizer
spirv-opt
spirv-cross
)
target_link_libraries(
shaderc
PRIVATE bx
bimg
bgfx-vertexlayout
fcpp
glslang
glsl-optimizer
spirv-opt
spirv-cross
webgpu
)
if(BGFX_AMALGAMATED)
target_link_libraries(shaderc PRIVATE bgfx-shader)
endif()
set_target_properties(
shaderc PROPERTIES FOLDER "bgfx/tools" #
OUTPUT_NAME ${BGFX_TOOLS_PREFIX}shaderc #
)
if(BGFX_BUILD_TOOLS_SHADER)
add_executable(bgfx::shaderc ALIAS shaderc)
if(BGFX_CUSTOM_TARGETS)
add_dependencies(tools shaderc)
endif()
endif()
if(ANDROID)
target_link_libraries(shaderc PRIVATE log)
elseif(IOS)
set_target_properties(shaderc PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER shaderc)
endif()
if(BGFX_INSTALL)
install(TARGETS shaderc EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()

29
cmake/bgfx/shared.cmake Normal file
View File

@@ -0,0 +1,29 @@
# 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/>.
add_library(bgfx-vertexlayout INTERFACE)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/generated/vertexlayout.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/generated/vertexlayout.cpp
)
target_sources(bgfx-vertexlayout INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/generated/vertexlayout.cpp)
target_include_directories(bgfx-vertexlayout INTERFACE ${BGFX_DIR}/include)
add_library(bgfx-shader INTERFACE)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/generated/shader.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/generated/shader.cpp)
target_sources(bgfx-shader INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/generated/shader.cpp)
target_include_directories(bgfx-shader INTERFACE ${BGFX_DIR}/include)
# Frameworks required on OS X
if(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
find_library(COCOA_LIBRARY Cocoa)
mark_as_advanced(COCOA_LIBRARY)
target_link_libraries(bgfx-vertexlayout INTERFACE ${COCOA_LIBRARY})
endif()

42
cmake/bgfx/texturev.cmake Normal file
View File

@@ -0,0 +1,42 @@
# 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/>.
# Grab the texturev source files
file(GLOB_RECURSE TEXTUREV_SOURCES #
${BGFX_DIR}/tools/texturev/*
)
if(ANDROID)
add_library(texturev SHARED ${TEXTUREV_SOURCES})
else()
add_executable(texturev ${TEXTUREV_SOURCES})
endif()
target_link_libraries(texturev PRIVATE example-common)
set_target_properties(
texturev PROPERTIES FOLDER "bgfx/tools" #
OUTPUT_NAME ${BGFX_TOOLS_PREFIX}texturev #
)
if(BGFX_BUILD_TOOLS_TEXTURE AND BGFX_CUSTOM_TARGETS)
add_dependencies(tools texturev)
endif()
if(ANDROID)
set_property(TARGET texturev PROPERTY PREFIX "")
elseif(EMSCRIPTEN)
target_link_options(texturev PRIVATE -sMAX_WEBGL_VERSION=2)
elseif(IOS)
set_target_properties(texturev PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER texturev)
endif()
if(BGFX_INSTALL)
install(TARGETS texturev EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()

View File

@@ -0,0 +1,157 @@
# ConfigureDebugging.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/>.
# configure_debugging( TARGET [OPTIONS...] )
#
# Configures the debugging settings in visual studio.
# Results in a no-op on non visual studio builds.
# Must be called in the same cmake file as the add_executable command.
#
# See OPTIONS variable in the function for supported user settings.
# See CONFIGS variable in the function for supported cmake configurations.
# See PROCESSORS variable in the function for supported architecture configurations.
#
# All variables can be set with one of the following formats:
#
# (OPTION)
# (OPTION)_(CONFIG)
# (OPTION)_(CONFIG)_(ARCH)
# (OPTION)_(ARCH)
#
# So, some examples (variables should be all caps):
#
# WORKING_DIR
# WORKING_DIR_X64
# WORKING_DIR_RELEASE_WIN32
# WORKING_DIR_X64
#
# An example of a full command:
#
# configure_debugging(target COMMAND "node.exe" COMMAND_X64 "node64.exe" WORKING_DIR ${CMAKE_SOURCE_DIR} DEBUGGER_ENV "PATH=%PATH%\\;$(ProjectDir)")
include(CMakeParseArguments)
function(configure_debugging ARG_TARGET)
if(MSVC)
# Visual Studio Options
set(OPTIONS
WORKING_DIR
LocalDebuggerWorkingDirectory
DEBUGGER_ENV
LocalDebuggerEnvironment
COMMAND
LocalDebuggerCommand
COMMAND_ARGS
LocalDebuggerCommandArguments
)
# Valid Configurations
set(CONFIGS Debug Release MinSizeRel RelWithDebInfo)
# Processors
set(PROCESSORS Win32 x64)
# Begin hackery
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(ACTIVE_PROCESSOR "x64")
else()
set(ACTIVE_PROCESSOR "Win32")
endif()
# Fix issues with semicolons, thx cmake
foreach(ARG ${ARGN})
string(REPLACE ";" "\\\\\\\\\\\\\\;" RES "${ARG}")
list(APPEND ARGS "${RES}")
endforeach()
# Build options for cmake_parse_arguments, result is ONE_ARG variable
set(ODD ON)
foreach(OPTION ${OPTIONS})
if(ODD)
set(ARG ${OPTION})
list(APPEND ONE_ARG ${ARG})
foreach(CONFIG ${CONFIGS})
string(TOUPPER ${CONFIG} CONFIG)
list(APPEND ONE_ARG ${ARG}_${CONFIG})
foreach(PROCESSOR ${PROCESSORS})
string(TOUPPER ${PROCESSOR} PROCESSOR)
list(APPEND ONE_ARG ${ARG}_${CONFIG}_${PROCESSOR})
endforeach()
endforeach()
foreach(PROCESSOR ${PROCESSORS})
string(TOUPPER ${PROCESSOR} PROCESSOR)
list(APPEND ONE_ARG ${ARG}_${PROCESSOR})
endforeach()
set(ODD OFF)
else()
set(ODD ON)
endif()
endforeach()
cmake_parse_arguments(ARG "" "${ONE_ARG}" "" ${ARGS})
# Parse options, fills in all variables of format ARG_(ARG)_(CONFIG)_(PROCESSOR), for example ARG_WORKING_DIR_DEBUG_X64
set(ODD ON)
foreach(OPTION ${OPTIONS})
if(ODD)
set(ARG ${OPTION})
foreach(CONFIG ${CONFIGS})
string(TOUPPER ${CONFIG} CONFIG_CAP)
if("${ARG_${ARG}_${CONFIG_CAP}}" STREQUAL "")
set(ARG_${ARG}_${CONFIG_CAP} ${ARG_${ARG}})
endif()
foreach(PROCESSOR ${PROCESSORS})
string(TOUPPER ${PROCESSOR} PROCESSOR_CAP)
if("${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "")
if("${ARG_${ARG}_${PROCESSOR_CAP}}" STREQUAL "")
set(ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP} ${ARG_${ARG}_${CONFIG_CAP}})
else()
set(ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP} ${ARG_${ARG}_${PROCESSOR_CAP}})
endif()
endif()
if(NOT "${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "")
endif()
endforeach()
endforeach()
set(ODD OFF)
else()
set(ODD ON)
endif()
endforeach()
# Create string to put in proj.vcxproj.user file
set(RESULT
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"
)
foreach(CONFIG ${CONFIGS})
string(TOUPPER ${CONFIG} CONFIG_CAPS)
foreach(PROCESSOR ${PROCESSORS})
if("${PROCESSOR}" STREQUAL "${ACTIVE_PROCESSOR}")
string(TOUPPER ${PROCESSOR} PROCESSOR_CAPS)
set(RESULT
"${RESULT}\n <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='${CONFIG}|${PROCESSOR}'\">"
)
set(ODD ON)
foreach(OPTION ${OPTIONS})
if(ODD)
set(ARG ${OPTION})
set(ODD OFF)
else()
set(VALUE ${ARG_${ARG}_${CONFIG_CAPS}_${PROCESSOR_CAPS}})
if(NOT "${VALUE}" STREQUAL "")
set(RESULT "${RESULT}\n <${OPTION}>${VALUE}</${OPTION}>")
endif()
set(ODD ON)
endif()
endforeach()
set(RESULT "${RESULT}\n </PropertyGroup>")
endif()
endforeach()
endforeach()
set(RESULT "${RESULT}\n</Project>")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET}.vcxproj.user "${RESULT}")
endif()
endfunction()

621
cmake/bgfxToolUtils.cmake Normal file
View File

@@ -0,0 +1,621 @@
# _bgfx_bin2c_parse(
# INPUT_FILE filename
# OUTPUT_FILE filename
# ARRAY_NAME name
# )
# Usage: bin2c -f <in> -o <out> -n <name>
function(_bgfx_bin2c_parse ARG_OUT)
set(options "")
set(oneValueArgs INPUT_FILE;OUTPUT_FILE;ARRAY_NAME)
set(multiValueArgs "")
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
set(CLI "")
# -f
if(ARG_INPUT_FILE)
list(APPEND CLI "-f" "${ARG_INPUT_FILE}")
else()
message(SEND_ERROR "Call to _bgfx_bin2c_parse() must have an INPUT_FILE")
endif()
# -o
if(ARG_OUTPUT_FILE)
list(APPEND CLI "-o" "${ARG_OUTPUT_FILE}")
else()
message(SEND_ERROR "Call to _bgfx_bin2c_parse() must have an OUTPUT_FILE")
endif()
# -n
if(ARG_ARRAY_NAME)
list(APPEND CLI "-n" "${ARG_ARRAY_NAME}")
else()
message(SEND_ERROR "Call to _bgfx_bin2c_parse() must have an ARRAY_NAME")
endif()
set(${ARG_OUT} ${CLI} PARENT_SCOPE)
endfunction()
# bgfx_compile_binary_to_header(
# INPUT_FILE filename
# OUTPUT_FILE filename
# ARRAY_NAME name
# )
#
function(bgfx_compile_binary_to_header)
set(options "")
set(oneValueArgs INPUT_FILE;OUTPUT_FILE;ARRAY_NAME)
set(multiValueArgs "")
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
_bgfx_bin2c_parse(
CLI
INPUT_FILE ${ARG_INPUT_FILE}
OUTPUT_FILE ${ARG_OUTPUT_FILE}
ARRAY_NAME ${ARG_ARRAY_NAME}
)
add_custom_command(
OUTPUT ${ARG_OUTPUT_FILE} #
COMMAND bgfx::bin2c ${CLI} #
MAIN_DEPENDENCY ${ARG_INPUT_FILE} #
)
endfunction()
# _bgfx_texturec_parse(
# FILE filename
# OUTPUT filename
# [FORMAT format]
# [QUALITY default|fastest|highest]
# [MIPS]
# [MIPSKIP N]
# [NORMALMAP]
# [EQUIRECT]
# [STRIP]
# [SDF]
# [REF alpha]
# [IQA]
# [PMA]
# [LINEAR]
# [MAX max size]
# [RADIANCE model]
# [AS extension]
# )
function(_bgfx_texturec_parse ARG_OUT)
cmake_parse_arguments(
ARG #
"MIPS;NORMALMAP;EQUIRECT;STRIP;SDF;IQA;PMA;LINEAR" #
"FILE;OUTPUT;FORMAT;QUALITY;MIPSKIP;REF;MAX;RADIANCE;AS" #
"" #
${ARGN} #
)
set(CLI "")
# -f
if(ARG_FILE)
list(APPEND CLI "-f" "${ARG_FILE}")
endif()
# -o
if(ARG_OUTPUT)
list(APPEND CLI "-o" "${ARG_OUTPUT}")
endif()
# -t
if(ARG_FORMAT)
list(APPEND CLI "-t" "${ARG_FORMAT}")
endif()
# -q
if(ARG_QUALITY)
list(APPEND CLI "-q" "${ARG_QUALITY}")
endif()
# --mips
if(ARG_MIPS)
list(APPEND CLI "--mips")
endif()
# --mipskip
if(ARG_MIPSKIP)
list(APPEND CLI "--mipskip" "${ARG_MIPSKIP}")
endif()
# --normalmap
if(ARG_NORMALMAP)
list(APPEND CLI "--normalmap")
endif()
# --equirect
if(ARG_EQUIRECT)
list(APPEND CLI "--equirect")
endif()
# --strip
if(ARG_STRIP)
list(APPEND CLI "--strip")
endif()
# --sdf
if(ARG_SDF)
list(APPEND CLI "--sdf")
endif()
# --ref
if(ARG_REF)
list(APPEND CLI "--ref" "${ARG_REF}")
endif()
# --iqa
if(ARG_IQA)
list(APPEND CLI "--iqa")
endif()
# --pma
if(ARG_PMA)
list(APPEND CLI "--pma")
endif()
# --linear
if(ARG_LINEAR)
list(APPEND CLI "--linear")
endif()
# --max
if(ARG_MAX)
list(APPEND CLI "--max" "${ARG_MAX}")
endif()
# --radiance
if(ARG_RADIANCE)
list(APPEND CLI "--radiance" "${ARG_RADIANCE}")
endif()
# --as
if(ARG_AS)
list(APPEND CLI "--as" "${ARG_AS}")
endif()
set(${ARG_OUT} ${CLI} PARENT_SCOPE)
endfunction()
# bgfx_compile_texture(
# FILE filename
# OUTPUT filename
# [FORMAT format]
# [QUALITY default|fastest|highest]
# [MIPS]
# [MIPSKIP N]
# [NORMALMAP]
# [EQUIRECT]
# [STRIP]
# [SDF]
# [REF alpha]
# [IQA]
# [PMA]
# [LINEAR]
# [MAX max size]
# [RADIANCE model]
# [AS extension]
# )
#
function(bgfx_compile_texture)
cmake_parse_arguments(
ARG #
"MIPS;NORMALMAP;EQUIRECT;STRIP;SDF;IQA;PMA;LINEAR" #
"FILE;OUTPUT;FORMAT;QUALITY;MIPSKIP;REF;MAX;RADIANCE;AS" #
"" #
${ARGN} #
)
_bgfx_texturec_parse(CLI ${ARGV})
add_custom_command(
OUTPUT ${ARG_OUTPUT} #
COMMAND bgfx::texturec ${CLI} #
MAIN_DEPENDENCY ${ARG_INPUT} #
)
endfunction()
# _bgfx_geometryc_parse(
# FILE filename
# OUTPUT filename
# [SCALE scale]
# [CCW]
# [FLIPV]
# [OBB num steps]
# [PACKNORMAL 0|1]
# [PACKUV 0|1]
# [TANGENT]
# [BARYCENTRIC]
# [COMPRESS]
# [LH_UP_Y|LH_UP_Z|RH_UP_Y|RH_UP_Z]
# )
function(_bgfx_geometryc_parse ARG_OUT)
cmake_parse_arguments(
ARG #
"CCW;FLIPV;TANGENT;BARYCENTRIC;COMPRESS;LH_UP_Y;LH_UP_Z;RH_UP_Y;RH_UP_Z" #
"FILE;OUTPUT;SCALE;OBB;PACKNORMAL;PACKUV" #
"" #
${ARGN} #
)
set(CLI "")
# -f
if(ARG_FILE)
list(APPEND CLI "-f" "${ARG_FILE}")
endif()
# -o
if(ARG_OUTPUT)
list(APPEND CLI "-o" "${ARG_OUTPUT}")
endif()
# -s
if(ARG_SCALE)
list(APPEND CLI "-s" "${ARG_SCALE}")
endif()
# --cw
if(ARG_QUALITY)
list(APPEND CLI "--cw")
endif()
# --flipv
if(ARG_FLIPV)
list(APPEND CLI "--flipv")
endif()
# --obb
if(ARG_OBB)
list(APPEND CLI "--mipskip" "${ARG_OBB}")
endif()
# --packnormal
if(ARG_PACKNORMAL)
list(APPEND CLI "--packnormal ${ARG_PACKNORMAL}")
endif()
# --packuv
if(ARG_PACKUV)
list(APPEND CLI "--packuv" ${ARG_PACKUV})
endif()
# --tangent
if(ARG_TANGENT)
list(APPEND CLI "--tangent")
endif()
# --barycentric
if(ARG_BARYCENTRIC)
list(APPEND CLI "--barycentric")
endif()
# --compress
if(ARG_REF)
list(APPEND CLI "--compress" "${ARG_COMPRESS}")
endif()
# --lh-up+y
if(ARG_LH_UP_Y)
list(APPEND CLI "--lh-up+y")
endif()
# --lh-up+z
if(ARG_LH_UP_Z)
list(APPEND CLI "--lh-up+z")
endif()
# --rh-up+y
if(ARG_RH_UP_Y)
list(APPEND CLI "--rh-up+y")
endif()
# --rh-up+z
if(ARG_RH_UP_Z)
list(APPEND CLI "--rh-up+z")
endif()
set(${ARG_OUT} ${CLI} PARENT_SCOPE)
endfunction()
# bgfx_compile_geometry(
# FILE filename
# OUTPUT filename
# [SCALE scale]
# [CCW]
# [FLIPV]
# [OBB num steps]
# [PACKNORMAL 0|1]
# [PACKUV 0|1]
# [TANGENT]
# [BARYCENTRIC]
# [COMPRESS]
# [LH_UP_Y|LH_UP_Z|RH_UP_Y|RH_UP_Z]
# )
#
function(bgfx_compile_geometry)
cmake_parse_arguments(
ARG #
"CCW;FLIPV;TANGENT;BARYCENTRIC;COMPRESS;LH_UP_Y;LH_UP_Z;RH_UP_Y;RH_UP_Z" #
"FILE;OUTPUT;SCALE;OBB;PACKNORMAL;PACKUV" #
"" #
${ARGN} #
)
_bgfx_geometryc_parse(CLI ${ARGV})
add_custom_command(
OUTPUT ${ARG_OUTPUT} #
COMMAND bgfx::geometryc ${CLI} #
MAIN_DEPENDENCY ${ARG_INPUT} #
)
endfunction()
# _bgfx_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(_bgfx_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 _bgfx_shaderc_parse() cannot have both flags ${PLATFORM} and ${P}.")
return()
endif()
set(PLATFORM "${P}")
endif()
endforeach()
if(PLATFORM STREQUAL "")
message(SEND_ERROR "Call to _bgfx_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 NACL)
list(APPEND CLI "--platform" "nacl")
elseif(PLATFORM STREQUAL OSX)
list(APPEND CLI "--platform" "osx")
elseif(PLATFORM STREQUAL UNIX)
list(APPEND CLI "--platform" "linux")
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 _bgfx_shaderc_parse() cannot have both flags ${TYPE} and ${T}.")
return()
endif()
set(TYPE "${T}")
endif()
endforeach()
if("${TYPE}" STREQUAL "")
message(SEND_ERROR "Call to _bgfx_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(_bgfx_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 s_3_0 dx9 PROFILE ${PROFILE})
string(REPLACE s_4_0 dx10 PROFILE ${PROFILE})
string(REPLACE s_5_0 dx11 PROFILE ${PROFILE})
set(${PROFILE_EXT} ${PROFILE} PARENT_SCOPE)
endfunction()
# bgfx_compile_shader_to_header(
# TYPE VERTEX|FRAGMENT|COMPUTE
# SHADERS filenames
# VARYING_DEF filename
# OUTPUT_DIR directory
# OUT_FILES_VAR variable name
# INCLUDE_DIRS directories
# )
#
function(bgfx_compile_shader_to_header)
set(options "")
set(oneValueArgs TYPE VARYING_DEF OUTPUT_DIR OUT_FILES_VAR)
set(multiValueArgs SHADERS INCLUDE_DIRS)
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" OR ARGS_TYPE STREQUAL "FRAGMENT")
list(APPEND PROFILES s_3_0)
list(APPEND PROFILES s_4_0)
list(APPEND PROFILES s_5_0)
elseif(ARGS_TYPE STREQUAL "COMPUTE")
list(APPEND PROFILES s_4_0)
list(APPEND PROFILES s_5_0)
else()
message(error "shaderc: Unsupported type")
endif()
else()
message(error "shaderc: Unsupported platform")
endif()
set(ALL_OUTPUTS "")
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})
_bgfx_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()
_bgfx_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} ${ARGS_INCLUDE_DIRS}
BIN2C BIN2C ${SHADER_FILE_NAME_WE}_${PROFILE_EXT}
)
list(APPEND OUTPUTS ${OUTPUT})
list(APPEND ALL_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()
if(DEFINED ARGS_OUT_FILES_VAR)
set(${ARGS_OUT_FILES_VAR} ${ALL_OUTPUTS} PARENT_SCOPE)
endif()
endfunction()

View File

@@ -1,45 +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/>.
# Third party libs
include( cmake/3rdparty/astc-codec.cmake )
include( cmake/3rdparty/astc.cmake )
include( cmake/3rdparty/edtaa3.cmake )
include( cmake/3rdparty/etc1.cmake )
include( cmake/3rdparty/etc2.cmake )
include( cmake/3rdparty/iqa.cmake )
include( cmake/3rdparty/libsquish.cmake )
include( cmake/3rdparty/nvtt.cmake )
include( cmake/3rdparty/pvrtc.cmake )
include( cmake/3rdparty/tinyexr.cmake )
# Ensure the directory exists
if( NOT IS_DIRECTORY ${BIMG_DIR} )
message( SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}" )
return()
endif()
# Grab the bimg source files
file( GLOB BIMG_SOURCES ${BIMG_DIR}/src/*.cpp )
# Create the bimg target
add_library( bimg STATIC ${BIMG_SOURCES} )
# Add include directory of bimg
target_include_directories( bimg
PUBLIC
$<BUILD_INTERFACE:${BIMG_DIR}/include>
$<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 )
# Put in a "bgfx" folder in Visual Studio
set_target_properties( bimg PROPERTIES FOLDER "bgfx" )

25
cmake/bimg/3rdparty/astc_encoder.cmake vendored Normal file
View File

@@ -0,0 +1,25 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}")
return()
endif()
if(NOT ASTC_ENCODER_LIBRARIES)
file(
GLOB_RECURSE #
ASTC_ENCODER_SOURCES #
${BIMG_DIR}/3rdparty/astc-encoder/source/*.cpp #
${BIMG_DIR}/3rdparty/astc-encoder/source/*.h #
)
set(ASTC_ENCODER_INCLUDE_DIR ${BIMG_DIR}/3rdparty/astc-encoder/include)
endif()

25
cmake/bimg/3rdparty/edtaa3.cmake vendored Normal file
View File

@@ -0,0 +1,25 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}")
return()
endif()
if(NOT EDTAA3_LIBRARIES)
file(
GLOB_RECURSE #
EDTAA3_SOURCES #
${BIMG_DIR}/3rdparty/edtaa3/**.cpp #
${BIMG_DIR}/3rdparty/edtaa3/**.h #
)
set(EDTAA3_INCLUDE_DIR ${BIMG_DIR}/3rdparty)
endif()

View File

@@ -1,19 +1,22 @@
# 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 etc1 )
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}")
return()
endif()
file( GLOB ETC1_SOURCES ${BIMG_DIR}/3rdparty/etc1/*.cpp ${BIMG_DIR}/3rdparty/etc1/*.h )
add_library( etc1 STATIC ${ETC1_SOURCES} )
target_include_directories( etc1 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( etc1 PROPERTIES FOLDER "bgfx/3rdparty" )
if(NOT ETC1_LIBRARIES)
file(GLOB_RECURSE ETC1_SOURCES ${BIMG_DIR}/3rdparty/etc1/**.cpp #
${BIMG_DIR}/3rdparty/etc1/**.hpp #
)
set(ETC1_INCLUDE_DIR ${BIMG_DIR}/3rdparty)
endif()

View File

@@ -1,19 +1,25 @@
# 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 )
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}")
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" )
if(NOT ETC2_LIBRARIES)
file(
GLOB_RECURSE #
ETC2_SOURCES #
${BIMG_DIR}/3rdparty/etc2/**.cpp #
${BIMG_DIR}/3rdparty/etc2/**.hpp #
)
set(ETC2_INCLUDE_DIR ${BIMG_DIR}/3rdparty)
endif()

25
cmake/bimg/3rdparty/iqa.cmake vendored Normal file
View File

@@ -0,0 +1,25 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}")
return()
endif()
if(NOT IQA_LIBRARIES)
file(
GLOB_RECURSE #
IQA_SOURCES #
${BIMG_DIR}/3rdparty/iqa/include/**.h #
${BIMG_DIR}/3rdparty/iqa/source/**.c #
)
set(IQA_INCLUDE_DIR ${BIMG_DIR}/3rdparty/iqa/include)
endif()

View File

@@ -1,19 +1,25 @@
# 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 squish )
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}")
return()
endif()
file( GLOB SQUISH_SOURCES ${BIMG_DIR}/3rdparty/libsquish/*.cpp ${BIMG_DIR}/3rdparty/libsquish/*.h ${BIMG_DIR}/3rdparty/libsquish/*.inl )
add_library( squish STATIC ${SQUISH_SOURCES} )
target_include_directories( squish PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( squish PROPERTIES FOLDER "bgfx/3rdparty" )
if(NOT LIBSQUISH_LIBRARIES)
file(
GLOB_RECURSE #
LIBSQUISH_SOURCES #
${BIMG_DIR}/3rdparty/libsquish/**.cpp #
${BIMG_DIR}/3rdparty/libsquish/**.h #
)
set(LIBSQUISH_INCLUDE_DIR ${BIMG_DIR}/3rdparty)
endif()

26
cmake/bimg/3rdparty/loadpng.cmake vendored Normal file
View File

@@ -0,0 +1,26 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}")
return()
endif()
if(NOT LOADPNG_LIBRARIES)
file(
GLOB_RECURSE #
LOADPNG_SOURCES #
${BIMG_DIR}/3rdparty/lodepng/lodepng.cpp #
${BIMG_DIR}/3rdparty/lodepng/lodepng.h #
)
set_source_files_properties(${BIMG_DIR}/3rdparty/lodepng/lodepng.cpp PROPERTIES HEADER_FILE_ONLY ON)
set(LOADPNG_INCLUDE_DIR ${BIMG_DIR}/3rdparty)
endif()

View File

@@ -1,20 +1,23 @@
# 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 etc2 )
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}")
return()
endif()
file( GLOB ETC2_SOURCES ${BIMG_DIR}/3rdparty/etc2/*.cpp ${BIMG_DIR}/3rdparty/etc2/*.h )
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 )
if(NOT MINIZ_LIBRARIES)
file(GLOB_RECURSE #
MINIZ_SOURCES #
${BIMG_DIR}/3rdparty/tinyexr/deps/miniz/miniz.* #
)
set(MINIZ_INCLUDE_DIR ${BIMG_DIR}/3rdparty/tinyexr/deps/miniz)
endif()

View File

@@ -1,19 +1,25 @@
# 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 edtaa3 )
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}")
return()
endif()
file( GLOB EDTAA3_SOURCES ${BIMG_DIR}/3rdparty/edtaa3/*.cpp ${BIMG_DIR}/3rdparty/edtaa3/*.h )
add_library( edtaa3 STATIC ${EDTAA3_SOURCES} )
target_include_directories( edtaa3 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( edtaa3 PROPERTIES FOLDER "bgfx/3rdparty" )
if(NOT NVTT_LIBRARIES)
file(
GLOB_RECURSE #
NVTT_SOURCES #
${BIMG_DIR}/3rdparty/nvtt/**.cpp #
${BIMG_DIR}/3rdparty/nvtt/**.h #
)
set(NVTT_INCLUDE_DIR ${BIMG_DIR}/3rdparty/nvtt)
endif()

View File

@@ -1,19 +1,25 @@
# 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 pvrtc )
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}")
return()
endif()
file( GLOB PVRTC_SOURCES ${BIMG_DIR}/3rdparty/pvrtc/*.cpp ${BIMG_DIR}/3rdparty/pvrtc/*.h )
add_library( pvrtc STATIC ${PVRTC_SOURCES} )
target_include_directories( pvrtc PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( pvrtc PROPERTIES FOLDER "bgfx/3rdparty" )
if(NOT PVRTC_LIBRARIES)
file(
GLOB_RECURSE #
PVRTC_SOURCES #
${BIMG_DIR}/3rdparty/pvrtc/**.cpp #
${BIMG_DIR}/3rdparty/pvrtc/**.h #
)
set(PVRTC_INCLUDE_DIR ${BIMG_DIR}/3rdparty)
endif()

View File

@@ -1,19 +1,23 @@
# 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 iqa )
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}")
return()
endif()
file( GLOB IQA_SOURCES ${BIMG_DIR}/3rdparty/iqa/source/*.c ${BIMG_DIR}/3rdparty/iqa/include/*.h )
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" )
if(NOT TINYEXR_LIBRARIES)
file(GLOB_RECURSE #
TINYEXR_SOURCES #
${BIMG_DIR}/3rdparty/tinyexr/**.h #
)
set(TINYEXR_INCLUDE_DIR ${BIMG_DIR}/3rdparty)
endif()

28
cmake/bimg/CMakeLists.txt Normal file
View File

@@ -0,0 +1,28 @@
# 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/>.
include(3rdparty/loadpng.cmake)
include(3rdparty/libsquish.cmake)
include(3rdparty/astc_encoder.cmake)
include(3rdparty/edtaa3.cmake)
include(3rdparty/etc1.cmake)
include(3rdparty/etc2.cmake)
include(3rdparty/nvtt.cmake)
include(3rdparty/pvrtc.cmake)
include(3rdparty/tinyexr.cmake)
include(3rdparty/iqa.cmake)
include(3rdparty/miniz.cmake)
include(bimg.cmake)
include(bimg_decode.cmake)
include(bimg_encode.cmake)
if(BGFX_BUILD_TOOLS_TEXTURE)
include(texturec.cmake)
endif()

56
cmake/bimg/bimg.cmake Normal file
View File

@@ -0,0 +1,56 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}")
return()
endif()
file(
GLOB_RECURSE
BIMG_SOURCES
${BIMG_DIR}/include/* #
${BIMG_DIR}/src/image.* #
${BIMG_DIR}/src/image_gnf.cpp #
#
${ASTC_ENCODER_SOURCES}
${MINIZ_SOURCES}
)
add_library(bimg STATIC ${BIMG_SOURCES})
# Put in a "bgfx" folder in Visual Studio
set_target_properties(bimg PROPERTIES FOLDER "bgfx")
target_include_directories(
bimg PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/include>$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE ${ASTC_ENCODER_INCLUDE_DIR} #
${MINIZ_INCLUDE_DIR} #
)
target_link_libraries(
bimg
PUBLIC bx #
${ASTC_ENCODER_LIBRARIES} #
${MINIZ_LIBRARIES} #
)
if(BGFX_INSTALL AND NOT BGFX_LIBRARY_TYPE MATCHES "SHARED")
install(
TARGETS bimg
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()

View File

@@ -0,0 +1,57 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg_decode, directory does not exist. ${BIMG_DIR}")
return()
endif()
file(
GLOB_RECURSE
BIMG_DECODE_SOURCES #
${BIMG_DIR}/include/* #
${BIMG_DIR}/src/image_decode.* #
#
${LOADPNG_SOURCES} #
${MINIZ_SOURCES} #
)
add_library(bimg_decode STATIC ${BIMG_DECODE_SOURCES})
# Put in a "bgfx" folder in Visual Studio
set_target_properties(bimg_decode PROPERTIES FOLDER "bgfx")
target_include_directories(
bimg_decode
PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE ${LOADPNG_INCLUDE_DIR} #
${MINIZ_INCLUDE_DIR} #
${TINYEXR_INCLUDE_DIR} #
)
target_link_libraries(
bimg_decode
PUBLIC bx #
${LOADPNG_LIBRARIES} #
${MINIZ_LIBRARIES} #
${TINYEXR_LIBRARIES} #
)
if(BGFX_INSTALL AND NOT BGFX_LIBRARY_TYPE MATCHES "SHARED")
install(
TARGETS bimg_decode
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()

View File

@@ -0,0 +1,99 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BIMG_DIR})
message(SEND_ERROR "Could not load bimg_encode, directory does not exist. ${BIMG_DIR}")
return()
endif()
add_library(bimg_encode STATIC)
# Put in a "bgfx" folder in Visual Studio
set_target_properties(bimg_encode PROPERTIES FOLDER "bgfx")
target_include_directories(
bimg_encode
PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE ${LIBSQUISH_INCLUDE_DIR} #
${ASTC_ENCODER_INCLUDE_DIR} #
${EDTAA3_INCLUDE_DIR} #
${ETC1_INCLUDE_DIR} #
${ETC2_INCLUDE_DIR} #
${NVTT_INCLUDE_DIR} #
${PVRTC_INCLUDE_DIR} #
${TINYEXR_INCLUDE_DIR} #
${IQA_INCLUDE_DIR} #
${MINIZ_INCLUDE_DIR} #
)
file(
GLOB_RECURSE
BIMG_ENCODE_SOURCES
${BIMG_DIR}/include/* #
${BIMG_DIR}/src/image_encode.* #
${BIMG_DIR}/src/image_cubemap_filter.* #
${LIBSQUISH_SOURCES} #
${EDTAA3_SOURCES} #
${ETC1_SOURCES} #
${ETC2_SOURCES} #
${NVTT_SOURCES} #
${PVRTC_SOURCES} #
${TINYEXR_SOURCES}
${IQA_SOURCES} #
)
target_sources(bimg_encode PRIVATE ${BIMG_ENCODE_SOURCES})
target_link_libraries(
bimg_encode
PUBLIC bx #
${LIBSQUISH_LIBRARIES} #
${ASTC_ENCODER_LIBRARIES} #
${EDTAA3_LIBRARIES} #
${ETC1_LIBRARIES} #
${ETC2_LIBRARIES} #
${NVTT_LIBRARIES} #
${PVRTC_LIBRARIES} #
${TINYEXR_LIBRARIES} #
${IQA_LIBRARIES} #
)
include(CheckCXXCompilerFlag)
foreach(flag "-Wno-implicit-fallthrough" "-Wno-shadow" "-Wno-shift-negative-value" "-Wno-undef")
check_cxx_compiler_flag(${flag} flag_supported)
if(flag_supported)
target_compile_options(bimg_encode PRIVATE ${flag})
endif()
endforeach()
foreach(flag "-Wno-class-memaccess" "-Wno-deprecated-copy")
check_cxx_compiler_flag(${flag} flag_supported)
if(flag_supported)
foreach(file ${BIMG_ENCODE_SOURCES})
get_source_file_property(lang ${file} LANGUAGE)
if(lang STREQUAL "CXX")
set_source_files_properties(${file} PROPERTIES COMPILE_OPTIONS ${flag})
endif()
endforeach()
endif()
endforeach()
if(BGFX_INSTALL AND NOT BGFX_LIBRARY_TYPE MATCHES "SHARED")
install(
TARGETS bimg_encode
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()

40
cmake/bimg/texturec.cmake Normal file
View File

@@ -0,0 +1,40 @@
# 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/>.
# Grab the texturec source files
file(GLOB_RECURSE TEXTUREC_SOURCES #
${BIMG_DIR}/tools/texturec/*.cpp #
${BIMG_DIR}/tools/texturec/*.h #
)
add_executable(texturec ${TEXTUREC_SOURCES})
target_link_libraries(texturec PRIVATE bimg_decode bimg_encode bimg)
set_target_properties(
texturec PROPERTIES FOLDER "bgfx/tools" #
OUTPUT_NAME ${BGFX_TOOLS_PREFIX}texturec #
)
if(BGFX_BUILD_TOOLS_TEXTURE)
add_executable(bgfx::texturec ALIAS texturec)
if(BGFX_CUSTOM_TARGETS)
add_dependencies(tools texturec)
endif()
endif()
if(ANDROID)
target_link_libraries(texturec PRIVATE log)
elseif(IOS)
set_target_properties(texturec PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER texturec)
endif()
if(BGFX_INSTALL)
install(TARGETS texturec EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()

View File

@@ -1,90 +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/>.
# Ensure the directory exists
if( NOT IS_DIRECTORY ${BX_DIR} )
message( SEND_ERROR "Could not load bx, directory does not exist. ${BX_DIR}" )
return()
endif()
# Grab the bx source files
file( GLOB BX_SOURCES ${BX_DIR}/src/*.cpp )
if(BX_AMALGAMATED)
set(BX_NOBUILD ${BX_SOURCES})
list(REMOVE_ITEM BX_NOBUILD ${BX_DIR}/src/amalgamated.cpp)
foreach(BX_SRC ${BX_NOBUILD})
set_source_files_properties( ${BX_SRC} PROPERTIES HEADER_FILE_ONLY ON )
endforeach()
else()
set_source_files_properties( ${BX_DIR}/src/amalgamated.cpp PROPERTIES HEADER_FILE_ONLY ON )
endif()
# Create the bx target
add_library( bx STATIC ${BX_SOURCES} )
# Link against psapi on Windows
if( WIN32 )
target_link_libraries( bx PUBLIC psapi )
endif()
include(GNUInstallDirs)
# Add include directory of bx
target_include_directories( bx
PUBLIC
$<BUILD_INTERFACE:${BX_DIR}/include>
$<BUILD_INTERFACE:${BX_DIR}/3rdparty>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> )
# Build system specific configurations
if( MINGW )
target_include_directories( bx
PUBLIC
$<BUILD_INTERFACE:${BX_DIR}/include/compat/mingw>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/mingw> )
elseif( WIN32 )
target_include_directories( bx
PUBLIC
$<BUILD_INTERFACE:${BX_DIR}/include/compat/msvc>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/msvc> )
elseif( APPLE )
target_include_directories( bx
PUBLIC
$<BUILD_INTERFACE:${BX_DIR}/include/compat/osx>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/osx> )
endif()
# All configurations
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 PRIVATE "$<$<CONFIG:Debug>:BX_CONFIG_DEBUG=1>" )
if(BGFX_CONFIG_DEBUG)
target_compile_definitions( bx PRIVATE BX_CONFIG_DEBUG=1)
endif()
# Additional dependencies on Unix
if( UNIX AND NOT APPLE AND NOT ANDROID )
# Threads
find_package( Threads )
target_link_libraries( bx ${CMAKE_THREAD_LIBS_INIT} dl )
# Real time (for clock_gettime)
target_link_libraries( bx rt )
elseif(APPLE)
find_library( FOUNDATION_LIBRARY Foundation)
mark_as_advanced( FOUNDATION_LIBRARY )
target_link_libraries( bx PUBLIC ${FOUNDATION_LIBRARY} )
endif()
# Put in a "bgfx" folder in Visual Studio
set_target_properties( bx PROPERTIES FOLDER "bgfx" )

41
cmake/bx/CMakeLists.txt Normal file
View File

@@ -0,0 +1,41 @@
# 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/>.
include(bx.cmake)
if(BGFX_BUILD_TOOLS_BIN2C)
include(bin2c.cmake)
endif()
if(BGFX_BUILD_TESTS)
file(
GLOB
BX_TEST_SOURCES #
${BX_DIR}/3rdparty/catch/catch_amalgamated.cpp
${BX_DIR}/tests/*_test.cpp #
${BX_DIR}/tests/*.h #
${BX_DIR}/tests/dbg.* #
)
add_executable(bx_test ${BX_TEST_SOURCES})
target_compile_definitions(bx_test PRIVATE CATCH_AMALGAMATED_CUSTOM_MAIN)
target_link_libraries(bx_test PRIVATE bx)
add_test(NAME bx.test COMMAND bx_test)
file(
GLOB
BX_BENCH_SOURCES #
${BX_DIR}/tests/*_bench.cpp #
${BX_DIR}/tests/*_bench.h #
${BX_DIR}/tests/dbg.* #
)
add_executable(bx_bench ${BX_BENCH_SOURCES})
target_link_libraries(bx_bench PRIVATE bx)
add_test(NAME bx.bench COMMAND bx_bench)
endif()

40
cmake/bx/bin2c.cmake Normal file
View File

@@ -0,0 +1,40 @@
# 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/>.
# Grab the bin2c source files
file(GLOB_RECURSE BIN2C_SOURCES #
${BX_DIR}/tools/bin2c/*.cpp #
${BX_DIR}/tools/bin2c/*.h #
)
add_executable(bin2c ${BIN2C_SOURCES})
target_link_libraries(bin2c PRIVATE bx)
set_target_properties(
bin2c PROPERTIES FOLDER "bgfx/tools" #
OUTPUT_NAME ${BGFX_TOOLS_PREFIX}bin2c #
)
if(BGFX_BUILD_TOOLS_BIN2C)
add_executable(bgfx::bin2c ALIAS bin2c)
if(BGFX_CUSTOM_TARGETS)
add_dependencies(tools bin2c)
endif()
endif()
if(ANDROID)
target_link_libraries(bin2c PRIVATE log)
elseif(IOS)
set_target_properties(bin2c PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER bin2c)
endif()
if(BGFX_INSTALL)
install(TARGETS bin2c EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()

134
cmake/bx/bx.cmake Normal file
View File

@@ -0,0 +1,134 @@
# 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/>.
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BX_DIR})
message(SEND_ERROR "Could not load bx, directory does not exist. ${BX_DIR}")
return()
endif()
include(GNUInstallDirs)
# Grab the bx source files
file(
GLOB_RECURSE
BX_SOURCES
${BX_DIR}/include/*.h #
${BX_DIR}/include/**.inl #
${BX_DIR}/src/*.cpp #
${BX_DIR}/scripts/*.natvis #
)
if(BX_AMALGAMATED)
list(APPEND BX_NOBUILD "${BX_DIR}/src/allocator.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/bounds.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/bx.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/commandline.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/crtnone.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/debug.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/dtoa.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/easing.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/file.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/filepath.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/hash.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/math.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/mutex.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/os.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/process.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/semaphore.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/settings.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/sort.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/string.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/thread.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/timer.cpp")
list(APPEND BX_NOBUILD "${BX_DIR}/src/url.cpp")
else()
file(GLOB_RECURSE BX_NOBUILD "${BX_DIR}/src/amalgamated.*")
endif()
# Exclude files from the build but keep them in project
foreach(BX_SRC ${BX_NOBUILD})
set_source_files_properties(${BX_SRC} PROPERTIES HEADER_FILE_ONLY ON)
endforeach()
add_library(bx STATIC ${BX_SOURCES})
# Put in a "bgfx" folder in Visual Studio
set_target_properties(bx PROPERTIES FOLDER "bgfx")
# Build system specific configurations
if(MINGW)
set(BX_COMPAT_PLATFORM mingw)
elseif(WIN32)
set(BX_COMPAT_PLATFORM msvc)
elseif(APPLE) # APPLE is technically UNIX... ORDERING MATTERS!
set(BX_COMPAT_PLATFORM osx)
elseif(UNIX)
set(BX_COMPAT_PLATFORM linux)
endif()
# Add include directory of bx
target_include_directories(
bx
PUBLIC $<BUILD_INTERFACE:${BX_DIR}/include> #
$<BUILD_INTERFACE:${BX_DIR}/3rdparty> #
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> #
$<BUILD_INTERFACE:${BX_DIR}/include/compat/${BX_COMPAT_PLATFORM}> #
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/${BX_COMPAT_PLATFORM}> #
)
# All configurations
target_compile_definitions(bx PUBLIC "BX_CONFIG_DEBUG=$<IF:$<CONFIG:Debug>,1,$<BOOL:${BX_CONFIG_DEBUG}>>")
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_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)
endif()
# Additional dependencies on Unix
if(ANDROID)
# For __android_log_write
find_library(LOG_LIBRARY log)
mark_as_advanced(LOG_LIBRARY)
target_link_libraries(bx PUBLIC ${LOG_LIBRARY})
elseif(APPLE)
find_library(FOUNDATION_LIBRARY Foundation)
mark_as_advanced(FOUNDATION_LIBRARY)
target_link_libraries(bx PUBLIC ${FOUNDATION_LIBRARY})
elseif(UNIX)
# Threads
find_package(Threads)
target_link_libraries(bx ${CMAKE_THREAD_LIBS_INIT} dl)
# Real time (for clock_gettime)
target_link_libraries(bx rt)
endif()
# Put in a "bgfx" folder in Visual Studio
set_target_properties(bx PROPERTIES FOLDER "bgfx")
if(NOT BGFX_LIBRARY_TYPE MATCHES "SHARED")
install(
TARGETS bx
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()

View File

@@ -1,282 +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/>.
include( CMakeParseArguments )
include( cmake/util/ConfigureDebugging.cmake )
include( cmake/3rdparty/dear-imgui.cmake )
include( cmake/3rdparty/meshoptimizer.cmake )
function( add_bgfx_shader FILE FOLDER )
get_filename_component( FILENAME "${FILE}" NAME_WE )
string( SUBSTRING "${FILENAME}" 0 2 TYPE )
if( "${TYPE}" STREQUAL "fs" )
set( TYPE "FRAGMENT" )
set( D3D_PREFIX "ps" )
elseif( "${TYPE}" STREQUAL "vs" )
set( TYPE "VERTEX" )
set( D3D_PREFIX "vs" )
elseif( "${TYPE}" STREQUAL "cs" )
set( TYPE "COMPUTE" )
set( D3D_PREFIX "cs" )
else()
set( TYPE "" )
endif()
if( NOT "${TYPE}" STREQUAL "" )
set( COMMON FILE ${FILE} ${TYPE} INCLUDES ${BGFX_DIR}/src )
set( OUTPUTS "" )
set( OUTPUTS_PRETTY "" )
if( WIN32 )
# dx9
if( NOT "${TYPE}" STREQUAL "COMPUTE" )
set( DX9_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/dx9/${FILENAME}.bin )
shaderc_parse( DX9 ${COMMON} WINDOWS PROFILE ${D3D_PREFIX}_3_0 O 3 OUTPUT ${DX9_OUTPUT} )
list( APPEND OUTPUTS "DX9" )
set( OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX9, " )
endif()
# dx11
set( DX11_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/dx11/${FILENAME}.bin )
if( NOT "${TYPE}" STREQUAL "COMPUTE" )
shaderc_parse( DX11 ${COMMON} WINDOWS PROFILE ${D3D_PREFIX}_5_0 O 3 OUTPUT ${DX11_OUTPUT} )
else()
shaderc_parse( DX11 ${COMMON} WINDOWS PROFILE ${D3D_PREFIX}_5_0 O 1 OUTPUT ${DX11_OUTPUT} )
endif()
list( APPEND OUTPUTS "DX11" )
set( OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX11, " )
endif()
if( APPLE )
# metal
set( METAL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/metal/${FILENAME}.bin )
shaderc_parse( METAL ${COMMON} OSX PROFILE metal OUTPUT ${METAL_OUTPUT} )
list( APPEND OUTPUTS "METAL" )
set( OUTPUTS_PRETTY "${OUTPUTS_PRETTY}Metal, " )
endif()
# essl
if( NOT "${TYPE}" STREQUAL "COMPUTE" )
set( ESSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/essl/${FILENAME}.bin )
shaderc_parse( ESSL ${COMMON} ANDROID OUTPUT ${ESSL_OUTPUT} )
list( APPEND OUTPUTS "ESSL" )
set( OUTPUTS_PRETTY "${OUTPUTS_PRETTY}ESSL, " )
endif()
# glsl
set( GLSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/glsl/${FILENAME}.bin )
if( NOT "${TYPE}" STREQUAL "COMPUTE" )
shaderc_parse( GLSL ${COMMON} LINUX PROFILE 120 OUTPUT ${GLSL_OUTPUT} )
else()
shaderc_parse( GLSL ${COMMON} LINUX PROFILE 430 OUTPUT ${GLSL_OUTPUT} )
endif()
list( APPEND OUTPUTS "GLSL" )
set( OUTPUTS_PRETTY "${OUTPUTS_PRETTY}GLSL, " )
# spirv
if( NOT "${TYPE}" STREQUAL "COMPUTE" )
set( SPIRV_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/spirv/${FILENAME}.bin )
shaderc_parse( SPIRV ${COMMON} LINUX PROFILE spirv OUTPUT ${SPIRV_OUTPUT} )
list( APPEND OUTPUTS "SPIRV" )
set( OUTPUTS_PRETTY "${OUTPUTS_PRETTY}SPIRV" )
set( OUTPUT_FILES "" )
set( COMMANDS "" )
endif()
foreach( OUT ${OUTPUTS} )
list( APPEND OUTPUT_FILES ${${OUT}_OUTPUT} )
list( APPEND COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${${OUT}} )
get_filename_component( OUT_DIR ${${OUT}_OUTPUT} DIRECTORY )
file( MAKE_DIRECTORY ${OUT_DIR} )
endforeach()
file( RELATIVE_PATH PRINT_NAME ${BGFX_DIR}/examples ${FILE} )
add_custom_command(
MAIN_DEPENDENCY
${FILE}
OUTPUT
${OUTPUT_FILES}
${COMMANDS}
COMMENT "Compiling shader ${PRINT_NAME} for ${OUTPUTS_PRETTY}"
)
endif()
endfunction()
function( add_example ARG_NAME )
# Parse arguments
cmake_parse_arguments( ARG "COMMON" "" "DIRECTORIES;SOURCES" ${ARGN} )
# Get all source files
list( APPEND ARG_DIRECTORIES "${BGFX_DIR}/examples/${ARG_NAME}" )
set( SOURCES "" )
set( SHADERS "" )
foreach( DIR ${ARG_DIRECTORIES} )
if( APPLE )
file( GLOB GLOB_SOURCES ${DIR}/*.mm )
list( APPEND SOURCES ${GLOB_SOURCES} )
endif()
file( GLOB GLOB_SOURCES ${DIR}/*.c ${DIR}/*.cpp ${DIR}/*.h ${DIR}/*.sc )
list( APPEND SOURCES ${GLOB_SOURCES} )
file( GLOB GLOB_SHADERS ${DIR}/*.sc )
list( APPEND SHADERS ${GLOB_SHADERS} )
endforeach()
# Add target
if( ARG_COMMON )
add_library( example-${ARG_NAME} STATIC EXCLUDE_FROM_ALL ${SOURCES} )
target_include_directories( example-${ARG_NAME} PUBLIC ${BGFX_DIR}/examples/common )
target_link_libraries( example-${ARG_NAME} PUBLIC bgfx bx bimg dear-imgui meshoptimizer )
if( BGFX_WITH_GLFW )
find_package( glfw3 REQUIRED )
target_link_libraries( example-${ARG_NAME} PUBLIC glfw )
target_compile_definitions( example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_GLFW )
elseif( BGFX_WITH_SDL )
find_package( SDL2 REQUIRED )
target_link_libraries( example-${ARG_NAME} PUBLIC ${SDL2_LIBRARIES} )
target_compile_definitions( example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_SDL )
elseif( UNIX AND NOT APPLE )
target_link_libraries( example-${ARG_NAME} PUBLIC X11 )
endif()
else()
if( BGFX_INSTALL_EXAMPLES )
add_executable( example-${ARG_NAME} WIN32 ${SOURCES} )
else()
add_executable( example-${ARG_NAME} WIN32 EXCLUDE_FROM_ALL ${SOURCES} )
endif()
target_link_libraries( example-${ARG_NAME} example-common )
configure_debugging( example-${ARG_NAME} WORKING_DIR ${BGFX_DIR}/examples/runtime )
if( MSVC )
set_target_properties( example-${ARG_NAME} PROPERTIES LINK_FLAGS "/ENTRY:\"mainCRTStartup\"" )
endif()
if( BGFX_CUSTOM_TARGETS )
add_dependencies( examples example-${ARG_NAME} )
endif()
if( IOS )
set_target_properties(example-${ARG_NAME} PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER example-${ARG_NAME}
MACOSX_BUNDLE_BUNDLE_VERSION 0
MACOSX_BUNDLE_SHORT_VERSION_STRING 0
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer")
endif()
endif()
target_compile_definitions( example-${ARG_NAME} PRIVATE "-D_CRT_SECURE_NO_WARNINGS" "-D__STDC_FORMAT_MACROS" "-DENTRY_CONFIG_IMPLEMENT_MAIN=1" )
# Configure shaders
if( NOT ARG_COMMON AND NOT IOS AND NOT EMSCRIPTEN)
foreach( SHADER ${SHADERS} )
add_bgfx_shader( ${SHADER} ${ARG_NAME} )
endforeach()
source_group( "Shader Files" FILES ${SHADERS})
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")
endif()
# Directory name
set_target_properties( example-${ARG_NAME} PROPERTIES FOLDER "bgfx/examples" )
if (IOS OR WIN32)
# on iOS we need to build a bundle so have to copy the data rather than symlink
# and on windows we can't create symlinks
add_custom_command( TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E copy_directory ${BGFX_DIR}/examples/runtime/ $<TARGET_FILE_DIR:example-${ARG_NAME}>)
else()
# For everything else symlink some folders into our output directory
add_custom_command( TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/font $<TARGET_FILE_DIR:example-${ARG_NAME}>/font)
add_custom_command( TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/images $<TARGET_FILE_DIR:example-${ARG_NAME}>/images)
add_custom_command( TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/meshes $<TARGET_FILE_DIR:example-${ARG_NAME}>/meshes)
add_custom_command( TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/shaders $<TARGET_FILE_DIR:example-${ARG_NAME}>/shaders)
add_custom_command( TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/text $<TARGET_FILE_DIR:example-${ARG_NAME}>/text)
add_custom_command( TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/textures $<TARGET_FILE_DIR:example-${ARG_NAME}>/textures)
endif()
endfunction()
# Build all examples target
if( BGFX_CUSTOM_TARGETS )
add_custom_target( examples )
set_target_properties( examples PROPERTIES FOLDER "bgfx/examples" )
endif()
# Add common library for examples
add_example(
common
COMMON
DIRECTORIES
${BGFX_DIR}/examples/common/debugdraw
${BGFX_DIR}/examples/common/entry
${BGFX_DIR}/examples/common/font
${BGFX_DIR}/examples/common/imgui
${BGFX_DIR}/examples/common/nanovg
${BGFX_DIR}/examples/common/ps
)
# Only add examples if set, otherwise we still need exmaples common for tools
if( BGFX_BUILD_EXAMPLES )
# Add examples
set(
BGFX_EXAMPLES
00-helloworld
01-cubes
02-metaballs
03-raymarch
04-mesh
05-instancing
06-bump
07-callback
08-update
09-hdr
10-font
11-fontsdf
12-lod
13-stencil
14-shadowvolumes
15-shadowmaps-simple
16-shadowmaps
17-drawstress
18-ibl
19-oit
20-nanovg
# 21-deferred
22-windows
23-vectordisplay
24-nbody
25-c99
26-occlusion
27-terrain
28-wireframe
29-debugdraw
30-picking
31-rsm
32-particles
33-pom
34-mvs
35-dynamic
36-sky
# 37-gpudrivenrendering
38-bloom
39-assao
40-svt
# 41-tess
42-bunnylod
43-denoise
44-sss
45-bokeh
)
foreach( EXAMPLE ${BGFX_EXAMPLES} )
add_example( ${EXAMPLE} )
endforeach()
endif()

View File

@@ -1,36 +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/>.
add_library( bgfx-vertexlayout INTERFACE )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/generated/vertexlayout.cpp.in
${CMAKE_CURRENT_BINARY_DIR}/generated/vertexlayout.cpp )
target_sources( bgfx-vertexlayout INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/generated/vertexlayout.cpp )
target_include_directories( bgfx-vertexlayout INTERFACE ${BGFX_DIR}/include )
add_library( bgfx-shader INTERFACE )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/generated/shader.cpp.in
${CMAKE_CURRENT_BINARY_DIR}/generated/shader.cpp )
target_sources( bgfx-shader INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/generated/shader.cpp )
target_include_directories( bgfx-shader INTERFACE ${BGFX_DIR}/include )
add_library( bgfx-bounds INTERFACE )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/generated/bounds.cpp.in
${CMAKE_CURRENT_BINARY_DIR}/generated/bounds.cpp )
target_sources( bgfx-bounds INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/generated/bounds.cpp )
target_include_directories( bgfx-bounds INTERFACE ${BGFX_DIR}/include )
target_include_directories( bgfx-bounds INTERFACE ${BGFX_DIR}/examples/common )
# Frameworks required on OS X
if( ${CMAKE_SYSTEM_NAME} MATCHES Darwin )
find_library( COCOA_LIBRARY Cocoa )
mark_as_advanced( COCOA_LIBRARY )
target_link_libraries( bgfx-vertexlayout INTERFACE ${COCOA_LIBRARY} )
endif()

View File

@@ -1,20 +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( BGFX_CUSTOM_TARGETS )
add_custom_target( tools )
set_target_properties( tools PROPERTIES FOLDER "bgfx/tools" )
endif()
include( cmake/tools/geometryc.cmake )
include( cmake/tools/geometryv.cmake )
include( cmake/tools/shaderc.cmake )
include( cmake/tools/texturec.cmake )
include( cmake/tools/texturev.cmake )

View File

@@ -1,26 +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/>.
include( CMakeParseArguments )
include( cmake/3rdparty/meshoptimizer.cmake )
add_executable( geometryc ${BGFX_DIR}/tools/geometryc/geometryc.cpp )
target_compile_definitions( geometryc PRIVATE "-D_CRT_SECURE_NO_WARNINGS" )
set_target_properties( geometryc PROPERTIES FOLDER "bgfx/tools" )
target_link_libraries( geometryc bx bgfx-bounds bgfx-vertexlayout meshoptimizer )
if( BGFX_CUSTOM_TARGETS )
add_dependencies( tools geometryc )
endif()
if (IOS)
set_target_properties(geometryc PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER geometryc)
endif()

View File

@@ -1,21 +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/>.
add_executable( geometryv ${BGFX_DIR}/tools/geometryv/geometryv.cpp )
set_target_properties( geometryv PROPERTIES FOLDER "bgfx/tools" )
target_link_libraries( geometryv example-common )
if( BGFX_CUSTOM_TARGETS )
add_dependencies( tools geometryv )
endif()
if (IOS)
set_target_properties(geometryv PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER geometryv)
endif()

View File

@@ -1,369 +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/>.
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 )
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 PRIVATE bx bimg bgfx-vertexlayout bgfx-shader fcpp glsl-optimizer glslang spirv-cross spirv-tools webgpu)
if( BGFX_CUSTOM_TARGETS )
add_dependencies( tools shaderc )
endif()
if (ANDROID)
target_link_libraries(shaderc PRIVATE log)
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()

View File

@@ -1,25 +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/>.
include( CMakeParseArguments )
add_executable( texturec ${BIMG_DIR}/tools/texturec/texturec.cpp )
set_target_properties( texturec PROPERTIES FOLDER "bgfx/tools" )
target_link_libraries( texturec bimg )
if( BGFX_CUSTOM_TARGETS )
add_dependencies( tools texturec )
endif()
if (ANDROID)
target_link_libraries( texturec log )
elseif (IOS)
set_target_properties(texturec PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER texturec)
endif()

View File

@@ -1,23 +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/>.
include( CMakeParseArguments )
add_executable( texturev ${BGFX_DIR}/tools/texturev/texturev.cpp )
set_target_properties( texturev PROPERTIES FOLDER "bgfx/tools" )
target_link_libraries( texturev example-common )
if( BGFX_CUSTOM_TARGETS )
add_dependencies( tools texturev )
endif()
if (IOS)
set_target_properties(texturev PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER texturev)
endif()

View File

@@ -1,159 +0,0 @@
# ConfigureDebugging.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/>.
#
# configure_debugging( TARGET [OPTIONS...] )
#
# Configures the debugging settings in visual studio.
# Results in a no-op on non visual studio builds.
# Must be called in the same cmake file as the add_executable command.
#
# See OPTIONS variable in the function for supported user settings.
# See CONFIGS variable in the function for supported cmake configurations.
# See PROCESSORS variable in the function for supported architecture configurations.
#
# All variables can be set with one of the following formats:
#
# (OPTION)
# (OPTION)_(CONFIG)
# (OPTION)_(CONFIG)_(ARCH)
# (OPTION)_(ARCH)
#
# So, some examples (variables should be all caps):
#
# WORKING_DIR
# WORKING_DIR_X64
# WORKING_DIR_RELEASE_WIN32
# WORKING_DIR_X64
#
# An example of a full command:
#
# configure_debugging(target COMMAND "node.exe" COMMAND_X64 "node64.exe" WORKING_DIR ${CMAKE_SOURCE_DIR} DEBUGGER_ENV "PATH=%PATH%\\;$(ProjectDir)")
include( CMakeParseArguments )
function( configure_debugging ARG_TARGET )
if( MSVC )
# Visual Studio Options
set(
OPTIONS
WORKING_DIR LocalDebuggerWorkingDirectory
DEBUGGER_ENV LocalDebuggerEnvironment
COMMAND LocalDebuggerCommand
COMMAND_ARGS LocalDebuggerCommandArguments
)
# Valid Configurations
set(
CONFIGS
Debug
Release
MinSizeRel
RelWithDebInfo
)
# Processors
set(
PROCESSORS
Win32
x64
)
# Begin hackery
if( ${CMAKE_SIZEOF_VOID_P} EQUAL 8 )
set( ACTIVE_PROCESSOR "x64" )
else()
set( ACTIVE_PROCESSOR "Win32" )
endif()
# Fix issues with semicolons, thx cmake
foreach( ARG ${ARGN} )
string( REPLACE ";" "\\\\\\\\\\\\\\;" RES "${ARG}" )
list( APPEND ARGS "${RES}" )
endforeach()
# Build options for cmake_parse_arguments, result is ONE_ARG variable
set( ODD ON )
foreach( OPTION ${OPTIONS} )
if( ODD )
set( ARG ${OPTION} )
list( APPEND ONE_ARG ${ARG} )
foreach( CONFIG ${CONFIGS} )
string( TOUPPER ${CONFIG} CONFIG )
list( APPEND ONE_ARG ${ARG}_${CONFIG} )
foreach( PROCESSOR ${PROCESSORS} )
string( TOUPPER ${PROCESSOR} PROCESSOR )
list( APPEND ONE_ARG ${ARG}_${CONFIG}_${PROCESSOR} )
endforeach()
endforeach()
foreach( PROCESSOR ${PROCESSORS} )
string( TOUPPER ${PROCESSOR} PROCESSOR )
list( APPEND ONE_ARG ${ARG}_${PROCESSOR} )
endforeach()
set( ODD OFF )
else()
set( ODD ON )
endif()
endforeach()
cmake_parse_arguments( ARG "" "${ONE_ARG}" "" ${ARGS} )
# Parse options, fills in all variables of format ARG_(ARG)_(CONFIG)_(PROCESSOR), for example ARG_WORKING_DIR_DEBUG_X64
set( ODD ON )
foreach( OPTION ${OPTIONS} )
if( ODD )
set( ARG ${OPTION} )
foreach( CONFIG ${CONFIGS} )
string( TOUPPER ${CONFIG} CONFIG_CAP )
if( "${ARG_${ARG}_${CONFIG_CAP}}" STREQUAL "" )
set( ARG_${ARG}_${CONFIG_CAP} ${ARG_${ARG}} )
endif()
foreach( PROCESSOR ${PROCESSORS} )
string( TOUPPER ${PROCESSOR} PROCESSOR_CAP )
if( "${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "" )
if( "${ARG_${ARG}_${PROCESSOR_CAP}}" STREQUAL "" )
set( ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP} ${ARG_${ARG}_${CONFIG_CAP}} )
else()
set( ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP} ${ARG_${ARG}_${PROCESSOR_CAP}} )
endif()
endif()
if( NOT "${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "" )
endif()
endforeach()
endforeach()
set( ODD OFF )
else()
set( ODD ON )
endif()
endforeach()
# Create string to put in proj.vcxproj.user file
set( RESULT "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">" )
foreach( CONFIG ${CONFIGS} )
string( TOUPPER ${CONFIG} CONFIG_CAPS )
foreach( PROCESSOR ${PROCESSORS} )
if( "${PROCESSOR}" STREQUAL "${ACTIVE_PROCESSOR}" )
string( TOUPPER ${PROCESSOR} PROCESSOR_CAPS )
set( RESULT "${RESULT}\n <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='${CONFIG}|${PROCESSOR}'\">" )
set( ODD ON )
foreach( OPTION ${OPTIONS} )
if( ODD )
set( ARG ${OPTION} )
set( ODD OFF )
else()
set( VALUE ${ARG_${ARG}_${CONFIG_CAPS}_${PROCESSOR_CAPS}} )
if( NOT "${VALUE}" STREQUAL "" )
set( RESULT "${RESULT}\n <${OPTION}>${VALUE}</${OPTION}>" )
endif()
set( ODD ON )
endif()
endforeach()
set( RESULT "${RESULT}\n </PropertyGroup>" )
endif()
endforeach()
endforeach()
set( RESULT "${RESULT}\n</Project>" )
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET}.vcxproj.user "${RESULT}" )
endif()
endfunction()

View File

@@ -4,7 +4,7 @@
# | | +--- Commit number (https://github.com/bkaradzic/bgfx / git rev-list --count HEAD)
# | +------- API version (from https://github.com/bkaradzic/bgfx/blob/master/scripts/bgfx.idl#L4)
# +--------- Major revision (always 1)
#
# BGFX_API_VERSION generated from https://github.com/bkaradzic/bgfx/blob/master/scripts/bgfx.idl#L4
# bgfx/src/version.h:
# BGFX_REV_NUMBER
@@ -12,20 +12,23 @@
find_package(Git QUIET)
execute_process(COMMAND "${GIT_EXECUTABLE}" -C bgfx log --pretty=format:'%h' -n 1
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REV
ERROR_QUIET)
execute_process(
COMMAND "${GIT_EXECUTABLE}" -C bgfx log --pretty=format:'%h' -n 1
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REV
ERROR_QUIET
)
execute_process(COMMAND "${GIT_EXECUTABLE}" -C bgfx rev-list --count HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REV_COUNT
ERROR_QUIET)
execute_process(
COMMAND "${GIT_EXECUTABLE}" -C bgfx rev-list --count HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REV_COUNT
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
)
# read version(100) from bgfx.idl
file(READ "${BGFX_DIR}/scripts/bgfx.idl" BGFX_IDL)
string(REGEX MATCH "version\\(([^\)]+)\\)"
BGFX_API_VERSION ${BGFX_IDL})
string(REGEX MATCH "version\\(([^\)]+)\\)" BGFX_API_VERSION ${BGFX_IDL})
set(BGFX_API_VERSION ${CMAKE_MATCH_1})
set(BGFX_REV_NUMBER ${GIT_REV_COUNT})
set(BGFX_REV ${GIT_REV})