Add cmake-format config

Improve formatting.
Use Tabs.
Make copyright one whole comment block.
Remove spaces inside of functions and after if.
Remove excessive whitespace.
Add github action to validate formatting.
This commit is contained in:
Sandy Carter
2023-01-06 14:41:57 -05:00
committed by Sandy
parent c53792d472
commit 471da90712
17 changed files with 1041 additions and 631 deletions

271
.cmake-format.py Normal file
View File

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

55
.github/workflows/format.yml vendored Normal file
View 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

View File

@@ -1,10 +1,10 @@
# 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/>.
@@ -123,52 +123,65 @@ 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
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}"
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
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}"
INCLUDES
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()
if(BGFX_CONFIG_RENDERER_WEBGPU)
install( TARGETS 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}"
INCLUDES
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()
# install headers (this should be done as a target probably... ^)
install( DIRECTORY ${BX_DIR}/include/bx ${BX_DIR}/include/compat ${BX_DIR}/include/tinystl DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(DIRECTORY ${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}")
@@ -178,29 +191,18 @@ if( BGFX_INSTALL )
)
# install tools
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfxToolUtils.cmake
DESTINATION "${config_install_dir}")
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(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}" )
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}" )
install(TARGETS texturec EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(TARGETS texturev EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
endif()
@@ -215,16 +217,9 @@ if( BGFX_INSTALL )
# Config
# * <prefix>/lib/cmake/bgfx/bgfxConfig.cmake
# * <prefix>/lib/cmake/bgfx/bgfxConfigVersion.cmake
install(
FILES "${project_config}" "${version_config}"
DESTINATION "${config_install_dir}"
)
install(FILES "${project_config}" "${version_config}" DESTINATION "${config_install_dir}")
# Config
# * <prefix>/lib/cmake/bgfx/bgfxTargets.cmake
install(
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
)
install(EXPORT "${TARGETS_EXPORT_NAME}" NAMESPACE "${namespace}" DESTINATION "${config_install_dir}")
endif()

View File

@@ -10,15 +10,12 @@ 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
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}"
)
set_target_properties(bgfx::shaderc PROPERTIES IMPORTED_LOCATION "${shaderc_EXECUTABLE}")
endif()
include("${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake")

View File

@@ -1,10 +1,10 @@
# 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/>.
@@ -26,7 +26,15 @@ 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})
@@ -70,13 +78,17 @@ if( NOT ${BGFX_OPENGLES_VERSION} STREQUAL "" )
endif()
if(NOT ${BGFX_CONFIG_DEFAULT_MAX_ENCODERS} STREQUAL "")
target_compile_definitions( bgfx
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"
@@ -102,7 +114,8 @@ if( MSVC )
endif()
# Add debug config required in bx headers since bx is private
target_compile_definitions(bgfx
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}>>>"
@@ -111,34 +124,37 @@ target_compile_definitions(bgfx
# directx-headers
set(DIRECTX_HEADERS)
if (UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID) # Only Linux
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 )
${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 ${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)
# 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")
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)
@@ -150,10 +166,16 @@ elseif( APPLE )
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} )
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
@@ -180,5 +202,7 @@ 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)
set_source_files_properties(
${BGFX_DIR}/src/renderer_vk.cpp PROPERTIES LANGUAGE OBJCXX XCODE_EXPLICIT_FILE_TYPE sourcecode.cpp.objcpp
)
endif()

View File

@@ -1,10 +1,10 @@
# 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/>.
@@ -32,13 +32,24 @@ file( GLOB BIMG_SOURCES ${BIMG_DIR}/src/*.cpp )
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")

View File

@@ -1,10 +1,10 @@
# 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/>.
@@ -42,33 +42,32 @@ 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> )
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> )
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> )
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> )
target_include_directories(
bx PUBLIC $<BUILD_INTERFACE:${BX_DIR}/include/compat/linux>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/linux>
)
endif()
# All configurations

View File

@@ -1,10 +1,10 @@
# 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/>.
@@ -41,7 +41,12 @@ function( add_bgfx_shader FILE FOLDER )
# 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} )
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()
@@ -49,9 +54,19 @@ function( add_bgfx_shader FILE FOLDER )
# 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} )
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, ")
@@ -102,11 +117,7 @@ function( add_bgfx_shader FILE FOLDER )
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()
@@ -162,17 +173,27 @@ function( add_example ARG_NAME )
add_dependencies(examples example-${ARG_NAME})
endif()
if(IOS)
set_target_properties(example-${ARG_NAME} PROPERTIES MACOSX_BUNDLE ON
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")
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)
if(NOT ARG_COMMON
AND NOT IOS
AND NOT EMSCRIPTEN
AND NOT ANDROID
)
foreach(SHADER ${SHADERS})
add_bgfx_shader(${SHADER} ${ARG_NAME})
endforeach()
@@ -180,9 +201,9 @@ function( add_example ARG_NAME )
endif()
if(NOT ARG_COMMON AND EMSCRIPTEN)
set_target_properties(example-${ARG_NAME}
PROPERTIES
LINK_FLAGS
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"
)
@@ -194,15 +215,36 @@ function( add_example ARG_NAME )
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()
@@ -229,8 +271,7 @@ add_example(
# Only add examples if set, otherwise we still need exmaples common for tools
if(BGFX_BUILD_EXAMPLES)
# Add examples
set(
BGFX_EXAMPLES
set(BGFX_EXAMPLES
00-helloworld
01-cubes
02-metaballs

View File

@@ -1,23 +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_library(bgfx-vertexlayout INTERFACE)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/generated/vertexlayout.cpp.in
${CMAKE_CURRENT_BINARY_DIR}/generated/vertexlayout.cpp )
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/generated/vertexlayout.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/generated/vertexlayout.cpp
)
target_sources(bgfx-vertexlayout INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/generated/vertexlayout.cpp)
target_include_directories(bgfx-vertexlayout INTERFACE ${BGFX_DIR}/include)
add_library(bgfx-shader INTERFACE)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/generated/shader.cpp.in
${CMAKE_CURRENT_BINARY_DIR}/generated/shader.cpp )
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)

View File

@@ -1,10 +1,10 @@
# 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/>.

View File

@@ -1,10 +1,10 @@
# 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/>.
@@ -21,6 +21,5 @@ if( BGFX_CUSTOM_TARGETS )
endif()
if(IOS)
set_target_properties(geometryc PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER geometryc)
set_target_properties(geometryc PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER geometryc)
endif()

View File

@@ -1,10 +1,10 @@
# 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/>.
@@ -19,6 +19,5 @@ if( BGFX_CUSTOM_TARGETS )
endif()
if(IOS)
set_target_properties(geometryv PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER geometryv)
set_target_properties(geometryv PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER geometryv)
endif()

View File

@@ -1,10 +1,10 @@
# 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/>.
@@ -17,10 +17,31 @@ 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 )
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)
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)
@@ -29,6 +50,5 @@ endif()
if(ANDROID)
target_link_libraries(shaderc PRIVATE log)
elseif(IOS)
set_target_properties(shaderc PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER shaderc)
set_target_properties(shaderc PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER shaderc)
endif()

View File

@@ -20,6 +20,5 @@ endif()
if(ANDROID)
target_link_libraries(texturec log)
elseif(IOS)
set_target_properties(texturec PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER texturec)
set_target_properties(texturec PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER texturec)
endif()

View File

@@ -21,6 +21,5 @@ if( BGFX_CUSTOM_TARGETS )
endif()
if(IOS)
set_target_properties(texturev PROPERTIES MACOSX_BUNDLE ON
MACOSX_BUNDLE_GUI_IDENTIFIER texturev)
set_target_properties(texturev PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER texturev)
endif()

View File

@@ -1,13 +1,13 @@
# ConfigureDebugging.cmake
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty.
#
# You should have received a copy of the CC0 Public Domain Dedication along with
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
#
# configure_debugging( TARGET [OPTIONS...] )
#
# Configures the debugging settings in visual studio.
@@ -41,29 +41,22 @@ include( CMakeParseArguments )
function(configure_debugging ARG_TARGET)
if(MSVC)
# Visual Studio Options
set(
OPTIONS
WORKING_DIR LocalDebuggerWorkingDirectory
DEBUGGER_ENV LocalDebuggerEnvironment
COMMAND LocalDebuggerCommand
COMMAND_ARGS LocalDebuggerCommandArguments
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)
@@ -120,6 +113,7 @@ function( configure_debugging ARG_TARGET )
endif()
endif()
if(NOT "${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "")
endif()
endforeach()
endforeach()
@@ -129,13 +123,17 @@ function( configure_debugging ARG_TARGET )
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\">" )
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(RESULT
"${RESULT}\n <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='${CONFIG}|${PROCESSOR}'\">"
)
set(ODD ON)
foreach(OPTION ${OPTIONS})
if(ODD)

View File

@@ -4,7 +4,7 @@
# | | +--- Commit number (https://github.com/bkaradzic/bgfx / git rev-list --count HEAD)
# | +------- API version (from https://github.com/bkaradzic/bgfx/blob/master/scripts/bgfx.idl#L4)
# +--------- Major revision (always 1)
#
# BGFX_API_VERSION generated from https://github.com/bkaradzic/bgfx/blob/master/scripts/bgfx.idl#L4
# bgfx/src/version.h:
# BGFX_REV_NUMBER
@@ -12,20 +12,23 @@
find_package(Git QUIET)
execute_process(COMMAND "${GIT_EXECUTABLE}" -C bgfx log --pretty=format:'%h' -n 1
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)
ERROR_QUIET
)
execute_process(COMMAND "${GIT_EXECUTABLE}" -C bgfx rev-list --count HEAD
execute_process(
COMMAND "${GIT_EXECUTABLE}" -C bgfx rev-list --count HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REV_COUNT
ERROR_QUIET)
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})