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