Compare commits

...

28 Commits

Author SHA1 Message Date
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
41 changed files with 1180 additions and 681 deletions

271
.cmake-format.py Normal file
View File

@@ -0,0 +1,271 @@
# ----------------------------------
# Options affecting listfile parsing
# ----------------------------------
with section("parse"):
# Specify structure for custom cmake functions
additional_commands = { 'compile_shader_to_header': { 'kwargs': { 'OUTPUT_DIR': 1,
'SHADERS': '+',
'TYPE': 1,
'VARYING_DEF': 1},
'pargs': {'flags': [], 'nargs': '*'}},
'get_profile_ext': {'pargs': {'nargs': 2}},
'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+'}}}
# 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 = 'windows'
# 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 = {}

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

@@ -25,11 +25,11 @@ jobs:
- id: version
run: |
API_VERSION=$(grep -Eo "BGFX_API_VERSION UINT32_C\([0-9]+\)" bgfx/include/bgfx/defines.h | grep -Eo "[0-9]+" | tail -1)
REVISION=$(cd bgfx && git rev-list HEAD --count)
BGFX_REVISION=$(cd bgfx && git rev-list HEAD --count)
BGFX_CMAKE_REVISION=$(git rev-list HEAD --count)
SHA=$(cd bgfx && git rev-parse HEAD)
SHA7="${GITHUB_SHA::7}"
TAG="v1.${API_VERSION}.${REVISION}-${SHA7}"
echo "::set-output name=revision::${REVISION}"
TAG="v1.${API_VERSION}.${BGFX_REVISION}-${BGFX_CMAKE_REVISION}"
echo "::set-output name=revision::${BGFX_REVISION}"
echo "::set-output name=sha::${SHA}"
echo "::set-output name=tag::${TAG}"

View File

@@ -1,87 +1,102 @@
# 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 )
cmake_minimum_required(VERSION 3.0)
project(bgfx)
set_property( GLOBAL PROPERTY USE_FOLDERS ON )
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++" )
if(APPLE AND NOT XCODE)
set(CMAKE_CXX_FLAGS "-ObjC++")
endif()
if (MSVC AND (MSVC_VERSION GREATER_EQUAL 1914))
add_compile_options("/Zc:__cplusplus")
if(MSVC AND (MSVC_VERSION GREATER_EQUAL 1914))
add_compile_options("/Zc:__cplusplus")
endif()
option( BGFX_BUILD_TOOLS "Build bgfx tools." ON )
option( BGFX_BUILD_TOOLS_SHADER "Build bgfx shader tools." ON )
option( BGFX_BUILD_TOOLS_GEOMETRY "Build bgfx geometry tools." ON )
option( BGFX_BUILD_TOOLS_TEXTURE "Build bgfx texture tools." ON )
option( BGFX_BUILD_EXAMPLES "Build bgfx examples." ON )
option( BGFX_INSTALL "Create installation target." ON )
option( BGFX_INSTALL_EXAMPLES "Install examples and their runtimes." OFF )
option( BGFX_CUSTOM_TARGETS "Include convenience custom targets." ON )
option( BGFX_AMALGAMATED "Amalgamated bgfx build for faster compilation" OFF )
option( BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF )
option( BGFX_CONFIG_MULTITHREADED "Build bgfx with multithreaded configuration" ON )
option( BGFX_CONFIG_RENDERER_WEBGPU "Enables the webgpu renderer" OFF )
option( BX_CONFIG_DEBUG "Log debug messages (default: on in debug)" OFF )
option(BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF)
option(BX_CONFIG_DEBUG "Log debug messages (default: on in debug)" OFF)
option(BGFX_AMALGAMATED "Amalgamated bgfx build for faster compilation" OFF)
option(BGFX_BUILD_TOOLS "Build bgfx tools." ON)
option(BGFX_BUILD_TOOLS_SHADER "Build bgfx shader tools." ON)
option(BGFX_BUILD_TOOLS_GEOMETRY "Build bgfx geometry tools." ON)
option(BGFX_BUILD_TOOLS_TEXTURE "Build bgfx texture tools." ON)
option(BGFX_BUILD_EXAMPLES "Build bgfx examples." ON)
option(BGFX_INSTALL "Create installation target." ON)
option(BGFX_INSTALL_EXAMPLES "Install examples and their runtimes." OFF)
option(BGFX_CUSTOM_TARGETS "Include convenience custom targets." ON)
option(BGFX_CONFIG_MULTITHREADED "Build bgfx with multithreaded configuration" ON)
option(BGFX_CONFIG_RENDERER_WEBGPU "Enable the webgpu renderer" OFF)
option(BGFX_CONFIG_DEBUG_ANNOTATION "Enable gfx debug annotations (default: on in debug)" OFF)
set( BGFX_OPENGL_VERSION "" CACHE STRING "Specify minimum opengl version" )
set( BGFX_OPENGLES_VERSION "" CACHE STRING "Specify minimum OpenGL ES version" )
set( BGFX_LIBRARY_TYPE "STATIC" CACHE STRING "Linking type for library" )
set(BGFX_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)")
if( BGFX_LIBRARY_TYPE MATCHES "SHARED" )
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
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}")
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}")
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}")
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_CURRENT_SOURCE_DIR}/cmake/version.cmake )
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.cmake)
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/shared.cmake )
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bx.cmake )
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bimg.cmake )
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfx.cmake )
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/shared.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bx.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bimg.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfx.cmake)
if( BGFX_BUILD_TOOLS )
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/tools.cmake )
if(BGFX_BUILD_TOOLS)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/tools.cmake)
endif()
if( BGFX_BUILD_TOOLS OR BGFX_BUILD_EXAMPLES )
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/examples.cmake )
if(BGFX_BUILD_TOOLS OR BGFX_BUILD_EXAMPLES)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/examples.cmake)
endif()
if( BGFX_INSTALL )
if(BGFX_INSTALL)
include(GNUInstallDirs)
# Layout. This works for all platforms:
@@ -108,102 +123,103 @@ if( BGFX_INSTALL )
else()
set(BGFX_COMPATIBILITY SameMinorVersion)
endif()
write_basic_package_version_file(
"${version_config}"
VERSION ${PROJECT_VERSION}
COMPATIBILITY ${BGFX_COMPATIBILITY}
)
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_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in"
"${project_config}"
"${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( 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}"
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}"
if(NOT BGFX_LIBRARY_TYPE MATCHES "SHARED")
install(
TARGETS bimg
bx
astc-encoder
edtaa3
etc1
etc2
iqa
squish
nvtt
pvrtc
tinyexr
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
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}"
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()
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}")
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(FILES ${BGFX_DIR}/src/bgfx_shader.sh ${BGFX_DIR}/src/bgfx_compute.sh
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bgfx"
)
# install tools
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfxToolUtils.cmake
DESTINATION "${config_install_dir}")
if( BGFX_BUILD_TOOLS )
install( TARGETS shaderc
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS geometryc
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS geometryv
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS texturec
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS texturev
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfxToolUtils.cmake DESTINATION "${config_install_dir}")
if(BGFX_BUILD_TOOLS)
if(BGFX_BUILD_TOOLS_SHADER)
install(TARGETS shaderc EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
if(BGFX_BUILD_TOOLS_GEOMETRY)
install(TARGETS geometryc EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(TARGETS geometryv EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
if(BGFX_BUILD_TOOLS_TEXTURE)
install(TARGETS texturec EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(TARGETS texturev EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
endif()
# install examples
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 )
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}"
)
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}"
)
install(EXPORT "${TARGETS_EXPORT_NAME}" NAMESPACE "${namespace}" DESTINATION "${config_install_dir}")
endif()

View File

@@ -1,37 +1,38 @@
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
-------------
---
```bash
git clone https://github.com/bkaradzic/bgfx.cmake.git
cd bgfx.cmake
git submodule init
git submodule update
mkdir build
cd build
cmake ..
cmake -S. -Bcmake-build # $CMakeOptions
cmake --build cmake-build
```
If downloading via zip (instead of using git submodules) manually download bx, bimg and bgfx and copy them into the root directory, or locate them via `BX_DIR`, `BIMG_DIR` and `BGFX_DIR` CMake variables.
How To Use
-------------
This project is setup to be included a few different ways. To include bgfx source code in your project simply use add_subdirectory to include this project. To build bgfx binaries build the `INSTALL` target (or `make install`). The installed files will be in the directory specified by `CMAKE_INSTALL_PREFIX` which I recommend you set to `./install` so it will export to your build directory. Note you may want to build install on both `Release` and `Debug` configurations.
----------
This project is setup to be included a few different ways. To include bgfx source code in your project simply use add_subdirectory to include this project. To build bgfx binaries build the `INSTALL` target (or `make install`). The installed files will be in the directory specified by `CMAKE_INSTALL_PREFIX` which we recommend you set to `./install` so it will export to your build directory. Note you may want to build install on both `Release` and `Debug` configurations.
Features
-------------
--------
* No outside dependencies besides bx, bimg, bgfx, and CMake.
* Tested on Visual Studio 2015, Xcode, gcc 5.4, clang 3.8.
* Tested on
* Windows, OSX, Linux, Android, UWP, Emscripten (experimental)
* VSCode, Visual Studio, Xcode, gcc, clang.
* Compiles bgfx, tools & examples.
* Detects shader modifications and automatically rebuilds them for all examples.
Does this work with latest bx/bgfx/bimg?
-------------
----------------------------------------
Probably! This project needs to be updated if a dependency is added or the bgfx build system changes. The bgfx repository is very active but these types of changes are rare. New examples have to be added manually as well, but not doing so will merely result in that example not showing up and won't break anything else. If pulling latest causes issues, be sure to manually reconfigure CMake as the glob patterns may need to be refreshed (the use of glob patterns in CMake is generally discouraged but in this project it helps to ensure upwards compatibilty with newer bgfx updates).

2
bgfx

Submodule bgfx updated: 8e94c8c2db...5f435ea56b

2
bimg

Submodule bimg updated: 90ac47dfb0...1af90543ca

2
bx

Submodule bx updated: dbafa143d9...aed1086c48

View File

@@ -8,21 +8,23 @@
# You should have received a copy of the CC0 Public Domain Dedication along with
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
if( TARGET astc-codec )
if( TARGET astc-encoder )
return()
endif()
file(
GLOB
ASTC_CODEC_SOURCES
${BIMG_DIR}/3rdparty/astc-codec/src/decoder/*.cc
${BIMG_DIR}/3rdparty/astc-codec/src/decoder/*.h
ASTC_ENCODER_SOURCES
${BIMG_DIR}/3rdparty/astc-encoder/source/*.cpp
${BIMG_DIR}/3rdparty/astc-encoder/include/*.h
)
add_library( astc-codec STATIC ${ASTC_CODEC_SOURCES} )
target_include_directories( astc-codec
add_library( astc-encoder STATIC ${ASTC_ENCODER_SOURCES} )
target_include_directories( astc-encoder
PUBLIC
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty>
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-codec>
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-codec/include> )
set_target_properties( astc-codec PROPERTIES FOLDER "bgfx/3rdparty" )
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-encoder>
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-encoder/include> )
set_target_properties( astc-encoder
PROPERTIES
FOLDER "bgfx/3rdparty" )

View File

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

View File

@@ -18,4 +18,7 @@ add_library( dear-imgui STATIC EXCLUDE_FROM_ALL ${dear_IMGUI_SOURCES} )
target_compile_definitions( dear-imgui PRIVATE "-D_CRT_SECURE_NO_WARNINGS" "-D__STDC_FORMAT_MACROS" )
target_include_directories( dear-imgui PUBLIC ${BGFX_DIR}/3rdparty )
target_link_libraries( dear-imgui PUBLIC bx )
set_target_properties( dear-imgui PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( dear-imgui
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -16,4 +16,7 @@ file( GLOB EDTAA3_SOURCES ${BIMG_DIR}/3rdparty/edtaa3/*.cpp ${BIMG_DIR}/3rdparty
add_library( edtaa3 STATIC ${EDTAA3_SOURCES} )
target_include_directories( edtaa3 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( edtaa3 PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( edtaa3
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -16,4 +16,7 @@ file( GLOB ETC1_SOURCES ${BIMG_DIR}/3rdparty/etc1/*.cpp ${BIMG_DIR}/3rdparty/etc
add_library( etc1 STATIC ${ETC1_SOURCES} )
target_include_directories( etc1 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( etc1 PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( etc1
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -16,5 +16,8 @@ file( GLOB ETC2_SOURCES ${BIMG_DIR}/3rdparty/etc2/*.cpp ${BIMG_DIR}/3rdparty/etc
add_library( etc2 STATIC ${ETC2_SOURCES} )
target_include_directories( etc2 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( etc2 PROPERTIES FOLDER "bgfx/3rdparty" )
target_link_libraries( etc2 PUBLIC bx )
target_link_libraries( etc2 PUBLIC bx )
set_target_properties( etc2
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -28,5 +28,8 @@ if( MSVC )
set_target_properties( fcpp PROPERTIES COMPILE_FLAGS "/W0" )
endif()
set_target_properties( fcpp PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( fcpp
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
set_source_files_properties( ${BGFX_DIR}/3rdparty/fcpp/usecpp.c PROPERTIES HEADER_FILE_ONLY ON )

View File

@@ -84,4 +84,7 @@ elseif(APPLE)
-Wno-deprecated-register
)
endif()
set_target_properties( glsl-optimizer PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( glsl-optimizer
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -40,7 +40,10 @@ target_include_directories( glslang PUBLIC
${BGFX_DIR}/3rdparty
)
set_target_properties( glslang PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( glslang
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
if( MSVC )
target_compile_options( glslang PRIVATE
@@ -95,4 +98,4 @@ endif()
target_compile_definitions( glslang PRIVATE
ENABLE_OPT=1
ENABLE_HLSL=1
)
)

View File

@@ -16,4 +16,7 @@ file( GLOB IQA_SOURCES ${BIMG_DIR}/3rdparty/iqa/source/*.c ${BIMG_DIR}/3rdparty/
add_library( iqa STATIC ${IQA_SOURCES} )
target_include_directories( iqa PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/iqa/include> )
set_target_properties( iqa PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( iqa
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -16,4 +16,7 @@ file( GLOB SQUISH_SOURCES ${BIMG_DIR}/3rdparty/libsquish/*.cpp ${BIMG_DIR}/3rdpa
add_library( squish STATIC ${SQUISH_SOURCES} )
target_include_directories( squish PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( squish PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( squish
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -16,4 +16,7 @@ file( GLOB MESHOPTIMIZER_SOURCES ${BGFX_DIR}/3rdparty/meshoptimizer/src/*.cpp ${
add_library( meshoptimizer STATIC ${MESHOPTIMIZER_SOURCES} )
target_include_directories( meshoptimizer PUBLIC ${BGFX_DIR}/3rdparty )
set_target_properties( meshoptimizer PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( meshoptimizer
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -32,5 +32,8 @@ target_include_directories( nvtt
PUBLIC
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty>
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/nvtt> )
set_target_properties( nvtt PROPERTIES FOLDER "bgfx/3rdparty" )
target_link_libraries( nvtt PUBLIC bx )
target_link_libraries( nvtt PUBLIC bx )
set_target_properties( nvtt
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -16,4 +16,7 @@ file( GLOB PVRTC_SOURCES ${BIMG_DIR}/3rdparty/pvrtc/*.cpp ${BIMG_DIR}/3rdparty/p
add_library( pvrtc STATIC ${PVRTC_SOURCES} )
target_include_directories( pvrtc PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
set_target_properties( pvrtc PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( pvrtc
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -35,4 +35,7 @@ if( MSVC )
)
endif()
set_target_properties( spirv-cross PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( spirv-cross
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -55,4 +55,7 @@ else()
endif()
endif()
set_target_properties( spirv-tools PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( spirv-tools
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -6,4 +6,7 @@ file( GLOB_RECURSE TINYEXR_SOURCES ${BIMG_DIR}/3rdparty/tinyexr/*.c ${BIMG_DIR}/
add_library( tinyexr STATIC ${TINYEXR_SOURCES} )
target_include_directories( tinyexr PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/tinyexr/deps/miniz> )
set_target_properties( tinyexr PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( tinyexr
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -28,4 +28,7 @@ target_include_directories( webgpu
$<BUILD_INTERFACE:${BGFX_DIR}/3rdparty/webgpu/include>
)
# set_target_properties( webgpu PROPERTIES FOLDER "bgfx/3rdparty" )
set_target_properties( webgpu
PROPERTIES
FOLDER "bgfx/3rdparty"
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )

View File

@@ -6,20 +6,17 @@ list(GET BGFX_INCLUDE_PATH 0 BGFX_INCLUDE_PATH_1) # bgfx::bgfx exports include d
set(BGFX_SHADER_INCLUDE_PATH ${BGFX_INCLUDE_PATH_1}/bgfx)
# If cross compiling, we need a host-compatible version of shaderc to compile shaders
if (@CMAKE_CROSSCOMPILING@ AND NOT TARGET bgfx::shaderc)
find_program(
shaderc_EXECUTABLE REQUIRED
NAMES bgfx-shaderc shaderc
PATHS /usr/bin
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-linux/tools/bgfx
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-windows/tools/bgfx
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-osx/tools/bgfx
)
add_executable(bgfx::shaderc IMPORTED)
set_target_properties(
bgfx::shaderc PROPERTIES IMPORTED_LOCATION "${shaderc_EXECUTABLE}"
)
endif ()
if(@CMAKE_CROSSCOMPILING@ AND NOT TARGET bgfx::shaderc)
find_program(
shaderc_EXECUTABLE REQUIRED
NAMES bgfx-shaderc shaderc
PATHS /usr/bin ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-linux/tools/bgfx
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-windows/tools/bgfx
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-osx/tools/bgfx
)
add_executable(bgfx::shaderc IMPORTED)
set_target_properties(bgfx::shaderc PROPERTIES IMPORTED_LOCATION "${shaderc_EXECUTABLE}")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake")
check_required_components("@PROJECT_NAME@")
check_required_components("@PROJECT_NAME@")

View File

@@ -1,21 +1,21 @@
# 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)
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}" )
if(NOT IS_DIRECTORY ${BGFX_DIR})
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
return()
endif()
@@ -26,117 +26,183 @@ else()
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 )
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 )
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 )
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} )
add_library(bgfx STATIC ${BGFX_SOURCES})
else()
add_library( bgfx SHARED ${BGFX_SOURCES} )
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()
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} )
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} )
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" )
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=$<IF:$<CONFIG:Debug>,1,$<BOOL:${BX_CONFIG_DEBUG}>>"
"BGFX_CONFIG_MULTITHREADED=$<BOOL:${BGFX_CONFIG_MULTITHREADED}>"
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}>"
)
# 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 -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} )
# 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()
if( UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID )
# 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})
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 )
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 )
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" )
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)
if(XCODE)
set_source_files_properties(
${BGFX_DIR}/src/renderer_vk.cpp PROPERTIES LANGUAGE OBJCXX XCODE_EXPLICIT_FILE_TYPE sourcecode.cpp.objcpp
)
endif()

View File

@@ -170,14 +170,9 @@ function (_get_profile_ext PROFILE PROFILE_EXT)
string(REPLACE 120 glsl PROFILE ${PROFILE})
string(REPLACE spirv spv PROFILE ${PROFILE})
string(REPLACE metal mtl PROFILE ${PROFILE})
string(REPLACE vs_3_0 dx9 PROFILE ${PROFILE})
string(REPLACE vs_4_0 dx10 PROFILE ${PROFILE})
string(REPLACE vs_5_0 dx11 PROFILE ${PROFILE})
string(REPLACE ps_3_0 dx9 PROFILE ${PROFILE})
string(REPLACE ps_4_0 dx10 PROFILE ${PROFILE})
string(REPLACE ps_5_0 dx11 PROFILE ${PROFILE})
string(REPLACE cs_4_0 dx10 PROFILE ${PROFILE})
string(REPLACE cs_5_0 dx11 PROFILE ${PROFILE})
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}
@@ -215,17 +210,13 @@ function (compile_shader_to_header)
OR CYGWIN
)
set(PLATFORM WINDOWS)
if (ARGS_TYPE STREQUAL "VERTEX")
list(APPEND PROFILES vs_3_0)
list(APPEND PROFILES vs_4_0)
list(APPEND PROFILES vs_5_0)
elseif (ARGS_TYPE STREQUAL "FRAGMENT")
list(APPEND PROFILES ps_3_0)
list(APPEND PROFILES ps_4_0)
list(APPEND PROFILES ps_5_0)
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 cs_4_0)
list(APPEND PROFILES cs_5_0)
list(APPEND PROFILES s_4_0)
list(APPEND PROFILES s_5_0)
else ()
message(error "shaderc: Unsupported type")
endif ()

View File

@@ -1,45 +1,55 @@
# 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_CURRENT_LIST_DIR}/3rdparty/astc-codec.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/astc.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/edtaa3.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/etc1.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/etc2.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/iqa.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/libsquish.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/nvtt.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/pvrtc.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/tinyexr.cmake )
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/astc-encoder.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/edtaa3.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/etc1.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/etc2.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/iqa.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/libsquish.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/nvtt.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/pvrtc.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/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}" )
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 )
file(GLOB BIMG_SOURCES ${BIMG_DIR}/src/*.cpp)
# Create the bimg target
add_library( bimg STATIC ${BIMG_SOURCES} )
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}>)
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 )
target_link_libraries(
bimg
PUBLIC bx
PRIVATE astc-encoder
edtaa3
etc1
etc2
iqa
squish
nvtt
pvrtc
tinyexr
)
# Put in a "bgfx" folder in Visual Studio
set_target_properties( bimg PROPERTIES FOLDER "bgfx" )
set_target_properties(bimg PROPERTIES FOLDER "bgfx")

View File

@@ -1,96 +1,100 @@
# 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}" )
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 )
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 )
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 )
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} )
add_library(bx STATIC ${BX_SOURCES})
target_compile_features( bx PUBLIC cxx_std_14 )
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> )
target_compile_options(bx PUBLIC $<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>)
# Link against psapi on Windows
if( WIN32 )
target_link_libraries( bx PUBLIC psapi )
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}> )
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> )
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) # APPLE is technically UNIX... ORDERING MATTERS!
target_include_directories(
bx PUBLIC $<BUILD_INTERFACE:${BX_DIR}/include/compat/osx>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/osx>
)
elseif(UNIX)
target_include_directories(
bx PUBLIC $<BUILD_INTERFACE:${BX_DIR}/include/compat/linux>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/linux>
)
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 PUBLIC "__STDC_LIMIT_MACROS")
target_compile_definitions(bx PUBLIC "__STDC_FORMAT_MACROS")
target_compile_definitions(bx PUBLIC "__STDC_CONSTANT_MACROS")
target_compile_definitions(bx PUBLIC "BX_CONFIG_DEBUG=$<IF:$<CONFIG:Debug>,1,$<BOOL:${BX_CONFIG_DEBUG}>>")
# 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 )
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 )
find_package(Threads)
target_link_libraries(bx ${CMAKE_THREAD_LIBS_INIT} dl)
# Real time (for clock_gettime)
target_link_libraries( bx rt )
target_link_libraries(bx rt)
endif()
# Put in a "bgfx" folder in Visual Studio
set_target_properties( bx PROPERTIES FOLDER "bgfx" )
set_target_properties(bx PROPERTIES FOLDER "bgfx")

View File

@@ -1,216 +1,258 @@
# 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(CMakeParseArguments)
include( ${CMAKE_CURRENT_LIST_DIR}/util/ConfigureDebugging.cmake )
include(${CMAKE_CURRENT_LIST_DIR}/util/ConfigureDebugging.cmake)
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/dear-imgui.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/meshoptimizer.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake )
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/dear-imgui.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/meshoptimizer.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake)
function( add_bgfx_shader FILE FOLDER )
get_filename_component( FILENAME "${FILE}" NAME_WE )
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" )
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 "" )
set(TYPE "")
endif()
if( NOT "${TYPE}" STREQUAL "" )
set( COMMON FILE ${FILE} ${TYPE} INCLUDES ${BGFX_DIR}/src )
set( OUTPUTS "" )
set( OUTPUTS_PRETTY "" )
if(NOT "${TYPE}" STREQUAL "")
set(COMMON FILE ${FILE} ${TYPE} INCLUDES ${BGFX_DIR}/src)
set(OUTPUTS "")
set(OUTPUTS_PRETTY "")
if( WIN32 )
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, " )
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} )
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} )
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, " )
list(APPEND OUTPUTS "DX11")
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX11, ")
endif()
if( APPLE )
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, " )
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, " )
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} )
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} )
shaderc_parse(GLSL ${COMMON} LINUX PROFILE 430 OUTPUT ${GLSL_OUTPUT})
endif()
list( APPEND OUTPUTS "GLSL" )
set( OUTPUTS_PRETTY "${OUTPUTS_PRETTY}GLSL, " )
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 "" )
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} )
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} )
file(RELATIVE_PATH PRINT_NAME ${BGFX_DIR}/examples ${FILE})
add_custom_command(
MAIN_DEPENDENCY
${FILE}
OUTPUT
${OUTPUT_FILES}
${COMMANDS}
MAIN_DEPENDENCY ${FILE} OUTPUT ${OUTPUT_FILES} ${COMMANDS}
COMMENT "Compiling shader ${PRINT_NAME} for ${OUTPUTS_PRETTY}"
)
endif()
endfunction()
function( add_example ARG_NAME )
function(add_example ARG_NAME)
# Parse arguments
cmake_parse_arguments( ARG "COMMON" "" "DIRECTORIES;SOURCES" ${ARGN} )
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} )
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} )
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 )
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} )
if(BGFX_INSTALL_EXAMPLES)
add_executable(example-${ARG_NAME} WIN32 ${SOURCES})
else()
add_executable( example-${ARG_NAME} WIN32 EXCLUDE_FROM_ALL ${SOURCES} )
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\"" )
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} )
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")
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" )
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} )
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})
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"
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" )
set_target_properties(example-${ARG_NAME} PROPERTIES FOLDER "bgfx/examples")
if (IOS OR WIN32)
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}>)
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)
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" )
if(BGFX_CUSTOM_TARGETS)
add_custom_target(examples)
set_target_properties(examples PROPERTIES FOLDER "bgfx/examples")
endif()
# Add common library for examples
@@ -227,10 +269,9 @@ add_example(
)
# Only add examples if set, otherwise we still need exmaples common for tools
if( BGFX_BUILD_EXAMPLES )
if(BGFX_BUILD_EXAMPLES)
# Add examples
set(
BGFX_EXAMPLES
set(BGFX_EXAMPLES
00-helloworld
01-cubes
02-metaballs
@@ -252,7 +293,7 @@ if( BGFX_BUILD_EXAMPLES )
18-ibl
19-oit
20-nanovg
# 21-deferred
# 21-deferred
22-windows
23-vectordisplay
24-nbody
@@ -268,11 +309,11 @@ if( BGFX_BUILD_EXAMPLES )
34-mvs
35-dynamic
36-sky
# 37-gpudrivenrendering
# 37-gpudrivenrendering
38-bloom
39-assao
40-svt
# 41-tess
# 41-tess
42-bunnylod
43-denoise
44-sss
@@ -281,7 +322,7 @@ if( BGFX_BUILD_EXAMPLES )
47-pixelformats
)
foreach( EXAMPLE ${BGFX_EXAMPLES} )
add_example( ${EXAMPLE} )
foreach(EXAMPLE ${BGFX_EXAMPLES})
add_example(${EXAMPLE})
endforeach()
endif()

View File

@@ -1,29 +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-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 )
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 )
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} )
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,28 +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/>.
if( BGFX_CUSTOM_TARGETS )
add_custom_target( tools )
set_target_properties( tools PROPERTIES FOLDER "bgfx/tools" )
if(BGFX_CUSTOM_TARGETS)
add_custom_target(tools)
set_target_properties(tools PROPERTIES FOLDER "bgfx/tools")
endif()
if( BGFX_BUILD_TOOLS_SHADER )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/shaderc.cmake )
if(BGFX_BUILD_TOOLS_SHADER)
include(${CMAKE_CURRENT_LIST_DIR}/tools/shaderc.cmake)
endif()
if( BGFX_BUILD_TOOLS_GEOMETRY )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/geometryc.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/geometryv.cmake )
if(BGFX_BUILD_TOOLS_GEOMETRY)
include(${CMAKE_CURRENT_LIST_DIR}/tools/geometryc.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/tools/geometryv.cmake)
endif()
if( BGFX_BUILD_TOOLS_TEXTURE )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/texturec.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/tools/texturev.cmake )
if(BGFX_BUILD_TOOLS_TEXTURE)
include(${CMAKE_CURRENT_LIST_DIR}/tools/texturec.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/tools/texturev.cmake)
endif()

View File

@@ -1,26 +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/>.
include( CMakeParseArguments )
include(CMakeParseArguments)
include( ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/meshoptimizer.cmake )
include(${CMAKE_CURRENT_LIST_DIR}/../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-vertexlayout meshoptimizer )
if( BGFX_CUSTOM_TARGETS )
add_dependencies( tools geometryc )
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-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)
if(IOS)
set_target_properties(geometryc PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER geometryc)
endif()

View File

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

View File

@@ -1,34 +1,54 @@
# 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(CMakeParseArguments)
include( ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/fcpp.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/glsl-optimizer.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/glslang.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/spirv-cross.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/spirv-tools.cmake )
include( ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/webgpu.cmake )
include(${CMAKE_CURRENT_LIST_DIR}/../3rdparty/fcpp.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../3rdparty/glsl-optimizer.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../3rdparty/glslang.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../3rdparty/spirv-cross.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../3rdparty/spirv-tools.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../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)
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 )
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)
if(ANDROID)
target_link_libraries(shaderc PRIVATE log)
elseif(IOS)
set_target_properties(shaderc PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER shaderc)
endif()

View File

@@ -8,18 +8,17 @@
# 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(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 )
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()
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

@@ -8,19 +8,18 @@
# 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(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 (EMSCRIPTEN)
target_link_options( texturev PRIVATE -sMAX_WEBGL_VERSION=2 )
add_executable(texturev ${BGFX_DIR}/tools/texturev/texturev.cpp)
set_target_properties(texturev PROPERTIES FOLDER "bgfx/tools")
target_link_libraries(texturev example-common)
if(EMSCRIPTEN)
target_link_options(texturev PRIVATE -sMAX_WEBGL_VERSION=2)
endif()
if( BGFX_CUSTOM_TARGETS )
add_dependencies( tools texturev )
if(BGFX_CUSTOM_TARGETS)
add_dependencies(tools texturev)
endif()
if (IOS)
set_target_properties(texturev PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER texturev)
if(IOS)
set_target_properties(texturev PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER texturev)
endif()

View File

@@ -1,13 +1,13 @@
# 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.
@@ -36,124 +36,122 @@
#
# configure_debugging(target COMMAND "node.exe" COMMAND_X64 "node64.exe" WORKING_DIR ${CMAKE_SOURCE_DIR} DEBUGGER_ENV "PATH=%PATH%\\;$(ProjectDir)")
include( CMakeParseArguments )
include(CMakeParseArguments)
function( configure_debugging ARG_TARGET )
if( MSVC )
function(configure_debugging ARG_TARGET)
if(MSVC)
# Visual Studio Options
set(
OPTIONS
WORKING_DIR LocalDebuggerWorkingDirectory
DEBUGGER_ENV LocalDebuggerEnvironment
COMMAND LocalDebuggerCommand
COMMAND_ARGS LocalDebuggerCommandArguments
set(OPTIONS
WORKING_DIR
LocalDebuggerWorkingDirectory
DEBUGGER_ENV
LocalDebuggerEnvironment
COMMAND
LocalDebuggerCommand
COMMAND_ARGS
LocalDebuggerCommandArguments
)
# Valid Configurations
set(
CONFIGS
Debug
Release
MinSizeRel
RelWithDebInfo
)
set(CONFIGS Debug Release MinSizeRel RelWithDebInfo)
# Processors
set(
PROCESSORS
Win32
x64
)
set(PROCESSORS Win32 x64)
# Begin hackery
if( ${CMAKE_SIZEOF_VOID_P} EQUAL 8 )
set( ACTIVE_PROCESSOR "x64" )
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(ACTIVE_PROCESSOR "x64")
else()
set( ACTIVE_PROCESSOR "Win32" )
set(ACTIVE_PROCESSOR "Win32")
endif()
# Fix issues with semicolons, thx cmake
foreach( ARG ${ARGN} )
string( REPLACE ";" "\\\\\\\\\\\\\\;" RES "${ARG}" )
list( APPEND ARGS "${RES}" )
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} )
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} )
foreach(PROCESSOR ${PROCESSORS})
string(TOUPPER ${PROCESSOR} PROCESSOR)
list(APPEND ONE_ARG ${ARG}_${PROCESSOR})
endforeach()
set( ODD OFF )
set(ODD OFF)
else()
set( ODD ON )
set(ODD ON)
endif()
endforeach()
cmake_parse_arguments( ARG "" "${ONE_ARG}" "" ${ARGS} )
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}} )
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}} )
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}} )
set(ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP} ${ARG_${ARG}_${PROCESSOR_CAP}})
endif()
endif()
if( NOT "${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "" )
if(NOT "${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "")
endif()
endforeach()
endforeach()
set( ODD OFF )
set(ODD OFF)
else()
set( ODD ON )
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 )
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}>" )
set(VALUE ${ARG_${ARG}_${CONFIG_CAPS}_${PROCESSOR_CAPS}})
if(NOT "${VALUE}" STREQUAL "")
set(RESULT "${RESULT}\n <${OPTION}>${VALUE}</${OPTION}>")
endif()
set( ODD ON )
set(ODD ON)
endif()
endforeach()
set( RESULT "${RESULT}\n </PropertyGroup>" )
set(RESULT "${RESULT}\n </PropertyGroup>")
endif()
endforeach()
endforeach()
set( RESULT "${RESULT}\n</Project>" )
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET}.vcxproj.user "${RESULT}" )
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
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})