mirror of
https://github.com/bkaradzic/bgfx.cmake.git
synced 2026-02-17 21:12:35 +01:00
Compare commits
9 Commits
v1.118.839
...
v1.118.839
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c1607365f | ||
|
|
576c2b9694 | ||
|
|
99537daccd | ||
|
|
e9b0bb3b6c | ||
|
|
d50eec41c1 | ||
|
|
34d0f372b1 | ||
|
|
87180e3b7e | ||
|
|
ef8234966e | ||
|
|
c85f396456 |
@@ -4,38 +4,46 @@
|
||||
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+'}}}
|
||||
additional_commands = { '_bgfx_bin2c_parse': { 'kwargs': { 'ARRAY_NAME': 1,
|
||||
'INPUT_FILE': 1,
|
||||
'OUTPUT_FILE': 1},
|
||||
'pargs': {'flags': [], 'nargs': '*'}},
|
||||
'_bgfx_get_profile_ext': {'pargs': {'nargs': 2}},
|
||||
'_bgfx_shaderc_parse': { 'kwargs': { 'BIN2C': 1,
|
||||
'DEFINES': '+',
|
||||
'FILE': 1,
|
||||
'INCLUDES': '+',
|
||||
'O': 1,
|
||||
'OUTPUT': 1,
|
||||
'PROFILE': 1,
|
||||
'VARYINGDEF': 1},
|
||||
'pargs': { 'flags': [ 'DEPENDS',
|
||||
'ANDROID',
|
||||
'ASM_JS',
|
||||
'IOS',
|
||||
'LINUX',
|
||||
'NACL',
|
||||
'OSX',
|
||||
'WINDOWS',
|
||||
'PREPROCESS',
|
||||
'RAW',
|
||||
'FRAGMENT',
|
||||
'VERTEX',
|
||||
'COMPUTE',
|
||||
'VERBOSE',
|
||||
'DEBUG',
|
||||
'DISASM',
|
||||
'WERROR'],
|
||||
'nargs': '1+'}},
|
||||
'bgfx_compile_binary_to_header': { 'kwargs': { 'ARRAY_NAME': 1,
|
||||
'INPUT_FILE': 1,
|
||||
'OUTPUT_FILE': 1},
|
||||
'pargs': {'flags': [], 'nargs': '*'}},
|
||||
'bgfx_compile_shader_to_header': { 'kwargs': { 'OUTPUT_DIR': 1,
|
||||
'SHADERS': '+',
|
||||
'TYPE': 1,
|
||||
'VARYING_DEF': 1},
|
||||
'pargs': {'flags': [], 'nargs': '*'}}}
|
||||
|
||||
# Override configurations per-command where available
|
||||
override_spec = {}
|
||||
@@ -115,7 +123,7 @@ with section("format"):
|
||||
max_lines_hwrap = 2
|
||||
|
||||
# What style line endings to use in the output.
|
||||
line_ending = 'windows'
|
||||
line_ending = 'unix'
|
||||
|
||||
# Format command names consistently as 'lower' or 'upper' case
|
||||
command_case = 'canonical'
|
||||
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -13,4 +13,9 @@ install_manifest.txt
|
||||
generated/*
|
||||
!generated/*.in
|
||||
cmake_install.cmake
|
||||
.cache/
|
||||
.cache/
|
||||
.vscode/
|
||||
.idea/
|
||||
Makefile
|
||||
install*/
|
||||
cmake-build-*/
|
||||
|
||||
460
CMakeLists.txt
460
CMakeLists.txt
@@ -1,225 +1,235 @@
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(bgfx)
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# Makefile generators on apple need this flag to compile mixed objective/c++
|
||||
if(APPLE AND NOT XCODE)
|
||||
set(CMAKE_CXX_FLAGS "-ObjC++")
|
||||
endif()
|
||||
|
||||
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)
|
||||
|
||||
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_property(CACHE BGFX_LIBRARY_TYPE PROPERTY STRINGS STATIC SHARED)
|
||||
|
||||
if(BGFX_LIBRARY_TYPE MATCHES "SHARED")
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
endif()
|
||||
|
||||
if(NOT BX_DIR)
|
||||
set(BX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bx" CACHE STRING "Location of bx.")
|
||||
elseif(NOT IS_ABSOLUTE "${BX_DIR}")
|
||||
get_filename_component(BX_DIR "${BX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
if(NOT BIMG_DIR)
|
||||
set(BIMG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bimg" CACHE STRING "Location of bimg.")
|
||||
elseif(NOT IS_ABSOLUTE "${BIMG_DIR}")
|
||||
get_filename_component(BIMG_DIR "${BIMG_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
if(NOT BGFX_DIR)
|
||||
set(BGFX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bgfx" CACHE STRING "Location of bgfx.")
|
||||
elseif(NOT IS_ABSOLUTE "${BGFX_DIR}")
|
||||
get_filename_component(BGFX_DIR "${BGFX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
# sets project version from api ver / git rev
|
||||
include(${CMAKE_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)
|
||||
|
||||
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)
|
||||
endif()
|
||||
|
||||
if(BGFX_INSTALL)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Layout. This works for all platforms:
|
||||
# * <prefix>/lib*/cmake/<PROJECT-NAME>
|
||||
# * <prefix>/lib*/
|
||||
# * <prefix>/include/
|
||||
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
|
||||
# Configuration
|
||||
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
|
||||
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
|
||||
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
|
||||
set(namespace "${PROJECT_NAME}::")
|
||||
|
||||
# Include module with fuction 'write_basic_package_version_file'
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# Configure '<PROJECT-NAME>ConfigVersion.cmake'
|
||||
# Use:
|
||||
# * PROJECT_VERSION
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
|
||||
set(BGFX_COMPATIBILITY SameMajorVersion)
|
||||
else()
|
||||
set(BGFX_COMPATIBILITY SameMinorVersion)
|
||||
endif()
|
||||
write_basic_package_version_file("${version_config}" VERSION ${PROJECT_VERSION} COMPATIBILITY ${BGFX_COMPATIBILITY})
|
||||
|
||||
# Configure '<PROJECT-NAME>Config.cmake'
|
||||
# Use variables:
|
||||
# * TARGETS_EXPORT_NAME
|
||||
# * PROJECT_NAME
|
||||
configure_package_config_file(
|
||||
"${CMAKE_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}"
|
||||
)
|
||||
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}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# install headers (this should be done as a target probably... ^)
|
||||
install(DIRECTORY ${BX_DIR}/include/bx ${BX_DIR}/include/compat ${BX_DIR}/include/tinystl
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
install(DIRECTORY ${BIMG_DIR}/include/bimg DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
install(DIRECTORY ${BGFX_DIR}/include/bgfx DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
|
||||
# header required for shader compilation
|
||||
install(FILES ${BGFX_DIR}/src/bgfx_shader.sh ${BGFX_DIR}/src/bgfx_compute.sh
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bgfx"
|
||||
)
|
||||
|
||||
# install tools
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfxToolUtils.cmake DESTINATION "${config_install_dir}")
|
||||
if(BGFX_BUILD_TOOLS)
|
||||
if(BGFX_BUILD_TOOLS_SHADER)
|
||||
install(TARGETS shaderc EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endif()
|
||||
if(BGFX_BUILD_TOOLS_GEOMETRY)
|
||||
install(TARGETS geometryc EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
install(TARGETS geometryv EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endif()
|
||||
if(BGFX_BUILD_TOOLS_TEXTURE)
|
||||
install(TARGETS texturec EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
install(TARGETS texturev EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# install examples
|
||||
if(BGFX_BUILD_EXAMPLES AND BGFX_INSTALL_EXAMPLES)
|
||||
install(DIRECTORY ${BGFX_DIR}/examples/runtime/ DESTINATION examples)
|
||||
foreach(EXAMPLE ${BGFX_EXAMPLES})
|
||||
install(TARGETS example-${EXAMPLE} DESTINATION examples)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Config
|
||||
# * <prefix>/lib/cmake/bgfx/bgfxConfig.cmake
|
||||
# * <prefix>/lib/cmake/bgfx/bgfxConfigVersion.cmake
|
||||
install(FILES "${project_config}" "${version_config}" DESTINATION "${config_install_dir}")
|
||||
|
||||
# Config
|
||||
# * <prefix>/lib/cmake/bgfx/bgfxTargets.cmake
|
||||
install(EXPORT "${TARGETS_EXPORT_NAME}" NAMESPACE "${namespace}" DESTINATION "${config_install_dir}")
|
||||
endif()
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
project(bgfx)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# Makefile generators on apple need this flag to compile mixed objective/c++
|
||||
if(APPLE AND NOT XCODE)
|
||||
set(CMAKE_CXX_FLAGS "-ObjC++")
|
||||
endif()
|
||||
|
||||
if(MSVC AND (MSVC_VERSION GREATER_EQUAL 1914))
|
||||
add_compile_options("/Zc:__cplusplus")
|
||||
endif()
|
||||
|
||||
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_BIN2C "Build bx binary to c converter." 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_BUILD_TESTS "Build bgfx tests." OFF)
|
||||
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_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)
|
||||
|
||||
if(BGFX_LIBRARY_TYPE MATCHES "SHARED")
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
endif()
|
||||
|
||||
if(BGFX_BUILD_TESTS)
|
||||
enable_testing()
|
||||
endif()
|
||||
|
||||
if(NOT BX_DIR)
|
||||
set(BX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bx" CACHE STRING "Location of bx.")
|
||||
elseif(NOT IS_ABSOLUTE "${BX_DIR}")
|
||||
get_filename_component(BX_DIR "${BX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
if(NOT BIMG_DIR)
|
||||
set(BIMG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bimg" CACHE STRING "Location of bimg.")
|
||||
elseif(NOT IS_ABSOLUTE "${BIMG_DIR}")
|
||||
get_filename_component(BIMG_DIR "${BIMG_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
if(NOT BGFX_DIR)
|
||||
set(BGFX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bgfx" CACHE STRING "Location of bgfx.")
|
||||
elseif(NOT IS_ABSOLUTE "${BGFX_DIR}")
|
||||
get_filename_component(BGFX_DIR "${BGFX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
|
||||
# sets project version from api ver / git rev
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.cmake)
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/shared.cmake)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bx)
|
||||
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)
|
||||
endif()
|
||||
|
||||
if(BGFX_BUILD_TOOLS OR BGFX_BUILD_EXAMPLES)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/examples.cmake)
|
||||
endif()
|
||||
|
||||
if(BGFX_INSTALL)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Layout. This works for all platforms:
|
||||
# * <prefix>/lib*/cmake/<PROJECT-NAME>
|
||||
# * <prefix>/lib*/
|
||||
# * <prefix>/include/
|
||||
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
|
||||
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
|
||||
# Configuration
|
||||
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
|
||||
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
|
||||
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
|
||||
set(namespace "${PROJECT_NAME}::")
|
||||
|
||||
# Include module with fuction 'write_basic_package_version_file'
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
# Configure '<PROJECT-NAME>ConfigVersion.cmake'
|
||||
# Use:
|
||||
# * PROJECT_VERSION
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
|
||||
set(BGFX_COMPATIBILITY SameMajorVersion)
|
||||
else()
|
||||
set(BGFX_COMPATIBILITY SameMinorVersion)
|
||||
endif()
|
||||
write_basic_package_version_file("${version_config}" VERSION ${PROJECT_VERSION} COMPATIBILITY ${BGFX_COMPATIBILITY})
|
||||
|
||||
# Configure '<PROJECT-NAME>Config.cmake'
|
||||
# Use variables:
|
||||
# * TARGETS_EXPORT_NAME
|
||||
# * PROJECT_NAME
|
||||
configure_package_config_file(
|
||||
"${CMAKE_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}"
|
||||
)
|
||||
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}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# install headers (this should be done as a target probably... ^)
|
||||
install(DIRECTORY ${BX_DIR}/include/bx ${BX_DIR}/include/compat ${BX_DIR}/include/tinystl
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
install(DIRECTORY ${BIMG_DIR}/include/bimg DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
install(DIRECTORY ${BGFX_DIR}/include/bgfx DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
|
||||
# header required for shader compilation
|
||||
install(FILES ${BGFX_DIR}/src/bgfx_shader.sh ${BGFX_DIR}/src/bgfx_compute.sh
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bgfx"
|
||||
)
|
||||
|
||||
# install tools
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfxToolUtils.cmake DESTINATION "${config_install_dir}")
|
||||
if(BGFX_BUILD_TOOLS)
|
||||
if(BGFX_BUILD_TOOLS_BIN2C)
|
||||
install(TARGETS bin2c EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endif()
|
||||
if(BGFX_BUILD_TOOLS_SHADER)
|
||||
install(TARGETS shaderc EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endif()
|
||||
if(BGFX_BUILD_TOOLS_GEOMETRY)
|
||||
install(TARGETS geometryc EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
install(TARGETS geometryv EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endif()
|
||||
if(BGFX_BUILD_TOOLS_TEXTURE)
|
||||
install(TARGETS texturec EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
install(TARGETS texturev EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# install examples
|
||||
if(BGFX_BUILD_EXAMPLES AND BGFX_INSTALL_EXAMPLES)
|
||||
install(DIRECTORY ${BGFX_DIR}/examples/runtime/ DESTINATION examples)
|
||||
foreach(EXAMPLE ${BGFX_EXAMPLES})
|
||||
install(TARGETS example-${EXAMPLE} DESTINATION examples)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Config
|
||||
# * <prefix>/lib/cmake/bgfx/bgfxConfig.cmake
|
||||
# * <prefix>/lib/cmake/bgfx/bgfxConfigVersion.cmake
|
||||
install(FILES "${project_config}" "${version_config}" DESTINATION "${config_install_dir}")
|
||||
|
||||
# Config
|
||||
# * <prefix>/lib/cmake/bgfx/bgfxTargets.cmake
|
||||
install(EXPORT "${TARGETS_EXPORT_NAME}" NAMESPACE "${namespace}" DESTINATION "${config_install_dir}")
|
||||
endif()
|
||||
|
||||
104
README.md
104
README.md
@@ -1,13 +1,11 @@
|
||||
bgfx.cmake
|
||||
==========
|
||||
# bgfx.cmake
|
||||
[](https://github.com/bkaradzic/bgfx.cmake/workflows/Release/badge.svg)
|
||||
|
||||
**NOTE: This port only made to be used as C++ library, some features (such as bindings) might not work! For those features, please use original repo with GENie instead.**
|
||||
|
||||
This repo contains cmake configuration files that can be used to build bgfx with CMake.
|
||||
|
||||
Building
|
||||
---
|
||||
## Building
|
||||
|
||||
```bash
|
||||
git clone https://github.com/bkaradzic/bgfx.cmake.git
|
||||
@@ -20,12 +18,10 @@ cmake --build cmake-build
|
||||
|
||||
If downloading via zip (instead of using git submodules) manually download bx, bimg and bgfx and copy them into the root directory, or locate them via `BX_DIR`, `BIMG_DIR` and `BGFX_DIR` CMake variables.
|
||||
|
||||
How To Use
|
||||
----------
|
||||
## How To Use
|
||||
This project is setup to be included a few different ways. To include bgfx source code in your project simply use add_subdirectory to include this project. To build bgfx binaries build the `INSTALL` target (or `make install`). The installed files will be in the directory specified by `CMAKE_INSTALL_PREFIX` which we recommend you set to `./install` so it will export to your build directory. Note you may want to build install on both `Release` and `Debug` configurations.
|
||||
|
||||
Features
|
||||
--------
|
||||
## Features
|
||||
* No outside dependencies besides bx, bimg, bgfx, and CMake.
|
||||
* Tested on
|
||||
* Windows, OSX, Linux, Android, UWP, Emscripten (experimental)
|
||||
@@ -33,6 +29,94 @@ Features
|
||||
* Compiles bgfx, tools & examples.
|
||||
* Detects shader modifications and automatically rebuilds them for all examples.
|
||||
|
||||
Does this work with latest bx/bgfx/bimg?
|
||||
----------------------------------------
|
||||
## Added cmake commands
|
||||
bgfx.cmake will install `bgfxToolUtils.cmake` which has useful cmake functions for using bgfx's tools:
|
||||
|
||||
### `bgfx_compile_binary_to_header`
|
||||
Add a build rule for a binary file to the generated build system using bin2c.
|
||||
```cmake
|
||||
bgfx_compile_binary_to_header(
|
||||
INPUT_FILE filename
|
||||
OUTPUT_FILE filename
|
||||
ARRAY_NAME name
|
||||
)
|
||||
```
|
||||
This defines a bin2c command to generate a specified `OUTPUT_FILE` header with an array `ARRAY_NAME` with the binary representation of a `INPUT_FILE` file.
|
||||
|
||||
Adding these `INPUT_FILE` as source files to a target will run `bin2c` at build time and they will rebuild if either the contents of the `INPUT_FILE` change.
|
||||
|
||||
#### Examples: Generating an image as a header
|
||||
```cmake
|
||||
bgfx_compile_binary_to_header(
|
||||
INPUT_FILE image.png
|
||||
OUTPUT_FILE ${CMAKE_BINARY_DIR}/include/generated/images/image.png.h
|
||||
)
|
||||
add_library(myLib image.png)
|
||||
target_include_directories(myLib ${CMAKE_BINARY_DIR}/include/generated/images)
|
||||
```
|
||||
|
||||
```cpp
|
||||
// main.cpp
|
||||
#include <image.png.h>
|
||||
```
|
||||
|
||||
### `bgfx_compile_shader_to_header`
|
||||
Add a build rule for a `*.sc` shader to the generated build system using shaderc.
|
||||
```cmake
|
||||
bgfx_compile_shader_to_header(
|
||||
TYPE VERTEX|FRAGMENT|COMPUTE
|
||||
SHADERS filenames
|
||||
VARYING_DEF filename
|
||||
OUTPUT_DIR directory
|
||||
)
|
||||
```
|
||||
This defines a shaderc command to generate headers for a number of `TYPE` shaders with `SHADERS` files and `VARYING_DEF` file in the `OUTPUT_DIR` directory. There will be one generated shader for each supported rendering API on this current platform according to the `BGFX_EMBEDDED_SHADER` macro in `bgfx/embedded_shader.h`.
|
||||
|
||||
The generated headers will have names in the format of `${SHADERS}.${RENDERING_API}.bin.h` where `RENDERING_API` can be `glsl`, `essl`, `spv`, `dx9`, `dx11` and `mtl` depending on the availability of the platform.
|
||||
|
||||
Adding these `SHADERS` as source files to a target will run `shaderc` at build time and they will rebuild if either the contents of the `SHADERS` or the `VARYING_DEF` change.
|
||||
|
||||
#### Examples: Generating shaders as headers
|
||||
```cmake
|
||||
bgfx_compile_shader_to_header(
|
||||
TYPE VERTEX
|
||||
SHADERS vs.sc
|
||||
VARYING_DEF varying.def.sc
|
||||
OUTPUT_DIR ${CMAKE_BINARY_DIR}/include/generated/shaders
|
||||
)
|
||||
bgfx_compile_shader_to_header(
|
||||
TYPE FRAGMENT
|
||||
SHADERS fs.sc
|
||||
VARYING_DEF ${CMAKE_SOURCE_DIR}/varying.def.sc
|
||||
OUTPUT_DIR ${CMAKE_BINARY_DIR}/include/generated/shaders
|
||||
)
|
||||
|
||||
add_library(myLib main.cpp vs.sc fs.sc)
|
||||
target_include_directories(myLib ${CMAKE_BINARY_DIR}/include/generated/shaders)
|
||||
```
|
||||
|
||||
```cpp
|
||||
// main.cpp
|
||||
#include <vs.sc.glsl.bin.h>
|
||||
#include <vs.sc.essl.bin.h>
|
||||
#include <vs.sc.spv.bin.h>
|
||||
#include <fs.sc.glsl.bin.h>
|
||||
#include <fs.sc.essl.bin.h>
|
||||
#include <fs.sc.spv.bin.h>
|
||||
#if defined(_WIN32)
|
||||
#include <vs.sc.dx9.bin.h>
|
||||
#include <vs.sc.dx11.bin.h>
|
||||
#include <fs.sc.dx9.bin.h>
|
||||
#include <fs.sc.dx11.bin.h>
|
||||
#endif // defined(_WIN32)
|
||||
#if __APPLE__
|
||||
#include <vs.sc.mtl.bin.h>
|
||||
#include <fs.sc.mtl.bin.h>
|
||||
#endif // __APPLE__
|
||||
|
||||
const bgfx::EmbeddedShader k_vs = BGFX_EMBEDDED_SHADER(vs);
|
||||
const bgfx::EmbeddedShader k_fs = BGFX_EMBEDDED_SHADER(fs);
|
||||
```
|
||||
|
||||
## Does this work with latest bx/bgfx/bimg?
|
||||
Probably! This project needs to be updated if a dependency is added or the bgfx build system changes. The bgfx repository is very active but these types of changes are rare. New examples have to be added manually as well, but not doing so will merely result in that example not showing up and won't break anything else. If pulling latest causes issues, be sure to manually reconfigure CMake as the glob patterns may need to be refreshed (the use of glob patterns in CMake is generally discouraged but in this project it helps to ensure upwards compatibilty with newer bgfx updates).
|
||||
|
||||
24
cmake/3rdparty/astc-encoder.cmake
vendored
24
cmake/3rdparty/astc-encoder.cmake
vendored
@@ -8,23 +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/>.
|
||||
|
||||
if( TARGET astc-encoder )
|
||||
if(TARGET astc-encoder)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(
|
||||
GLOB
|
||||
ASTC_ENCODER_SOURCES
|
||||
${BIMG_DIR}/3rdparty/astc-encoder/source/*.cpp
|
||||
${BIMG_DIR}/3rdparty/astc-encoder/include/*.h
|
||||
file(GLOB ASTC_ENCODER_SOURCES ${BIMG_DIR}/3rdparty/astc-encoder/source/*.cpp
|
||||
${BIMG_DIR}/3rdparty/astc-encoder/include/*.h
|
||||
)
|
||||
|
||||
add_library( astc-encoder STATIC ${ASTC_ENCODER_SOURCES} )
|
||||
target_include_directories( astc-encoder
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty>
|
||||
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-encoder>
|
||||
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-encoder/include> )
|
||||
set_target_properties( astc-encoder
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty" )
|
||||
add_library(astc-encoder STATIC ${ASTC_ENCODER_SOURCES})
|
||||
target_include_directories(
|
||||
astc-encoder PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-encoder>
|
||||
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/astc-encoder/include>
|
||||
)
|
||||
set_target_properties(astc-encoder PROPERTIES FOLDER "bgfx/3rdparty")
|
||||
|
||||
47
cmake/3rdparty/dear-imgui.cmake
vendored
47
cmake/3rdparty/dear-imgui.cmake
vendored
@@ -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/>.
|
||||
|
||||
if( TARGET dear-imgui )
|
||||
return()
|
||||
endif()
|
||||
|
||||
file( GLOB dear_IMGUI_SOURCES ${BGFX_DIR}/3rdparty/dear-imgui/*.cpp ${BGFX_DIR}/3rdparty/dear-imgui/*.h ${BGFX_DIR}/3rdparty/dear-imgui/*.inl )
|
||||
|
||||
add_library( dear-imgui STATIC EXCLUDE_FROM_ALL ${dear_IMGUI_SOURCES} )
|
||||
target_compile_definitions( dear-imgui PRIVATE "-D_CRT_SECURE_NO_WARNINGS" "-D__STDC_FORMAT_MACROS" )
|
||||
target_include_directories( dear-imgui PUBLIC ${BGFX_DIR}/3rdparty )
|
||||
target_link_libraries( dear-imgui PUBLIC bx )
|
||||
set_target_properties( dear-imgui
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if(TARGET dear-imgui)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(GLOB dear_IMGUI_SOURCES ${BGFX_DIR}/3rdparty/dear-imgui/*.cpp ${BGFX_DIR}/3rdparty/dear-imgui/*.h
|
||||
${BGFX_DIR}/3rdparty/dear-imgui/*.inl
|
||||
)
|
||||
|
||||
add_library(dear-imgui STATIC EXCLUDE_FROM_ALL ${dear_IMGUI_SOURCES})
|
||||
target_compile_definitions(dear-imgui PRIVATE "-D_CRT_SECURE_NO_WARNINGS" "-D__STDC_FORMAT_MACROS")
|
||||
target_include_directories(dear-imgui PUBLIC ${BGFX_DIR}/3rdparty)
|
||||
target_link_libraries(dear-imgui PUBLIC bx)
|
||||
set_target_properties(dear-imgui PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
13
cmake/3rdparty/edtaa3.cmake
vendored
13
cmake/3rdparty/edtaa3.cmake
vendored
@@ -8,15 +8,12 @@
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if( TARGET edtaa3 )
|
||||
if(TARGET edtaa3)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file( GLOB EDTAA3_SOURCES ${BIMG_DIR}/3rdparty/edtaa3/*.cpp ${BIMG_DIR}/3rdparty/edtaa3/*.h )
|
||||
file(GLOB EDTAA3_SOURCES ${BIMG_DIR}/3rdparty/edtaa3/*.cpp ${BIMG_DIR}/3rdparty/edtaa3/*.h)
|
||||
|
||||
add_library( edtaa3 STATIC ${EDTAA3_SOURCES} )
|
||||
target_include_directories( edtaa3 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
|
||||
set_target_properties( edtaa3
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
add_library(edtaa3 STATIC ${EDTAA3_SOURCES})
|
||||
target_include_directories(edtaa3 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty>)
|
||||
set_target_properties(edtaa3 PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
13
cmake/3rdparty/etc1.cmake
vendored
13
cmake/3rdparty/etc1.cmake
vendored
@@ -8,15 +8,12 @@
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if( TARGET etc1 )
|
||||
if(TARGET etc1)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file( GLOB ETC1_SOURCES ${BIMG_DIR}/3rdparty/etc1/*.cpp ${BIMG_DIR}/3rdparty/etc1/*.h )
|
||||
file(GLOB ETC1_SOURCES ${BIMG_DIR}/3rdparty/etc1/*.cpp ${BIMG_DIR}/3rdparty/etc1/*.h)
|
||||
|
||||
add_library( etc1 STATIC ${ETC1_SOURCES} )
|
||||
target_include_directories( etc1 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
|
||||
set_target_properties( etc1
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
add_library(etc1 STATIC ${ETC1_SOURCES})
|
||||
target_include_directories(etc1 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty>)
|
||||
set_target_properties(etc1 PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
15
cmake/3rdparty/etc2.cmake
vendored
15
cmake/3rdparty/etc2.cmake
vendored
@@ -8,16 +8,13 @@
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if( TARGET etc2 )
|
||||
if(TARGET etc2)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file( GLOB ETC2_SOURCES ${BIMG_DIR}/3rdparty/etc2/*.cpp ${BIMG_DIR}/3rdparty/etc2/*.h )
|
||||
file(GLOB ETC2_SOURCES ${BIMG_DIR}/3rdparty/etc2/*.cpp ${BIMG_DIR}/3rdparty/etc2/*.h)
|
||||
|
||||
add_library( etc2 STATIC ${ETC2_SOURCES} )
|
||||
target_include_directories( etc2 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
|
||||
target_link_libraries( etc2 PUBLIC bx )
|
||||
set_target_properties( etc2
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
add_library(etc2 STATIC ${ETC2_SOURCES})
|
||||
target_include_directories(etc2 PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty>)
|
||||
target_link_libraries(etc2 PUBLIC bx)
|
||||
set_target_properties(etc2 PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
61
cmake/3rdparty/fcpp.cmake
vendored
61
cmake/3rdparty/fcpp.cmake
vendored
@@ -1,35 +1,26 @@
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if( TARGET fcpp )
|
||||
return()
|
||||
endif()
|
||||
|
||||
file( GLOB FCPP_SOURCES ${BGFX_DIR}/3rdparty/fcpp/*.c ${BGFX_DIR}/3rdparty/fcpp/*.h )
|
||||
|
||||
add_library( fcpp STATIC ${FCPP_SOURCES} )
|
||||
target_include_directories( fcpp PUBLIC ${BGFX_DIR}/3rdparty/fcpp )
|
||||
target_compile_definitions( fcpp
|
||||
PRIVATE
|
||||
NINCLUDE=64
|
||||
NWORK=65536
|
||||
NBUFF=65536
|
||||
OLD_PREPROCESSOR=0
|
||||
)
|
||||
|
||||
if( MSVC )
|
||||
set_target_properties( fcpp PROPERTIES COMPILE_FLAGS "/W0" )
|
||||
endif()
|
||||
|
||||
set_target_properties( fcpp
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
set_source_files_properties( ${BGFX_DIR}/3rdparty/fcpp/usecpp.c PROPERTIES HEADER_FILE_ONLY ON )
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if(TARGET fcpp)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(GLOB FCPP_SOURCES ${BGFX_DIR}/3rdparty/fcpp/*.c ${BGFX_DIR}/3rdparty/fcpp/*.h)
|
||||
|
||||
add_library(fcpp STATIC ${FCPP_SOURCES})
|
||||
target_include_directories(fcpp PUBLIC ${BGFX_DIR}/3rdparty/fcpp)
|
||||
target_compile_definitions(fcpp PRIVATE NINCLUDE=64 NWORK=65536 NBUFF=65536 OLD_PREPROCESSOR=0)
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(fcpp PROPERTIES COMPILE_FLAGS "/W0")
|
||||
endif()
|
||||
|
||||
set_target_properties(fcpp PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
set_source_files_properties(${BGFX_DIR}/3rdparty/fcpp/usecpp.c PROPERTIES HEADER_FILE_ONLY ON)
|
||||
|
||||
170
cmake/3rdparty/glsl-optimizer.cmake
vendored
170
cmake/3rdparty/glsl-optimizer.cmake
vendored
@@ -1,90 +1,80 @@
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if( TARGET glsl-optimizer )
|
||||
return()
|
||||
endif()
|
||||
|
||||
set( GLSL-OPTIMIZER_INCLUDES
|
||||
${BGFX_DIR}/3rdparty/glsl-optimizer/include
|
||||
${BGFX_DIR}/3rdparty/glsl-optimizer/src/mesa
|
||||
${BGFX_DIR}/3rdparty/glsl-optimizer/src/mapi
|
||||
${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl
|
||||
${BGFX_DIR}/3rdparty/glsl-optimizer/src
|
||||
)
|
||||
|
||||
# glsl-optimizer makes UBSan segfault for whatever reason
|
||||
# We already know that it's full of UB anyway... so just don't build it with UBSan
|
||||
string(REPLACE "-fsanitize=undefined" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" )
|
||||
string(REPLACE "-fsanitize=undefined" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
|
||||
|
||||
# glcpp
|
||||
file( GLOB GLCPP_SOURCES ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/glcpp/*.c ${BGFX_DIR}/3rdparty/glsl-optimizer/src/util/*.c )
|
||||
# Library must be static because hash_table_ctor referenced in function glcpp_parser_create
|
||||
add_library( glcpp STATIC ${GLCPP_SOURCES} )
|
||||
target_include_directories( glcpp PUBLIC ${GLSL-OPTIMIZER_INCLUDES} )
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options( glcpp PRIVATE "-fno-strict-aliasing")
|
||||
endif()
|
||||
if( MSVC )
|
||||
set_target_properties( glcpp PROPERTIES COMPILE_FLAGS "/W0" )
|
||||
endif()
|
||||
set_target_properties( glcpp PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
|
||||
# mesa
|
||||
file( GLOB MESA_SOURCES ${BGFX_DIR}/3rdparty/glsl-optimizer/src/mesa/program/*.c ${BGFX_DIR}/3rdparty/glsl-optimizer/src/mesa/main/*.c )
|
||||
# Library must be static because mesa/program/prog_hash_table.c uses _mesa_error_no_memory which is in glsl/standalone_scaffolding.cpp of glsl-optimizer
|
||||
add_library( mesa STATIC ${MESA_SOURCES} )
|
||||
target_include_directories( mesa PUBLIC ${GLSL-OPTIMIZER_INCLUDES} )
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options( mesa PRIVATE "-fno-strict-aliasing")
|
||||
endif()
|
||||
if( MSVC )
|
||||
set_target_properties( mesa PROPERTIES COMPILE_FLAGS "/W0" )
|
||||
endif()
|
||||
set_target_properties( mesa PROPERTIES FOLDER "bgfx/3rdparty" )
|
||||
|
||||
# glsl-optimizer
|
||||
file( GLOB GLSL-OPTIMIZER_SOURCES ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/*.cpp ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/*.c )
|
||||
file( GLOB GLSL-OPTIMIZER_SOURCES_REMOVE ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/main.cpp ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/builtin_stubs.cpp )
|
||||
list( REMOVE_ITEM GLSL-OPTIMIZER_SOURCES ${GLSL-OPTIMIZER_SOURCES_REMOVE} )
|
||||
add_library( glsl-optimizer STATIC ${GLSL-OPTIMIZER_SOURCES} )
|
||||
target_link_libraries( glsl-optimizer glcpp mesa )
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options( glsl-optimizer
|
||||
PRIVATE
|
||||
-fno-strict-aliasing
|
||||
-Wno-implicit-fallthrough
|
||||
-Wno-parentheses
|
||||
-Wno-sign-compare
|
||||
-Wno-unused-function
|
||||
-Wno-unused-parameter
|
||||
)
|
||||
endif()
|
||||
if( MSVC )
|
||||
set_target_properties( glsl-optimizer PROPERTIES COMPILE_FLAGS "/W0" )
|
||||
target_compile_definitions( glsl-optimizer
|
||||
PRIVATE
|
||||
__STDC__
|
||||
__STDC_VERSION__=199901L
|
||||
strdup=_strdup
|
||||
alloca=_alloca
|
||||
isascii=__isascii
|
||||
)
|
||||
elseif(APPLE)
|
||||
target_compile_options( glsl-optimizer
|
||||
PRIVATE
|
||||
-Wno-deprecated-register
|
||||
)
|
||||
endif()
|
||||
set_target_properties( glsl-optimizer
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if(TARGET glsl-optimizer)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(GLSL-OPTIMIZER_INCLUDES
|
||||
${BGFX_DIR}/3rdparty/glsl-optimizer/include ${BGFX_DIR}/3rdparty/glsl-optimizer/src/mesa
|
||||
${BGFX_DIR}/3rdparty/glsl-optimizer/src/mapi ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl
|
||||
${BGFX_DIR}/3rdparty/glsl-optimizer/src
|
||||
)
|
||||
|
||||
# glsl-optimizer makes UBSan segfault for whatever reason
|
||||
# We already know that it's full of UB anyway... so just don't build it with UBSan
|
||||
string(REPLACE "-fsanitize=undefined" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string(REPLACE "-fsanitize=undefined" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
# glcpp
|
||||
file(GLOB GLCPP_SOURCES ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/glcpp/*.c
|
||||
${BGFX_DIR}/3rdparty/glsl-optimizer/src/util/*.c
|
||||
)
|
||||
# Library must be static because hash_table_ctor referenced in function glcpp_parser_create
|
||||
add_library(glcpp STATIC ${GLCPP_SOURCES})
|
||||
target_include_directories(glcpp PUBLIC ${GLSL-OPTIMIZER_INCLUDES})
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options(glcpp PRIVATE "-fno-strict-aliasing")
|
||||
endif()
|
||||
if(MSVC)
|
||||
set_target_properties(glcpp PROPERTIES COMPILE_FLAGS "/W0")
|
||||
endif()
|
||||
set_target_properties(glcpp PROPERTIES FOLDER "bgfx/3rdparty")
|
||||
|
||||
# mesa
|
||||
file(GLOB MESA_SOURCES ${BGFX_DIR}/3rdparty/glsl-optimizer/src/mesa/program/*.c
|
||||
${BGFX_DIR}/3rdparty/glsl-optimizer/src/mesa/main/*.c
|
||||
)
|
||||
# Library must be static because mesa/program/prog_hash_table.c uses _mesa_error_no_memory which is in glsl/standalone_scaffolding.cpp of glsl-optimizer
|
||||
add_library(mesa STATIC ${MESA_SOURCES})
|
||||
target_include_directories(mesa PUBLIC ${GLSL-OPTIMIZER_INCLUDES})
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options(mesa PRIVATE "-fno-strict-aliasing")
|
||||
endif()
|
||||
if(MSVC)
|
||||
set_target_properties(mesa PROPERTIES COMPILE_FLAGS "/W0")
|
||||
endif()
|
||||
set_target_properties(mesa PROPERTIES FOLDER "bgfx/3rdparty")
|
||||
|
||||
# glsl-optimizer
|
||||
file(GLOB GLSL-OPTIMIZER_SOURCES ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/*.cpp
|
||||
${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/*.c
|
||||
)
|
||||
file(GLOB GLSL-OPTIMIZER_SOURCES_REMOVE ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/main.cpp
|
||||
${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/builtin_stubs.cpp
|
||||
)
|
||||
list(REMOVE_ITEM GLSL-OPTIMIZER_SOURCES ${GLSL-OPTIMIZER_SOURCES_REMOVE})
|
||||
add_library(glsl-optimizer STATIC ${GLSL-OPTIMIZER_SOURCES})
|
||||
target_link_libraries(glsl-optimizer glcpp mesa)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
target_compile_options(
|
||||
glsl-optimizer PRIVATE -fno-strict-aliasing -Wno-implicit-fallthrough -Wno-parentheses -Wno-sign-compare
|
||||
-Wno-unused-function -Wno-unused-parameter
|
||||
)
|
||||
endif()
|
||||
if(MSVC)
|
||||
set_target_properties(glsl-optimizer PROPERTIES COMPILE_FLAGS "/W0")
|
||||
target_compile_definitions(
|
||||
glsl-optimizer PRIVATE __STDC__ __STDC_VERSION__=199901L strdup=_strdup alloca=_alloca isascii=__isascii
|
||||
)
|
||||
elseif(APPLE)
|
||||
target_compile_options(glsl-optimizer PRIVATE -Wno-deprecated-register)
|
||||
endif()
|
||||
set_target_properties(glsl-optimizer PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
192
cmake/3rdparty/glslang.cmake
vendored
192
cmake/3rdparty/glslang.cmake
vendored
@@ -1,101 +1,91 @@
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if( TARGET glslang )
|
||||
return()
|
||||
endif()
|
||||
|
||||
file( GLOB GLSLANG_SOURCES
|
||||
${BGFX_DIR}/3rdparty/glslang/glslang/GenericCodeGen/*.cpp
|
||||
${BGFX_DIR}/3rdparty/glslang/glslang/MachineIndependent/*.cpp
|
||||
${BGFX_DIR}/3rdparty/glslang/glslang/MachineIndependent/preprocessor/*.cpp
|
||||
${BGFX_DIR}/3rdparty/glslang/glslang/HLSL/*.cpp
|
||||
${BGFX_DIR}/3rdparty/glslang/hlsl/*.cpp
|
||||
${BGFX_DIR}/3rdparty/glslang/SPIRV/*.cpp
|
||||
${BGFX_DIR}/3rdparty/glslang/OGLCompilersDLL/*.cpp
|
||||
)
|
||||
|
||||
if( WIN32 )
|
||||
list( APPEND GLSLANG_SOURCES ${BGFX_DIR}/3rdparty/glslang/glslang/OSDependent/Windows/ossource.cpp )
|
||||
else()
|
||||
list( APPEND GLSLANG_SOURCES ${BGFX_DIR}/3rdparty/glslang/glslang/OSDependent/Unix/ossource.cpp )
|
||||
endif()
|
||||
|
||||
add_library( glslang STATIC EXCLUDE_FROM_ALL ${GLSLANG_SOURCES} )
|
||||
target_include_directories( glslang PUBLIC
|
||||
${BGFX_DIR}/3rdparty/spirv-tools/include
|
||||
${BGFX_DIR}/3rdparty/spirv-tools/source
|
||||
${BGFX_DIR}/3rdparty/glslang
|
||||
${BGFX_DIR}/3rdparty/glslang/glslang/Include
|
||||
${BGFX_DIR}/3rdparty/glslang/glslang/Public
|
||||
|
||||
PRIVATE
|
||||
${BGFX_DIR}/3rdparty
|
||||
)
|
||||
|
||||
set_target_properties( glslang
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
|
||||
if( MSVC )
|
||||
target_compile_options( glslang PRIVATE
|
||||
"/wd4005"
|
||||
"/wd4065"
|
||||
"/wd4100"
|
||||
"/wd4127"
|
||||
"/wd4189"
|
||||
"/wd4244"
|
||||
"/wd4310"
|
||||
"/wd4389"
|
||||
"/wd4456"
|
||||
"/wd4457"
|
||||
"/wd4458"
|
||||
"/wd4702"
|
||||
"/wd4715"
|
||||
"/wd4838"
|
||||
)
|
||||
else()
|
||||
target_compile_options( glslang PRIVATE
|
||||
"-Wno-ignored-qualifiers"
|
||||
"-Wno-implicit-fallthrough"
|
||||
"-Wno-missing-field-initializers"
|
||||
"-Wno-reorder"
|
||||
"-Wno-return-type"
|
||||
"-Wno-shadow"
|
||||
"-Wno-sign-compare"
|
||||
"-Wno-switch"
|
||||
"-Wno-undef"
|
||||
"-Wno-unknown-pragmas"
|
||||
"-Wno-unused-function"
|
||||
"-Wno-unused-parameter"
|
||||
"-Wno-unused-variable"
|
||||
"-fno-strict-aliasing"
|
||||
)
|
||||
endif()
|
||||
|
||||
if( APPLE )
|
||||
target_compile_options( glslang PRIVATE
|
||||
"-Wno-c++11-extensions"
|
||||
"-Wno-unused-const-variable"
|
||||
"-Wno-deprecated-register"
|
||||
)
|
||||
endif()
|
||||
|
||||
if( UNIX AND NOT APPLE )
|
||||
target_compile_options( glslang PRIVATE
|
||||
"-Wno-unused-but-set-variable"
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions( glslang PRIVATE
|
||||
ENABLE_OPT=1
|
||||
ENABLE_HLSL=1
|
||||
)
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if(TARGET glslang)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(
|
||||
GLOB
|
||||
GLSLANG_SOURCES
|
||||
${BGFX_DIR}/3rdparty/glslang/glslang/GenericCodeGen/*.cpp
|
||||
${BGFX_DIR}/3rdparty/glslang/glslang/MachineIndependent/*.cpp
|
||||
${BGFX_DIR}/3rdparty/glslang/glslang/MachineIndependent/preprocessor/*.cpp
|
||||
${BGFX_DIR}/3rdparty/glslang/glslang/HLSL/*.cpp
|
||||
${BGFX_DIR}/3rdparty/glslang/hlsl/*.cpp
|
||||
${BGFX_DIR}/3rdparty/glslang/SPIRV/*.cpp
|
||||
${BGFX_DIR}/3rdparty/glslang/OGLCompilersDLL/*.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND GLSLANG_SOURCES ${BGFX_DIR}/3rdparty/glslang/glslang/OSDependent/Windows/ossource.cpp)
|
||||
else()
|
||||
list(APPEND GLSLANG_SOURCES ${BGFX_DIR}/3rdparty/glslang/glslang/OSDependent/Unix/ossource.cpp)
|
||||
endif()
|
||||
|
||||
add_library(glslang STATIC EXCLUDE_FROM_ALL ${GLSLANG_SOURCES})
|
||||
target_include_directories(
|
||||
glslang
|
||||
PUBLIC ${BGFX_DIR}/3rdparty/spirv-tools/include ${BGFX_DIR}/3rdparty/spirv-tools/source ${BGFX_DIR}/3rdparty/glslang
|
||||
${BGFX_DIR}/3rdparty/glslang/glslang/Include ${BGFX_DIR}/3rdparty/glslang/glslang/Public
|
||||
PRIVATE ${BGFX_DIR}/3rdparty
|
||||
)
|
||||
|
||||
set_target_properties(glslang PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
if(MSVC)
|
||||
target_compile_options(
|
||||
glslang
|
||||
PRIVATE "/wd4005"
|
||||
"/wd4065"
|
||||
"/wd4100"
|
||||
"/wd4127"
|
||||
"/wd4189"
|
||||
"/wd4244"
|
||||
"/wd4310"
|
||||
"/wd4389"
|
||||
"/wd4456"
|
||||
"/wd4457"
|
||||
"/wd4458"
|
||||
"/wd4702"
|
||||
"/wd4715"
|
||||
"/wd4838"
|
||||
)
|
||||
else()
|
||||
target_compile_options(
|
||||
glslang
|
||||
PRIVATE "-Wno-ignored-qualifiers"
|
||||
"-Wno-implicit-fallthrough"
|
||||
"-Wno-missing-field-initializers"
|
||||
"-Wno-reorder"
|
||||
"-Wno-return-type"
|
||||
"-Wno-shadow"
|
||||
"-Wno-sign-compare"
|
||||
"-Wno-switch"
|
||||
"-Wno-undef"
|
||||
"-Wno-unknown-pragmas"
|
||||
"-Wno-unused-function"
|
||||
"-Wno-unused-parameter"
|
||||
"-Wno-unused-variable"
|
||||
"-fno-strict-aliasing"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
target_compile_options(
|
||||
glslang PRIVATE "-Wno-c++11-extensions" "-Wno-unused-const-variable" "-Wno-deprecated-register"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_compile_options(glslang PRIVATE "-Wno-unused-but-set-variable")
|
||||
endif()
|
||||
|
||||
target_compile_definitions(glslang PRIVATE ENABLE_OPT=1 ENABLE_HLSL=1)
|
||||
|
||||
13
cmake/3rdparty/iqa.cmake
vendored
13
cmake/3rdparty/iqa.cmake
vendored
@@ -8,15 +8,12 @@
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if( TARGET iqa )
|
||||
if(TARGET iqa)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file( GLOB IQA_SOURCES ${BIMG_DIR}/3rdparty/iqa/source/*.c ${BIMG_DIR}/3rdparty/iqa/include/*.h )
|
||||
file(GLOB IQA_SOURCES ${BIMG_DIR}/3rdparty/iqa/source/*.c ${BIMG_DIR}/3rdparty/iqa/include/*.h)
|
||||
|
||||
add_library( iqa STATIC ${IQA_SOURCES} )
|
||||
target_include_directories( iqa PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/iqa/include> )
|
||||
set_target_properties( iqa
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
add_library(iqa STATIC ${IQA_SOURCES})
|
||||
target_include_directories(iqa PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/iqa/include>)
|
||||
set_target_properties(iqa PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
15
cmake/3rdparty/libsquish.cmake
vendored
15
cmake/3rdparty/libsquish.cmake
vendored
@@ -8,15 +8,14 @@
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if( TARGET squish )
|
||||
if(TARGET squish)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file( GLOB SQUISH_SOURCES ${BIMG_DIR}/3rdparty/libsquish/*.cpp ${BIMG_DIR}/3rdparty/libsquish/*.h ${BIMG_DIR}/3rdparty/libsquish/*.inl )
|
||||
file(GLOB SQUISH_SOURCES ${BIMG_DIR}/3rdparty/libsquish/*.cpp ${BIMG_DIR}/3rdparty/libsquish/*.h
|
||||
${BIMG_DIR}/3rdparty/libsquish/*.inl
|
||||
)
|
||||
|
||||
add_library( squish STATIC ${SQUISH_SOURCES} )
|
||||
target_include_directories( squish PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
|
||||
set_target_properties( squish
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
add_library(squish STATIC ${SQUISH_SOURCES})
|
||||
target_include_directories(squish PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty>)
|
||||
set_target_properties(squish PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
13
cmake/3rdparty/meshoptimizer.cmake
vendored
13
cmake/3rdparty/meshoptimizer.cmake
vendored
@@ -8,15 +8,12 @@
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if( TARGET meshoptimizer )
|
||||
if(TARGET meshoptimizer)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file( GLOB MESHOPTIMIZER_SOURCES ${BGFX_DIR}/3rdparty/meshoptimizer/src/*.cpp ${BGFX_DIR}/3rdparty/meshoptimizer/src/*.h )
|
||||
file(GLOB MESHOPTIMIZER_SOURCES ${BGFX_DIR}/3rdparty/meshoptimizer/src/*.cpp ${BGFX_DIR}/3rdparty/meshoptimizer/src/*.h)
|
||||
|
||||
add_library( meshoptimizer STATIC ${MESHOPTIMIZER_SOURCES} )
|
||||
target_include_directories( meshoptimizer PUBLIC ${BGFX_DIR}/3rdparty )
|
||||
set_target_properties( meshoptimizer
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
add_library(meshoptimizer STATIC ${MESHOPTIMIZER_SOURCES})
|
||||
target_include_directories(meshoptimizer PUBLIC ${BGFX_DIR}/3rdparty)
|
||||
set_target_properties(meshoptimizer PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
18
cmake/3rdparty/nvtt.cmake
vendored
18
cmake/3rdparty/nvtt.cmake
vendored
@@ -8,7 +8,7 @@
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if( TARGET nvtt )
|
||||
if(TARGET nvtt)
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -27,13 +27,9 @@ file(
|
||||
${BIMG_DIR}/3rdparty/nvtt/*.h
|
||||
)
|
||||
|
||||
add_library( nvtt STATIC ${NVTT_SOURCES} )
|
||||
target_include_directories( nvtt
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty>
|
||||
$<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/nvtt> )
|
||||
target_link_libraries( nvtt PUBLIC bx )
|
||||
set_target_properties( nvtt
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
add_library(nvtt STATIC ${NVTT_SOURCES})
|
||||
target_include_directories(
|
||||
nvtt PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/nvtt>
|
||||
)
|
||||
target_link_libraries(nvtt PUBLIC bx)
|
||||
set_target_properties(nvtt PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
13
cmake/3rdparty/pvrtc.cmake
vendored
13
cmake/3rdparty/pvrtc.cmake
vendored
@@ -8,15 +8,12 @@
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if( TARGET pvrtc )
|
||||
if(TARGET pvrtc)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file( GLOB PVRTC_SOURCES ${BIMG_DIR}/3rdparty/pvrtc/*.cpp ${BIMG_DIR}/3rdparty/pvrtc/*.h )
|
||||
file(GLOB PVRTC_SOURCES ${BIMG_DIR}/3rdparty/pvrtc/*.cpp ${BIMG_DIR}/3rdparty/pvrtc/*.h)
|
||||
|
||||
add_library( pvrtc STATIC ${PVRTC_SOURCES} )
|
||||
target_include_directories( pvrtc PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> )
|
||||
set_target_properties( pvrtc
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
add_library(pvrtc STATIC ${PVRTC_SOURCES})
|
||||
target_include_directories(pvrtc PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty>)
|
||||
set_target_properties(pvrtc PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
32
cmake/3rdparty/spirv-cross.cmake
vendored
32
cmake/3rdparty/spirv-cross.cmake
vendored
@@ -8,34 +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/>.
|
||||
|
||||
if( TARGET spirv-cross )
|
||||
if(TARGET spirv-cross)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(
|
||||
GLOB
|
||||
SPIRV_CROSS_SOURCES
|
||||
${BGFX_DIR}/3rdparty/spirv-cross/*.cpp
|
||||
${BGFX_DIR}/3rdparty/spirv-cross/*.h
|
||||
)
|
||||
file(GLOB SPIRV_CROSS_SOURCES ${BGFX_DIR}/3rdparty/spirv-cross/*.cpp ${BGFX_DIR}/3rdparty/spirv-cross/*.h)
|
||||
|
||||
add_library( spirv-cross STATIC ${SPIRV_CROSS_SOURCES} )
|
||||
target_compile_definitions( spirv-cross PRIVATE SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS )
|
||||
target_include_directories( spirv-cross PUBLIC
|
||||
${BGFX_DIR}/3rdparty/spirv-cross
|
||||
${BGFX_DIR}/3rdparty/spirv-cross/include
|
||||
)
|
||||
add_library(spirv-cross STATIC ${SPIRV_CROSS_SOURCES})
|
||||
target_compile_definitions(spirv-cross PRIVATE SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
|
||||
target_include_directories(spirv-cross PUBLIC ${BGFX_DIR}/3rdparty/spirv-cross ${BGFX_DIR}/3rdparty/spirv-cross/include)
|
||||
|
||||
if( MSVC )
|
||||
target_compile_options( spirv-cross PRIVATE
|
||||
"/wd4018"
|
||||
"/wd4245"
|
||||
"/wd4706"
|
||||
"/wd4715"
|
||||
)
|
||||
if(MSVC)
|
||||
target_compile_options(spirv-cross PRIVATE "/wd4018" "/wd4245" "/wd4706" "/wd4715")
|
||||
endif()
|
||||
|
||||
set_target_properties( spirv-cross
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
set_target_properties(spirv-cross PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
37
cmake/3rdparty/spirv-tools.cmake
vendored
37
cmake/3rdparty/spirv-tools.cmake
vendored
@@ -8,7 +8,7 @@
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if( TARGET spirv-tools )
|
||||
if(TARGET spirv-tools)
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -27,35 +27,22 @@ file(
|
||||
${BGFX_DIR}/3rdparty/spirv-tools/source/val/*.h
|
||||
)
|
||||
|
||||
add_library( spirv-tools STATIC ${SPIRV_TOOLS_SOURCES} )
|
||||
target_include_directories( spirv-tools PUBLIC
|
||||
${BGFX_DIR}/3rdparty/spirv-headers/include
|
||||
${BGFX_DIR}/3rdparty/spirv-tools
|
||||
${BGFX_DIR}/3rdparty/spirv-tools/include
|
||||
${BGFX_DIR}/3rdparty/spirv-tools/include/generated
|
||||
${BGFX_DIR}/3rdparty/spirv-tools/source
|
||||
add_library(spirv-tools STATIC ${SPIRV_TOOLS_SOURCES})
|
||||
target_include_directories(
|
||||
spirv-tools
|
||||
PUBLIC ${BGFX_DIR}/3rdparty/spirv-headers/include ${BGFX_DIR}/3rdparty/spirv-tools
|
||||
${BGFX_DIR}/3rdparty/spirv-tools/include ${BGFX_DIR}/3rdparty/spirv-tools/include/generated
|
||||
${BGFX_DIR}/3rdparty/spirv-tools/source
|
||||
)
|
||||
|
||||
if( MSVC )
|
||||
target_compile_options( spirv-tools PRIVATE
|
||||
"/wd4127"
|
||||
"/wd4389"
|
||||
"/wd4702"
|
||||
"/wd4706"
|
||||
)
|
||||
if(MSVC)
|
||||
target_compile_options(spirv-tools PRIVATE "/wd4127" "/wd4389" "/wd4702" "/wd4706")
|
||||
else()
|
||||
target_compile_options( spirv-tools PRIVATE
|
||||
"-Wno-switch"
|
||||
)
|
||||
target_compile_options(spirv-tools PRIVATE "-Wno-switch")
|
||||
|
||||
if(MINGW OR ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
|
||||
target_compile_options( spirv-tools PRIVATE
|
||||
"-Wno-misleading-indentation"
|
||||
)
|
||||
target_compile_options(spirv-tools PRIVATE "-Wno-misleading-indentation")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_target_properties( spirv-tools
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
set_target_properties(spirv-tools PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
23
cmake/3rdparty/tinyexr.cmake
vendored
23
cmake/3rdparty/tinyexr.cmake
vendored
@@ -1,12 +1,11 @@
|
||||
if( TARGET tinyexr )
|
||||
return()
|
||||
endif()
|
||||
|
||||
file( GLOB_RECURSE TINYEXR_SOURCES ${BIMG_DIR}/3rdparty/tinyexr/*.c ${BIMG_DIR}/3rdparty/tinyexr/*.h )
|
||||
|
||||
add_library( tinyexr STATIC ${TINYEXR_SOURCES} )
|
||||
target_include_directories( tinyexr PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/tinyexr/deps/miniz> )
|
||||
set_target_properties( tinyexr
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
if(TARGET tinyexr)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE TINYEXR_SOURCES ${BIMG_DIR}/3rdparty/tinyexr/*.c ${BIMG_DIR}/3rdparty/tinyexr/*.h)
|
||||
|
||||
add_library(tinyexr STATIC ${TINYEXR_SOURCES})
|
||||
target_include_directories(
|
||||
tinyexr PUBLIC $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty> $<BUILD_INTERFACE:${BIMG_DIR}/3rdparty/tinyexr/deps/miniz>
|
||||
)
|
||||
set_target_properties(tinyexr PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
21
cmake/3rdparty/webgpu.cmake
vendored
21
cmake/3rdparty/webgpu.cmake
vendored
@@ -8,27 +8,20 @@
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
if( TARGET webgpu )
|
||||
if(TARGET webgpu)
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(
|
||||
GLOB
|
||||
WEBGPU_SOURCES
|
||||
${BGFX_DIR}/3rdparty/webgpu/include/webgpu/*.h
|
||||
# ${BGFX_DIR}/3rdparty/webgpu/webgpu_cpp.cpp # requires dawn to be installed
|
||||
file(GLOB WEBGPU_SOURCES ${BGFX_DIR}/3rdparty/webgpu/include/webgpu/*.h
|
||||
# ${BGFX_DIR}/3rdparty/webgpu/webgpu_cpp.cpp # requires dawn to be installed
|
||||
)
|
||||
|
||||
# Library without sources is interface
|
||||
#add_library( webgpu STATIC ${WEBGPU_SOURCES} )
|
||||
add_library(webgpu INTERFACE)
|
||||
target_include_directories( webgpu
|
||||
# PUBLIC
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${BGFX_DIR}/3rdparty/webgpu/include>
|
||||
target_include_directories(
|
||||
webgpu # PUBLIC
|
||||
INTERFACE $<BUILD_INTERFACE:${BGFX_DIR}/3rdparty/webgpu/include>
|
||||
)
|
||||
|
||||
set_target_properties( webgpu
|
||||
PROPERTIES
|
||||
FOLDER "bgfx/3rdparty"
|
||||
PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-" )
|
||||
set_target_properties(webgpu PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")
|
||||
|
||||
@@ -6,16 +6,27 @@ 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}")
|
||||
if(@CMAKE_CROSSCOMPILING@)
|
||||
macro(_bgfx_crosscompile_use_host_tool TOOL_NAME)
|
||||
if(NOT TARGET bgfx::${TOOL_NAME})
|
||||
find_program(
|
||||
${TOOL_NAME}_EXECUTABLE REQUIRED
|
||||
NAMES bgfx-${TOOL_NAME} ${TOOL_NAME}
|
||||
PATHS /usr/bin #
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-linux/tools/bgfx
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-windows/tools/bgfx
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/packages/bgfx_x64-osx/tools/bgfx
|
||||
)
|
||||
add_executable(bgfx::${TOOL_NAME} IMPORTED)
|
||||
set_target_properties(bgfx::${TOOL_NAME} PROPERTIES IMPORTED_LOCATION "${${TOOL_NAME}_EXECUTABLE}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
_bgfx_crosscompile_use_host_tool(bin2c)
|
||||
_bgfx_crosscompile_use_host_tool(shaderc)
|
||||
_bgfx_crosscompile_use_host_tool(texturec)
|
||||
_bgfx_crosscompile_use_host_tool(texturev)
|
||||
_bgfx_crosscompile_use_host_tool(geometryv)
|
||||
endif()
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake")
|
||||
|
||||
416
cmake/bgfx.cmake
416
cmake/bgfx.cmake
@@ -1,208 +1,208 @@
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
# To prevent this warning: https://cmake.org/cmake/help/git-stage/policy/CMP0072.html
|
||||
if(POLICY CMP0072)
|
||||
cmake_policy(SET CMP0072 NEW)
|
||||
endif()
|
||||
|
||||
# Ensure the directory exists
|
||||
if(NOT IS_DIRECTORY ${BGFX_DIR})
|
||||
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT APPLE)
|
||||
set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.cpp)
|
||||
else()
|
||||
set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.mm)
|
||||
endif()
|
||||
|
||||
# Grab the bgfx source files
|
||||
file(
|
||||
GLOB
|
||||
BGFX_SOURCES
|
||||
${BGFX_DIR}/src/*.cpp
|
||||
${BGFX_DIR}/src/*.mm
|
||||
${BGFX_DIR}/src/*.h
|
||||
${BGFX_DIR}/include/bgfx/*.h
|
||||
${BGFX_DIR}/include/bgfx/c99/*.h
|
||||
)
|
||||
if(BGFX_AMALGAMATED)
|
||||
set(BGFX_NOBUILD ${BGFX_SOURCES})
|
||||
list(REMOVE_ITEM BGFX_NOBUILD ${BGFX_AMALGAMATED_SOURCE})
|
||||
foreach(BGFX_SRC ${BGFX_NOBUILD})
|
||||
set_source_files_properties(${BGFX_SRC} PROPERTIES HEADER_FILE_ONLY ON)
|
||||
endforeach()
|
||||
else()
|
||||
# Do not build using amalgamated sources
|
||||
set_source_files_properties(${BGFX_DIR}/src/amalgamated.cpp PROPERTIES HEADER_FILE_ONLY ON)
|
||||
set_source_files_properties(${BGFX_DIR}/src/amalgamated.mm PROPERTIES HEADER_FILE_ONLY ON)
|
||||
endif()
|
||||
|
||||
# Create the bgfx target
|
||||
if(BGFX_LIBRARY_TYPE STREQUAL STATIC)
|
||||
add_library(bgfx STATIC ${BGFX_SOURCES})
|
||||
else()
|
||||
add_library(bgfx SHARED ${BGFX_SOURCES})
|
||||
target_compile_definitions(bgfx PUBLIC BGFX_SHARED_LIB_BUILD=1)
|
||||
endif()
|
||||
|
||||
if(BGFX_CONFIG_RENDERER_WEBGPU)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/webgpu.cmake)
|
||||
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_RENDERER_WEBGPU=1)
|
||||
if(EMSCRIPTEN)
|
||||
target_link_options(bgfx PRIVATE "-s USE_WEBGPU=1")
|
||||
else()
|
||||
target_link_libraries(bgfx PRIVATE webgpu)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
target_link_options(bgfx PUBLIC "-sMAX_WEBGL_VERSION=2")
|
||||
endif()
|
||||
|
||||
if(NOT ${BGFX_OPENGL_VERSION} STREQUAL "")
|
||||
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION=${BGFX_OPENGL_VERSION})
|
||||
endif()
|
||||
|
||||
if(NOT ${BGFX_OPENGLES_VERSION} STREQUAL "")
|
||||
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION=${BGFX_OPENGLES_VERSION})
|
||||
endif()
|
||||
|
||||
if(NOT ${BGFX_CONFIG_DEFAULT_MAX_ENCODERS} STREQUAL "")
|
||||
target_compile_definitions(
|
||||
bgfx
|
||||
PUBLIC
|
||||
"BGFX_CONFIG_DEFAULT_MAX_ENCODERS=$<IF:$<BOOL:${BGFX_CONFIG_MULTITHREADED}>,${BGFX_CONFIG_DEFAULT_MAX_ENCODERS},1>"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(BGFX_CONFIG_OPTIONS "")
|
||||
list(
|
||||
APPEND
|
||||
BGFX_CONFIG_OPTIONS
|
||||
"BGFX_CONFIG_MAX_DRAW_CALLS"
|
||||
"BGFX_CONFIG_MAX_VIEWS"
|
||||
"BGFX_CONFIG_MAX_FRAME_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_VERTEX_LAYOUTS"
|
||||
"BGFX_CONFIG_MAX_VERTEX_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_INDEX_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_TEXTURES"
|
||||
"BGFX_CONFIG_MAX_TEXTURE_SAMPLERS"
|
||||
"BGFX_CONFIG_MAX_SHADERS"
|
||||
"BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM"
|
||||
)
|
||||
foreach(BGFX_CONFIG_OPTION IN LISTS BGFX_CONFIG_OPTIONS)
|
||||
if(NOT ${${BGFX_CONFIG_OPTION}} STREQUAL "")
|
||||
target_compile_definitions(bgfx PUBLIC "${BGFX_CONFIG_OPTION}=${${BGFX_CONFIG_OPTION}}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Special Visual Studio Flags
|
||||
if(MSVC)
|
||||
target_compile_definitions(bgfx PRIVATE "_CRT_SECURE_NO_WARNINGS")
|
||||
endif()
|
||||
|
||||
# Add debug config required in bx headers since bx is private
|
||||
target_compile_definitions(
|
||||
bgfx
|
||||
PUBLIC
|
||||
"BX_CONFIG_DEBUG=$<OR:$<CONFIG:Debug>,$<BOOL:${BX_CONFIG_DEBUG}>>"
|
||||
"BGFX_CONFIG_DEBUG_ANNOTATION=$<AND:$<NOT:$<STREQUAL:${CMAKE_SYSTEM_NAME},WindowsStore>>,$<OR:$<CONFIG:Debug>,$<BOOL:${BGFX_CONFIG_DEBUG_ANNOTATION}>>>"
|
||||
"BGFX_CONFIG_MULTITHREADED=$<BOOL:${BGFX_CONFIG_MULTITHREADED}>"
|
||||
)
|
||||
|
||||
# directx-headers
|
||||
set(DIRECTX_HEADERS)
|
||||
if(UNIX
|
||||
AND NOT APPLE
|
||||
AND NOT EMSCRIPTEN
|
||||
AND NOT ANDROID
|
||||
) # Only Linux
|
||||
set(DIRECTX_HEADERS
|
||||
${BGFX_DIR}/3rdparty/directx-headers/include/directx ${BGFX_DIR}/3rdparty/directx-headers/include
|
||||
${BGFX_DIR}/3rdparty/directx-headers/include/wsl/stubs
|
||||
)
|
||||
elseif(WIN32) # Only Windows
|
||||
set(DIRECTX_HEADERS ${BGFX_DIR}/3rdparty/directx-headers/include/directx
|
||||
${BGFX_DIR}/3rdparty/directx-headers/include
|
||||
)
|
||||
endif()
|
||||
|
||||
# Includes
|
||||
target_include_directories(
|
||||
bgfx PRIVATE ${DIRECTX_HEADERS} ${BGFX_DIR}/3rdparty ${BGFX_DIR}/3rdparty/khronos
|
||||
PUBLIC $<BUILD_INTERFACE:${BGFX_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
||||
# bgfx depends on bx and bimg
|
||||
target_link_libraries(bgfx PRIVATE bx bimg)
|
||||
|
||||
# Frameworks required on iOS, tvOS and macOS
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES iOS|tvOS)
|
||||
target_link_libraries(
|
||||
bgfx
|
||||
PUBLIC
|
||||
"-framework OpenGLES -framework Metal -framework UIKit -framework CoreGraphics -framework QuartzCore -framework IOKit -framework CoreFoundation"
|
||||
)
|
||||
elseif(APPLE)
|
||||
find_library(COCOA_LIBRARY Cocoa)
|
||||
find_library(METAL_LIBRARY Metal)
|
||||
find_library(QUARTZCORE_LIBRARY QuartzCore)
|
||||
find_library(IOKIT_LIBRARY IOKit)
|
||||
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
|
||||
mark_as_advanced(COCOA_LIBRARY)
|
||||
mark_as_advanced(METAL_LIBRARY)
|
||||
mark_as_advanced(QUARTZCORE_LIBRARY)
|
||||
mark_as_advanced(IOKIT_LIBRARY)
|
||||
mark_as_advanced(COREFOUNDATION_LIBRARY)
|
||||
target_link_libraries(
|
||||
bgfx PUBLIC ${COCOA_LIBRARY} ${METAL_LIBRARY} ${QUARTZCORE_LIBRARY} ${IOKIT_LIBRARY} ${COREFOUNDATION_LIBRARY}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(UNIX
|
||||
AND NOT APPLE
|
||||
AND NOT EMSCRIPTEN
|
||||
AND NOT ANDROID
|
||||
)
|
||||
find_package(X11 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
#The following commented libraries are linked by bx
|
||||
#find_package(Threads REQUIRED)
|
||||
#find_library(LIBRT_LIBRARIES rt)
|
||||
#find_library(LIBDL_LIBRARIES dl)
|
||||
target_link_libraries(bgfx PUBLIC ${X11_LIBRARIES} ${OPENGL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# Exclude mm files if not on OS X
|
||||
if(NOT APPLE)
|
||||
set_source_files_properties(${BGFX_DIR}/src/glcontext_eagl.mm PROPERTIES HEADER_FILE_ONLY ON)
|
||||
set_source_files_properties(${BGFX_DIR}/src/glcontext_nsgl.mm PROPERTIES HEADER_FILE_ONLY ON)
|
||||
set_source_files_properties(${BGFX_DIR}/src/renderer_mtl.mm PROPERTIES HEADER_FILE_ONLY ON)
|
||||
endif()
|
||||
|
||||
# Exclude glx context on non-unix
|
||||
if(NOT UNIX OR APPLE)
|
||||
set_source_files_properties(${BGFX_DIR}/src/glcontext_glx.cpp PROPERTIES HEADER_FILE_ONLY ON)
|
||||
endif()
|
||||
|
||||
# Put in a "bgfx" folder in Visual Studio
|
||||
set_target_properties(bgfx PROPERTIES FOLDER "bgfx")
|
||||
|
||||
# in Xcode we need to specify this file as objective-c++ (instead of renaming to .mm)
|
||||
if(XCODE)
|
||||
set_source_files_properties(
|
||||
${BGFX_DIR}/src/renderer_vk.cpp PROPERTIES LANGUAGE OBJCXX XCODE_EXPLICIT_FILE_TYPE sourcecode.cpp.objcpp
|
||||
)
|
||||
endif()
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
# To prevent this warning: https://cmake.org/cmake/help/git-stage/policy/CMP0072.html
|
||||
if(POLICY CMP0072)
|
||||
cmake_policy(SET CMP0072 NEW)
|
||||
endif()
|
||||
|
||||
# Ensure the directory exists
|
||||
if(NOT IS_DIRECTORY ${BGFX_DIR})
|
||||
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT APPLE)
|
||||
set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.cpp)
|
||||
else()
|
||||
set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.mm)
|
||||
endif()
|
||||
|
||||
# Grab the bgfx source files
|
||||
file(
|
||||
GLOB
|
||||
BGFX_SOURCES
|
||||
${BGFX_DIR}/src/*.cpp
|
||||
${BGFX_DIR}/src/*.mm
|
||||
${BGFX_DIR}/src/*.h
|
||||
${BGFX_DIR}/include/bgfx/*.h
|
||||
${BGFX_DIR}/include/bgfx/c99/*.h
|
||||
)
|
||||
if(BGFX_AMALGAMATED)
|
||||
set(BGFX_NOBUILD ${BGFX_SOURCES})
|
||||
list(REMOVE_ITEM BGFX_NOBUILD ${BGFX_AMALGAMATED_SOURCE})
|
||||
foreach(BGFX_SRC ${BGFX_NOBUILD})
|
||||
set_source_files_properties(${BGFX_SRC} PROPERTIES HEADER_FILE_ONLY ON)
|
||||
endforeach()
|
||||
else()
|
||||
# Do not build using amalgamated sources
|
||||
set_source_files_properties(${BGFX_DIR}/src/amalgamated.cpp PROPERTIES HEADER_FILE_ONLY ON)
|
||||
set_source_files_properties(${BGFX_DIR}/src/amalgamated.mm PROPERTIES HEADER_FILE_ONLY ON)
|
||||
endif()
|
||||
|
||||
# Create the bgfx target
|
||||
if(BGFX_LIBRARY_TYPE STREQUAL STATIC)
|
||||
add_library(bgfx STATIC ${BGFX_SOURCES})
|
||||
else()
|
||||
add_library(bgfx SHARED ${BGFX_SOURCES})
|
||||
target_compile_definitions(bgfx PUBLIC BGFX_SHARED_LIB_BUILD=1)
|
||||
endif()
|
||||
|
||||
if(BGFX_CONFIG_RENDERER_WEBGPU)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/webgpu.cmake)
|
||||
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_RENDERER_WEBGPU=1)
|
||||
if(EMSCRIPTEN)
|
||||
target_link_options(bgfx PRIVATE "-s USE_WEBGPU=1")
|
||||
else()
|
||||
target_link_libraries(bgfx PRIVATE webgpu)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
target_link_options(bgfx PUBLIC "-sMAX_WEBGL_VERSION=2")
|
||||
endif()
|
||||
|
||||
if(NOT ${BGFX_OPENGL_VERSION} STREQUAL "")
|
||||
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGL_MIN_VERSION=${BGFX_OPENGL_VERSION})
|
||||
endif()
|
||||
|
||||
if(NOT ${BGFX_OPENGLES_VERSION} STREQUAL "")
|
||||
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_RENDERER_OPENGLES_MIN_VERSION=${BGFX_OPENGLES_VERSION})
|
||||
endif()
|
||||
|
||||
if(NOT ${BGFX_CONFIG_DEFAULT_MAX_ENCODERS} STREQUAL "")
|
||||
target_compile_definitions(
|
||||
bgfx
|
||||
PUBLIC
|
||||
"BGFX_CONFIG_DEFAULT_MAX_ENCODERS=$<IF:$<BOOL:${BGFX_CONFIG_MULTITHREADED}>,${BGFX_CONFIG_DEFAULT_MAX_ENCODERS},1>"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(BGFX_CONFIG_OPTIONS "")
|
||||
list(
|
||||
APPEND
|
||||
BGFX_CONFIG_OPTIONS
|
||||
"BGFX_CONFIG_MAX_DRAW_CALLS"
|
||||
"BGFX_CONFIG_MAX_VIEWS"
|
||||
"BGFX_CONFIG_MAX_FRAME_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_VERTEX_LAYOUTS"
|
||||
"BGFX_CONFIG_MAX_VERTEX_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_INDEX_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS"
|
||||
"BGFX_CONFIG_MAX_TEXTURES"
|
||||
"BGFX_CONFIG_MAX_TEXTURE_SAMPLERS"
|
||||
"BGFX_CONFIG_MAX_SHADERS"
|
||||
"BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM"
|
||||
)
|
||||
foreach(BGFX_CONFIG_OPTION IN LISTS BGFX_CONFIG_OPTIONS)
|
||||
if(NOT ${${BGFX_CONFIG_OPTION}} STREQUAL "")
|
||||
target_compile_definitions(bgfx PUBLIC "${BGFX_CONFIG_OPTION}=${${BGFX_CONFIG_OPTION}}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Special Visual Studio Flags
|
||||
if(MSVC)
|
||||
target_compile_definitions(bgfx PRIVATE "_CRT_SECURE_NO_WARNINGS")
|
||||
endif()
|
||||
|
||||
# Add debug config required in bx headers since bx is private
|
||||
target_compile_definitions(
|
||||
bgfx
|
||||
PUBLIC
|
||||
"BX_CONFIG_DEBUG=$<OR:$<CONFIG:Debug>,$<BOOL:${BX_CONFIG_DEBUG}>>"
|
||||
"BGFX_CONFIG_DEBUG_ANNOTATION=$<AND:$<NOT:$<STREQUAL:${CMAKE_SYSTEM_NAME},WindowsStore>>,$<OR:$<CONFIG:Debug>,$<BOOL:${BGFX_CONFIG_DEBUG_ANNOTATION}>>>"
|
||||
"BGFX_CONFIG_MULTITHREADED=$<BOOL:${BGFX_CONFIG_MULTITHREADED}>"
|
||||
)
|
||||
|
||||
# directx-headers
|
||||
set(DIRECTX_HEADERS)
|
||||
if(UNIX
|
||||
AND NOT APPLE
|
||||
AND NOT EMSCRIPTEN
|
||||
AND NOT ANDROID
|
||||
) # Only Linux
|
||||
set(DIRECTX_HEADERS
|
||||
${BGFX_DIR}/3rdparty/directx-headers/include/directx ${BGFX_DIR}/3rdparty/directx-headers/include
|
||||
${BGFX_DIR}/3rdparty/directx-headers/include/wsl/stubs
|
||||
)
|
||||
elseif(WIN32) # Only Windows
|
||||
set(DIRECTX_HEADERS ${BGFX_DIR}/3rdparty/directx-headers/include/directx
|
||||
${BGFX_DIR}/3rdparty/directx-headers/include
|
||||
)
|
||||
endif()
|
||||
|
||||
# Includes
|
||||
target_include_directories(
|
||||
bgfx PRIVATE ${DIRECTX_HEADERS} ${BGFX_DIR}/3rdparty ${BGFX_DIR}/3rdparty/khronos
|
||||
PUBLIC $<BUILD_INTERFACE:${BGFX_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
||||
# bgfx depends on bx and bimg
|
||||
target_link_libraries(bgfx PRIVATE bx bimg)
|
||||
|
||||
# Frameworks required on iOS, tvOS and macOS
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES iOS|tvOS)
|
||||
target_link_libraries(
|
||||
bgfx
|
||||
PUBLIC
|
||||
"-framework OpenGLES -framework Metal -framework UIKit -framework CoreGraphics -framework QuartzCore -framework IOKit -framework CoreFoundation"
|
||||
)
|
||||
elseif(APPLE)
|
||||
find_library(COCOA_LIBRARY Cocoa)
|
||||
find_library(METAL_LIBRARY Metal)
|
||||
find_library(QUARTZCORE_LIBRARY QuartzCore)
|
||||
find_library(IOKIT_LIBRARY IOKit)
|
||||
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
|
||||
mark_as_advanced(COCOA_LIBRARY)
|
||||
mark_as_advanced(METAL_LIBRARY)
|
||||
mark_as_advanced(QUARTZCORE_LIBRARY)
|
||||
mark_as_advanced(IOKIT_LIBRARY)
|
||||
mark_as_advanced(COREFOUNDATION_LIBRARY)
|
||||
target_link_libraries(
|
||||
bgfx PUBLIC ${COCOA_LIBRARY} ${METAL_LIBRARY} ${QUARTZCORE_LIBRARY} ${IOKIT_LIBRARY} ${COREFOUNDATION_LIBRARY}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(UNIX
|
||||
AND NOT APPLE
|
||||
AND NOT EMSCRIPTEN
|
||||
AND NOT ANDROID
|
||||
)
|
||||
find_package(X11 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
#The following commented libraries are linked by bx
|
||||
#find_package(Threads REQUIRED)
|
||||
#find_library(LIBRT_LIBRARIES rt)
|
||||
#find_library(LIBDL_LIBRARIES dl)
|
||||
target_link_libraries(bgfx PUBLIC ${X11_LIBRARIES} ${OPENGL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# Exclude mm files if not on OS X
|
||||
if(NOT APPLE)
|
||||
set_source_files_properties(${BGFX_DIR}/src/glcontext_eagl.mm PROPERTIES HEADER_FILE_ONLY ON)
|
||||
set_source_files_properties(${BGFX_DIR}/src/glcontext_nsgl.mm PROPERTIES HEADER_FILE_ONLY ON)
|
||||
set_source_files_properties(${BGFX_DIR}/src/renderer_mtl.mm PROPERTIES HEADER_FILE_ONLY ON)
|
||||
endif()
|
||||
|
||||
# Exclude glx context on non-unix
|
||||
if(NOT UNIX OR APPLE)
|
||||
set_source_files_properties(${BGFX_DIR}/src/glcontext_glx.cpp PROPERTIES HEADER_FILE_ONLY ON)
|
||||
endif()
|
||||
|
||||
# Put in a "bgfx" folder in Visual Studio
|
||||
set_target_properties(bgfx PROPERTIES FOLDER "bgfx")
|
||||
|
||||
# in Xcode we need to specify this file as objective-c++ (instead of renaming to .mm)
|
||||
if(XCODE)
|
||||
set_source_files_properties(
|
||||
${BGFX_DIR}/src/renderer_vk.cpp PROPERTIES LANGUAGE OBJCXX XCODE_EXPLICIT_FILE_TYPE sourcecode.cpp.objcpp
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -1,4 +1,65 @@
|
||||
# shaderc_parse(
|
||||
# _bgfx_bin2c_parse(
|
||||
# INPUT_FILE filename
|
||||
# OUTPUT_FILE filename
|
||||
# ARRAY_NAME name
|
||||
# )
|
||||
# Usage: bin2c -f <in> -o <out> -n <name>
|
||||
function(_bgfx_bin2c_parse ARG_OUT)
|
||||
set(options "")
|
||||
set(oneValueArgs INPUT_FILE;OUTPUT_FILE;ARRAY_NAME)
|
||||
set(multiValueArgs "")
|
||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
||||
set(CLI "")
|
||||
|
||||
# -f
|
||||
if(ARG_INPUT_FILE)
|
||||
list(APPEND CLI "-f" "${ARG_INPUT_FILE}")
|
||||
else()
|
||||
message(SEND_ERROR "Call to _bgfx_bin2c_parse() must have an INPUT_FILE")
|
||||
endif()
|
||||
|
||||
# -o
|
||||
if(ARG_OUTPUT_FILE)
|
||||
list(APPEND CLI "-o" "${ARG_OUTPUT_FILE}")
|
||||
else()
|
||||
message(SEND_ERROR "Call to _bgfx_bin2c_parse() must have an OUTPUT_FILE")
|
||||
endif()
|
||||
|
||||
# -n
|
||||
if(ARG_ARRAY_NAME)
|
||||
list(APPEND CLI "-n" "${ARG_ARRAY_NAME}")
|
||||
else()
|
||||
message(SEND_ERROR "Call to _bgfx_bin2c_parse() must have an ARRAY_NAME")
|
||||
endif()
|
||||
|
||||
set(${ARG_OUT} ${CLI} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# bgfx_compile_binary_to_header(
|
||||
# INPUT_FILE filename
|
||||
# OUTPUT_FILE filename
|
||||
# ARRAY_NAME name
|
||||
# )
|
||||
#
|
||||
function(bgfx_compile_binary_to_header)
|
||||
set(options "")
|
||||
set(oneValueArgs INPUT_FILE;OUTPUT_FILE;ARRAY_NAME)
|
||||
set(multiValueArgs "")
|
||||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
||||
_bgfx_bin2c_parse(
|
||||
CLI
|
||||
INPUT_FILE ${ARG_INPUT_FILE}
|
||||
OUTPUT_FILE ${ARG_OUTPUT_FILE}
|
||||
ARRAY_NAME ${ARG_ARRAY_NAME}
|
||||
)
|
||||
add_custom_command(
|
||||
OUTPUT ${ARG_OUTPUT_FILE} #
|
||||
COMMAND bgfx::bin2c ${CLI} #
|
||||
MAIN_DEPENDENCY ${ARG_INPUT_FILE} #
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# _bgfx_shaderc_parse(
|
||||
# FILE filename
|
||||
# OUTPUT filename
|
||||
# FRAGMENT|VERTEX|COMPUTE
|
||||
@@ -17,252 +78,250 @@
|
||||
# [DISASM]
|
||||
# [WERROR]
|
||||
# )
|
||||
function( shaderc_parse ARG_OUT )
|
||||
cmake_parse_arguments( ARG "DEPENDS;ANDROID;ASM_JS;IOS;LINUX;NACL;OSX;WINDOWS;PREPROCESS;RAW;FRAGMENT;VERTEX;COMPUTE;VERBOSE;DEBUG;DISASM;WERROR" "FILE;OUTPUT;VARYINGDEF;BIN2C;PROFILE;O" "INCLUDES;DEFINES" ${ARGN} )
|
||||
set( CLI "" )
|
||||
function(_bgfx_shaderc_parse ARG_OUT)
|
||||
cmake_parse_arguments(
|
||||
ARG
|
||||
"DEPENDS;ANDROID;ASM_JS;IOS;LINUX;NACL;OSX;WINDOWS;PREPROCESS;RAW;FRAGMENT;VERTEX;COMPUTE;VERBOSE;DEBUG;DISASM;WERROR"
|
||||
"FILE;OUTPUT;VARYINGDEF;BIN2C;PROFILE;O"
|
||||
"INCLUDES;DEFINES"
|
||||
${ARGN}
|
||||
)
|
||||
set(CLI "")
|
||||
|
||||
# -f
|
||||
if( ARG_FILE )
|
||||
list( APPEND CLI "-f" "${ARG_FILE}" )
|
||||
if(ARG_FILE)
|
||||
list(APPEND CLI "-f" "${ARG_FILE}")
|
||||
endif()
|
||||
|
||||
# -i
|
||||
if( ARG_INCLUDES )
|
||||
foreach( INCLUDE ${ARG_INCLUDES} )
|
||||
list( APPEND CLI "-i" )
|
||||
list( APPEND CLI "${INCLUDE}" )
|
||||
if(ARG_INCLUDES)
|
||||
foreach(INCLUDE ${ARG_INCLUDES})
|
||||
list(APPEND CLI "-i")
|
||||
list(APPEND CLI "${INCLUDE}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# -o
|
||||
if( ARG_OUTPUT )
|
||||
list( APPEND CLI "-o" "${ARG_OUTPUT}" )
|
||||
if(ARG_OUTPUT)
|
||||
list(APPEND CLI "-o" "${ARG_OUTPUT}")
|
||||
endif()
|
||||
|
||||
# --bin2c
|
||||
if( ARG_BIN2C )
|
||||
list( APPEND CLI "--bin2c" "${ARG_BIN2C}" )
|
||||
if(ARG_BIN2C)
|
||||
list(APPEND CLI "--bin2c" "${ARG_BIN2C}")
|
||||
endif()
|
||||
|
||||
# --depends
|
||||
if( ARG_DEPENDS )
|
||||
list( APPEND CLI "--depends" )
|
||||
if(ARG_DEPENDS)
|
||||
list(APPEND CLI "--depends")
|
||||
endif()
|
||||
|
||||
# --platform
|
||||
set( PLATFORM "" )
|
||||
set( PLATFORMS "ANDROID;ASM_JS;IOS;LINUX;NACL;OSX;WINDOWS" )
|
||||
foreach( P ${PLATFORMS} )
|
||||
if( ARG_${P} )
|
||||
if( PLATFORM )
|
||||
message( SEND_ERROR "Call to shaderc_parse() cannot have both flags ${PLATFORM} and ${P}." )
|
||||
set(PLATFORM "")
|
||||
set(PLATFORMS "ANDROID;ASM_JS;IOS;LINUX;NACL;OSX;WINDOWS")
|
||||
foreach(P ${PLATFORMS})
|
||||
if(ARG_${P})
|
||||
if(PLATFORM)
|
||||
message(SEND_ERROR "Call to _bgfx_shaderc_parse() cannot have both flags ${PLATFORM} and ${P}.")
|
||||
return()
|
||||
endif()
|
||||
set( PLATFORM "${P}" )
|
||||
set(PLATFORM "${P}")
|
||||
endif()
|
||||
endforeach()
|
||||
if( "${PLATFORM}" STREQUAL "" )
|
||||
message( SEND_ERROR "Call to shaderc_parse() must have a platform flag: ${PLATFORMS}" )
|
||||
if(PLATFORM STREQUAL "")
|
||||
message(SEND_ERROR "Call to _bgfx_shaderc_parse() must have a platform flag: ${PLATFORMS}")
|
||||
return()
|
||||
elseif( "${PLATFORM}" STREQUAL "ANDROID" )
|
||||
list( APPEND CLI "--platform" "android" )
|
||||
elseif( "${PLATFORM}" STREQUAL "ASM_JS" )
|
||||
list( APPEND CLI "--platform" "asm.js" )
|
||||
elseif( "${PLATFORM}" STREQUAL "IOS" )
|
||||
list( APPEND CLI "--platform" "ios" )
|
||||
elseif( "${PLATFORM}" STREQUAL "LINUX" )
|
||||
list( APPEND CLI "--platform" "linux" )
|
||||
elseif( "${PLATFORM}" STREQUAL "NACL" )
|
||||
list( APPEND CLI "--platform" "nacl" )
|
||||
elseif( "${PLATFORM}" STREQUAL "OSX" )
|
||||
list( APPEND CLI "--platform" "osx" )
|
||||
elseif( "${PLATFORM}" STREQUAL "WINDOWS" )
|
||||
list( APPEND CLI "--platform" "windows" )
|
||||
elseif(PLATFORM STREQUAL ANDROID)
|
||||
list(APPEND CLI "--platform" "android")
|
||||
elseif(PLATFORM STREQUAL ASM_JS)
|
||||
list(APPEND CLI "--platform" "asm.js")
|
||||
elseif(PLATFORM STREQUAL IOS)
|
||||
list(APPEND CLI "--platform" "ios")
|
||||
elseif(PLATFORM STREQUAL NACL)
|
||||
list(APPEND CLI "--platform" "nacl")
|
||||
elseif(PLATFORM STREQUAL OSX)
|
||||
list(APPEND CLI "--platform" "osx")
|
||||
elseif(PLATFORM STREQUAL UNIX)
|
||||
list(APPEND CLI "--platform" "linux")
|
||||
elseif(PLATFORM STREQUAL WINDOWS)
|
||||
list(APPEND CLI "--platform" "windows")
|
||||
endif()
|
||||
|
||||
# --preprocess
|
||||
if( ARG_PREPROCESS )
|
||||
list( APPEND CLI "--preprocess" )
|
||||
if(ARG_PREPROCESS)
|
||||
list(APPEND CLI "--preprocess")
|
||||
endif()
|
||||
|
||||
# --define
|
||||
if( ARG_DEFINES )
|
||||
list( APPEND CLI "--defines" )
|
||||
set( DEFINES "" )
|
||||
foreach( DEFINE ${ARG_DEFINES} )
|
||||
if( NOT "${DEFINES}" STREQUAL "" )
|
||||
set( DEFINES "${DEFINES}\\\\;${DEFINE}" )
|
||||
if(ARG_DEFINES)
|
||||
list(APPEND CLI "--defines")
|
||||
set(DEFINES "")
|
||||
foreach(DEFINE ${ARG_DEFINES})
|
||||
if(NOT "${DEFINES}" STREQUAL "")
|
||||
set(DEFINES "${DEFINES}\\\\;${DEFINE}")
|
||||
else()
|
||||
set( DEFINES "${DEFINE}" )
|
||||
set(DEFINES "${DEFINE}")
|
||||
endif()
|
||||
endforeach()
|
||||
list( APPEND CLI "${DEFINES}" )
|
||||
list(APPEND CLI "${DEFINES}")
|
||||
endif()
|
||||
|
||||
# --raw
|
||||
if( ARG_RAW )
|
||||
list( APPEND CLI "--raw" )
|
||||
if(ARG_RAW)
|
||||
list(APPEND CLI "--raw")
|
||||
endif()
|
||||
|
||||
# --type
|
||||
set( TYPE "" )
|
||||
set( TYPES "FRAGMENT;VERTEX;COMPUTE" )
|
||||
foreach( T ${TYPES} )
|
||||
if( ARG_${T} )
|
||||
if( TYPE )
|
||||
message( SEND_ERROR "Call to shaderc_parse() cannot have both flags ${TYPE} and ${T}." )
|
||||
set(TYPE "")
|
||||
set(TYPES "FRAGMENT;VERTEX;COMPUTE")
|
||||
foreach(T ${TYPES})
|
||||
if(ARG_${T})
|
||||
if(TYPE)
|
||||
message(SEND_ERROR "Call to _bgfx_shaderc_parse() cannot have both flags ${TYPE} and ${T}.")
|
||||
return()
|
||||
endif()
|
||||
set( TYPE "${T}" )
|
||||
set(TYPE "${T}")
|
||||
endif()
|
||||
endforeach()
|
||||
if( "${TYPE}" STREQUAL "" )
|
||||
message( SEND_ERROR "Call to shaderc_parse() must have a type flag: ${TYPES}" )
|
||||
if("${TYPE}" STREQUAL "")
|
||||
message(SEND_ERROR "Call to _bgfx_shaderc_parse() must have a type flag: ${TYPES}")
|
||||
return()
|
||||
elseif( "${TYPE}" STREQUAL "FRAGMENT" )
|
||||
list( APPEND CLI "--type" "fragment" )
|
||||
elseif( "${TYPE}" STREQUAL "VERTEX" )
|
||||
list( APPEND CLI "--type" "vertex" )
|
||||
elseif( "${TYPE}" STREQUAL "COMPUTE" )
|
||||
list( APPEND CLI "--type" "compute" )
|
||||
elseif("${TYPE}" STREQUAL "FRAGMENT")
|
||||
list(APPEND CLI "--type" "fragment")
|
||||
elseif("${TYPE}" STREQUAL "VERTEX")
|
||||
list(APPEND CLI "--type" "vertex")
|
||||
elseif("${TYPE}" STREQUAL "COMPUTE")
|
||||
list(APPEND CLI "--type" "compute")
|
||||
endif()
|
||||
|
||||
# --varyingdef
|
||||
if( ARG_VARYINGDEF )
|
||||
list( APPEND CLI "--varyingdef" "${ARG_VARYINGDEF}" )
|
||||
if(ARG_VARYINGDEF)
|
||||
list(APPEND CLI "--varyingdef" "${ARG_VARYINGDEF}")
|
||||
endif()
|
||||
|
||||
# --verbose
|
||||
if( ARG_VERBOSE )
|
||||
list( APPEND CLI "--verbose" )
|
||||
if(ARG_VERBOSE)
|
||||
list(APPEND CLI "--verbose")
|
||||
endif()
|
||||
|
||||
# --debug
|
||||
if( ARG_DEBUG )
|
||||
list( APPEND CLI "--debug" )
|
||||
if(ARG_DEBUG)
|
||||
list(APPEND CLI "--debug")
|
||||
endif()
|
||||
|
||||
# --disasm
|
||||
if( ARG_DISASM )
|
||||
list( APPEND CLI "--disasm" )
|
||||
if(ARG_DISASM)
|
||||
list(APPEND CLI "--disasm")
|
||||
endif()
|
||||
|
||||
# --profile
|
||||
if( ARG_PROFILE )
|
||||
list( APPEND CLI "--profile" "${ARG_PROFILE}" )
|
||||
if(ARG_PROFILE)
|
||||
list(APPEND CLI "--profile" "${ARG_PROFILE}")
|
||||
endif()
|
||||
|
||||
# -O
|
||||
if( ARG_O )
|
||||
list( APPEND CLI "-O" "${ARG_O}" )
|
||||
if(ARG_O)
|
||||
list(APPEND CLI "-O" "${ARG_O}")
|
||||
endif()
|
||||
|
||||
# --Werror
|
||||
if( ARG_WERROR )
|
||||
list( APPEND CLI "--Werror" )
|
||||
if(ARG_WERROR)
|
||||
list(APPEND CLI "--Werror")
|
||||
endif()
|
||||
|
||||
set( ${ARG_OUT} ${CLI} PARENT_SCOPE )
|
||||
set(${ARG_OUT} ${CLI} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function (_get_profile_ext PROFILE PROFILE_EXT)
|
||||
string(REPLACE 300_es essl PROFILE ${PROFILE})
|
||||
string(REPLACE 120 glsl PROFILE ${PROFILE})
|
||||
string(REPLACE spirv spv PROFILE ${PROFILE})
|
||||
string(REPLACE metal mtl PROFILE ${PROFILE})
|
||||
string(REPLACE s_3_0 dx9 PROFILE ${PROFILE})
|
||||
string(REPLACE s_4_0 dx10 PROFILE ${PROFILE})
|
||||
string(REPLACE s_5_0 dx11 PROFILE ${PROFILE})
|
||||
function(_bgfx_get_profile_ext PROFILE PROFILE_EXT)
|
||||
string(REPLACE 300_es essl PROFILE ${PROFILE})
|
||||
string(REPLACE 120 glsl PROFILE ${PROFILE})
|
||||
string(REPLACE spirv spv PROFILE ${PROFILE})
|
||||
string(REPLACE metal mtl PROFILE ${PROFILE})
|
||||
string(REPLACE s_3_0 dx9 PROFILE ${PROFILE})
|
||||
string(REPLACE s_4_0 dx10 PROFILE ${PROFILE})
|
||||
string(REPLACE s_5_0 dx11 PROFILE ${PROFILE})
|
||||
|
||||
set(${PROFILE_EXT}
|
||||
${PROFILE}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
endfunction ()
|
||||
set(${PROFILE_EXT} ${PROFILE} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# compile_shader_to_header(
|
||||
# TYPE VERTEX|FRAGMENT|COMPUTE
|
||||
# SHADERS filenames
|
||||
# VARYING_DEF filename
|
||||
# OUTPUT_DIR directory
|
||||
#)
|
||||
# bgfx_compile_shader_to_header(
|
||||
# TYPE VERTEX|FRAGMENT|COMPUTE
|
||||
# SHADERS filenames
|
||||
# VARYING_DEF filename
|
||||
# OUTPUT_DIR directory
|
||||
# )
|
||||
#
|
||||
function (compile_shader_to_header)
|
||||
set(options "")
|
||||
set(oneValueArgs TYPE VARYING_DEF OUTPUT_DIR)
|
||||
set(multiValueArgs SHADERS)
|
||||
cmake_parse_arguments(
|
||||
ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}"
|
||||
)
|
||||
function(bgfx_compile_shader_to_header)
|
||||
set(options "")
|
||||
set(oneValueArgs TYPE VARYING_DEF OUTPUT_DIR)
|
||||
set(multiValueArgs SHADERS)
|
||||
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
||||
|
||||
set(PROFILES 120 300_es spirv) # pssl
|
||||
if (UNIX AND NOT APPLE)
|
||||
set(PLATFORM LINUX)
|
||||
elseif (EMSCRIPTEN)
|
||||
set(PLATFORM ASM_JS)
|
||||
elseif (APPLE)
|
||||
set(PLATFORM OSX)
|
||||
list(APPEND PROFILES metal)
|
||||
elseif (
|
||||
WIN32
|
||||
OR MINGW
|
||||
OR MSYS
|
||||
OR CYGWIN
|
||||
)
|
||||
set(PLATFORM WINDOWS)
|
||||
if (ARGS_TYPE STREQUAL "VERTEX" OR ARGS_TYPE STREQUAL "FRAGMENT")
|
||||
list(APPEND PROFILES s_3_0)
|
||||
list(APPEND PROFILES s_4_0)
|
||||
list(APPEND PROFILES s_5_0)
|
||||
elseif (ARGS_TYPE STREQUAL "COMPUTE")
|
||||
list(APPEND PROFILES s_4_0)
|
||||
list(APPEND PROFILES s_5_0)
|
||||
else ()
|
||||
message(error "shaderc: Unsupported type")
|
||||
endif ()
|
||||
else ()
|
||||
message(error "shaderc: Unsupported platform")
|
||||
endif ()
|
||||
set(PROFILES 120 300_es spirv) # pssl
|
||||
if(UNIX AND NOT APPLE)
|
||||
set(PLATFORM LINUX)
|
||||
elseif(EMSCRIPTEN)
|
||||
set(PLATFORM ASM_JS)
|
||||
elseif(APPLE)
|
||||
set(PLATFORM OSX)
|
||||
list(APPEND PROFILES metal)
|
||||
elseif(
|
||||
WIN32
|
||||
OR MINGW
|
||||
OR MSYS
|
||||
OR CYGWIN
|
||||
)
|
||||
set(PLATFORM WINDOWS)
|
||||
if(ARGS_TYPE STREQUAL "VERTEX" OR ARGS_TYPE STREQUAL "FRAGMENT")
|
||||
list(APPEND PROFILES s_3_0)
|
||||
list(APPEND PROFILES s_4_0)
|
||||
list(APPEND PROFILES s_5_0)
|
||||
elseif(ARGS_TYPE STREQUAL "COMPUTE")
|
||||
list(APPEND PROFILES s_4_0)
|
||||
list(APPEND PROFILES s_5_0)
|
||||
else()
|
||||
message(error "shaderc: Unsupported type")
|
||||
endif()
|
||||
else()
|
||||
message(error "shaderc: Unsupported platform")
|
||||
endif()
|
||||
|
||||
foreach (SHADER_FILE ${ARGS_SHADERS})
|
||||
source_group("Shaders" FILES "${SHADER}")
|
||||
get_filename_component(SHADER_FILE_BASENAME ${SHADER_FILE} NAME)
|
||||
get_filename_component(SHADER_FILE_NAME_WE ${SHADER_FILE} NAME_WE)
|
||||
get_filename_component(SHADER_FILE_ABSOLUTE ${SHADER_FILE} ABSOLUTE)
|
||||
foreach(SHADER_FILE ${ARGS_SHADERS})
|
||||
source_group("Shaders" FILES "${SHADER}")
|
||||
get_filename_component(SHADER_FILE_BASENAME ${SHADER_FILE} NAME)
|
||||
get_filename_component(SHADER_FILE_NAME_WE ${SHADER_FILE} NAME_WE)
|
||||
get_filename_component(SHADER_FILE_ABSOLUTE ${SHADER_FILE} ABSOLUTE)
|
||||
|
||||
# Build output targets and their commands
|
||||
set(OUTPUTS "")
|
||||
set(COMMANDS "")
|
||||
foreach (PROFILE ${PROFILES})
|
||||
_get_profile_ext(${PROFILE} PROFILE_EXT)
|
||||
set(OUTPUT
|
||||
${ARGS_OUTPUT_DIR}/${SHADER_FILE_BASENAME}.${PROFILE_EXT}.bin.h
|
||||
)
|
||||
set(PLATFORM_I ${PLATFORM})
|
||||
if (PROFILE STREQUAL "spirv")
|
||||
set(PLATFORM_I LINUX)
|
||||
endif ()
|
||||
shaderc_parse(
|
||||
CLI #
|
||||
${ARGS_TYPE} ${PLATFORM_I} WERROR
|
||||
"$<$<CONFIG:debug>:DEBUG>$<$<CONFIG:relwithdebinfo>:DEBUG>"
|
||||
FILE ${SHADER_FILE_ABSOLUTE}
|
||||
OUTPUT ${OUTPUT}
|
||||
PROFILE ${PROFILE}
|
||||
O "$<$<CONFIG:debug>:0>$<$<CONFIG:release>:3>$<$<CONFIG:relwithdebinfo>:3>$<$<CONFIG:minsizerel>:3>"
|
||||
VARYINGDEF ${ARGS_VARYING_DEF}
|
||||
INCLUDES ${BGFX_SHADER_INCLUDE_PATH}
|
||||
BIN2C BIN2C ${SHADER_FILE_NAME_WE}_${PROFILE_EXT}
|
||||
)
|
||||
list(APPEND OUTPUTS ${OUTPUT})
|
||||
list(APPEND COMMANDS COMMAND bgfx::shaderc ${CLI})
|
||||
endforeach ()
|
||||
# Build output targets and their commands
|
||||
set(OUTPUTS "")
|
||||
set(COMMANDS "")
|
||||
foreach(PROFILE ${PROFILES})
|
||||
_bgfx_get_profile_ext(${PROFILE} PROFILE_EXT)
|
||||
set(OUTPUT ${ARGS_OUTPUT_DIR}/${SHADER_FILE_BASENAME}.${PROFILE_EXT}.bin.h)
|
||||
set(PLATFORM_I ${PLATFORM})
|
||||
if(PROFILE STREQUAL "spirv")
|
||||
set(PLATFORM_I LINUX)
|
||||
endif()
|
||||
_bgfx_shaderc_parse(
|
||||
CLI #
|
||||
${ARGS_TYPE} ${PLATFORM_I} WERROR "$<$<CONFIG:debug>:DEBUG>$<$<CONFIG:relwithdebinfo>:DEBUG>"
|
||||
FILE ${SHADER_FILE_ABSOLUTE}
|
||||
OUTPUT ${OUTPUT}
|
||||
PROFILE ${PROFILE}
|
||||
O "$<$<CONFIG:debug>:0>$<$<CONFIG:release>:3>$<$<CONFIG:relwithdebinfo>:3>$<$<CONFIG:minsizerel>:3>"
|
||||
VARYINGDEF ${ARGS_VARYING_DEF}
|
||||
INCLUDES ${BGFX_SHADER_INCLUDE_PATH}
|
||||
BIN2C BIN2C ${SHADER_FILE_NAME_WE}_${PROFILE_EXT}
|
||||
)
|
||||
list(APPEND OUTPUTS ${OUTPUT})
|
||||
list(APPEND COMMANDS COMMAND bgfx::shaderc ${CLI})
|
||||
endforeach()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${OUTPUTS}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${ARGS_OUTPUT_DIR} ${COMMANDS}
|
||||
MAIN_DEPENDENCY ${SHADER_FILE_ABSOLUTE}
|
||||
DEPENDS ${ARGS_VARYING_DEF}
|
||||
)
|
||||
endforeach ()
|
||||
endfunction ()
|
||||
add_custom_command(
|
||||
OUTPUT ${OUTPUTS}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${ARGS_OUTPUT_DIR} ${COMMANDS}
|
||||
MAIN_DEPENDENCY ${SHADER_FILE_ABSOLUTE}
|
||||
DEPENDS ${ARGS_VARYING_DEF}
|
||||
)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
43
cmake/bx/CMakeLists.txt
Normal file
43
cmake/bx/CMakeLists.txt
Normal file
@@ -0,0 +1,43 @@
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
include(bx.cmake)
|
||||
|
||||
if(BGFX_BUILD_TOOLS)
|
||||
include(bin2c.cmake)
|
||||
endif()
|
||||
|
||||
if(BGFX_BUILD_TESTS)
|
||||
add_executable(bx_test)
|
||||
target_compile_definitions(bx_test PRIVATE CATCH_AMALGAMATED_CUSTOM_MAIN)
|
||||
file(
|
||||
GLOB
|
||||
BX_TEST_SOURCES #
|
||||
${BX_DIR}/3rdparty/catch/catch_amalgamated.cpp
|
||||
${BX_DIR}/tests/*_test.cpp #
|
||||
${BX_DIR}/tests/*.h #
|
||||
${BX_DIR}/tests/dbg.* #
|
||||
)
|
||||
target_sources(bx_test PRIVATE ${BX_TEST_SOURCES})
|
||||
target_link_libraries(bx_test PRIVATE bx)
|
||||
add_test(NAME bx.test COMMAND bx_test)
|
||||
|
||||
add_executable(bx_bench)
|
||||
file(
|
||||
GLOB
|
||||
BX_BENCH_SOURCES #
|
||||
${BX_DIR}/tests/*_bench.cpp #
|
||||
${BX_DIR}/tests/*_bench.h #
|
||||
${BX_DIR}/tests/dbg.* #
|
||||
)
|
||||
target_sources(bx_bench PRIVATE ${BX_BENCH_SOURCES})
|
||||
target_link_libraries(bx_bench PRIVATE bx)
|
||||
add_test(NAME bx.bench COMMAND bx_bench)
|
||||
endif()
|
||||
21
cmake/bx/bin2c.cmake
Normal file
21
cmake/bx/bin2c.cmake
Normal file
@@ -0,0 +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/>.
|
||||
|
||||
add_executable(bin2c)
|
||||
|
||||
# Grab the bin2c source files
|
||||
file(GLOB_RECURSE BIN2C_SOURCES #
|
||||
${BX_DIR}/tools/bin2c/*.cpp #
|
||||
${BX_DIR}/tools/bin2c/*.h #
|
||||
)
|
||||
|
||||
target_sources(bin2c PRIVATE ${BIN2C_SOURCES})
|
||||
target_link_libraries(bin2c PRIVATE bx)
|
||||
set_target_properties(bin2c PROPERTIES FOLDER "bgfx/tools")
|
||||
@@ -1,100 +1,125 @@
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
# Ensure the directory exists
|
||||
if(NOT IS_DIRECTORY ${BX_DIR})
|
||||
message(SEND_ERROR "Could not load bx, directory does not exist. ${BX_DIR}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Grab the bx source files
|
||||
file(GLOB BX_SOURCES ${BX_DIR}/src/*.cpp)
|
||||
|
||||
if(BX_AMALGAMATED)
|
||||
set(BX_NOBUILD ${BX_SOURCES})
|
||||
list(REMOVE_ITEM BX_NOBUILD ${BX_DIR}/src/amalgamated.cpp)
|
||||
foreach(BX_SRC ${BX_NOBUILD})
|
||||
set_source_files_properties(${BX_SRC} PROPERTIES HEADER_FILE_ONLY ON)
|
||||
endforeach()
|
||||
else()
|
||||
set_source_files_properties(${BX_DIR}/src/amalgamated.cpp PROPERTIES HEADER_FILE_ONLY ON)
|
||||
endif()
|
||||
|
||||
# Create the bx target
|
||||
add_library(bx STATIC ${BX_SOURCES})
|
||||
|
||||
target_compile_features(bx PUBLIC cxx_std_14)
|
||||
# (note: see bx\scripts\toolchain.lua for equivalent compiler flag)
|
||||
target_compile_options(bx PUBLIC $<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>)
|
||||
|
||||
# Link against psapi on Windows
|
||||
if(WIN32)
|
||||
target_link_libraries(bx PUBLIC psapi)
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Add include directory of bx
|
||||
target_include_directories(
|
||||
bx PUBLIC $<BUILD_INTERFACE:${BX_DIR}/include> $<BUILD_INTERFACE:${BX_DIR}/3rdparty>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
||||
# Build system specific configurations
|
||||
if(MINGW)
|
||||
target_include_directories(
|
||||
bx PUBLIC $<BUILD_INTERFACE:${BX_DIR}/include/compat/mingw>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/mingw>
|
||||
)
|
||||
elseif(WIN32)
|
||||
target_include_directories(
|
||||
bx PUBLIC $<BUILD_INTERFACE:${BX_DIR}/include/compat/msvc>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/msvc>
|
||||
)
|
||||
elseif(APPLE) # 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 "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)
|
||||
# Threads
|
||||
find_package(Threads)
|
||||
target_link_libraries(bx ${CMAKE_THREAD_LIBS_INIT} dl)
|
||||
|
||||
# Real time (for clock_gettime)
|
||||
target_link_libraries(bx rt)
|
||||
endif()
|
||||
|
||||
# Put in a "bgfx" folder in Visual Studio
|
||||
set_target_properties(bx PROPERTIES FOLDER "bgfx")
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
# Ensure the directory exists
|
||||
if(NOT IS_DIRECTORY ${BX_DIR})
|
||||
message(SEND_ERROR "Could not load bx, directory does not exist. ${BX_DIR}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
add_library(bx STATIC)
|
||||
|
||||
# Put in a "bgfx" folder in Visual Studio
|
||||
set_target_properties(bx PROPERTIES FOLDER "bgfx")
|
||||
|
||||
# Build system specific configurations
|
||||
if(MINGW)
|
||||
set(BX_COMPAT_PLATFORM mingw)
|
||||
elseif(WIN32)
|
||||
set(BX_COMPAT_PLATFORM msvc)
|
||||
elseif(APPLE) # APPLE is technically UNIX... ORDERING MATTERS!
|
||||
set(BX_COMPAT_PLATFORM osx)
|
||||
elseif(UNIX)
|
||||
set(BX_COMPAT_PLATFORM linux)
|
||||
endif()
|
||||
|
||||
# Add include directory of bx
|
||||
target_include_directories(
|
||||
bx
|
||||
PUBLIC $<BUILD_INTERFACE:${BX_DIR}/include> #
|
||||
$<BUILD_INTERFACE:${BX_DIR}/3rdparty> #
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> #
|
||||
$<BUILD_INTERFACE:${BX_DIR}/include/compat/${BX_COMPAT_PLATFORM}> #
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/compat/${BX_COMPAT_PLATFORM}> #
|
||||
)
|
||||
|
||||
# Grab the bx source files
|
||||
file(
|
||||
GLOB_RECURSE
|
||||
BX_SOURCES
|
||||
${BX_DIR}/include/*.h #
|
||||
${BX_DIR}/include/**.inl #
|
||||
${BX_DIR}/src/*.cpp #
|
||||
${BX_DIR}/scripts/*.natvis #
|
||||
)
|
||||
|
||||
if(BX_AMALGAMATED)
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/allocator.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/bounds.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/bx.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/commandline.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/crtnone.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/debug.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/dtoa.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/easing.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/file.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/filepath.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/hash.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/math.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/mutex.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/os.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/process.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/semaphore.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/settings.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/sort.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/string.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/thread.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/timer.cpp")
|
||||
list(APPEND BX_NOBUILD "${BX_DIR}/src/url.cpp")
|
||||
else()
|
||||
file(GLOB_RECURSE BX_NOBUILD "${BX_DIR}/src/amalgamated.*")
|
||||
endif()
|
||||
|
||||
# Exclude files from the build but keep them in project
|
||||
foreach(BX_SRC ${BX_NOBUILD})
|
||||
set_source_files_properties(${BX_SRC} PROPERTIES HEADER_FILE_ONLY ON)
|
||||
endforeach()
|
||||
|
||||
# Add sources to the project
|
||||
target_sources(bx PRIVATE ${BX_SOURCES})
|
||||
|
||||
# All configurations
|
||||
target_compile_definitions(bx PUBLIC "BX_CONFIG_DEBUG=$<IF:$<CONFIG:Debug>,1,$<BOOL:${BX_CONFIG_DEBUG}>>")
|
||||
target_compile_definitions(bx PUBLIC "__STDC_LIMIT_MACROS")
|
||||
target_compile_definitions(bx PUBLIC "__STDC_FORMAT_MACROS")
|
||||
target_compile_definitions(bx PUBLIC "__STDC_CONSTANT_MACROS")
|
||||
|
||||
target_compile_features(bx PUBLIC cxx_std_14)
|
||||
# (note: see bx\scripts\toolchain.lua for equivalent compiler flag)
|
||||
target_compile_options(bx PUBLIC $<$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>)
|
||||
|
||||
# Link against psapi on Windows
|
||||
if(WIN32)
|
||||
target_link_libraries(bx PUBLIC psapi)
|
||||
endif()
|
||||
|
||||
# Additional dependencies on Unix
|
||||
if(ANDROID)
|
||||
# For __android_log_write
|
||||
find_library(LOG_LIBRARY log)
|
||||
mark_as_advanced(LOG_LIBRARY)
|
||||
target_link_libraries(bx PUBLIC ${LOG_LIBRARY})
|
||||
elseif(APPLE)
|
||||
find_library(FOUNDATION_LIBRARY Foundation)
|
||||
mark_as_advanced(FOUNDATION_LIBRARY)
|
||||
target_link_libraries(bx PUBLIC ${FOUNDATION_LIBRARY})
|
||||
elseif(UNIX)
|
||||
# Threads
|
||||
find_package(Threads)
|
||||
target_link_libraries(bx ${CMAKE_THREAD_LIBS_INIT} dl)
|
||||
|
||||
# Real time (for clock_gettime)
|
||||
target_link_libraries(bx rt)
|
||||
endif()
|
||||
|
||||
# Put in a "bgfx" folder in Visual Studio
|
||||
set_target_properties(bx PROPERTIES FOLDER "bgfx")
|
||||
@@ -1,328 +1,328 @@
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/util/ConfigureDebugging.cmake)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/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")
|
||||
else()
|
||||
set(TYPE "")
|
||||
endif()
|
||||
|
||||
if(NOT "${TYPE}" STREQUAL "")
|
||||
set(COMMON FILE ${FILE} ${TYPE} INCLUDES ${BGFX_DIR}/src)
|
||||
set(OUTPUTS "")
|
||||
set(OUTPUTS_PRETTY "")
|
||||
|
||||
if(WIN32)
|
||||
# dx9
|
||||
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||
set(DX9_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/dx9/${FILENAME}.bin)
|
||||
shaderc_parse(
|
||||
DX9 ${COMMON} WINDOWS
|
||||
PROFILE ${D3D_PREFIX}_3_0
|
||||
O 3
|
||||
OUTPUT ${DX9_OUTPUT}
|
||||
)
|
||||
list(APPEND OUTPUTS "DX9")
|
||||
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX9, ")
|
||||
endif()
|
||||
|
||||
# dx11
|
||||
set(DX11_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/dx11/${FILENAME}.bin)
|
||||
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||
shaderc_parse(
|
||||
DX11 ${COMMON} WINDOWS
|
||||
PROFILE ${D3D_PREFIX}_5_0
|
||||
O 3
|
||||
OUTPUT ${DX11_OUTPUT}
|
||||
)
|
||||
else()
|
||||
shaderc_parse(
|
||||
DX11 ${COMMON} WINDOWS
|
||||
PROFILE ${D3D_PREFIX}_5_0
|
||||
O 1
|
||||
OUTPUT ${DX11_OUTPUT}
|
||||
)
|
||||
endif()
|
||||
list(APPEND OUTPUTS "DX11")
|
||||
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX11, ")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
# metal
|
||||
set(METAL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/metal/${FILENAME}.bin)
|
||||
shaderc_parse(METAL ${COMMON} OSX PROFILE metal OUTPUT ${METAL_OUTPUT})
|
||||
list(APPEND OUTPUTS "METAL")
|
||||
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}Metal, ")
|
||||
endif()
|
||||
|
||||
# essl
|
||||
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||
set(ESSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/essl/${FILENAME}.bin)
|
||||
shaderc_parse(ESSL ${COMMON} ANDROID OUTPUT ${ESSL_OUTPUT})
|
||||
list(APPEND OUTPUTS "ESSL")
|
||||
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}ESSL, ")
|
||||
endif()
|
||||
|
||||
# glsl
|
||||
set(GLSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/glsl/${FILENAME}.bin)
|
||||
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||
shaderc_parse(GLSL ${COMMON} LINUX PROFILE 120 OUTPUT ${GLSL_OUTPUT})
|
||||
else()
|
||||
shaderc_parse(GLSL ${COMMON} LINUX PROFILE 430 OUTPUT ${GLSL_OUTPUT})
|
||||
endif()
|
||||
list(APPEND OUTPUTS "GLSL")
|
||||
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}GLSL, ")
|
||||
|
||||
# spirv
|
||||
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||
set(SPIRV_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/spirv/${FILENAME}.bin)
|
||||
shaderc_parse(SPIRV ${COMMON} LINUX PROFILE spirv OUTPUT ${SPIRV_OUTPUT})
|
||||
list(APPEND OUTPUTS "SPIRV")
|
||||
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}SPIRV")
|
||||
set(OUTPUT_FILES "")
|
||||
set(COMMANDS "")
|
||||
endif()
|
||||
|
||||
foreach(OUT ${OUTPUTS})
|
||||
list(APPEND OUTPUT_FILES ${${OUT}_OUTPUT})
|
||||
list(APPEND COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${${OUT}})
|
||||
get_filename_component(OUT_DIR ${${OUT}_OUTPUT} DIRECTORY)
|
||||
file(MAKE_DIRECTORY ${OUT_DIR})
|
||||
endforeach()
|
||||
|
||||
file(RELATIVE_PATH PRINT_NAME ${BGFX_DIR}/examples ${FILE})
|
||||
add_custom_command(
|
||||
MAIN_DEPENDENCY ${FILE} OUTPUT ${OUTPUT_FILES} ${COMMANDS}
|
||||
COMMENT "Compiling shader ${PRINT_NAME} for ${OUTPUTS_PRETTY}"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(add_example ARG_NAME)
|
||||
# Parse arguments
|
||||
cmake_parse_arguments(ARG "COMMON" "" "DIRECTORIES;SOURCES" ${ARGN})
|
||||
|
||||
# Get all source files
|
||||
list(APPEND ARG_DIRECTORIES "${BGFX_DIR}/examples/${ARG_NAME}")
|
||||
set(SOURCES "")
|
||||
set(SHADERS "")
|
||||
foreach(DIR ${ARG_DIRECTORIES})
|
||||
if(APPLE)
|
||||
file(GLOB GLOB_SOURCES ${DIR}/*.mm)
|
||||
list(APPEND SOURCES ${GLOB_SOURCES})
|
||||
endif()
|
||||
file(GLOB GLOB_SOURCES ${DIR}/*.c ${DIR}/*.cpp ${DIR}/*.h ${DIR}/*.sc)
|
||||
list(APPEND SOURCES ${GLOB_SOURCES})
|
||||
file(GLOB GLOB_SHADERS ${DIR}/*.sc)
|
||||
list(APPEND SHADERS ${GLOB_SHADERS})
|
||||
endforeach()
|
||||
|
||||
# Add target
|
||||
if(ARG_COMMON)
|
||||
add_library(example-${ARG_NAME} STATIC EXCLUDE_FROM_ALL ${SOURCES})
|
||||
target_include_directories(example-${ARG_NAME} PUBLIC ${BGFX_DIR}/examples/common)
|
||||
target_link_libraries(example-${ARG_NAME} PUBLIC bgfx bx bimg dear-imgui meshoptimizer)
|
||||
if(BGFX_WITH_GLFW)
|
||||
find_package(glfw3 REQUIRED)
|
||||
target_link_libraries(example-${ARG_NAME} PUBLIC glfw)
|
||||
target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_GLFW)
|
||||
elseif(BGFX_WITH_SDL)
|
||||
find_package(SDL2 REQUIRED)
|
||||
target_link_libraries(example-${ARG_NAME} PUBLIC ${SDL2_LIBRARIES})
|
||||
target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_SDL)
|
||||
elseif(UNIX AND NOT APPLE)
|
||||
target_link_libraries(example-${ARG_NAME} PUBLIC X11)
|
||||
endif()
|
||||
else()
|
||||
if(BGFX_INSTALL_EXAMPLES)
|
||||
add_executable(example-${ARG_NAME} WIN32 ${SOURCES})
|
||||
else()
|
||||
add_executable(example-${ARG_NAME} WIN32 EXCLUDE_FROM_ALL ${SOURCES})
|
||||
endif()
|
||||
target_link_libraries(example-${ARG_NAME} example-common)
|
||||
configure_debugging(example-${ARG_NAME} WORKING_DIR ${BGFX_DIR}/examples/runtime)
|
||||
if(MSVC)
|
||||
set_target_properties(example-${ARG_NAME} PROPERTIES LINK_FLAGS "/ENTRY:\"mainCRTStartup\"")
|
||||
endif()
|
||||
if(BGFX_CUSTOM_TARGETS)
|
||||
add_dependencies(examples example-${ARG_NAME})
|
||||
endif()
|
||||
if(IOS)
|
||||
set_target_properties(
|
||||
example-${ARG_NAME}
|
||||
PROPERTIES MACOSX_BUNDLE ON
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER example-${ARG_NAME}
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION 0
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING 0
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
target_compile_definitions(
|
||||
example-${ARG_NAME} PRIVATE "-D_CRT_SECURE_NO_WARNINGS" "-D__STDC_FORMAT_MACROS"
|
||||
"-DENTRY_CONFIG_IMPLEMENT_MAIN=1"
|
||||
)
|
||||
|
||||
# Configure shaders
|
||||
if(NOT ARG_COMMON
|
||||
AND NOT IOS
|
||||
AND NOT EMSCRIPTEN
|
||||
AND NOT ANDROID
|
||||
)
|
||||
foreach(SHADER ${SHADERS})
|
||||
add_bgfx_shader(${SHADER} ${ARG_NAME})
|
||||
endforeach()
|
||||
source_group("Shader Files" FILES ${SHADERS})
|
||||
endif()
|
||||
|
||||
if(NOT ARG_COMMON AND EMSCRIPTEN)
|
||||
set_target_properties(
|
||||
example-${ARG_NAME}
|
||||
PROPERTIES LINK_FLAGS
|
||||
"-s PRECISE_F32=1 -s TOTAL_MEMORY=268435456 -s ENVIRONMENT=web --memory-init-file 1 --emrun"
|
||||
SUFFIX ".html"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Directory name
|
||||
set_target_properties(example-${ARG_NAME} PROPERTIES FOLDER "bgfx/examples")
|
||||
|
||||
if(IOS OR WIN32)
|
||||
# on iOS we need to build a bundle so have to copy the data rather than symlink
|
||||
# and on windows we can't create symlinks
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E copy_directory ${BGFX_DIR}/examples/runtime/
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>
|
||||
)
|
||||
else()
|
||||
# For everything else symlink some folders into our output directory
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/font
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>/font
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/images
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>/images
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/meshes
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>/meshes
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/shaders
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>/shaders
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/text
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>/text
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/textures
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>/textures
|
||||
)
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
# Build all examples target
|
||||
if(BGFX_CUSTOM_TARGETS)
|
||||
add_custom_target(examples)
|
||||
set_target_properties(examples PROPERTIES FOLDER "bgfx/examples")
|
||||
endif()
|
||||
|
||||
# Add common library for examples
|
||||
add_example(
|
||||
common
|
||||
COMMON
|
||||
DIRECTORIES
|
||||
${BGFX_DIR}/examples/common/debugdraw
|
||||
${BGFX_DIR}/examples/common/entry
|
||||
${BGFX_DIR}/examples/common/font
|
||||
${BGFX_DIR}/examples/common/imgui
|
||||
${BGFX_DIR}/examples/common/nanovg
|
||||
${BGFX_DIR}/examples/common/ps
|
||||
)
|
||||
|
||||
# Only add examples if set, otherwise we still need exmaples common for tools
|
||||
if(BGFX_BUILD_EXAMPLES)
|
||||
# Add examples
|
||||
set(BGFX_EXAMPLES
|
||||
00-helloworld
|
||||
01-cubes
|
||||
02-metaballs
|
||||
03-raymarch
|
||||
04-mesh
|
||||
05-instancing
|
||||
06-bump
|
||||
07-callback
|
||||
08-update
|
||||
09-hdr
|
||||
10-font
|
||||
11-fontsdf
|
||||
12-lod
|
||||
13-stencil
|
||||
14-shadowvolumes
|
||||
15-shadowmaps-simple
|
||||
16-shadowmaps
|
||||
17-drawstress
|
||||
18-ibl
|
||||
19-oit
|
||||
20-nanovg
|
||||
# 21-deferred
|
||||
22-windows
|
||||
23-vectordisplay
|
||||
24-nbody
|
||||
25-c99
|
||||
26-occlusion
|
||||
27-terrain
|
||||
28-wireframe
|
||||
29-debugdraw
|
||||
30-picking
|
||||
31-rsm
|
||||
32-particles
|
||||
33-pom
|
||||
34-mvs
|
||||
35-dynamic
|
||||
36-sky
|
||||
# 37-gpudrivenrendering
|
||||
38-bloom
|
||||
39-assao
|
||||
40-svt
|
||||
# 41-tess
|
||||
42-bunnylod
|
||||
43-denoise
|
||||
44-sss
|
||||
45-bokeh
|
||||
46-fsr
|
||||
47-pixelformats
|
||||
)
|
||||
|
||||
foreach(EXAMPLE ${BGFX_EXAMPLES})
|
||||
add_example(${EXAMPLE})
|
||||
endforeach()
|
||||
endif()
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
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)
|
||||
|
||||
function(add_bgfx_shader FILE FOLDER)
|
||||
get_filename_component(FILENAME "${FILE}" NAME_WE)
|
||||
string(SUBSTRING "${FILENAME}" 0 2 TYPE)
|
||||
if("${TYPE}" STREQUAL "fs")
|
||||
set(TYPE "FRAGMENT")
|
||||
set(D3D_PREFIX "ps")
|
||||
elseif("${TYPE}" STREQUAL "vs")
|
||||
set(TYPE "VERTEX")
|
||||
set(D3D_PREFIX "vs")
|
||||
elseif("${TYPE}" STREQUAL "cs")
|
||||
set(TYPE "COMPUTE")
|
||||
set(D3D_PREFIX "cs")
|
||||
else()
|
||||
set(TYPE "")
|
||||
endif()
|
||||
|
||||
if(NOT "${TYPE}" STREQUAL "")
|
||||
set(COMMON FILE ${FILE} ${TYPE} INCLUDES ${BGFX_DIR}/src)
|
||||
set(OUTPUTS "")
|
||||
set(OUTPUTS_PRETTY "")
|
||||
|
||||
if(WIN32)
|
||||
# dx9
|
||||
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||
set(DX9_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/dx9/${FILENAME}.bin)
|
||||
_bgfx_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")
|
||||
_bgfx_shaderc_parse(
|
||||
DX11 ${COMMON} WINDOWS
|
||||
PROFILE ${D3D_PREFIX}_5_0
|
||||
O 3
|
||||
OUTPUT ${DX11_OUTPUT}
|
||||
)
|
||||
else()
|
||||
_bgfx_shaderc_parse(
|
||||
DX11 ${COMMON} WINDOWS
|
||||
PROFILE ${D3D_PREFIX}_5_0
|
||||
O 1
|
||||
OUTPUT ${DX11_OUTPUT}
|
||||
)
|
||||
endif()
|
||||
list(APPEND OUTPUTS "DX11")
|
||||
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}DX11, ")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
# metal
|
||||
set(METAL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/metal/${FILENAME}.bin)
|
||||
_bgfx_shaderc_parse(METAL ${COMMON} OSX PROFILE metal OUTPUT ${METAL_OUTPUT})
|
||||
list(APPEND OUTPUTS "METAL")
|
||||
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}Metal, ")
|
||||
endif()
|
||||
|
||||
# essl
|
||||
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||
set(ESSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/essl/${FILENAME}.bin)
|
||||
_bgfx_shaderc_parse(ESSL ${COMMON} ANDROID OUTPUT ${ESSL_OUTPUT})
|
||||
list(APPEND OUTPUTS "ESSL")
|
||||
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}ESSL, ")
|
||||
endif()
|
||||
|
||||
# glsl
|
||||
set(GLSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/glsl/${FILENAME}.bin)
|
||||
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||
_bgfx_shaderc_parse(GLSL ${COMMON} LINUX PROFILE 120 OUTPUT ${GLSL_OUTPUT})
|
||||
else()
|
||||
_bgfx_shaderc_parse(GLSL ${COMMON} LINUX PROFILE 430 OUTPUT ${GLSL_OUTPUT})
|
||||
endif()
|
||||
list(APPEND OUTPUTS "GLSL")
|
||||
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}GLSL, ")
|
||||
|
||||
# spirv
|
||||
if(NOT "${TYPE}" STREQUAL "COMPUTE")
|
||||
set(SPIRV_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/spirv/${FILENAME}.bin)
|
||||
_bgfx_shaderc_parse(SPIRV ${COMMON} LINUX PROFILE spirv OUTPUT ${SPIRV_OUTPUT})
|
||||
list(APPEND OUTPUTS "SPIRV")
|
||||
set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}SPIRV")
|
||||
set(OUTPUT_FILES "")
|
||||
set(COMMANDS "")
|
||||
endif()
|
||||
|
||||
foreach(OUT ${OUTPUTS})
|
||||
list(APPEND OUTPUT_FILES ${${OUT}_OUTPUT})
|
||||
list(APPEND COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${${OUT}})
|
||||
get_filename_component(OUT_DIR ${${OUT}_OUTPUT} DIRECTORY)
|
||||
file(MAKE_DIRECTORY ${OUT_DIR})
|
||||
endforeach()
|
||||
|
||||
file(RELATIVE_PATH PRINT_NAME ${BGFX_DIR}/examples ${FILE})
|
||||
add_custom_command(
|
||||
MAIN_DEPENDENCY ${FILE} OUTPUT ${OUTPUT_FILES} ${COMMANDS}
|
||||
COMMENT "Compiling shader ${PRINT_NAME} for ${OUTPUTS_PRETTY}"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(add_example ARG_NAME)
|
||||
# Parse arguments
|
||||
cmake_parse_arguments(ARG "COMMON" "" "DIRECTORIES;SOURCES" ${ARGN})
|
||||
|
||||
# Get all source files
|
||||
list(APPEND ARG_DIRECTORIES "${BGFX_DIR}/examples/${ARG_NAME}")
|
||||
set(SOURCES "")
|
||||
set(SHADERS "")
|
||||
foreach(DIR ${ARG_DIRECTORIES})
|
||||
if(APPLE)
|
||||
file(GLOB GLOB_SOURCES ${DIR}/*.mm)
|
||||
list(APPEND SOURCES ${GLOB_SOURCES})
|
||||
endif()
|
||||
file(GLOB GLOB_SOURCES ${DIR}/*.c ${DIR}/*.cpp ${DIR}/*.h ${DIR}/*.sc)
|
||||
list(APPEND SOURCES ${GLOB_SOURCES})
|
||||
file(GLOB GLOB_SHADERS ${DIR}/*.sc)
|
||||
list(APPEND SHADERS ${GLOB_SHADERS})
|
||||
endforeach()
|
||||
|
||||
# Add target
|
||||
if(ARG_COMMON)
|
||||
add_library(example-${ARG_NAME} STATIC EXCLUDE_FROM_ALL ${SOURCES})
|
||||
target_include_directories(example-${ARG_NAME} PUBLIC ${BGFX_DIR}/examples/common)
|
||||
target_link_libraries(example-${ARG_NAME} PUBLIC bgfx bx bimg dear-imgui meshoptimizer)
|
||||
if(BGFX_WITH_GLFW)
|
||||
find_package(glfw3 REQUIRED)
|
||||
target_link_libraries(example-${ARG_NAME} PUBLIC glfw)
|
||||
target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_GLFW)
|
||||
elseif(BGFX_WITH_SDL)
|
||||
find_package(SDL2 REQUIRED)
|
||||
target_link_libraries(example-${ARG_NAME} PUBLIC ${SDL2_LIBRARIES})
|
||||
target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_SDL)
|
||||
elseif(UNIX AND NOT APPLE)
|
||||
target_link_libraries(example-${ARG_NAME} PUBLIC X11)
|
||||
endif()
|
||||
else()
|
||||
if(BGFX_INSTALL_EXAMPLES)
|
||||
add_executable(example-${ARG_NAME} WIN32 ${SOURCES})
|
||||
else()
|
||||
add_executable(example-${ARG_NAME} WIN32 EXCLUDE_FROM_ALL ${SOURCES})
|
||||
endif()
|
||||
target_link_libraries(example-${ARG_NAME} example-common)
|
||||
configure_debugging(example-${ARG_NAME} WORKING_DIR ${BGFX_DIR}/examples/runtime)
|
||||
if(MSVC)
|
||||
set_target_properties(example-${ARG_NAME} PROPERTIES LINK_FLAGS "/ENTRY:\"mainCRTStartup\"")
|
||||
endif()
|
||||
if(BGFX_CUSTOM_TARGETS)
|
||||
add_dependencies(examples example-${ARG_NAME})
|
||||
endif()
|
||||
if(IOS)
|
||||
set_target_properties(
|
||||
example-${ARG_NAME}
|
||||
PROPERTIES MACOSX_BUNDLE ON
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER example-${ARG_NAME}
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION 0
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING 0
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
target_compile_definitions(
|
||||
example-${ARG_NAME} PRIVATE "-D_CRT_SECURE_NO_WARNINGS" "-D__STDC_FORMAT_MACROS"
|
||||
"-DENTRY_CONFIG_IMPLEMENT_MAIN=1"
|
||||
)
|
||||
|
||||
# Configure shaders
|
||||
if(NOT ARG_COMMON
|
||||
AND NOT IOS
|
||||
AND NOT EMSCRIPTEN
|
||||
AND NOT ANDROID
|
||||
)
|
||||
foreach(SHADER ${SHADERS})
|
||||
add_bgfx_shader(${SHADER} ${ARG_NAME})
|
||||
endforeach()
|
||||
source_group("Shader Files" FILES ${SHADERS})
|
||||
endif()
|
||||
|
||||
if(NOT ARG_COMMON AND EMSCRIPTEN)
|
||||
set_target_properties(
|
||||
example-${ARG_NAME}
|
||||
PROPERTIES LINK_FLAGS
|
||||
"-s PRECISE_F32=1 -s TOTAL_MEMORY=268435456 -s ENVIRONMENT=web --memory-init-file 1 --emrun"
|
||||
SUFFIX ".html"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Directory name
|
||||
set_target_properties(example-${ARG_NAME} PROPERTIES FOLDER "bgfx/examples")
|
||||
|
||||
if(IOS OR WIN32)
|
||||
# on iOS we need to build a bundle so have to copy the data rather than symlink
|
||||
# and on windows we can't create symlinks
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E copy_directory ${BGFX_DIR}/examples/runtime/
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>
|
||||
)
|
||||
else()
|
||||
# For everything else symlink some folders into our output directory
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/font
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>/font
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/images
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>/images
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/meshes
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>/meshes
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/shaders
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>/shaders
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/text
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>/text
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET example-${ARG_NAME} COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/textures
|
||||
$<TARGET_FILE_DIR:example-${ARG_NAME}>/textures
|
||||
)
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
|
||||
# Build all examples target
|
||||
if(BGFX_CUSTOM_TARGETS)
|
||||
add_custom_target(examples)
|
||||
set_target_properties(examples PROPERTIES FOLDER "bgfx/examples")
|
||||
endif()
|
||||
|
||||
# Add common library for examples
|
||||
add_example(
|
||||
common
|
||||
COMMON
|
||||
DIRECTORIES
|
||||
${BGFX_DIR}/examples/common/debugdraw
|
||||
${BGFX_DIR}/examples/common/entry
|
||||
${BGFX_DIR}/examples/common/font
|
||||
${BGFX_DIR}/examples/common/imgui
|
||||
${BGFX_DIR}/examples/common/nanovg
|
||||
${BGFX_DIR}/examples/common/ps
|
||||
)
|
||||
|
||||
# Only add examples if set, otherwise we still need exmaples common for tools
|
||||
if(BGFX_BUILD_EXAMPLES)
|
||||
# Add examples
|
||||
set(BGFX_EXAMPLES
|
||||
00-helloworld
|
||||
01-cubes
|
||||
02-metaballs
|
||||
03-raymarch
|
||||
04-mesh
|
||||
05-instancing
|
||||
06-bump
|
||||
07-callback
|
||||
08-update
|
||||
09-hdr
|
||||
10-font
|
||||
11-fontsdf
|
||||
12-lod
|
||||
13-stencil
|
||||
14-shadowvolumes
|
||||
15-shadowmaps-simple
|
||||
16-shadowmaps
|
||||
17-drawstress
|
||||
18-ibl
|
||||
19-oit
|
||||
20-nanovg
|
||||
# 21-deferred
|
||||
22-windows
|
||||
23-vectordisplay
|
||||
24-nbody
|
||||
25-c99
|
||||
26-occlusion
|
||||
27-terrain
|
||||
28-wireframe
|
||||
29-debugdraw
|
||||
30-picking
|
||||
31-rsm
|
||||
32-particles
|
||||
33-pom
|
||||
34-mvs
|
||||
35-dynamic
|
||||
36-sky
|
||||
# 37-gpudrivenrendering
|
||||
38-bloom
|
||||
39-assao
|
||||
40-svt
|
||||
# 41-tess
|
||||
42-bunnylod
|
||||
43-denoise
|
||||
44-sss
|
||||
45-bokeh
|
||||
46-fsr
|
||||
47-pixelformats
|
||||
)
|
||||
|
||||
foreach(EXAMPLE ${BGFX_EXAMPLES})
|
||||
add_example(${EXAMPLE})
|
||||
endforeach()
|
||||
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")
|
||||
endif()
|
||||
|
||||
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)
|
||||
endif()
|
||||
|
||||
if(BGFX_BUILD_TOOLS_TEXTURE)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/tools/texturec.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/tools/texturev.cmake)
|
||||
endif()
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
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)
|
||||
endif()
|
||||
|
||||
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)
|
||||
endif()
|
||||
|
||||
@@ -1,54 +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(${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
|
||||
)
|
||||
|
||||
if(BGFX_CUSTOM_TARGETS)
|
||||
add_dependencies(tools shaderc)
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
target_link_libraries(shaderc PRIVATE log)
|
||||
elseif(IOS)
|
||||
set_target_properties(shaderc PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER shaderc)
|
||||
endif()
|
||||
# bgfx.cmake - bgfx building in cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../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
|
||||
)
|
||||
|
||||
if(BGFX_CUSTOM_TARGETS)
|
||||
add_dependencies(tools shaderc)
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
target_link_libraries(shaderc PRIVATE log)
|
||||
elseif(IOS)
|
||||
set_target_properties(shaderc PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER shaderc)
|
||||
endif()
|
||||
|
||||
@@ -1,157 +1,157 @@
|
||||
# ConfigureDebugging.cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
# configure_debugging( TARGET [OPTIONS...] )
|
||||
#
|
||||
# Configures the debugging settings in visual studio.
|
||||
# Results in a no-op on non visual studio builds.
|
||||
# Must be called in the same cmake file as the add_executable command.
|
||||
#
|
||||
# See OPTIONS variable in the function for supported user settings.
|
||||
# See CONFIGS variable in the function for supported cmake configurations.
|
||||
# See PROCESSORS variable in the function for supported architecture configurations.
|
||||
#
|
||||
# All variables can be set with one of the following formats:
|
||||
#
|
||||
# (OPTION)
|
||||
# (OPTION)_(CONFIG)
|
||||
# (OPTION)_(CONFIG)_(ARCH)
|
||||
# (OPTION)_(ARCH)
|
||||
#
|
||||
# So, some examples (variables should be all caps):
|
||||
#
|
||||
# WORKING_DIR
|
||||
# WORKING_DIR_X64
|
||||
# WORKING_DIR_RELEASE_WIN32
|
||||
# WORKING_DIR_X64
|
||||
#
|
||||
# An example of a full command:
|
||||
#
|
||||
# configure_debugging(target COMMAND "node.exe" COMMAND_X64 "node64.exe" WORKING_DIR ${CMAKE_SOURCE_DIR} DEBUGGER_ENV "PATH=%PATH%\\;$(ProjectDir)")
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(configure_debugging ARG_TARGET)
|
||||
if(MSVC)
|
||||
# Visual Studio Options
|
||||
set(OPTIONS
|
||||
WORKING_DIR
|
||||
LocalDebuggerWorkingDirectory
|
||||
DEBUGGER_ENV
|
||||
LocalDebuggerEnvironment
|
||||
COMMAND
|
||||
LocalDebuggerCommand
|
||||
COMMAND_ARGS
|
||||
LocalDebuggerCommandArguments
|
||||
)
|
||||
|
||||
# Valid Configurations
|
||||
set(CONFIGS Debug Release MinSizeRel RelWithDebInfo)
|
||||
|
||||
# Processors
|
||||
set(PROCESSORS Win32 x64)
|
||||
|
||||
# Begin hackery
|
||||
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||
set(ACTIVE_PROCESSOR "x64")
|
||||
else()
|
||||
set(ACTIVE_PROCESSOR "Win32")
|
||||
endif()
|
||||
# Fix issues with semicolons, thx cmake
|
||||
foreach(ARG ${ARGN})
|
||||
string(REPLACE ";" "\\\\\\\\\\\\\\;" RES "${ARG}")
|
||||
list(APPEND ARGS "${RES}")
|
||||
endforeach()
|
||||
# Build options for cmake_parse_arguments, result is ONE_ARG variable
|
||||
set(ODD ON)
|
||||
foreach(OPTION ${OPTIONS})
|
||||
if(ODD)
|
||||
set(ARG ${OPTION})
|
||||
list(APPEND ONE_ARG ${ARG})
|
||||
foreach(CONFIG ${CONFIGS})
|
||||
string(TOUPPER ${CONFIG} CONFIG)
|
||||
list(APPEND ONE_ARG ${ARG}_${CONFIG})
|
||||
foreach(PROCESSOR ${PROCESSORS})
|
||||
string(TOUPPER ${PROCESSOR} PROCESSOR)
|
||||
list(APPEND ONE_ARG ${ARG}_${CONFIG}_${PROCESSOR})
|
||||
endforeach()
|
||||
endforeach()
|
||||
foreach(PROCESSOR ${PROCESSORS})
|
||||
string(TOUPPER ${PROCESSOR} PROCESSOR)
|
||||
list(APPEND ONE_ARG ${ARG}_${PROCESSOR})
|
||||
endforeach()
|
||||
set(ODD OFF)
|
||||
else()
|
||||
set(ODD ON)
|
||||
endif()
|
||||
endforeach()
|
||||
cmake_parse_arguments(ARG "" "${ONE_ARG}" "" ${ARGS})
|
||||
# Parse options, fills in all variables of format ARG_(ARG)_(CONFIG)_(PROCESSOR), for example ARG_WORKING_DIR_DEBUG_X64
|
||||
set(ODD ON)
|
||||
foreach(OPTION ${OPTIONS})
|
||||
if(ODD)
|
||||
set(ARG ${OPTION})
|
||||
foreach(CONFIG ${CONFIGS})
|
||||
string(TOUPPER ${CONFIG} CONFIG_CAP)
|
||||
if("${ARG_${ARG}_${CONFIG_CAP}}" STREQUAL "")
|
||||
set(ARG_${ARG}_${CONFIG_CAP} ${ARG_${ARG}})
|
||||
endif()
|
||||
foreach(PROCESSOR ${PROCESSORS})
|
||||
string(TOUPPER ${PROCESSOR} PROCESSOR_CAP)
|
||||
if("${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "")
|
||||
if("${ARG_${ARG}_${PROCESSOR_CAP}}" STREQUAL "")
|
||||
set(ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP} ${ARG_${ARG}_${CONFIG_CAP}})
|
||||
else()
|
||||
set(ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP} ${ARG_${ARG}_${PROCESSOR_CAP}})
|
||||
endif()
|
||||
endif()
|
||||
if(NOT "${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "")
|
||||
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
set(ODD OFF)
|
||||
else()
|
||||
set(ODD ON)
|
||||
endif()
|
||||
endforeach()
|
||||
# Create string to put in proj.vcxproj.user file
|
||||
set(RESULT
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"
|
||||
)
|
||||
foreach(CONFIG ${CONFIGS})
|
||||
string(TOUPPER ${CONFIG} CONFIG_CAPS)
|
||||
foreach(PROCESSOR ${PROCESSORS})
|
||||
if("${PROCESSOR}" STREQUAL "${ACTIVE_PROCESSOR}")
|
||||
string(TOUPPER ${PROCESSOR} PROCESSOR_CAPS)
|
||||
set(RESULT
|
||||
"${RESULT}\n <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='${CONFIG}|${PROCESSOR}'\">"
|
||||
)
|
||||
set(ODD ON)
|
||||
foreach(OPTION ${OPTIONS})
|
||||
if(ODD)
|
||||
set(ARG ${OPTION})
|
||||
set(ODD OFF)
|
||||
else()
|
||||
set(VALUE ${ARG_${ARG}_${CONFIG_CAPS}_${PROCESSOR_CAPS}})
|
||||
if(NOT "${VALUE}" STREQUAL "")
|
||||
set(RESULT "${RESULT}\n <${OPTION}>${VALUE}</${OPTION}>")
|
||||
endif()
|
||||
set(ODD ON)
|
||||
endif()
|
||||
endforeach()
|
||||
set(RESULT "${RESULT}\n </PropertyGroup>")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
set(RESULT "${RESULT}\n</Project>")
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET}.vcxproj.user "${RESULT}")
|
||||
endif()
|
||||
endfunction()
|
||||
# ConfigureDebugging.cmake
|
||||
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||
# and related and neighboring rights to this software to the public domain
|
||||
# worldwide. This software is distributed without any warranty.
|
||||
#
|
||||
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
# configure_debugging( TARGET [OPTIONS...] )
|
||||
#
|
||||
# Configures the debugging settings in visual studio.
|
||||
# Results in a no-op on non visual studio builds.
|
||||
# Must be called in the same cmake file as the add_executable command.
|
||||
#
|
||||
# See OPTIONS variable in the function for supported user settings.
|
||||
# See CONFIGS variable in the function for supported cmake configurations.
|
||||
# See PROCESSORS variable in the function for supported architecture configurations.
|
||||
#
|
||||
# All variables can be set with one of the following formats:
|
||||
#
|
||||
# (OPTION)
|
||||
# (OPTION)_(CONFIG)
|
||||
# (OPTION)_(CONFIG)_(ARCH)
|
||||
# (OPTION)_(ARCH)
|
||||
#
|
||||
# So, some examples (variables should be all caps):
|
||||
#
|
||||
# WORKING_DIR
|
||||
# WORKING_DIR_X64
|
||||
# WORKING_DIR_RELEASE_WIN32
|
||||
# WORKING_DIR_X64
|
||||
#
|
||||
# An example of a full command:
|
||||
#
|
||||
# configure_debugging(target COMMAND "node.exe" COMMAND_X64 "node64.exe" WORKING_DIR ${CMAKE_SOURCE_DIR} DEBUGGER_ENV "PATH=%PATH%\\;$(ProjectDir)")
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(configure_debugging ARG_TARGET)
|
||||
if(MSVC)
|
||||
# Visual Studio Options
|
||||
set(OPTIONS
|
||||
WORKING_DIR
|
||||
LocalDebuggerWorkingDirectory
|
||||
DEBUGGER_ENV
|
||||
LocalDebuggerEnvironment
|
||||
COMMAND
|
||||
LocalDebuggerCommand
|
||||
COMMAND_ARGS
|
||||
LocalDebuggerCommandArguments
|
||||
)
|
||||
|
||||
# Valid Configurations
|
||||
set(CONFIGS Debug Release MinSizeRel RelWithDebInfo)
|
||||
|
||||
# Processors
|
||||
set(PROCESSORS Win32 x64)
|
||||
|
||||
# Begin hackery
|
||||
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||
set(ACTIVE_PROCESSOR "x64")
|
||||
else()
|
||||
set(ACTIVE_PROCESSOR "Win32")
|
||||
endif()
|
||||
# Fix issues with semicolons, thx cmake
|
||||
foreach(ARG ${ARGN})
|
||||
string(REPLACE ";" "\\\\\\\\\\\\\\;" RES "${ARG}")
|
||||
list(APPEND ARGS "${RES}")
|
||||
endforeach()
|
||||
# Build options for cmake_parse_arguments, result is ONE_ARG variable
|
||||
set(ODD ON)
|
||||
foreach(OPTION ${OPTIONS})
|
||||
if(ODD)
|
||||
set(ARG ${OPTION})
|
||||
list(APPEND ONE_ARG ${ARG})
|
||||
foreach(CONFIG ${CONFIGS})
|
||||
string(TOUPPER ${CONFIG} CONFIG)
|
||||
list(APPEND ONE_ARG ${ARG}_${CONFIG})
|
||||
foreach(PROCESSOR ${PROCESSORS})
|
||||
string(TOUPPER ${PROCESSOR} PROCESSOR)
|
||||
list(APPEND ONE_ARG ${ARG}_${CONFIG}_${PROCESSOR})
|
||||
endforeach()
|
||||
endforeach()
|
||||
foreach(PROCESSOR ${PROCESSORS})
|
||||
string(TOUPPER ${PROCESSOR} PROCESSOR)
|
||||
list(APPEND ONE_ARG ${ARG}_${PROCESSOR})
|
||||
endforeach()
|
||||
set(ODD OFF)
|
||||
else()
|
||||
set(ODD ON)
|
||||
endif()
|
||||
endforeach()
|
||||
cmake_parse_arguments(ARG "" "${ONE_ARG}" "" ${ARGS})
|
||||
# Parse options, fills in all variables of format ARG_(ARG)_(CONFIG)_(PROCESSOR), for example ARG_WORKING_DIR_DEBUG_X64
|
||||
set(ODD ON)
|
||||
foreach(OPTION ${OPTIONS})
|
||||
if(ODD)
|
||||
set(ARG ${OPTION})
|
||||
foreach(CONFIG ${CONFIGS})
|
||||
string(TOUPPER ${CONFIG} CONFIG_CAP)
|
||||
if("${ARG_${ARG}_${CONFIG_CAP}}" STREQUAL "")
|
||||
set(ARG_${ARG}_${CONFIG_CAP} ${ARG_${ARG}})
|
||||
endif()
|
||||
foreach(PROCESSOR ${PROCESSORS})
|
||||
string(TOUPPER ${PROCESSOR} PROCESSOR_CAP)
|
||||
if("${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "")
|
||||
if("${ARG_${ARG}_${PROCESSOR_CAP}}" STREQUAL "")
|
||||
set(ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP} ${ARG_${ARG}_${CONFIG_CAP}})
|
||||
else()
|
||||
set(ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP} ${ARG_${ARG}_${PROCESSOR_CAP}})
|
||||
endif()
|
||||
endif()
|
||||
if(NOT "${ARG_${ARG}_${CONFIG_CAP}_${PROCESSOR_CAP}}" STREQUAL "")
|
||||
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
set(ODD OFF)
|
||||
else()
|
||||
set(ODD ON)
|
||||
endif()
|
||||
endforeach()
|
||||
# Create string to put in proj.vcxproj.user file
|
||||
set(RESULT
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"
|
||||
)
|
||||
foreach(CONFIG ${CONFIGS})
|
||||
string(TOUPPER ${CONFIG} CONFIG_CAPS)
|
||||
foreach(PROCESSOR ${PROCESSORS})
|
||||
if("${PROCESSOR}" STREQUAL "${ACTIVE_PROCESSOR}")
|
||||
string(TOUPPER ${PROCESSOR} PROCESSOR_CAPS)
|
||||
set(RESULT
|
||||
"${RESULT}\n <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='${CONFIG}|${PROCESSOR}'\">"
|
||||
)
|
||||
set(ODD ON)
|
||||
foreach(OPTION ${OPTIONS})
|
||||
if(ODD)
|
||||
set(ARG ${OPTION})
|
||||
set(ODD OFF)
|
||||
else()
|
||||
set(VALUE ${ARG_${ARG}_${CONFIG_CAPS}_${PROCESSOR_CAPS}})
|
||||
if(NOT "${VALUE}" STREQUAL "")
|
||||
set(RESULT "${RESULT}\n <${OPTION}>${VALUE}</${OPTION}>")
|
||||
endif()
|
||||
set(ODD ON)
|
||||
endif()
|
||||
endforeach()
|
||||
set(RESULT "${RESULT}\n </PropertyGroup>")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
set(RESULT "${RESULT}\n</Project>")
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET}.vcxproj.user "${RESULT}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
Reference in New Issue
Block a user