mirror of
https://github.com/bkaradzic/bgfx.cmake.git
synced 2026-02-17 21:12:35 +01:00
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.
This commit is contained in:
271
.cmake-format.py
Normal file
271
.cmake-format.py
Normal 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 = {}
|
||||||
|
|
||||||
55
.github/workflows/format.yml
vendored
Normal file
55
.github/workflows/format.yml
vendored
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# https://github.com/openblack/bgfx.cmake/blob/master/.github/workflows/format.yml
|
||||||
|
name: Format
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request_target:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
job:
|
||||||
|
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
|
||||||
249
CMakeLists.txt
249
CMakeLists.txt
@@ -1,102 +1,102 @@
|
|||||||
# bgfx.cmake - bgfx building in cmake
|
# bgfx.cmake - bgfx building in cmake
|
||||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||||
|
#
|
||||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
# 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
|
# and related and neighboring rights to this software to the public domain
|
||||||
# worldwide. This software is distributed without any warranty.
|
# worldwide. This software is distributed without any warranty.
|
||||||
|
#
|
||||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
# 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/>.
|
# 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)
|
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 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
# Makefile generators on apple need this flag to compile mixed objective/c++
|
# Makefile generators on apple need this flag to compile mixed objective/c++
|
||||||
if( APPLE AND NOT XCODE )
|
if(APPLE AND NOT XCODE)
|
||||||
set( CMAKE_CXX_FLAGS "-ObjC++" )
|
set(CMAKE_CXX_FLAGS "-ObjC++")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC AND (MSVC_VERSION GREATER_EQUAL 1914))
|
if(MSVC AND (MSVC_VERSION GREATER_EQUAL 1914))
|
||||||
add_compile_options("/Zc:__cplusplus")
|
add_compile_options("/Zc:__cplusplus")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option( BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF )
|
option(BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF)
|
||||||
option( BX_CONFIG_DEBUG "Log debug messages (default: on in debug)" 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_AMALGAMATED "Amalgamated bgfx build for faster compilation" OFF)
|
||||||
option( BGFX_BUILD_TOOLS "Build bgfx tools." ON )
|
option(BGFX_BUILD_TOOLS "Build bgfx tools." ON)
|
||||||
option( BGFX_BUILD_TOOLS_SHADER "Build bgfx shader 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_GEOMETRY "Build bgfx geometry tools." ON)
|
||||||
option( BGFX_BUILD_TOOLS_TEXTURE "Build bgfx texture tools." ON )
|
option(BGFX_BUILD_TOOLS_TEXTURE "Build bgfx texture tools." ON)
|
||||||
option( BGFX_BUILD_EXAMPLES "Build bgfx examples." ON )
|
option(BGFX_BUILD_EXAMPLES "Build bgfx examples." ON)
|
||||||
option( BGFX_INSTALL "Create installation target." ON )
|
option(BGFX_INSTALL "Create installation target." ON)
|
||||||
option( BGFX_INSTALL_EXAMPLES "Install examples and their runtimes." OFF )
|
option(BGFX_INSTALL_EXAMPLES "Install examples and their runtimes." OFF)
|
||||||
option( BGFX_CUSTOM_TARGETS "Include convenience custom targets." ON )
|
option(BGFX_CUSTOM_TARGETS "Include convenience custom targets." ON)
|
||||||
option( BGFX_CONFIG_MULTITHREADED "Build bgfx with multithreaded configuration" ON )
|
option(BGFX_CONFIG_MULTITHREADED "Build bgfx with multithreaded configuration" ON)
|
||||||
option( BGFX_CONFIG_RENDERER_WEBGPU "Enable the webgpu renderer" OFF )
|
option(BGFX_CONFIG_RENDERER_WEBGPU "Enable the webgpu renderer" OFF)
|
||||||
option( BGFX_CONFIG_DEBUG_ANNOTATION "Enable gfx debug annotations (default: on in debug)" 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_OPENGL_VERSION "" CACHE STRING "Specify minimum opengl version")
|
||||||
set( BGFX_OPENGLES_VERSION "" CACHE STRING "Specify minimum OpenGL ES 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_LIBRARY_TYPE "STATIC" CACHE STRING "Linking type for library")
|
||||||
|
|
||||||
set( BGFX_CONFIG_DEFAULT_MAX_ENCODERS "" CACHE STRING "Specify default maximum encoder count (multithreaded only)" )
|
set(BGFX_CONFIG_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_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_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_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_LAYOUTS "" CACHE STRING "Specify maximum vertex layouts")
|
||||||
set( BGFX_CONFIG_MAX_VERTEX_BUFFERS "" CACHE STRING "Specify maximum vertex buffer count" )
|
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_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_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_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_TEXTURES "" CACHE STRING "Specify maximum texture count")
|
||||||
set( BGFX_CONFIG_MAX_TEXTURE_SAMPLERS "" CACHE STRING "Specify maximum texture samplers" )
|
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_MAX_SHADERS "" CACHE STRING "Specify shader count")
|
||||||
set( BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM "" CACHE STRING "Specify maximum program count as 2^(program bits)" )
|
set(BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM "" CACHE STRING "Specify maximum program count as 2^(program bits)")
|
||||||
|
|
||||||
set_property( CACHE BGFX_LIBRARY_TYPE PROPERTY STRINGS STATIC SHARED )
|
set_property(CACHE BGFX_LIBRARY_TYPE PROPERTY STRINGS STATIC SHARED)
|
||||||
|
|
||||||
if( BGFX_LIBRARY_TYPE MATCHES "SHARED" )
|
if(BGFX_LIBRARY_TYPE MATCHES "SHARED")
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( NOT BX_DIR )
|
if(NOT BX_DIR)
|
||||||
set( BX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bx" CACHE STRING "Location of bx." )
|
set(BX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bx" CACHE STRING "Location of bx.")
|
||||||
elseif( NOT IS_ABSOLUTE "${BX_DIR}")
|
elseif(NOT IS_ABSOLUTE "${BX_DIR}")
|
||||||
get_filename_component(BX_DIR "${BX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
get_filename_component(BX_DIR "${BX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
endif()
|
endif()
|
||||||
if( NOT BIMG_DIR )
|
if(NOT BIMG_DIR)
|
||||||
set( BIMG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bimg" CACHE STRING "Location of bimg." )
|
set(BIMG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bimg" CACHE STRING "Location of bimg.")
|
||||||
elseif( NOT IS_ABSOLUTE "${BIMG_DIR}")
|
elseif(NOT IS_ABSOLUTE "${BIMG_DIR}")
|
||||||
get_filename_component(BIMG_DIR "${BIMG_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
get_filename_component(BIMG_DIR "${BIMG_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
endif()
|
endif()
|
||||||
if( NOT BGFX_DIR )
|
if(NOT BGFX_DIR)
|
||||||
set( BGFX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bgfx" CACHE STRING "Location of bgfx." )
|
set(BGFX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bgfx" CACHE STRING "Location of bgfx.")
|
||||||
elseif( NOT IS_ABSOLUTE "${BGFX_DIR}")
|
elseif(NOT IS_ABSOLUTE "${BGFX_DIR}")
|
||||||
get_filename_component(BGFX_DIR "${BGFX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
get_filename_component(BGFX_DIR "${BGFX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# sets project version from api ver / git rev
|
# 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/shared.cmake)
|
||||||
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bx.cmake )
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bx.cmake)
|
||||||
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bimg.cmake )
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bimg.cmake)
|
||||||
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfx.cmake )
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfx.cmake)
|
||||||
|
|
||||||
if( BGFX_BUILD_TOOLS )
|
if(BGFX_BUILD_TOOLS)
|
||||||
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/tools.cmake )
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/tools.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( BGFX_BUILD_TOOLS OR BGFX_BUILD_EXAMPLES )
|
if(BGFX_BUILD_TOOLS OR BGFX_BUILD_EXAMPLES)
|
||||||
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/examples.cmake )
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/examples.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( BGFX_INSTALL )
|
if(BGFX_INSTALL)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# Layout. This works for all platforms:
|
# Layout. This works for all platforms:
|
||||||
@@ -123,108 +123,103 @@ if( BGFX_INSTALL )
|
|||||||
else()
|
else()
|
||||||
set(BGFX_COMPATIBILITY SameMinorVersion)
|
set(BGFX_COMPATIBILITY SameMinorVersion)
|
||||||
endif()
|
endif()
|
||||||
write_basic_package_version_file(
|
write_basic_package_version_file("${version_config}" VERSION ${PROJECT_VERSION} COMPATIBILITY ${BGFX_COMPATIBILITY})
|
||||||
"${version_config}"
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
COMPATIBILITY ${BGFX_COMPATIBILITY}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Configure '<PROJECT-NAME>Config.cmake'
|
# Configure '<PROJECT-NAME>Config.cmake'
|
||||||
# Use variables:
|
# Use variables:
|
||||||
# * TARGETS_EXPORT_NAME
|
# * TARGETS_EXPORT_NAME
|
||||||
# * PROJECT_NAME
|
# * PROJECT_NAME
|
||||||
configure_package_config_file(
|
configure_package_config_file(
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in"
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in" "${project_config}"
|
||||||
"${project_config}"
|
|
||||||
INSTALL_DESTINATION "${config_install_dir}"
|
INSTALL_DESTINATION "${config_install_dir}"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(FILES ${BGFX_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/licences/${PROJECT_NAME})
|
install(FILES ${BGFX_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/licences/${PROJECT_NAME})
|
||||||
|
|
||||||
install( TARGETS bgfx
|
install(
|
||||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
TARGETS bgfx
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||||
|
INCLUDES
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
)
|
)
|
||||||
if( NOT BGFX_LIBRARY_TYPE MATCHES "SHARED" )
|
if(NOT BGFX_LIBRARY_TYPE MATCHES "SHARED")
|
||||||
install( TARGETS bimg bx astc-encoder edtaa3 etc1 etc2 iqa squish nvtt pvrtc tinyexr
|
install(
|
||||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
TARGETS bimg
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
bx
|
||||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
astc-encoder
|
||||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
edtaa3
|
||||||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
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()
|
endif()
|
||||||
if (BGFX_CONFIG_RENDERER_WEBGPU)
|
if(BGFX_CONFIG_RENDERER_WEBGPU)
|
||||||
install( TARGETS webgpu
|
install(
|
||||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
TARGETS webgpu
|
||||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||||
|
INCLUDES
|
||||||
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# install headers (this should be done as a target probably... ^)
|
# 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 ${BX_DIR}/include/bx ${BX_DIR}/include/compat ${BX_DIR}/include/tinystl
|
||||||
install( DIRECTORY ${BIMG_DIR}/include/bimg DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
install( DIRECTORY ${BGFX_DIR}/include/bgfx 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
|
# header required for shader compilation
|
||||||
install( FILES ${BGFX_DIR}/src/bgfx_shader.sh ${BGFX_DIR}/src/bgfx_compute.sh
|
install(FILES ${BGFX_DIR}/src/bgfx_shader.sh ${BGFX_DIR}/src/bgfx_compute.sh
|
||||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bgfx"
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bgfx"
|
||||||
)
|
)
|
||||||
|
|
||||||
# install tools
|
# install tools
|
||||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfxToolUtils.cmake
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfxToolUtils.cmake DESTINATION "${config_install_dir}")
|
||||||
DESTINATION "${config_install_dir}")
|
if(BGFX_BUILD_TOOLS)
|
||||||
if( BGFX_BUILD_TOOLS )
|
if(BGFX_BUILD_TOOLS_SHADER)
|
||||||
if (BGFX_BUILD_TOOLS_SHADER)
|
install(TARGETS shaderc EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||||
install( TARGETS shaderc
|
|
||||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
|
||||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
|
||||||
endif()
|
endif()
|
||||||
if (BGFX_BUILD_TOOLS_GEOMETRY)
|
if(BGFX_BUILD_TOOLS_GEOMETRY)
|
||||||
install( TARGETS geometryc
|
install(TARGETS geometryc EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
install(TARGETS geometryv EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
|
||||||
install( TARGETS geometryv
|
|
||||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
|
||||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
|
||||||
endif()
|
endif()
|
||||||
if (BGFX_BUILD_TOOLS_TEXTURE)
|
if(BGFX_BUILD_TOOLS_TEXTURE)
|
||||||
install( TARGETS texturec
|
install(TARGETS texturec EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
install(TARGETS texturev EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
|
||||||
install( TARGETS texturev
|
|
||||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
|
||||||
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# install examples
|
# install examples
|
||||||
if( BGFX_BUILD_EXAMPLES AND BGFX_INSTALL_EXAMPLES )
|
if(BGFX_BUILD_EXAMPLES AND BGFX_INSTALL_EXAMPLES)
|
||||||
install( DIRECTORY ${BGFX_DIR}/examples/runtime/ DESTINATION examples )
|
install(DIRECTORY ${BGFX_DIR}/examples/runtime/ DESTINATION examples)
|
||||||
foreach( EXAMPLE ${BGFX_EXAMPLES} )
|
foreach(EXAMPLE ${BGFX_EXAMPLES})
|
||||||
install( TARGETS example-${EXAMPLE} DESTINATION examples )
|
install(TARGETS example-${EXAMPLE} DESTINATION examples)
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Config
|
# Config
|
||||||
# * <prefix>/lib/cmake/bgfx/bgfxConfig.cmake
|
# * <prefix>/lib/cmake/bgfx/bgfxConfig.cmake
|
||||||
# * <prefix>/lib/cmake/bgfx/bgfxConfigVersion.cmake
|
# * <prefix>/lib/cmake/bgfx/bgfxConfigVersion.cmake
|
||||||
install(
|
install(FILES "${project_config}" "${version_config}" DESTINATION "${config_install_dir}")
|
||||||
FILES "${project_config}" "${version_config}"
|
|
||||||
DESTINATION "${config_install_dir}"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Config
|
# Config
|
||||||
# * <prefix>/lib/cmake/bgfx/bgfxTargets.cmake
|
# * <prefix>/lib/cmake/bgfx/bgfxTargets.cmake
|
||||||
install(
|
install(EXPORT "${TARGETS_EXPORT_NAME}" NAMESPACE "${namespace}" DESTINATION "${config_install_dir}")
|
||||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
|
||||||
NAMESPACE "${namespace}"
|
|
||||||
DESTINATION "${config_install_dir}"
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -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)
|
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 cross compiling, we need a host-compatible version of shaderc to compile shaders
|
||||||
if (@CMAKE_CROSSCOMPILING@ AND NOT TARGET bgfx::shaderc)
|
if(@CMAKE_CROSSCOMPILING@ AND NOT TARGET bgfx::shaderc)
|
||||||
find_program(
|
find_program(
|
||||||
shaderc_EXECUTABLE REQUIRED
|
shaderc_EXECUTABLE REQUIRED
|
||||||
NAMES bgfx-shaderc shaderc
|
NAMES bgfx-shaderc shaderc
|
||||||
PATHS /usr/bin
|
PATHS /usr/bin ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-linux/tools/bgfx
|
||||||
${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-windows/tools/bgfx
|
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-osx/tools/bgfx
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-osx/tools/bgfx
|
)
|
||||||
)
|
add_executable(bgfx::shaderc IMPORTED)
|
||||||
add_executable(bgfx::shaderc IMPORTED)
|
set_target_properties(bgfx::shaderc PROPERTIES IMPORTED_LOCATION "${shaderc_EXECUTABLE}")
|
||||||
set_target_properties(
|
endif()
|
||||||
bgfx::shaderc PROPERTIES IMPORTED_LOCATION "${shaderc_EXECUTABLE}"
|
|
||||||
)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake")
|
||||||
check_required_components("@PROJECT_NAME@")
|
check_required_components("@PROJECT_NAME@")
|
||||||
|
|||||||
186
cmake/bgfx.cmake
186
cmake/bgfx.cmake
@@ -1,21 +1,21 @@
|
|||||||
# bgfx.cmake - bgfx building in cmake
|
# bgfx.cmake - bgfx building in cmake
|
||||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||||
|
#
|
||||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
# 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
|
# and related and neighboring rights to this software to the public domain
|
||||||
# worldwide. This software is distributed without any warranty.
|
# worldwide. This software is distributed without any warranty.
|
||||||
|
#
|
||||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
# 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/>.
|
# 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
|
# To prevent this warning: https://cmake.org/cmake/help/git-stage/policy/CMP0072.html
|
||||||
if(POLICY CMP0072)
|
if(POLICY CMP0072)
|
||||||
cmake_policy(SET CMP0072 NEW)
|
cmake_policy(SET CMP0072 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Ensure the directory exists
|
# Ensure the directory exists
|
||||||
if( NOT IS_DIRECTORY ${BGFX_DIR} )
|
if(NOT IS_DIRECTORY ${BGFX_DIR})
|
||||||
message( SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}" )
|
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -26,57 +26,69 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Grab the bgfx source files
|
# 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)
|
if(BGFX_AMALGAMATED)
|
||||||
set(BGFX_NOBUILD ${BGFX_SOURCES})
|
set(BGFX_NOBUILD ${BGFX_SOURCES})
|
||||||
list(REMOVE_ITEM BGFX_NOBUILD ${BGFX_AMALGAMATED_SOURCE})
|
list(REMOVE_ITEM BGFX_NOBUILD ${BGFX_AMALGAMATED_SOURCE})
|
||||||
foreach(BGFX_SRC ${BGFX_NOBUILD})
|
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()
|
endforeach()
|
||||||
else()
|
else()
|
||||||
# Do not build using amalgamated sources
|
# 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.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.mm PROPERTIES HEADER_FILE_ONLY ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Create the bgfx target
|
# Create the bgfx target
|
||||||
if(BGFX_LIBRARY_TYPE STREQUAL STATIC)
|
if(BGFX_LIBRARY_TYPE STREQUAL STATIC)
|
||||||
add_library( bgfx STATIC ${BGFX_SOURCES} )
|
add_library(bgfx STATIC ${BGFX_SOURCES})
|
||||||
else()
|
else()
|
||||||
add_library( bgfx SHARED ${BGFX_SOURCES} )
|
add_library(bgfx SHARED ${BGFX_SOURCES})
|
||||||
target_compile_definitions( bgfx PUBLIC BGFX_SHARED_LIB_BUILD=1 )
|
target_compile_definitions(bgfx PUBLIC BGFX_SHARED_LIB_BUILD=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BGFX_CONFIG_RENDERER_WEBGPU)
|
if(BGFX_CONFIG_RENDERER_WEBGPU)
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/webgpu.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/webgpu.cmake)
|
||||||
target_compile_definitions( bgfx PRIVATE BGFX_CONFIG_RENDERER_WEBGPU=1)
|
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_RENDERER_WEBGPU=1)
|
||||||
if (EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
target_link_options(bgfx PRIVATE "-s USE_WEBGPU=1")
|
target_link_options(bgfx PRIVATE "-s USE_WEBGPU=1")
|
||||||
else()
|
else()
|
||||||
target_link_libraries(bgfx PRIVATE webgpu)
|
target_link_libraries(bgfx PRIVATE webgpu)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
target_link_options(bgfx PUBLIC "-sMAX_WEBGL_VERSION=2")
|
target_link_options(bgfx PUBLIC "-sMAX_WEBGL_VERSION=2")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( NOT ${BGFX_OPENGL_VERSION} STREQUAL "" )
|
if(NOT ${BGFX_OPENGL_VERSION} STREQUAL "")
|
||||||
target_compile_definitions( bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION=${BGFX_OPENGL_VERSION} )
|
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION=${BGFX_OPENGL_VERSION})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( NOT ${BGFX_OPENGLES_VERSION} STREQUAL "" )
|
if(NOT ${BGFX_OPENGLES_VERSION} STREQUAL "")
|
||||||
target_compile_definitions( bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION=${BGFX_OPENGLES_VERSION} )
|
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION=${BGFX_OPENGLES_VERSION})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( NOT ${BGFX_CONFIG_DEFAULT_MAX_ENCODERS} STREQUAL "" )
|
if(NOT ${BGFX_CONFIG_DEFAULT_MAX_ENCODERS} STREQUAL "")
|
||||||
target_compile_definitions( bgfx
|
target_compile_definitions(
|
||||||
|
bgfx
|
||||||
PUBLIC
|
PUBLIC
|
||||||
"BGFX_CONFIG_DEFAULT_MAX_ENCODERS=$<IF:$<BOOL:${BGFX_CONFIG_MULTITHREADED}>,${BGFX_CONFIG_DEFAULT_MAX_ENCODERS},1>" )
|
"BGFX_CONFIG_DEFAULT_MAX_ENCODERS=$<IF:$<BOOL:${BGFX_CONFIG_MULTITHREADED}>,${BGFX_CONFIG_DEFAULT_MAX_ENCODERS},1>"
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(BGFX_CONFIG_OPTIONS "")
|
set(BGFX_CONFIG_OPTIONS "")
|
||||||
list(APPEND BGFX_CONFIG_OPTIONS
|
list(
|
||||||
|
APPEND
|
||||||
|
BGFX_CONFIG_OPTIONS
|
||||||
"BGFX_CONFIG_MAX_DRAW_CALLS"
|
"BGFX_CONFIG_MAX_DRAW_CALLS"
|
||||||
"BGFX_CONFIG_MAX_VIEWS"
|
"BGFX_CONFIG_MAX_VIEWS"
|
||||||
"BGFX_CONFIG_MAX_FRAME_BUFFERS"
|
"BGFX_CONFIG_MAX_FRAME_BUFFERS"
|
||||||
@@ -91,94 +103,106 @@ list(APPEND BGFX_CONFIG_OPTIONS
|
|||||||
"BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM"
|
"BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM"
|
||||||
)
|
)
|
||||||
foreach(BGFX_CONFIG_OPTION IN LISTS BGFX_CONFIG_OPTIONS)
|
foreach(BGFX_CONFIG_OPTION IN LISTS BGFX_CONFIG_OPTIONS)
|
||||||
if( NOT ${${BGFX_CONFIG_OPTION}} STREQUAL "" )
|
if(NOT ${${BGFX_CONFIG_OPTION}} STREQUAL "")
|
||||||
target_compile_definitions( bgfx PUBLIC "${BGFX_CONFIG_OPTION}=${${BGFX_CONFIG_OPTION}}" )
|
target_compile_definitions(bgfx PUBLIC "${BGFX_CONFIG_OPTION}=${${BGFX_CONFIG_OPTION}}")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Special Visual Studio Flags
|
# Special Visual Studio Flags
|
||||||
if( MSVC )
|
if(MSVC)
|
||||||
target_compile_definitions( bgfx PRIVATE "_CRT_SECURE_NO_WARNINGS" )
|
target_compile_definitions(bgfx PRIVATE "_CRT_SECURE_NO_WARNINGS")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Add debug config required in bx headers since bx is private
|
# Add debug config required in bx headers since bx is private
|
||||||
target_compile_definitions(bgfx
|
target_compile_definitions(
|
||||||
PUBLIC
|
bgfx
|
||||||
"BX_CONFIG_DEBUG=$<OR:$<CONFIG:Debug>,$<BOOL:${BX_CONFIG_DEBUG}>>"
|
PUBLIC
|
||||||
"BGFX_CONFIG_DEBUG_ANNOTATION=$<AND:$<NOT:$<STREQUAL:${CMAKE_SYSTEM_NAME},WindowsStore>>,$<OR:$<CONFIG:Debug>,$<BOOL:${BGFX_CONFIG_DEBUG_ANNOTATION}>>>"
|
"BX_CONFIG_DEBUG=$<OR:$<CONFIG:Debug>,$<BOOL:${BX_CONFIG_DEBUG}>>"
|
||||||
"BGFX_CONFIG_MULTITHREADED=$<BOOL:${BGFX_CONFIG_MULTITHREADED}>"
|
"BGFX_CONFIG_DEBUG_ANNOTATION=$<AND:$<NOT:$<STREQUAL:${CMAKE_SYSTEM_NAME},WindowsStore>>,$<OR:$<CONFIG:Debug>,$<BOOL:${BGFX_CONFIG_DEBUG_ANNOTATION}>>>"
|
||||||
|
"BGFX_CONFIG_MULTITHREADED=$<BOOL:${BGFX_CONFIG_MULTITHREADED}>"
|
||||||
)
|
)
|
||||||
|
|
||||||
# directx-headers
|
# directx-headers
|
||||||
set (DIRECTX_HEADERS)
|
set(DIRECTX_HEADERS)
|
||||||
if (UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID) # Only Linux
|
if(UNIX
|
||||||
set (DIRECTX_HEADERS
|
AND NOT APPLE
|
||||||
${BGFX_DIR}/3rdparty/directx-headers/include/directx
|
AND NOT EMSCRIPTEN
|
||||||
${BGFX_DIR}/3rdparty/directx-headers/include
|
AND NOT ANDROID
|
||||||
${BGFX_DIR}/3rdparty/directx-headers/include/wsl/stubs )
|
) # Only Linux
|
||||||
elseif (WIN32) # Only Windows
|
set(DIRECTX_HEADERS
|
||||||
set (DIRECTX_HEADERS
|
${BGFX_DIR}/3rdparty/directx-headers/include/directx ${BGFX_DIR}/3rdparty/directx-headers/include
|
||||||
${BGFX_DIR}/3rdparty/directx-headers/include/directx
|
${BGFX_DIR}/3rdparty/directx-headers/include/wsl/stubs
|
||||||
${BGFX_DIR}/3rdparty/directx-headers/include )
|
)
|
||||||
|
elseif(WIN32) # Only Windows
|
||||||
|
set(DIRECTX_HEADERS ${BGFX_DIR}/3rdparty/directx-headers/include/directx
|
||||||
|
${BGFX_DIR}/3rdparty/directx-headers/include
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
target_include_directories( bgfx
|
target_include_directories(
|
||||||
PRIVATE
|
bgfx PRIVATE ${DIRECTX_HEADERS} ${BGFX_DIR}/3rdparty ${BGFX_DIR}/3rdparty/khronos
|
||||||
${DIRECTX_HEADERS}
|
PUBLIC $<BUILD_INTERFACE:${BGFX_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
${BGFX_DIR}/3rdparty
|
)
|
||||||
${BGFX_DIR}/3rdparty/khronos
|
|
||||||
PUBLIC
|
|
||||||
$<BUILD_INTERFACE:${BGFX_DIR}/include>
|
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
|
||||||
|
|
||||||
# bgfx depends on bx and bimg
|
# bgfx depends on bx and bimg
|
||||||
target_link_libraries( bgfx PRIVATE bx bimg )
|
target_link_libraries(bgfx PRIVATE bx bimg)
|
||||||
|
|
||||||
# Frameworks required on iOS, tvOS and macOS
|
# Frameworks required on iOS, tvOS and macOS
|
||||||
if( ${CMAKE_SYSTEM_NAME} MATCHES iOS|tvOS )
|
if(${CMAKE_SYSTEM_NAME} MATCHES iOS|tvOS)
|
||||||
target_link_libraries (bgfx PUBLIC
|
target_link_libraries(
|
||||||
"-framework OpenGLES -framework Metal -framework UIKit -framework CoreGraphics -framework QuartzCore -framework IOKit -framework CoreFoundation")
|
bgfx
|
||||||
elseif( APPLE )
|
PUBLIC
|
||||||
find_library( COCOA_LIBRARY Cocoa )
|
"-framework OpenGLES -framework Metal -framework UIKit -framework CoreGraphics -framework QuartzCore -framework IOKit -framework CoreFoundation"
|
||||||
find_library( METAL_LIBRARY Metal )
|
)
|
||||||
find_library( QUARTZCORE_LIBRARY QuartzCore )
|
elseif(APPLE)
|
||||||
find_library( IOKIT_LIBRARY IOKit )
|
find_library(COCOA_LIBRARY Cocoa)
|
||||||
find_library( COREFOUNDATION_LIBRARY CoreFoundation )
|
find_library(METAL_LIBRARY Metal)
|
||||||
mark_as_advanced( COCOA_LIBRARY )
|
find_library(QUARTZCORE_LIBRARY QuartzCore)
|
||||||
mark_as_advanced( METAL_LIBRARY )
|
find_library(IOKIT_LIBRARY IOKit)
|
||||||
mark_as_advanced( QUARTZCORE_LIBRARY )
|
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
|
||||||
mark_as_advanced( IOKIT_LIBRARY )
|
mark_as_advanced(COCOA_LIBRARY)
|
||||||
mark_as_advanced( COREFOUNDATION_LIBRARY )
|
mark_as_advanced(METAL_LIBRARY)
|
||||||
target_link_libraries( bgfx PUBLIC ${COCOA_LIBRARY} ${METAL_LIBRARY} ${QUARTZCORE_LIBRARY} ${IOKIT_LIBRARY} ${COREFOUNDATION_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()
|
endif()
|
||||||
|
|
||||||
if( UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID )
|
if(UNIX
|
||||||
|
AND NOT APPLE
|
||||||
|
AND NOT EMSCRIPTEN
|
||||||
|
AND NOT ANDROID
|
||||||
|
)
|
||||||
find_package(X11 REQUIRED)
|
find_package(X11 REQUIRED)
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
#The following commented libraries are linked by bx
|
#The following commented libraries are linked by bx
|
||||||
#find_package(Threads REQUIRED)
|
#find_package(Threads REQUIRED)
|
||||||
#find_library(LIBRT_LIBRARIES rt)
|
#find_library(LIBRT_LIBRARIES rt)
|
||||||
#find_library(LIBDL_LIBRARIES dl)
|
#find_library(LIBDL_LIBRARIES dl)
|
||||||
target_link_libraries( bgfx PUBLIC ${X11_LIBRARIES} ${OPENGL_LIBRARIES})
|
target_link_libraries(bgfx PUBLIC ${X11_LIBRARIES} ${OPENGL_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Exclude mm files if not on OS X
|
# Exclude mm files if not on OS X
|
||||||
if( NOT APPLE )
|
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_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/glcontext_nsgl.mm PROPERTIES HEADER_FILE_ONLY ON)
|
||||||
set_source_files_properties( ${BGFX_DIR}/src/renderer_mtl.mm PROPERTIES HEADER_FILE_ONLY ON )
|
set_source_files_properties(${BGFX_DIR}/src/renderer_mtl.mm PROPERTIES HEADER_FILE_ONLY ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Exclude glx context on non-unix
|
# Exclude glx context on non-unix
|
||||||
if( NOT UNIX OR APPLE )
|
if(NOT UNIX OR APPLE)
|
||||||
set_source_files_properties( ${BGFX_DIR}/src/glcontext_glx.cpp PROPERTIES HEADER_FILE_ONLY ON )
|
set_source_files_properties(${BGFX_DIR}/src/glcontext_glx.cpp PROPERTIES HEADER_FILE_ONLY ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Put in a "bgfx" folder in Visual Studio
|
# 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)
|
# in Xcode we need to specify this file as objective-c++ (instead of renaming to .mm)
|
||||||
if (XCODE)
|
if(XCODE)
|
||||||
set_source_files_properties(${BGFX_DIR}/src/renderer_vk.cpp PROPERTIES LANGUAGE OBJCXX XCODE_EXPLICIT_FILE_TYPE sourcecode.cpp.objcpp)
|
set_source_files_properties(
|
||||||
|
${BGFX_DIR}/src/renderer_vk.cpp PROPERTIES LANGUAGE OBJCXX XCODE_EXPLICIT_FILE_TYPE sourcecode.cpp.objcpp
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,44 +1,55 @@
|
|||||||
# bgfx.cmake - bgfx building in cmake
|
# bgfx.cmake - bgfx building in cmake
|
||||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||||
|
#
|
||||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
# 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
|
# and related and neighboring rights to this software to the public domain
|
||||||
# worldwide. This software is distributed without any warranty.
|
# worldwide. This software is distributed without any warranty.
|
||||||
|
#
|
||||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
# 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/>.
|
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
# Third party libs
|
# Third party libs
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/astc-encoder.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/astc-encoder.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/edtaa3.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/edtaa3.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/etc1.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/etc1.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/etc2.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/etc2.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/iqa.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/iqa.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/libsquish.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/libsquish.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/nvtt.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/nvtt.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/pvrtc.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/pvrtc.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/tinyexr.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/tinyexr.cmake)
|
||||||
|
|
||||||
# Ensure the directory exists
|
# Ensure the directory exists
|
||||||
if( NOT IS_DIRECTORY ${BIMG_DIR} )
|
if(NOT IS_DIRECTORY ${BIMG_DIR})
|
||||||
message( SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}" )
|
message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Grab the bimg source files
|
# 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
|
# Create the bimg target
|
||||||
add_library( bimg STATIC ${BIMG_SOURCES} )
|
add_library(bimg STATIC ${BIMG_SOURCES})
|
||||||
|
|
||||||
# Add include directory of bimg
|
# Add include directory of bimg
|
||||||
target_include_directories( bimg
|
target_include_directories(
|
||||||
PUBLIC
|
bimg PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
$<BUILD_INTERFACE:${BIMG_DIR}/include>
|
)
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
|
||||||
|
|
||||||
# bimg dependencies
|
# bimg dependencies
|
||||||
target_link_libraries( bimg PUBLIC bx PRIVATE astc-encoder 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
|
# Put in a "bgfx" folder in Visual Studio
|
||||||
set_target_properties( bimg PROPERTIES FOLDER "bgfx" )
|
set_target_properties(bimg PROPERTIES FOLDER "bgfx")
|
||||||
|
|||||||
107
cmake/bx.cmake
107
cmake/bx.cmake
@@ -1,101 +1,100 @@
|
|||||||
# bgfx.cmake - bgfx building in cmake
|
# bgfx.cmake - bgfx building in cmake
|
||||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||||
|
#
|
||||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
# 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
|
# and related and neighboring rights to this software to the public domain
|
||||||
# worldwide. This software is distributed without any warranty.
|
# worldwide. This software is distributed without any warranty.
|
||||||
|
#
|
||||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
# 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/>.
|
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
# Ensure the directory exists
|
# Ensure the directory exists
|
||||||
if( NOT IS_DIRECTORY ${BX_DIR} )
|
if(NOT IS_DIRECTORY ${BX_DIR})
|
||||||
message( SEND_ERROR "Could not load bx, directory does not exist. ${BX_DIR}" )
|
message(SEND_ERROR "Could not load bx, directory does not exist. ${BX_DIR}")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Grab the bx source files
|
# Grab the bx source files
|
||||||
file( GLOB BX_SOURCES ${BX_DIR}/src/*.cpp )
|
file(GLOB BX_SOURCES ${BX_DIR}/src/*.cpp)
|
||||||
|
|
||||||
if(BX_AMALGAMATED)
|
if(BX_AMALGAMATED)
|
||||||
set(BX_NOBUILD ${BX_SOURCES})
|
set(BX_NOBUILD ${BX_SOURCES})
|
||||||
list(REMOVE_ITEM BX_NOBUILD ${BX_DIR}/src/amalgamated.cpp)
|
list(REMOVE_ITEM BX_NOBUILD ${BX_DIR}/src/amalgamated.cpp)
|
||||||
foreach(BX_SRC ${BX_NOBUILD})
|
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()
|
endforeach()
|
||||||
else()
|
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()
|
endif()
|
||||||
|
|
||||||
# Create the bx target
|
# 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)
|
# (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
|
# Link against psapi on Windows
|
||||||
if( WIN32 )
|
if(WIN32)
|
||||||
target_link_libraries( bx PUBLIC psapi )
|
target_link_libraries(bx PUBLIC psapi)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# Add include directory of bx
|
# Add include directory of bx
|
||||||
target_include_directories( bx
|
target_include_directories(
|
||||||
PUBLIC
|
bx PUBLIC $<BUILD_INTERFACE:${BX_DIR}/include> $<BUILD_INTERFACE:${BX_DIR}/3rdparty>
|
||||||
$<BUILD_INTERFACE:${BX_DIR}/include>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||||
$<BUILD_INTERFACE:${BX_DIR}/3rdparty>
|
)
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> )
|
|
||||||
|
|
||||||
# Build system specific configurations
|
# Build system specific configurations
|
||||||
if( MINGW )
|
if(MINGW)
|
||||||
target_include_directories( bx
|
target_include_directories(
|
||||||
PUBLIC
|
bx PUBLIC $<BUILD_INTERFACE:${BX_DIR}/include/compat/mingw>
|
||||||
$<BUILD_INTERFACE:${BX_DIR}/include/compat/mingw>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/mingw>
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/mingw> )
|
)
|
||||||
elseif( WIN32 )
|
elseif(WIN32)
|
||||||
target_include_directories( bx
|
target_include_directories(
|
||||||
PUBLIC
|
bx PUBLIC $<BUILD_INTERFACE:${BX_DIR}/include/compat/msvc>
|
||||||
$<BUILD_INTERFACE:${BX_DIR}/include/compat/msvc>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/msvc>
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/msvc> )
|
)
|
||||||
elseif( APPLE ) # APPLE is technically UNIX... ORDERING MATTERS!
|
elseif(APPLE) # APPLE is technically UNIX... ORDERING MATTERS!
|
||||||
target_include_directories( bx
|
target_include_directories(
|
||||||
PUBLIC
|
bx PUBLIC $<BUILD_INTERFACE:${BX_DIR}/include/compat/osx>
|
||||||
$<BUILD_INTERFACE:${BX_DIR}/include/compat/osx>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/osx>
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/osx> )
|
)
|
||||||
elseif ( UNIX )
|
elseif(UNIX)
|
||||||
target_include_directories( bx
|
target_include_directories(
|
||||||
PUBLIC
|
bx PUBLIC $<BUILD_INTERFACE:${BX_DIR}/include/compat/linux>
|
||||||
$<BUILD_INTERFACE:${BX_DIR}/include/compat/linux>
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/linux>
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/linux> )
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# All configurations
|
# All configurations
|
||||||
target_compile_definitions( bx PUBLIC "__STDC_LIMIT_MACROS" )
|
target_compile_definitions(bx PUBLIC "__STDC_LIMIT_MACROS")
|
||||||
target_compile_definitions( bx PUBLIC "__STDC_FORMAT_MACROS" )
|
target_compile_definitions(bx PUBLIC "__STDC_FORMAT_MACROS")
|
||||||
target_compile_definitions( bx PUBLIC "__STDC_CONSTANT_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}>>")
|
target_compile_definitions(bx PUBLIC "BX_CONFIG_DEBUG=$<IF:$<CONFIG:Debug>,1,$<BOOL:${BX_CONFIG_DEBUG}>>")
|
||||||
|
|
||||||
# Additional dependencies on Unix
|
# Additional dependencies on Unix
|
||||||
if (ANDROID)
|
if(ANDROID)
|
||||||
# For __android_log_write
|
# For __android_log_write
|
||||||
find_library( LOG_LIBRARY log )
|
find_library(LOG_LIBRARY log)
|
||||||
mark_as_advanced( LOG_LIBRARY )
|
mark_as_advanced(LOG_LIBRARY)
|
||||||
target_link_libraries( bx PUBLIC ${LOG_LIBRARY} )
|
target_link_libraries(bx PUBLIC ${LOG_LIBRARY})
|
||||||
elseif( APPLE )
|
elseif(APPLE)
|
||||||
find_library( FOUNDATION_LIBRARY Foundation)
|
find_library(FOUNDATION_LIBRARY Foundation)
|
||||||
mark_as_advanced( FOUNDATION_LIBRARY )
|
mark_as_advanced(FOUNDATION_LIBRARY)
|
||||||
target_link_libraries( bx PUBLIC ${FOUNDATION_LIBRARY} )
|
target_link_libraries(bx PUBLIC ${FOUNDATION_LIBRARY})
|
||||||
elseif( UNIX )
|
elseif(UNIX)
|
||||||
# Threads
|
# Threads
|
||||||
find_package( Threads )
|
find_package(Threads)
|
||||||
target_link_libraries( bx ${CMAKE_THREAD_LIBS_INIT} dl )
|
target_link_libraries(bx ${CMAKE_THREAD_LIBS_INIT} dl)
|
||||||
|
|
||||||
# Real time (for clock_gettime)
|
# Real time (for clock_gettime)
|
||||||
target_link_libraries( bx rt )
|
target_link_libraries(bx rt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Put in a "bgfx" folder in Visual Studio
|
# Put in a "bgfx" folder in Visual Studio
|
||||||
set_target_properties( bx PROPERTIES FOLDER "bgfx" )
|
set_target_properties(bx PROPERTIES FOLDER "bgfx")
|
||||||
|
|||||||
@@ -1,216 +1,258 @@
|
|||||||
# bgfx.cmake - bgfx building in cmake
|
# bgfx.cmake - bgfx building in cmake
|
||||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||||
|
#
|
||||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
# 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
|
# and related and neighboring rights to this software to the public domain
|
||||||
# worldwide. This software is distributed without any warranty.
|
# worldwide. This software is distributed without any warranty.
|
||||||
|
#
|
||||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
# 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/>.
|
# 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/dear-imgui.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/3rdparty/meshoptimizer.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/meshoptimizer.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake)
|
||||||
|
|
||||||
function( add_bgfx_shader FILE FOLDER )
|
function(add_bgfx_shader FILE FOLDER)
|
||||||
get_filename_component( FILENAME "${FILE}" NAME_WE )
|
get_filename_component(FILENAME "${FILE}" NAME_WE)
|
||||||
string( SUBSTRING "${FILENAME}" 0 2 TYPE )
|
string(SUBSTRING "${FILENAME}" 0 2 TYPE)
|
||||||
if( "${TYPE}" STREQUAL "fs" )
|
if("${TYPE}" STREQUAL "fs")
|
||||||
set( TYPE "FRAGMENT" )
|
set(TYPE "FRAGMENT")
|
||||||
set( D3D_PREFIX "ps" )
|
set(D3D_PREFIX "ps")
|
||||||
elseif( "${TYPE}" STREQUAL "vs" )
|
elseif("${TYPE}" STREQUAL "vs")
|
||||||
set( TYPE "VERTEX" )
|
set(TYPE "VERTEX")
|
||||||
set( D3D_PREFIX "vs" )
|
set(D3D_PREFIX "vs")
|
||||||
elseif( "${TYPE}" STREQUAL "cs" )
|
elseif("${TYPE}" STREQUAL "cs")
|
||||||
set( TYPE "COMPUTE" )
|
set(TYPE "COMPUTE")
|
||||||
set( D3D_PREFIX "cs" )
|
set(D3D_PREFIX "cs")
|
||||||
else()
|
else()
|
||||||
set( TYPE "" )
|
set(TYPE "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( NOT "${TYPE}" STREQUAL "" )
|
if(NOT "${TYPE}" STREQUAL "")
|
||||||
set( COMMON FILE ${FILE} ${TYPE} INCLUDES ${BGFX_DIR}/src )
|
set(COMMON FILE ${FILE} ${TYPE} INCLUDES ${BGFX_DIR}/src)
|
||||||
set( OUTPUTS "" )
|
set(OUTPUTS "")
|
||||||
set( OUTPUTS_PRETTY "" )
|
set(OUTPUTS_PRETTY "")
|
||||||
|
|
||||||
if( WIN32 )
|
if(WIN32)
|
||||||
# dx9
|
# dx9
|
||||||
if( NOT "${TYPE}" STREQUAL "COMPUTE" )
|
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||||
set( DX9_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/dx9/${FILENAME}.bin )
|
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} )
|
shaderc_parse(
|
||||||
list( APPEND OUTPUTS "DX9" )
|
DX9 ${COMMON} WINDOWS
|
||||||
set( OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX9, " )
|
PROFILE ${D3D_PREFIX}_3_0
|
||||||
|
O 3
|
||||||
|
OUTPUT ${DX9_OUTPUT}
|
||||||
|
)
|
||||||
|
list(APPEND OUTPUTS "DX9")
|
||||||
|
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX9, ")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# dx11
|
# dx11
|
||||||
set( DX11_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/dx11/${FILENAME}.bin )
|
set(DX11_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/dx11/${FILENAME}.bin)
|
||||||
if( NOT "${TYPE}" STREQUAL "COMPUTE" )
|
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||||
shaderc_parse( DX11 ${COMMON} WINDOWS PROFILE ${D3D_PREFIX}_5_0 O 3 OUTPUT ${DX11_OUTPUT} )
|
shaderc_parse(
|
||||||
|
DX11 ${COMMON} WINDOWS
|
||||||
|
PROFILE ${D3D_PREFIX}_5_0
|
||||||
|
O 3
|
||||||
|
OUTPUT ${DX11_OUTPUT}
|
||||||
|
)
|
||||||
else()
|
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()
|
endif()
|
||||||
list( APPEND OUTPUTS "DX11" )
|
list(APPEND OUTPUTS "DX11")
|
||||||
set( OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX11, " )
|
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX11, ")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( APPLE )
|
if(APPLE)
|
||||||
# metal
|
# metal
|
||||||
set( METAL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/metal/${FILENAME}.bin )
|
set(METAL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/metal/${FILENAME}.bin)
|
||||||
shaderc_parse( METAL ${COMMON} OSX PROFILE metal OUTPUT ${METAL_OUTPUT} )
|
shaderc_parse(METAL ${COMMON} OSX PROFILE metal OUTPUT ${METAL_OUTPUT})
|
||||||
list( APPEND OUTPUTS "METAL" )
|
list(APPEND OUTPUTS "METAL")
|
||||||
set( OUTPUTS_PRETTY "${OUTPUTS_PRETTY}Metal, " )
|
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}Metal, ")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# essl
|
# essl
|
||||||
if( NOT "${TYPE}" STREQUAL "COMPUTE" )
|
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||||
set( ESSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/essl/${FILENAME}.bin )
|
set(ESSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/essl/${FILENAME}.bin)
|
||||||
shaderc_parse( ESSL ${COMMON} ANDROID OUTPUT ${ESSL_OUTPUT} )
|
shaderc_parse(ESSL ${COMMON} ANDROID OUTPUT ${ESSL_OUTPUT})
|
||||||
list( APPEND OUTPUTS "ESSL" )
|
list(APPEND OUTPUTS "ESSL")
|
||||||
set( OUTPUTS_PRETTY "${OUTPUTS_PRETTY}ESSL, " )
|
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}ESSL, ")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# glsl
|
# glsl
|
||||||
set( GLSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/glsl/${FILENAME}.bin )
|
set(GLSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/glsl/${FILENAME}.bin)
|
||||||
if( NOT "${TYPE}" STREQUAL "COMPUTE" )
|
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||||
shaderc_parse( GLSL ${COMMON} LINUX PROFILE 120 OUTPUT ${GLSL_OUTPUT} )
|
shaderc_parse(GLSL ${COMMON} LINUX PROFILE 120 OUTPUT ${GLSL_OUTPUT})
|
||||||
else()
|
else()
|
||||||
shaderc_parse( GLSL ${COMMON} LINUX PROFILE 430 OUTPUT ${GLSL_OUTPUT} )
|
shaderc_parse(GLSL ${COMMON} LINUX PROFILE 430 OUTPUT ${GLSL_OUTPUT})
|
||||||
endif()
|
endif()
|
||||||
list( APPEND OUTPUTS "GLSL" )
|
list(APPEND OUTPUTS "GLSL")
|
||||||
set( OUTPUTS_PRETTY "${OUTPUTS_PRETTY}GLSL, " )
|
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}GLSL, ")
|
||||||
|
|
||||||
# spirv
|
# spirv
|
||||||
if( NOT "${TYPE}" STREQUAL "COMPUTE" )
|
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||||
set( SPIRV_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/spirv/${FILENAME}.bin )
|
set(SPIRV_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/spirv/${FILENAME}.bin)
|
||||||
shaderc_parse( SPIRV ${COMMON} LINUX PROFILE spirv OUTPUT ${SPIRV_OUTPUT} )
|
shaderc_parse(SPIRV ${COMMON} LINUX PROFILE spirv OUTPUT ${SPIRV_OUTPUT})
|
||||||
list( APPEND OUTPUTS "SPIRV" )
|
list(APPEND OUTPUTS "SPIRV")
|
||||||
set( OUTPUTS_PRETTY "${OUTPUTS_PRETTY}SPIRV" )
|
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}SPIRV")
|
||||||
set( OUTPUT_FILES "" )
|
set(OUTPUT_FILES "")
|
||||||
set( COMMANDS "" )
|
set(COMMANDS "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
foreach( OUT ${OUTPUTS} )
|
foreach(OUT ${OUTPUTS})
|
||||||
list( APPEND OUTPUT_FILES ${${OUT}_OUTPUT} )
|
list(APPEND OUTPUT_FILES ${${OUT}_OUTPUT})
|
||||||
list( APPEND COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${${OUT}} )
|
list(APPEND COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${${OUT}})
|
||||||
get_filename_component( OUT_DIR ${${OUT}_OUTPUT} DIRECTORY )
|
get_filename_component(OUT_DIR ${${OUT}_OUTPUT} DIRECTORY)
|
||||||
file( MAKE_DIRECTORY ${OUT_DIR} )
|
file(MAKE_DIRECTORY ${OUT_DIR})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
file( RELATIVE_PATH PRINT_NAME ${BGFX_DIR}/examples ${FILE} )
|
file(RELATIVE_PATH PRINT_NAME ${BGFX_DIR}/examples ${FILE})
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
MAIN_DEPENDENCY
|
MAIN_DEPENDENCY ${FILE} OUTPUT ${OUTPUT_FILES} ${COMMANDS}
|
||||||
${FILE}
|
|
||||||
OUTPUT
|
|
||||||
${OUTPUT_FILES}
|
|
||||||
${COMMANDS}
|
|
||||||
COMMENT "Compiling shader ${PRINT_NAME} for ${OUTPUTS_PRETTY}"
|
COMMENT "Compiling shader ${PRINT_NAME} for ${OUTPUTS_PRETTY}"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function( add_example ARG_NAME )
|
function(add_example ARG_NAME)
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
cmake_parse_arguments( ARG "COMMON" "" "DIRECTORIES;SOURCES" ${ARGN} )
|
cmake_parse_arguments(ARG "COMMON" "" "DIRECTORIES;SOURCES" ${ARGN})
|
||||||
|
|
||||||
# Get all source files
|
# Get all source files
|
||||||
list( APPEND ARG_DIRECTORIES "${BGFX_DIR}/examples/${ARG_NAME}" )
|
list(APPEND ARG_DIRECTORIES "${BGFX_DIR}/examples/${ARG_NAME}")
|
||||||
set( SOURCES "" )
|
set(SOURCES "")
|
||||||
set( SHADERS "" )
|
set(SHADERS "")
|
||||||
foreach( DIR ${ARG_DIRECTORIES} )
|
foreach(DIR ${ARG_DIRECTORIES})
|
||||||
if( APPLE )
|
if(APPLE)
|
||||||
file( GLOB GLOB_SOURCES ${DIR}/*.mm )
|
file(GLOB GLOB_SOURCES ${DIR}/*.mm)
|
||||||
list( APPEND SOURCES ${GLOB_SOURCES} )
|
list(APPEND SOURCES ${GLOB_SOURCES})
|
||||||
endif()
|
endif()
|
||||||
file( GLOB GLOB_SOURCES ${DIR}/*.c ${DIR}/*.cpp ${DIR}/*.h ${DIR}/*.sc )
|
file(GLOB GLOB_SOURCES ${DIR}/*.c ${DIR}/*.cpp ${DIR}/*.h ${DIR}/*.sc)
|
||||||
list( APPEND SOURCES ${GLOB_SOURCES} )
|
list(APPEND SOURCES ${GLOB_SOURCES})
|
||||||
file( GLOB GLOB_SHADERS ${DIR}/*.sc )
|
file(GLOB GLOB_SHADERS ${DIR}/*.sc)
|
||||||
list( APPEND SHADERS ${GLOB_SHADERS} )
|
list(APPEND SHADERS ${GLOB_SHADERS})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Add target
|
# Add target
|
||||||
if( ARG_COMMON )
|
if(ARG_COMMON)
|
||||||
add_library( example-${ARG_NAME} STATIC EXCLUDE_FROM_ALL ${SOURCES} )
|
add_library(example-${ARG_NAME} STATIC EXCLUDE_FROM_ALL ${SOURCES})
|
||||||
target_include_directories( example-${ARG_NAME} PUBLIC ${BGFX_DIR}/examples/common )
|
target_include_directories(example-${ARG_NAME} PUBLIC ${BGFX_DIR}/examples/common)
|
||||||
target_link_libraries( example-${ARG_NAME} PUBLIC bgfx bx bimg dear-imgui meshoptimizer )
|
target_link_libraries(example-${ARG_NAME} PUBLIC bgfx bx bimg dear-imgui meshoptimizer)
|
||||||
if( BGFX_WITH_GLFW )
|
if(BGFX_WITH_GLFW)
|
||||||
find_package( glfw3 REQUIRED )
|
find_package(glfw3 REQUIRED)
|
||||||
target_link_libraries( example-${ARG_NAME} PUBLIC glfw )
|
target_link_libraries(example-${ARG_NAME} PUBLIC glfw)
|
||||||
target_compile_definitions( example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_GLFW )
|
target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_GLFW)
|
||||||
elseif( BGFX_WITH_SDL )
|
elseif(BGFX_WITH_SDL)
|
||||||
find_package( SDL2 REQUIRED )
|
find_package(SDL2 REQUIRED)
|
||||||
target_link_libraries( example-${ARG_NAME} PUBLIC ${SDL2_LIBRARIES} )
|
target_link_libraries(example-${ARG_NAME} PUBLIC ${SDL2_LIBRARIES})
|
||||||
target_compile_definitions( example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_SDL )
|
target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_SDL)
|
||||||
elseif( UNIX AND NOT APPLE )
|
elseif(UNIX AND NOT APPLE)
|
||||||
target_link_libraries( example-${ARG_NAME} PUBLIC X11 )
|
target_link_libraries(example-${ARG_NAME} PUBLIC X11)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if( BGFX_INSTALL_EXAMPLES )
|
if(BGFX_INSTALL_EXAMPLES)
|
||||||
add_executable( example-${ARG_NAME} WIN32 ${SOURCES} )
|
add_executable(example-${ARG_NAME} WIN32 ${SOURCES})
|
||||||
else()
|
else()
|
||||||
add_executable( example-${ARG_NAME} WIN32 EXCLUDE_FROM_ALL ${SOURCES} )
|
add_executable(example-${ARG_NAME} WIN32 EXCLUDE_FROM_ALL ${SOURCES})
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries( example-${ARG_NAME} example-common )
|
target_link_libraries(example-${ARG_NAME} example-common)
|
||||||
configure_debugging( example-${ARG_NAME} WORKING_DIR ${BGFX_DIR}/examples/runtime )
|
configure_debugging(example-${ARG_NAME} WORKING_DIR ${BGFX_DIR}/examples/runtime)
|
||||||
if( MSVC )
|
if(MSVC)
|
||||||
set_target_properties( example-${ARG_NAME} PROPERTIES LINK_FLAGS "/ENTRY:\"mainCRTStartup\"" )
|
set_target_properties(example-${ARG_NAME} PROPERTIES LINK_FLAGS "/ENTRY:\"mainCRTStartup\"")
|
||||||
endif()
|
endif()
|
||||||
if( BGFX_CUSTOM_TARGETS )
|
if(BGFX_CUSTOM_TARGETS)
|
||||||
add_dependencies( examples example-${ARG_NAME} )
|
add_dependencies(examples example-${ARG_NAME})
|
||||||
endif()
|
endif()
|
||||||
if( IOS )
|
if(IOS)
|
||||||
set_target_properties(example-${ARG_NAME} PROPERTIES MACOSX_BUNDLE ON
|
set_target_properties(
|
||||||
MACOSX_BUNDLE_GUI_IDENTIFIER example-${ARG_NAME}
|
example-${ARG_NAME}
|
||||||
MACOSX_BUNDLE_BUNDLE_VERSION 0
|
PROPERTIES MACOSX_BUNDLE ON
|
||||||
MACOSX_BUNDLE_SHORT_VERSION_STRING 0
|
MACOSX_BUNDLE_GUI_IDENTIFIER example-${ARG_NAME}
|
||||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer")
|
MACOSX_BUNDLE_BUNDLE_VERSION 0
|
||||||
|
MACOSX_BUNDLE_SHORT_VERSION_STRING 0
|
||||||
|
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
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
|
# Configure shaders
|
||||||
if( NOT ARG_COMMON AND NOT IOS AND NOT EMSCRIPTEN AND NOT ANDROID)
|
if(NOT ARG_COMMON
|
||||||
foreach( SHADER ${SHADERS} )
|
AND NOT IOS
|
||||||
add_bgfx_shader( ${SHADER} ${ARG_NAME} )
|
AND NOT EMSCRIPTEN
|
||||||
|
AND NOT ANDROID
|
||||||
|
)
|
||||||
|
foreach(SHADER ${SHADERS})
|
||||||
|
add_bgfx_shader(${SHADER} ${ARG_NAME})
|
||||||
endforeach()
|
endforeach()
|
||||||
source_group( "Shader Files" FILES ${SHADERS})
|
source_group("Shader Files" FILES ${SHADERS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT ARG_COMMON AND EMSCRIPTEN)
|
if(NOT ARG_COMMON AND EMSCRIPTEN)
|
||||||
set_target_properties(example-${ARG_NAME}
|
set_target_properties(
|
||||||
PROPERTIES
|
example-${ARG_NAME}
|
||||||
LINK_FLAGS
|
PROPERTIES LINK_FLAGS
|
||||||
"-s PRECISE_F32=1 -s TOTAL_MEMORY=268435456 -s ENVIRONMENT=web --memory-init-file 1 --emrun"
|
"-s PRECISE_F32=1 -s TOTAL_MEMORY=268435456 -s ENVIRONMENT=web --memory-init-file 1 --emrun"
|
||||||
SUFFIX ".html"
|
SUFFIX ".html"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Directory name
|
# 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
|
# 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
|
# 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()
|
else()
|
||||||
# For everything else symlink some folders into our output directory
|
# 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(
|
||||||
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)
|
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/font
|
||||||
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)
|
$<TARGET_FILE_DIR:example-${ARG_NAME}>/font
|
||||||
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(
|
||||||
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)
|
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/images
|
||||||
|
$<TARGET_FILE_DIR:example-${ARG_NAME}>/images
|
||||||
|
)
|
||||||
|
add_custom_command(
|
||||||
|
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/meshes
|
||||||
|
$<TARGET_FILE_DIR:example-${ARG_NAME}>/meshes
|
||||||
|
)
|
||||||
|
add_custom_command(
|
||||||
|
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/shaders
|
||||||
|
$<TARGET_FILE_DIR:example-${ARG_NAME}>/shaders
|
||||||
|
)
|
||||||
|
add_custom_command(
|
||||||
|
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/text
|
||||||
|
$<TARGET_FILE_DIR:example-${ARG_NAME}>/text
|
||||||
|
)
|
||||||
|
add_custom_command(
|
||||||
|
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/textures
|
||||||
|
$<TARGET_FILE_DIR:example-${ARG_NAME}>/textures
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Build all examples target
|
# Build all examples target
|
||||||
if( BGFX_CUSTOM_TARGETS )
|
if(BGFX_CUSTOM_TARGETS)
|
||||||
add_custom_target( examples )
|
add_custom_target(examples)
|
||||||
set_target_properties( examples PROPERTIES FOLDER "bgfx/examples" )
|
set_target_properties(examples PROPERTIES FOLDER "bgfx/examples")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Add common library for examples
|
# Add common library for examples
|
||||||
@@ -227,10 +269,9 @@ add_example(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Only add examples if set, otherwise we still need exmaples common for tools
|
# Only add examples if set, otherwise we still need exmaples common for tools
|
||||||
if( BGFX_BUILD_EXAMPLES )
|
if(BGFX_BUILD_EXAMPLES)
|
||||||
# Add examples
|
# Add examples
|
||||||
set(
|
set(BGFX_EXAMPLES
|
||||||
BGFX_EXAMPLES
|
|
||||||
00-helloworld
|
00-helloworld
|
||||||
01-cubes
|
01-cubes
|
||||||
02-metaballs
|
02-metaballs
|
||||||
@@ -252,7 +293,7 @@ if( BGFX_BUILD_EXAMPLES )
|
|||||||
18-ibl
|
18-ibl
|
||||||
19-oit
|
19-oit
|
||||||
20-nanovg
|
20-nanovg
|
||||||
# 21-deferred
|
# 21-deferred
|
||||||
22-windows
|
22-windows
|
||||||
23-vectordisplay
|
23-vectordisplay
|
||||||
24-nbody
|
24-nbody
|
||||||
@@ -268,11 +309,11 @@ if( BGFX_BUILD_EXAMPLES )
|
|||||||
34-mvs
|
34-mvs
|
||||||
35-dynamic
|
35-dynamic
|
||||||
36-sky
|
36-sky
|
||||||
# 37-gpudrivenrendering
|
# 37-gpudrivenrendering
|
||||||
38-bloom
|
38-bloom
|
||||||
39-assao
|
39-assao
|
||||||
40-svt
|
40-svt
|
||||||
# 41-tess
|
# 41-tess
|
||||||
42-bunnylod
|
42-bunnylod
|
||||||
43-denoise
|
43-denoise
|
||||||
44-sss
|
44-sss
|
||||||
@@ -281,7 +322,7 @@ if( BGFX_BUILD_EXAMPLES )
|
|||||||
47-pixelformats
|
47-pixelformats
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach( EXAMPLE ${BGFX_EXAMPLES} )
|
foreach(EXAMPLE ${BGFX_EXAMPLES})
|
||||||
add_example( ${EXAMPLE} )
|
add_example(${EXAMPLE})
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
# bgfx.cmake - bgfx building in cmake
|
# bgfx.cmake - bgfx building in cmake
|
||||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||||
|
#
|
||||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
# 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
|
# and related and neighboring rights to this software to the public domain
|
||||||
# worldwide. This software is distributed without any warranty.
|
# worldwide. This software is distributed without any warranty.
|
||||||
|
#
|
||||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
# 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/>.
|
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
add_library( bgfx-vertexlayout INTERFACE )
|
add_library(bgfx-vertexlayout INTERFACE)
|
||||||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/generated/vertexlayout.cpp.in
|
configure_file(
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/generated/vertexlayout.cpp )
|
${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 )
|
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
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/generated/shader.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/generated/shader.cpp)
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/generated/shader.cpp )
|
target_sources(bgfx-shader INTERFACE ${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)
|
||||||
target_include_directories( bgfx-shader INTERFACE ${BGFX_DIR}/include )
|
|
||||||
|
|
||||||
# Frameworks required on OS X
|
# Frameworks required on OS X
|
||||||
if( ${CMAKE_SYSTEM_NAME} MATCHES Darwin )
|
if(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
|
||||||
find_library( COCOA_LIBRARY Cocoa )
|
find_library(COCOA_LIBRARY Cocoa)
|
||||||
mark_as_advanced( COCOA_LIBRARY )
|
mark_as_advanced(COCOA_LIBRARY)
|
||||||
target_link_libraries( bgfx-vertexlayout INTERFACE ${COCOA_LIBRARY} )
|
target_link_libraries(bgfx-vertexlayout INTERFACE ${COCOA_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,28 +1,28 @@
|
|||||||
# bgfx.cmake - bgfx building in cmake
|
# bgfx.cmake - bgfx building in cmake
|
||||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||||
|
#
|
||||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
# 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
|
# and related and neighboring rights to this software to the public domain
|
||||||
# worldwide. This software is distributed without any warranty.
|
# worldwide. This software is distributed without any warranty.
|
||||||
|
#
|
||||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
# 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/>.
|
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
if( BGFX_CUSTOM_TARGETS )
|
if(BGFX_CUSTOM_TARGETS)
|
||||||
add_custom_target( tools )
|
add_custom_target(tools)
|
||||||
set_target_properties( tools PROPERTIES FOLDER "bgfx/tools" )
|
set_target_properties(tools PROPERTIES FOLDER "bgfx/tools")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( BGFX_BUILD_TOOLS_SHADER )
|
if(BGFX_BUILD_TOOLS_SHADER)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/shaderc.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/tools/shaderc.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( BGFX_BUILD_TOOLS_GEOMETRY )
|
if(BGFX_BUILD_TOOLS_GEOMETRY)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/geometryc.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/tools/geometryc.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/geometryv.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/tools/geometryv.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( BGFX_BUILD_TOOLS_TEXTURE )
|
if(BGFX_BUILD_TOOLS_TEXTURE)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/texturec.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/tools/texturec.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/tools/texturev.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/tools/texturev.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,26 +1,25 @@
|
|||||||
# bgfx.cmake - bgfx building in cmake
|
# bgfx.cmake - bgfx building in cmake
|
||||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||||
|
#
|
||||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
# 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
|
# and related and neighboring rights to this software to the public domain
|
||||||
# worldwide. This software is distributed without any warranty.
|
# worldwide. This software is distributed without any warranty.
|
||||||
|
#
|
||||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
# 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/>.
|
# 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 )
|
add_executable(geometryc ${BGFX_DIR}/tools/geometryc/geometryc.cpp)
|
||||||
target_compile_definitions( geometryc PRIVATE "-D_CRT_SECURE_NO_WARNINGS" )
|
target_compile_definitions(geometryc PRIVATE "-D_CRT_SECURE_NO_WARNINGS")
|
||||||
set_target_properties( geometryc PROPERTIES FOLDER "bgfx/tools" )
|
set_target_properties(geometryc PROPERTIES FOLDER "bgfx/tools")
|
||||||
target_link_libraries( geometryc bx bgfx-vertexlayout meshoptimizer )
|
target_link_libraries(geometryc bx bgfx-vertexlayout meshoptimizer)
|
||||||
if( BGFX_CUSTOM_TARGETS )
|
if(BGFX_CUSTOM_TARGETS)
|
||||||
add_dependencies( tools geometryc )
|
add_dependencies(tools geometryc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (IOS)
|
if(IOS)
|
||||||
set_target_properties(geometryc PROPERTIES MACOSX_BUNDLE ON
|
set_target_properties(geometryc PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER geometryc)
|
||||||
MACOSX_BUNDLE_GUI_IDENTIFIER geometryc)
|
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,24 +1,23 @@
|
|||||||
# bgfx.cmake - bgfx building in cmake
|
# bgfx.cmake - bgfx building in cmake
|
||||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||||
|
#
|
||||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
# 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
|
# and related and neighboring rights to this software to the public domain
|
||||||
# worldwide. This software is distributed without any warranty.
|
# worldwide. This software is distributed without any warranty.
|
||||||
|
#
|
||||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
# 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/>.
|
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
|
|
||||||
add_executable( geometryv ${BGFX_DIR}/tools/geometryv/geometryv.cpp )
|
add_executable(geometryv ${BGFX_DIR}/tools/geometryv/geometryv.cpp)
|
||||||
set_target_properties( geometryv PROPERTIES FOLDER "bgfx/tools" )
|
set_target_properties(geometryv PROPERTIES FOLDER "bgfx/tools")
|
||||||
target_link_libraries( geometryv example-common )
|
target_link_libraries(geometryv example-common)
|
||||||
if(EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
target_link_options( geometryv PRIVATE -sMAX_WEBGL_VERSION=2 )
|
target_link_options(geometryv PRIVATE -sMAX_WEBGL_VERSION=2)
|
||||||
endif()
|
endif()
|
||||||
if( BGFX_CUSTOM_TARGETS )
|
if(BGFX_CUSTOM_TARGETS)
|
||||||
add_dependencies( tools geometryv )
|
add_dependencies(tools geometryv)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (IOS)
|
if(IOS)
|
||||||
set_target_properties(geometryv PROPERTIES MACOSX_BUNDLE ON
|
set_target_properties(geometryv PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER geometryv)
|
||||||
MACOSX_BUNDLE_GUI_IDENTIFIER geometryv)
|
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,34 +1,54 @@
|
|||||||
# bgfx.cmake - bgfx building in cmake
|
# bgfx.cmake - bgfx building in cmake
|
||||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||||
|
#
|
||||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
# 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
|
# and related and neighboring rights to this software to the public domain
|
||||||
# worldwide. This software is distributed without any warranty.
|
# worldwide. This software is distributed without any warranty.
|
||||||
|
#
|
||||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
# 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/>.
|
# 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/fcpp.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/glsl-optimizer.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/../3rdparty/glsl-optimizer.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/glslang.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-cross.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/spirv-tools.cmake )
|
include(${CMAKE_CURRENT_LIST_DIR}/../3rdparty/spirv-tools.cmake)
|
||||||
include( ${CMAKE_CURRENT_LIST_DIR}/../3rdparty/webgpu.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 )
|
add_executable(
|
||||||
target_compile_definitions( shaderc PRIVATE "-D_CRT_SECURE_NO_WARNINGS" )
|
shaderc
|
||||||
set_target_properties( shaderc PROPERTIES FOLDER "bgfx/tools" )
|
${BGFX_DIR}/tools/shaderc/shaderc.cpp
|
||||||
target_link_libraries(shaderc PRIVATE bx bimg bgfx-vertexlayout bgfx-shader fcpp glsl-optimizer glslang spirv-cross spirv-tools webgpu)
|
${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 )
|
if(BGFX_CUSTOM_TARGETS)
|
||||||
add_dependencies( tools shaderc )
|
add_dependencies(tools shaderc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ANDROID)
|
if(ANDROID)
|
||||||
target_link_libraries(shaderc PRIVATE log)
|
target_link_libraries(shaderc PRIVATE log)
|
||||||
elseif (IOS)
|
elseif(IOS)
|
||||||
set_target_properties(shaderc PROPERTIES MACOSX_BUNDLE ON
|
set_target_properties(shaderc PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER shaderc)
|
||||||
MACOSX_BUNDLE_GUI_IDENTIFIER shaderc)
|
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -8,18 +8,17 @@
|
|||||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
# 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/>.
|
# 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 )
|
add_executable(texturec ${BIMG_DIR}/tools/texturec/texturec.cpp)
|
||||||
set_target_properties( texturec PROPERTIES FOLDER "bgfx/tools" )
|
set_target_properties(texturec PROPERTIES FOLDER "bgfx/tools")
|
||||||
target_link_libraries( texturec bimg )
|
target_link_libraries(texturec bimg)
|
||||||
if( BGFX_CUSTOM_TARGETS )
|
if(BGFX_CUSTOM_TARGETS)
|
||||||
add_dependencies( tools texturec )
|
add_dependencies(tools texturec)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ANDROID)
|
if(ANDROID)
|
||||||
target_link_libraries( texturec log )
|
target_link_libraries(texturec log)
|
||||||
elseif (IOS)
|
elseif(IOS)
|
||||||
set_target_properties(texturec PROPERTIES MACOSX_BUNDLE ON
|
set_target_properties(texturec PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER texturec)
|
||||||
MACOSX_BUNDLE_GUI_IDENTIFIER texturec)
|
endif()
|
||||||
endif()
|
|
||||||
|
|||||||
@@ -8,19 +8,18 @@
|
|||||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
# 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/>.
|
# 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 )
|
add_executable(texturev ${BGFX_DIR}/tools/texturev/texturev.cpp)
|
||||||
set_target_properties( texturev PROPERTIES FOLDER "bgfx/tools" )
|
set_target_properties(texturev PROPERTIES FOLDER "bgfx/tools")
|
||||||
target_link_libraries( texturev example-common )
|
target_link_libraries(texturev example-common)
|
||||||
if (EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
target_link_options( texturev PRIVATE -sMAX_WEBGL_VERSION=2 )
|
target_link_options(texturev PRIVATE -sMAX_WEBGL_VERSION=2)
|
||||||
endif()
|
endif()
|
||||||
if( BGFX_CUSTOM_TARGETS )
|
if(BGFX_CUSTOM_TARGETS)
|
||||||
add_dependencies( tools texturev )
|
add_dependencies(tools texturev)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (IOS)
|
if(IOS)
|
||||||
set_target_properties(texturev PROPERTIES MACOSX_BUNDLE ON
|
set_target_properties(texturev PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER texturev)
|
||||||
MACOSX_BUNDLE_GUI_IDENTIFIER texturev)
|
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
# ConfigureDebugging.cmake
|
# ConfigureDebugging.cmake
|
||||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||||
|
#
|
||||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
# 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
|
# and related and neighboring rights to this software to the public domain
|
||||||
# worldwide. This software is distributed without any warranty.
|
# worldwide. This software is distributed without any warranty.
|
||||||
|
#
|
||||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
# 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/>.
|
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||||
#
|
|
||||||
# configure_debugging( TARGET [OPTIONS...] )
|
# configure_debugging( TARGET [OPTIONS...] )
|
||||||
#
|
#
|
||||||
# Configures the debugging settings in visual studio.
|
# 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)")
|
# 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 )
|
function(configure_debugging ARG_TARGET)
|
||||||
if( MSVC )
|
if(MSVC)
|
||||||
# Visual Studio Options
|
# Visual Studio Options
|
||||||
set(
|
set(OPTIONS
|
||||||
OPTIONS
|
WORKING_DIR
|
||||||
WORKING_DIR LocalDebuggerWorkingDirectory
|
LocalDebuggerWorkingDirectory
|
||||||
DEBUGGER_ENV LocalDebuggerEnvironment
|
DEBUGGER_ENV
|
||||||
COMMAND LocalDebuggerCommand
|
LocalDebuggerEnvironment
|
||||||
COMMAND_ARGS LocalDebuggerCommandArguments
|
COMMAND
|
||||||
|
LocalDebuggerCommand
|
||||||
|
COMMAND_ARGS
|
||||||
|
LocalDebuggerCommandArguments
|
||||||
)
|
)
|
||||||
|
|
||||||
# Valid Configurations
|
# Valid Configurations
|
||||||
set(
|
set(CONFIGS Debug Release MinSizeRel RelWithDebInfo)
|
||||||
CONFIGS
|
|
||||||
Debug
|
|
||||||
Release
|
|
||||||
MinSizeRel
|
|
||||||
RelWithDebInfo
|
|
||||||
)
|
|
||||||
|
|
||||||
# Processors
|
# Processors
|
||||||
set(
|
set(PROCESSORS Win32 x64)
|
||||||
PROCESSORS
|
|
||||||
Win32
|
|
||||||
x64
|
|
||||||
)
|
|
||||||
|
|
||||||
# Begin hackery
|
# Begin hackery
|
||||||
if( ${CMAKE_SIZEOF_VOID_P} EQUAL 8 )
|
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||||
set( ACTIVE_PROCESSOR "x64" )
|
set(ACTIVE_PROCESSOR "x64")
|
||||||
else()
|
else()
|
||||||
set( ACTIVE_PROCESSOR "Win32" )
|
set(ACTIVE_PROCESSOR "Win32")
|
||||||
endif()
|
endif()
|
||||||
# Fix issues with semicolons, thx cmake
|
# Fix issues with semicolons, thx cmake
|
||||||
foreach( ARG ${ARGN} )
|
foreach(ARG ${ARGN})
|
||||||
string( REPLACE ";" "\\\\\\\\\\\\\\;" RES "${ARG}" )
|
string(REPLACE ";" "\\\\\\\\\\\\\\;" RES "${ARG}")
|
||||||
list( APPEND ARGS "${RES}" )
|
list(APPEND ARGS "${RES}")
|
||||||
endforeach()
|
endforeach()
|
||||||
# Build options for cmake_parse_arguments, result is ONE_ARG variable
|
# Build options for cmake_parse_arguments, result is ONE_ARG variable
|
||||||
set( ODD ON )
|
set(ODD ON)
|
||||||
foreach( OPTION ${OPTIONS} )
|
foreach(OPTION ${OPTIONS})
|
||||||
if( ODD )
|
if(ODD)
|
||||||
set( ARG ${OPTION} )
|
set(ARG ${OPTION})
|
||||||
list( APPEND ONE_ARG ${ARG} )
|
list(APPEND ONE_ARG ${ARG})
|
||||||
foreach( CONFIG ${CONFIGS} )
|
foreach(CONFIG ${CONFIGS})
|
||||||
string( TOUPPER ${CONFIG} CONFIG )
|
string(TOUPPER ${CONFIG} CONFIG)
|
||||||
list( APPEND ONE_ARG ${ARG}_${CONFIG} )
|
list(APPEND ONE_ARG ${ARG}_${CONFIG})
|
||||||
foreach( PROCESSOR ${PROCESSORS} )
|
foreach(PROCESSOR ${PROCESSORS})
|
||||||
string( TOUPPER ${PROCESSOR} PROCESSOR )
|
string(TOUPPER ${PROCESSOR} PROCESSOR)
|
||||||
list( APPEND ONE_ARG ${ARG}_${CONFIG}_${PROCESSOR} )
|
list(APPEND ONE_ARG ${ARG}_${CONFIG}_${PROCESSOR})
|
||||||
endforeach()
|
endforeach()
|
||||||
endforeach()
|
endforeach()
|
||||||
foreach( PROCESSOR ${PROCESSORS} )
|
foreach(PROCESSOR ${PROCESSORS})
|
||||||
string( TOUPPER ${PROCESSOR} PROCESSOR )
|
string(TOUPPER ${PROCESSOR} PROCESSOR)
|
||||||
list( APPEND ONE_ARG ${ARG}_${PROCESSOR} )
|
list(APPEND ONE_ARG ${ARG}_${PROCESSOR})
|
||||||
endforeach()
|
endforeach()
|
||||||
set( ODD OFF )
|
set(ODD OFF)
|
||||||
else()
|
else()
|
||||||
set( ODD ON )
|
set(ODD ON)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
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
|
# Parse options, fills in all variables of format ARG_(ARG)_(CONFIG)_(PROCESSOR), for example ARG_WORKING_DIR_DEBUG_X64
|
||||||
set( ODD ON )
|
set(ODD ON)
|
||||||
foreach( OPTION ${OPTIONS} )
|
foreach(OPTION ${OPTIONS})
|
||||||
if( ODD )
|
if(ODD)
|
||||||
set( ARG ${OPTION} )
|
set(ARG ${OPTION})
|
||||||
foreach( CONFIG ${CONFIGS} )
|
foreach(CONFIG ${CONFIGS})
|
||||||
string( TOUPPER ${CONFIG} CONFIG_CAP )
|
string(TOUPPER ${CONFIG} CONFIG_CAP)
|
||||||
if( "${ARG_${ARG}_${CONFIG_CAP}}" STREQUAL "" )
|
if("${ARG_${ARG}_${CONFIG_CAP}}" STREQUAL "")
|
||||||
set( ARG_${ARG}_${CONFIG_CAP} ${ARG_${ARG}} )
|
set(ARG_${ARG}_${CONFIG_CAP} ${ARG_${ARG}})
|
||||||
endif()
|
endif()
|
||||||
foreach( PROCESSOR ${PROCESSORS} )
|
foreach(PROCESSOR ${PROCESSORS})
|
||||||
string( TOUPPER ${PROCESSOR} PROCESSOR_CAP )
|
string(TOUPPER ${PROCESSOR} PROCESSOR_CAP)
|
||||||
if( "${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "" )
|
if("${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "")
|
||||||
if( "${ARG_${ARG}_${PROCESSOR_CAP}}" STREQUAL "" )
|
if("${ARG_${ARG}_${PROCESSOR_CAP}}" STREQUAL "")
|
||||||
set( ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP} ${ARG_${ARG}_${CONFIG_CAP}} )
|
set(ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP} ${ARG_${ARG}_${CONFIG_CAP}})
|
||||||
else()
|
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()
|
||||||
endif()
|
endif()
|
||||||
if( NOT "${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "" )
|
if(NOT "${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endforeach()
|
endforeach()
|
||||||
set( ODD OFF )
|
set(ODD OFF)
|
||||||
else()
|
else()
|
||||||
set( ODD ON )
|
set(ODD ON)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
# Create string to put in proj.vcxproj.user file
|
# 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\">" )
|
set(RESULT
|
||||||
foreach( CONFIG ${CONFIGS} )
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"
|
||||||
string( TOUPPER ${CONFIG} CONFIG_CAPS )
|
)
|
||||||
foreach( PROCESSOR ${PROCESSORS} )
|
foreach(CONFIG ${CONFIGS})
|
||||||
if( "${PROCESSOR}" STREQUAL "${ACTIVE_PROCESSOR}" )
|
string(TOUPPER ${CONFIG} CONFIG_CAPS)
|
||||||
string( TOUPPER ${PROCESSOR} PROCESSOR_CAPS )
|
foreach(PROCESSOR ${PROCESSORS})
|
||||||
set( RESULT "${RESULT}\n <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='${CONFIG}|${PROCESSOR}'\">" )
|
if("${PROCESSOR}" STREQUAL "${ACTIVE_PROCESSOR}")
|
||||||
set( ODD ON )
|
string(TOUPPER ${PROCESSOR} PROCESSOR_CAPS)
|
||||||
foreach( OPTION ${OPTIONS} )
|
set(RESULT
|
||||||
if( ODD )
|
"${RESULT}\n <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='${CONFIG}|${PROCESSOR}'\">"
|
||||||
set( ARG ${OPTION} )
|
)
|
||||||
set( ODD OFF )
|
set(ODD ON)
|
||||||
|
foreach(OPTION ${OPTIONS})
|
||||||
|
if(ODD)
|
||||||
|
set(ARG ${OPTION})
|
||||||
|
set(ODD OFF)
|
||||||
else()
|
else()
|
||||||
set( VALUE ${ARG_${ARG}_${CONFIG_CAPS}_${PROCESSOR_CAPS}} )
|
set(VALUE ${ARG_${ARG}_${CONFIG_CAPS}_${PROCESSOR_CAPS}})
|
||||||
if( NOT "${VALUE}" STREQUAL "" )
|
if(NOT "${VALUE}" STREQUAL "")
|
||||||
set( RESULT "${RESULT}\n <${OPTION}>${VALUE}</${OPTION}>" )
|
set(RESULT "${RESULT}\n <${OPTION}>${VALUE}</${OPTION}>")
|
||||||
endif()
|
endif()
|
||||||
set( ODD ON )
|
set(ODD ON)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
set( RESULT "${RESULT}\n </PropertyGroup>" )
|
set(RESULT "${RESULT}\n </PropertyGroup>")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endforeach()
|
endforeach()
|
||||||
set( RESULT "${RESULT}\n</Project>" )
|
set(RESULT "${RESULT}\n</Project>")
|
||||||
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET}.vcxproj.user "${RESULT}" )
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET}.vcxproj.user "${RESULT}")
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# | | +--- Commit number (https://github.com/bkaradzic/bgfx / git rev-list --count HEAD)
|
# | | +--- 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)
|
# | +------- API version (from https://github.com/bkaradzic/bgfx/blob/master/scripts/bgfx.idl#L4)
|
||||||
# +--------- Major revision (always 1)
|
# +--------- Major revision (always 1)
|
||||||
|
#
|
||||||
# BGFX_API_VERSION generated from https://github.com/bkaradzic/bgfx/blob/master/scripts/bgfx.idl#L4
|
# BGFX_API_VERSION generated from https://github.com/bkaradzic/bgfx/blob/master/scripts/bgfx.idl#L4
|
||||||
# bgfx/src/version.h:
|
# bgfx/src/version.h:
|
||||||
# BGFX_REV_NUMBER
|
# BGFX_REV_NUMBER
|
||||||
@@ -12,20 +12,23 @@
|
|||||||
|
|
||||||
find_package(Git QUIET)
|
find_package(Git QUIET)
|
||||||
|
|
||||||
execute_process(COMMAND "${GIT_EXECUTABLE}" -C bgfx log --pretty=format:'%h' -n 1
|
execute_process(
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
COMMAND "${GIT_EXECUTABLE}" -C bgfx log --pretty=format:'%h' -n 1
|
||||||
OUTPUT_VARIABLE GIT_REV
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
ERROR_QUIET)
|
OUTPUT_VARIABLE GIT_REV
|
||||||
|
ERROR_QUIET
|
||||||
|
)
|
||||||
|
|
||||||
execute_process(COMMAND "${GIT_EXECUTABLE}" -C bgfx rev-list --count HEAD
|
execute_process(
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
COMMAND "${GIT_EXECUTABLE}" -C bgfx rev-list --count HEAD
|
||||||
OUTPUT_VARIABLE GIT_REV_COUNT
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
ERROR_QUIET)
|
OUTPUT_VARIABLE GIT_REV_COUNT
|
||||||
|
ERROR_QUIET
|
||||||
|
)
|
||||||
|
|
||||||
# read version(100) from bgfx.idl
|
# read version(100) from bgfx.idl
|
||||||
file(READ "${BGFX_DIR}/scripts/bgfx.idl" BGFX_IDL)
|
file(READ "${BGFX_DIR}/scripts/bgfx.idl" BGFX_IDL)
|
||||||
string(REGEX MATCH "version\\(([^\)]+)\\)"
|
string(REGEX MATCH "version\\(([^\)]+)\\)" BGFX_API_VERSION ${BGFX_IDL})
|
||||||
BGFX_API_VERSION ${BGFX_IDL})
|
|
||||||
set(BGFX_API_VERSION ${CMAKE_MATCH_1})
|
set(BGFX_API_VERSION ${CMAKE_MATCH_1})
|
||||||
set(BGFX_REV_NUMBER ${GIT_REV_COUNT})
|
set(BGFX_REV_NUMBER ${GIT_REV_COUNT})
|
||||||
set(BGFX_REV ${GIT_REV})
|
set(BGFX_REV ${GIT_REV})
|
||||||
|
|||||||
Reference in New Issue
Block a user