From f83b4bda47279ce09dc8958c889224931305b630 Mon Sep 17 00:00:00 2001 From: AR Date: Thu, 26 Mar 2026 07:36:38 +0500 Subject: [PATCH 1/3] Add thirdparty rendering deps as submodules --- .gitignore | 1 + .gitmodules | 3 +++ CMakeLists.txt | 19 ++++++++++++++++++- cmake/Compiler.cmake | 6 ++++++ cmake/Modules.cmake | 11 +++++++++++ engine/native/CMakeLists.txt | 2 ++ engine/native/thirdparty/CMakeLists.txt | 17 +++++++++++++++++ engine/native/thirdparty/bgfx.cmake | 1 + 8 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .gitmodules create mode 100644 engine/native/thirdparty/CMakeLists.txt create mode 160000 engine/native/thirdparty/bgfx.cmake diff --git a/.gitignore b/.gitignore index 3e64994..adcee67 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ bits/ cmake-build-*/ bin/ build/ +graph/ CMakeUserPresets.json diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5e23af6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "engine/native/thirdparty/bgfx.cmake"] + path = engine/native/thirdparty/bgfx.cmake + url = https://github.com/bkaradzic/bgfx.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index da78302..8711cb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,25 @@ elseif (CMAKE_VERSION VERSION_GREATER_EQUAL "4.0.0") set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "a9e1cf81-9932-4810-974b-6eccaf14e457") endif() -project(DraconicEngine LANGUAGES C CXX) +find_package(Git QUIET) + +if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git") + message(STATUS "Updating submodules...") + execute_process( + COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE GIT_SUBMOD_RESULT + ) + + if(NOT GIT_SUBMOD_RESULT EQUAL "0") + message(FATAL_ERROR "Failed to update submodules. Please run manually.") + endif() +endif() +project(DraconicEngine LANGUAGES C CXX) +set(CMAKE_CXX_SCAN_FOR_MODULES ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMAKE_CXX_MODULE_STD ON) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") include(CTest) diff --git a/cmake/Compiler.cmake b/cmake/Compiler.cmake index 4525885..e79ec50 100644 --- a/cmake/Compiler.cmake +++ b/cmake/Compiler.cmake @@ -15,6 +15,12 @@ else() add_compile_definitions(DEBUG) endif() +# Force Clang to use libc++ +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-stdlib=libc++) + add_link_options(-stdlib=libc++) +endif() + if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") # TODO: Make SIMD level configurable or detect at runtime diff --git a/cmake/Modules.cmake b/cmake/Modules.cmake index 277065d..6b6276d 100644 --- a/cmake/Modules.cmake +++ b/cmake/Modules.cmake @@ -7,6 +7,10 @@ set(NATIVE_THIRD_PARTY_DIR "${NATIVE_SOURCE_DIR}/thirdparty") if (BUILD_TESTING) message(STATUS "Bootstrapping unit tests module boost.ut") add_library(boost_ut_main "${NATIVE_THIRD_PARTY_DIR}/boost/ut_main.cpp") + set_target_properties(boost_ut_main PROPERTIES + CXX_SCAN_FOR_MODULES ON + CXX_EXTENSIONS OFF + ) target_sources(boost_ut_main PUBLIC FILE_SET CXX_MODULES @@ -52,6 +56,12 @@ function(add_modules_library) message(STATUS "Adding static modules library ${LIB_TARGET}") add_library(${LIB_TARGET} STATIC) endif() + + set_target_properties(${LIB_TARGET} PROPERTIES + CXX_SCAN_FOR_MODULES ON + CXX_EXTENSIONS OFF + ) + target_compile_features(${LIB_TARGET} PUBLIC cxx_std_23) target_include_directories(${LIB_TARGET} PUBLIC ${NATIVE_SOURCE_DIR}) @@ -73,6 +83,7 @@ function(add_modules_library) string(PREPEND UNIT_TEST_TARGET "${LIB_TARGET}_") endif() add_executable(${UNIT_TEST_TARGET} ${UNIT_TEST_FILE}) + set_target_properties(${UNIT_TEST_TARGET} PROPERTIES CXX_SCAN_FOR_MODULES ON) target_compile_features(${UNIT_TEST_TARGET} PUBLIC cxx_std_23) target_link_libraries(${UNIT_TEST_TARGET} PRIVATE boost_ut_main ${LIB_TARGET}) message(STATUS "Unit test ${UNIT_TEST_TARGET}") diff --git a/engine/native/CMakeLists.txt b/engine/native/CMakeLists.txt index 65a4a5a..58f947d 100644 --- a/engine/native/CMakeLists.txt +++ b/engine/native/CMakeLists.txt @@ -1,3 +1,5 @@ +add_subdirectory(thirdparty) + include(Compiler) include(Modules) diff --git a/engine/native/thirdparty/CMakeLists.txt b/engine/native/thirdparty/CMakeLists.txt new file mode 100644 index 0000000..ab0415a --- /dev/null +++ b/engine/native/thirdparty/CMakeLists.txt @@ -0,0 +1,17 @@ +set(BGFX_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) +set(BGFX_BUILD_TOOLS OFF CACHE BOOL "" FORCE) +set(BGFX_INSTALL OFF CACHE BOOL "" FORCE) +set(CMAKE_CXX_SCAN_FOR_MODULES OFF) + +add_subdirectory(bgfx.cmake) + +# Prevent module scanning for bgfx & it's deps +set_target_properties(bgfx PROPERTIES CXX_SCAN_FOR_MODULES OFF) + +if(TARGET bx) + set_target_properties(bx PROPERTIES CXX_SCAN_FOR_MODULES OFF) +endif() + +if(TARGET bimg) + set_target_properties(bimg PROPERTIES CXX_SCAN_FOR_MODULES OFF) +endif() diff --git a/engine/native/thirdparty/bgfx.cmake b/engine/native/thirdparty/bgfx.cmake new file mode 160000 index 0000000..668550d --- /dev/null +++ b/engine/native/thirdparty/bgfx.cmake @@ -0,0 +1 @@ +Subproject commit 668550dc7c47c71860a39c5ef4c162e79294c93f From b5997bf466331ea2a61f3b24b3680446a84bc67a Mon Sep 17 00:00:00 2001 From: AbdulRehman Date: Thu, 26 Mar 2026 10:19:13 +0500 Subject: [PATCH 2/3] Apply suggestions Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- engine/native/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/native/CMakeLists.txt b/engine/native/CMakeLists.txt index 58f947d..6fec078 100644 --- a/engine/native/CMakeLists.txt +++ b/engine/native/CMakeLists.txt @@ -1,6 +1,7 @@ +include(Compiler) + add_subdirectory(thirdparty) -include(Compiler) include(Modules) add_modules_library(core SHARED) From 2f2da320349a8d1c258dd6f28794040a9cc3a69a Mon Sep 17 00:00:00 2001 From: AR Date: Tue, 31 Mar 2026 08:07:22 +0500 Subject: [PATCH 3/3] Apply suggestions --- .gitmodules | 12 +- CMakeLists.txt | 7 +- cmake/Modules.cmake | 7 + engine/native/CMakeLists.txt | 3 +- engine/native/thirdparty/CMakeLists.txt | 20 +- engine/native/thirdparty/bgfx | 1 + engine/native/thirdparty/bgfx.cmake | 1 - engine/native/thirdparty/bimg | 1 + engine/native/thirdparty/bx | 1 + .../native/thirdparty/cmake/Config.cmake.in | 31 + .../cmake/bgfx/3rdparty/dear-imgui.cmake | 26 + .../thirdparty/cmake/bgfx/3rdparty/fcpp.cmake | 64 ++ .../cmake/bgfx/3rdparty/glsl-optimizer.cmake | 246 +++++++ .../cmake/bgfx/3rdparty/glslang.cmake | 64 ++ .../cmake/bgfx/3rdparty/meshoptimizer.cmake | 25 + .../cmake/bgfx/3rdparty/spirv-cross.cmake | 60 ++ .../cmake/bgfx/3rdparty/spirv-opt.cmake | 159 ++++ .../thirdparty/cmake/bgfx/3rdparty/tint.cmake | 98 +++ .../cmake/bgfx/3rdparty/webgpu.cmake | 40 ++ .../thirdparty/cmake/bgfx/CMakeLists.txt | 34 + .../native/thirdparty/cmake/bgfx/bgfx.cmake | 223 ++++++ .../thirdparty/cmake/bgfx/examples.cmake | 365 ++++++++++ .../cmake/bgfx/generated/bounds.cpp.in | 1 + .../cmake/bgfx/generated/shader.cpp.in | 3 + .../cmake/bgfx/generated/vertexlayout.cpp.in | 1 + .../thirdparty/cmake/bgfx/geometryc.cmake | 43 ++ .../thirdparty/cmake/bgfx/geometryv.cmake | 42 ++ .../thirdparty/cmake/bgfx/shaderc.cmake | 95 +++ .../native/thirdparty/cmake/bgfx/shared.cmake | 29 + .../thirdparty/cmake/bgfx/texturev.cmake | 42 ++ .../cmake/bgfx/util/ConfigureDebugging.cmake | 157 ++++ .../thirdparty/cmake/bgfxToolUtils.cmake | 677 ++++++++++++++++++ .../cmake/bimg/3rdparty/astc_encoder.cmake | 25 + .../cmake/bimg/3rdparty/edtaa3.cmake | 25 + .../thirdparty/cmake/bimg/3rdparty/etc1.cmake | 22 + .../thirdparty/cmake/bimg/3rdparty/etc2.cmake | 25 + .../thirdparty/cmake/bimg/3rdparty/iqa.cmake | 25 + .../cmake/bimg/3rdparty/libsquish.cmake | 25 + .../cmake/bimg/3rdparty/loadpng.cmake | 26 + .../cmake/bimg/3rdparty/miniz.cmake | 23 + .../thirdparty/cmake/bimg/3rdparty/nvtt.cmake | 25 + .../cmake/bimg/3rdparty/pvrtc.cmake | 25 + .../cmake/bimg/3rdparty/tinyexr.cmake | 23 + .../thirdparty/cmake/bimg/CMakeLists.txt | 28 + .../native/thirdparty/cmake/bimg/bimg.cmake | 57 ++ .../thirdparty/cmake/bimg/bimg_decode.cmake | 57 ++ .../thirdparty/cmake/bimg/bimg_encode.cmake | 99 +++ .../thirdparty/cmake/bimg/texturec.cmake | 40 ++ .../native/thirdparty/cmake/bx/CMakeLists.txt | 41 ++ engine/native/thirdparty/cmake/bx/bin2c.cmake | 40 ++ engine/native/thirdparty/cmake/bx/bx.cmake | 143 ++++ engine/native/thirdparty/cmake/version.cmake | 40 ++ 52 files changed, 3372 insertions(+), 20 deletions(-) create mode 160000 engine/native/thirdparty/bgfx delete mode 160000 engine/native/thirdparty/bgfx.cmake create mode 160000 engine/native/thirdparty/bimg create mode 160000 engine/native/thirdparty/bx create mode 100644 engine/native/thirdparty/cmake/Config.cmake.in create mode 100644 engine/native/thirdparty/cmake/bgfx/3rdparty/dear-imgui.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/3rdparty/fcpp.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/3rdparty/glsl-optimizer.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/3rdparty/glslang.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/3rdparty/meshoptimizer.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/3rdparty/spirv-cross.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/3rdparty/spirv-opt.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/3rdparty/tint.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/3rdparty/webgpu.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/CMakeLists.txt create mode 100644 engine/native/thirdparty/cmake/bgfx/bgfx.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/examples.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/generated/bounds.cpp.in create mode 100644 engine/native/thirdparty/cmake/bgfx/generated/shader.cpp.in create mode 100644 engine/native/thirdparty/cmake/bgfx/generated/vertexlayout.cpp.in create mode 100644 engine/native/thirdparty/cmake/bgfx/geometryc.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/geometryv.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/shaderc.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/shared.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/texturev.cmake create mode 100644 engine/native/thirdparty/cmake/bgfx/util/ConfigureDebugging.cmake create mode 100644 engine/native/thirdparty/cmake/bgfxToolUtils.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/3rdparty/astc_encoder.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/3rdparty/edtaa3.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/3rdparty/etc1.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/3rdparty/etc2.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/3rdparty/iqa.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/3rdparty/libsquish.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/3rdparty/loadpng.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/3rdparty/miniz.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/3rdparty/nvtt.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/3rdparty/pvrtc.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/3rdparty/tinyexr.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/CMakeLists.txt create mode 100644 engine/native/thirdparty/cmake/bimg/bimg.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/bimg_decode.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/bimg_encode.cmake create mode 100644 engine/native/thirdparty/cmake/bimg/texturec.cmake create mode 100644 engine/native/thirdparty/cmake/bx/CMakeLists.txt create mode 100644 engine/native/thirdparty/cmake/bx/bin2c.cmake create mode 100644 engine/native/thirdparty/cmake/bx/bx.cmake create mode 100644 engine/native/thirdparty/cmake/version.cmake diff --git a/.gitmodules b/.gitmodules index 5e23af6..5a54242 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,9 @@ -[submodule "engine/native/thirdparty/bgfx.cmake"] - path = engine/native/thirdparty/bgfx.cmake - url = https://github.com/bkaradzic/bgfx.cmake +[submodule "engine/native/thirdparty/bx"] + path = engine/native/thirdparty/bx + url = https://github.com/bkaradzic/bx +[submodule "engine/native/thirdparty/bimg"] + path = engine/native/thirdparty/bimg + url = https://github.com/bkaradzic/bimg +[submodule "engine/native/thirdparty/bgfx"] + path = engine/native/thirdparty/bgfx + url = https://github.com/bkaradzic/bgfx diff --git a/CMakeLists.txt b/CMakeLists.txt index 8711cb8..2394fcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,9 +24,12 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git") endif() project(DraconicEngine LANGUAGES C CXX) -set(CMAKE_CXX_SCAN_FOR_MODULES ON) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +# Only have safe global rules here +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_MODULE_STD ON) + list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") include(CTest) diff --git a/cmake/Modules.cmake b/cmake/Modules.cmake index 6b6276d..6b8854a 100644 --- a/cmake/Modules.cmake +++ b/cmake/Modules.cmake @@ -93,6 +93,13 @@ function(add_modules_library) endfunction() +function(enable_modules target) + set_target_properties( + ${target} PROPERTIES + CXX_SCAN_FOR_MODULES ON + ) +endfunction() + function(target_link_modules) cmake_parse_arguments( MOD_LINK # prefix for all variables diff --git a/engine/native/CMakeLists.txt b/engine/native/CMakeLists.txt index 6fec078..ea1c43b 100644 --- a/engine/native/CMakeLists.txt +++ b/engine/native/CMakeLists.txt @@ -1,8 +1,7 @@ include(Compiler) +include(Modules) add_subdirectory(thirdparty) -include(Modules) - add_modules_library(core SHARED) target_link_libraries(core PUBLIC definitions math) diff --git a/engine/native/thirdparty/CMakeLists.txt b/engine/native/thirdparty/CMakeLists.txt index ab0415a..221f5d6 100644 --- a/engine/native/thirdparty/CMakeLists.txt +++ b/engine/native/thirdparty/CMakeLists.txt @@ -3,15 +3,11 @@ set(BGFX_BUILD_TOOLS OFF CACHE BOOL "" FORCE) set(BGFX_INSTALL OFF CACHE BOOL "" FORCE) set(CMAKE_CXX_SCAN_FOR_MODULES OFF) -add_subdirectory(bgfx.cmake) - -# Prevent module scanning for bgfx & it's deps -set_target_properties(bgfx PROPERTIES CXX_SCAN_FOR_MODULES OFF) - -if(TARGET bx) - set_target_properties(bx PROPERTIES CXX_SCAN_FOR_MODULES OFF) -endif() - -if(TARGET bimg) - set_target_properties(bimg PROPERTIES CXX_SCAN_FOR_MODULES OFF) -endif() +set(BX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bx CACHE STRING "" FORCE) +set(BIMG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bimg CACHE STRING "" FORCE) +set(BGFX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bgfx CACHE STRING "" FORCE) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bx bx-build) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bimg bimg-build) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfx bgfx-build) + +target_link_libraries(bgfx PUBLIC bx bimg) \ No newline at end of file diff --git a/engine/native/thirdparty/bgfx b/engine/native/thirdparty/bgfx new file mode 160000 index 0000000..8532b2c --- /dev/null +++ b/engine/native/thirdparty/bgfx @@ -0,0 +1 @@ +Subproject commit 8532b2c45d2f4332a9ac9734b85c2ea2253cb8d5 diff --git a/engine/native/thirdparty/bgfx.cmake b/engine/native/thirdparty/bgfx.cmake deleted file mode 160000 index 668550d..0000000 --- a/engine/native/thirdparty/bgfx.cmake +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 668550dc7c47c71860a39c5ef4c162e79294c93f diff --git a/engine/native/thirdparty/bimg b/engine/native/thirdparty/bimg new file mode 160000 index 0000000..9114b47 --- /dev/null +++ b/engine/native/thirdparty/bimg @@ -0,0 +1 @@ +Subproject commit 9114b47f532ce59cd0c6c9f8932df2c48888d4c1 diff --git a/engine/native/thirdparty/bx b/engine/native/thirdparty/bx new file mode 160000 index 0000000..cac72f6 --- /dev/null +++ b/engine/native/thirdparty/bx @@ -0,0 +1 @@ +Subproject commit cac72f6cfa0893393ea12692ebfacb4495f8c826 diff --git a/engine/native/thirdparty/cmake/Config.cmake.in b/engine/native/thirdparty/cmake/Config.cmake.in new file mode 100644 index 0000000..33a3943 --- /dev/null +++ b/engine/native/thirdparty/cmake/Config.cmake.in @@ -0,0 +1,31 @@ +@PACKAGE_INIT@ + +if(@BGFX_CMAKE_USER_SCRIPT_PRESENT@) + include("${CMAKE_CURRENT_LIST_DIR}/@BGFX_CMAKE_USER_SCRIPT_INSTALL_NAME@") +endif() +include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") +get_target_property(BGFX_INCLUDE_PATH bgfx::bgfx INTERFACE_INCLUDE_DIRECTORIES) +list(GET BGFX_INCLUDE_PATH 0 BGFX_INCLUDE_PATH_1) # bgfx::bgfx exports include directory twice? +set(BGFX_SHADER_INCLUDE_PATH ${BGFX_INCLUDE_PATH_1}/bgfx) + +# If cross compiling, we need a host-compatible version of shaderc to compile shaders +macro(_bgfx_crosscompile_use_host_tool TOOL_NAME) + if(NOT TARGET bgfx::${TOOL_NAME}) + find_program( + ${TOOL_NAME}_EXECUTABLE + NAMES bgfx-${TOOL_NAME} ${TOOL_NAME} + PATHS @BGFX_ADDITIONAL_TOOL_PATHS@ /usr/bin + ) + 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(texturec) +_bgfx_crosscompile_use_host_tool(shaderc) +_bgfx_crosscompile_use_host_tool(texturev) +_bgfx_crosscompile_use_host_tool(geometryv) + +include("${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/dear-imgui.cmake b/engine/native/thirdparty/cmake/bgfx/3rdparty/dear-imgui.cmake new file mode 100644 index 0000000..baaa9fd --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/3rdparty/dear-imgui.cmake @@ -0,0 +1,26 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# 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 DEAR_IMGUI_LIBRARIES) + file( + GLOB # + DEAR_IMGUI_SOURCES # + ${BGFX_DIR}/3rdparty/dear-imgui/*.cpp # + ${BGFX_DIR}/3rdparty/dear-imgui/*.h # + ${BGFX_DIR}/3rdparty/dear-imgui/*.inl # + ) + set(DEAR_IMGUI_INCLUDE_DIR ${BGFX_DIR}/3rdparty) +endif() diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/fcpp.cmake b/engine/native/thirdparty/cmake/bgfx/3rdparty/fcpp.cmake new file mode 100644 index 0000000..e62712c --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/3rdparty/fcpp.cmake @@ -0,0 +1,64 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# 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() + +set(FCPP_DIR ${BGFX_DIR}/3rdparty/fcpp) + +file( + GLOB + FCPP_SOURCES + ${FCPP_DIR}/*.h + ${FCPP_DIR}/cpp1.c + ${FCPP_DIR}/cpp2.c + ${FCPP_DIR}/cpp3.c + ${FCPP_DIR}/cpp4.c + ${FCPP_DIR}/cpp5.c + ${FCPP_DIR}/cpp6.c + ${FCPP_DIR}/cpp6.c +) + +add_library(fcpp STATIC ${FCPP_SOURCES}) + +target_compile_definitions( + fcpp + PRIVATE "NINCLUDE=64" # + "NWORK=65536" # + "NBUFF=65536" # + "OLD_PREPROCESSOR=0" # + # "MSG_PREFIX=\"Preprocessor: \"" # +) + +# Put in a "bgfx" folder in Visual Studio +set_target_properties(fcpp PROPERTIES FOLDER "bgfx") + +target_include_directories(fcpp PUBLIC ${FCPP_DIR}) + +if(MSVC) + target_compile_options( + fcpp + PRIVATE + "/wd4055" # warning C4055: 'type cast': from data pointer 'void *' to function pointer 'void (__cdecl *)(char *,void *)' + "/wd4244" # warning C4244: '=': conversion from 'const flex_int32_t' to 'YY_CHAR', possible loss of data + "/wd4701" # warning C4701: potentially uninitialized local variable 'lower' used + "/wd4706" # warning C4706: assignment within conditional expression + ) +else() + target_compile_options( + fcpp + PRIVATE -Wno-implicit-fallthrough # + -Wno-incompatible-pointer-types # + -Wno-parentheses-equality # + ) +endif() diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/glsl-optimizer.cmake b/engine/native/thirdparty/cmake/bgfx/3rdparty/glsl-optimizer.cmake new file mode 100644 index 0000000..a209a72 --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/3rdparty/glsl-optimizer.cmake @@ -0,0 +1,246 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# 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() + +set(GLSL_OPTIMIZER ${BGFX_DIR}/3rdparty/glsl-optimizer) + +file( + GLOB + GLSL_OPTIMIZER_SOURCES + ${GLSL_OPTIMIZER}/src/glsl/glcpp/glcpp.h + ${GLSL_OPTIMIZER}/src/glsl/glcpp/glcpp-lex.c + ${GLSL_OPTIMIZER}/src/glsl/glcpp/glcpp-parse.c + ${GLSL_OPTIMIZER}/src/glsl/glcpp/glcpp-parse.h + ${GLSL_OPTIMIZER}/src/glsl/glcpp/pp.c + ${GLSL_OPTIMIZER}/src/glsl/ast.h + ${GLSL_OPTIMIZER}/src/glsl/ast_array_index.cpp + ${GLSL_OPTIMIZER}/src/glsl/ast_expr.cpp + ${GLSL_OPTIMIZER}/src/glsl/ast_function.cpp + ${GLSL_OPTIMIZER}/src/glsl/ast_to_hir.cpp + ${GLSL_OPTIMIZER}/src/glsl/ast_type.cpp + ${GLSL_OPTIMIZER}/src/glsl/builtin_functions.cpp + ${GLSL_OPTIMIZER}/src/glsl/builtin_type_macros.h + ${GLSL_OPTIMIZER}/src/glsl/builtin_types.cpp + ${GLSL_OPTIMIZER}/src/glsl/builtin_variables.cpp + ${GLSL_OPTIMIZER}/src/glsl/glsl_lexer.cpp + ${GLSL_OPTIMIZER}/src/glsl/glsl_optimizer.cpp + ${GLSL_OPTIMIZER}/src/glsl/glsl_optimizer.h + ${GLSL_OPTIMIZER}/src/glsl/glsl_parser.cpp + ${GLSL_OPTIMIZER}/src/glsl/glsl_parser.h + ${GLSL_OPTIMIZER}/src/glsl/glsl_parser_extras.cpp + ${GLSL_OPTIMIZER}/src/glsl/glsl_parser_extras.h + ${GLSL_OPTIMIZER}/src/glsl/glsl_symbol_table.cpp + ${GLSL_OPTIMIZER}/src/glsl/glsl_symbol_table.h + ${GLSL_OPTIMIZER}/src/glsl/glsl_types.cpp + ${GLSL_OPTIMIZER}/src/glsl/glsl_types.h + ${GLSL_OPTIMIZER}/src/glsl/hir_field_selection.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir.h + ${GLSL_OPTIMIZER}/src/glsl/ir_basic_block.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_basic_block.h + ${GLSL_OPTIMIZER}/src/glsl/ir_builder.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_builder.h + ${GLSL_OPTIMIZER}/src/glsl/ir_clone.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_constant_expression.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_equals.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_expression_flattening.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_expression_flattening.h + ${GLSL_OPTIMIZER}/src/glsl/ir_function.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_function_can_inline.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_function_detect_recursion.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_function_inlining.h + ${GLSL_OPTIMIZER}/src/glsl/ir_hierarchical_visitor.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_hierarchical_visitor.h + ${GLSL_OPTIMIZER}/src/glsl/ir_hv_accept.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_import_prototypes.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_optimization.h + ${GLSL_OPTIMIZER}/src/glsl/ir_print_glsl_visitor.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_print_glsl_visitor.h + ${GLSL_OPTIMIZER}/src/glsl/ir_print_metal_visitor.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_print_metal_visitor.h + ${GLSL_OPTIMIZER}/src/glsl/ir_print_visitor.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_print_visitor.h + ${GLSL_OPTIMIZER}/src/glsl/ir_rvalue_visitor.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_rvalue_visitor.h + ${GLSL_OPTIMIZER}/src/glsl/ir_stats.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_stats.h + ${GLSL_OPTIMIZER}/src/glsl/ir_uniform.h + ${GLSL_OPTIMIZER}/src/glsl/ir_unused_structs.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_unused_structs.h + ${GLSL_OPTIMIZER}/src/glsl/ir_validate.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_variable_refcount.cpp + ${GLSL_OPTIMIZER}/src/glsl/ir_variable_refcount.h + ${GLSL_OPTIMIZER}/src/glsl/ir_visitor.h + ${GLSL_OPTIMIZER}/src/glsl/link_atomics.cpp + ${GLSL_OPTIMIZER}/src/glsl/link_functions.cpp + ${GLSL_OPTIMIZER}/src/glsl/link_interface_blocks.cpp + ${GLSL_OPTIMIZER}/src/glsl/link_uniform_block_active_visitor.cpp + ${GLSL_OPTIMIZER}/src/glsl/link_uniform_block_active_visitor.h + ${GLSL_OPTIMIZER}/src/glsl/link_uniform_blocks.cpp + ${GLSL_OPTIMIZER}/src/glsl/link_uniform_initializers.cpp + ${GLSL_OPTIMIZER}/src/glsl/link_uniforms.cpp + ${GLSL_OPTIMIZER}/src/glsl/link_varyings.cpp + ${GLSL_OPTIMIZER}/src/glsl/link_varyings.h + ${GLSL_OPTIMIZER}/src/glsl/linker.cpp + ${GLSL_OPTIMIZER}/src/glsl/linker.h + ${GLSL_OPTIMIZER}/src/glsl/list.h + ${GLSL_OPTIMIZER}/src/glsl/loop_analysis.cpp + ${GLSL_OPTIMIZER}/src/glsl/loop_analysis.h + ${GLSL_OPTIMIZER}/src/glsl/loop_controls.cpp + ${GLSL_OPTIMIZER}/src/glsl/loop_unroll.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_clip_distance.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_discard.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_discard_flow.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_if_to_cond_assign.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_instructions.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_jumps.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_mat_op_to_vec.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_named_interface_blocks.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_noise.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_offset_array.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_output_reads.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_packed_varyings.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_packing_builtins.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_ubo_reference.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_variable_index_to_cond_assign.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_vec_index_to_cond_assign.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_vec_index_to_swizzle.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_vector.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_vector_insert.cpp + ${GLSL_OPTIMIZER}/src/glsl/lower_vertex_id.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_algebraic.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_array_splitting.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_constant_folding.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_constant_propagation.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_constant_variable.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_copy_propagation.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_copy_propagation_elements.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_cse.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_dead_builtin_variables.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_dead_builtin_varyings.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_dead_code.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_dead_code_local.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_dead_functions.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_flatten_nested_if_blocks.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_flip_matrices.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_function_inlining.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_if_simplification.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_minmax.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_noop_swizzle.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_rebalance_tree.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_redundant_jumps.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_structure_splitting.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_swizzle_swizzle.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_tree_grafting.cpp + ${GLSL_OPTIMIZER}/src/glsl/opt_vectorize.cpp + ${GLSL_OPTIMIZER}/src/glsl/program.h + ${GLSL_OPTIMIZER}/src/glsl/s_expression.cpp + ${GLSL_OPTIMIZER}/src/glsl/s_expression.h + ${GLSL_OPTIMIZER}/src/glsl/standalone_scaffolding.cpp + ${GLSL_OPTIMIZER}/src/glsl/standalone_scaffolding.h + ${GLSL_OPTIMIZER}/src/glsl/strtod.c + ${GLSL_OPTIMIZER}/src/glsl/strtod.h + ${GLSL_OPTIMIZER}/src/mesa/main/compiler.h + ${GLSL_OPTIMIZER}/src/mesa/main/config.h + ${GLSL_OPTIMIZER}/src/mesa/main/context.h + ${GLSL_OPTIMIZER}/src/mesa/main/core.h + ${GLSL_OPTIMIZER}/src/mesa/main/dd.h + ${GLSL_OPTIMIZER}/src/mesa/main/errors.h + ${GLSL_OPTIMIZER}/src/mesa/main/glheader.h + ${GLSL_OPTIMIZER}/src/mesa/main/glminimal.h + ${GLSL_OPTIMIZER}/src/mesa/main/imports.c + ${GLSL_OPTIMIZER}/src/mesa/main/imports.h + ${GLSL_OPTIMIZER}/src/mesa/main/macros.h + ${GLSL_OPTIMIZER}/src/mesa/main/mtypes.h + ${GLSL_OPTIMIZER}/src/mesa/main/simple_list.h + ${GLSL_OPTIMIZER}/src/mesa/program/hash_table.h + ${GLSL_OPTIMIZER}/src/mesa/program/prog_hash_table.c + ${GLSL_OPTIMIZER}/src/mesa/program/prog_instruction.h + ${GLSL_OPTIMIZER}/src/mesa/program/prog_parameter.h + ${GLSL_OPTIMIZER}/src/mesa/program/prog_statevars.h + ${GLSL_OPTIMIZER}/src/mesa/program/symbol_table.c + ${GLSL_OPTIMIZER}/src/mesa/program/symbol_table.h + ${GLSL_OPTIMIZER}/src/util/hash_table.c + ${GLSL_OPTIMIZER}/src/util/hash_table.h + ${GLSL_OPTIMIZER}/src/util/macros.h + ${GLSL_OPTIMIZER}/src/util/ralloc.c + ${GLSL_OPTIMIZER}/src/util/ralloc.h +) + +add_library(glsl-optimizer STATIC ${GLSL_OPTIMIZER_SOURCES}) + +# Put in a "bgfx" folder in Visual Studio +set_target_properties(glsl-optimizer PROPERTIES FOLDER "bgfx") + +target_include_directories( + glsl-optimizer + PUBLIC ${GLSL_OPTIMIZER}/include # + ${GLSL_OPTIMIZER}/src/glsl # + PRIVATE ${GLSL_OPTIMIZER}/src # + ${GLSL_OPTIMIZER}/src/mesa # + ${GLSL_OPTIMIZER}/src/mapi # +) + +if(MSVC) + target_compile_definitions( + glsl-optimizer + PRIVATE "__STDC__" # + "__STDC_VERSION__=199901L" # + "strdup=_strdup" # + "alloca=_alloca" # + "isascii=__isascii" # + ) + target_compile_options( + glsl-optimizer + PRIVATE + "/wd4100" # error C4100: '' : unreferenced formal parameter + "/wd4127" # warning C4127: conditional expression is constant + "/wd4132" # warning C4132: 'deleted_key_value': const object should be initialized + "/wd4189" # warning C4189: 'interface_type': local variable is initialized but not referenced + "/wd4204" # warning C4204: nonstandard extension used: non-constant aggregate initializer + "/wd4244" # warning C4244: '=': conversion from 'const flex_int32_t' to 'YY_CHAR', possible loss of data + "/wd4389" # warning C4389: '!=': signed/unsigned mismatch + "/wd4245" # warning C4245: 'return': conversion from 'int' to 'unsigned int', signed/unsigned mismatch + "/wd4701" # warning C4701: potentially uninitialized local variable 'lower' used + "/wd4702" # warning C4702: unreachable code + "/wd4706" # warning C4706: assignment within conditional expression + "/wd4996" # warning C4996: 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. + ) +else() + target_compile_options( + glsl-optimizer + PRIVATE "-fno-strict-aliasing" # glsl-optimizer has bugs if strict aliasing is used. + # + "-Wno-implicit-fallthrough" # + "-Wno-parentheses" # + "-Wno-sign-compare" # + "-Wno-unused-function" # + "-Wno-unused-parameter" # + ) +endif() + +if(XCODE) + target_compile_options( + glsl-optimizer PRIVATE # + "-Wno-deprecated-register" # + ) +endif() + +if(MINGW) + target_compile_options( + glsl-optimizer PRIVATE # + "-Wno-misleading-indentation" # + ) +endif() diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/glslang.cmake b/engine/native/thirdparty/cmake/bgfx/3rdparty/glslang.cmake new file mode 100644 index 0000000..048cc87 --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/3rdparty/glslang.cmake @@ -0,0 +1,64 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# 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() + +set(GLSLANG ${BGFX_DIR}/3rdparty/glslang) +set(SPIRV_TOOLS ${BGFX_DIR}/3rdparty/spirv-tools) + +file( + GLOB_RECURSE + GLSLANG_SOURCES + ${GLSLANG}/glslang/*.cpp + ${GLSLANG}/glslang/*.h + # + ${GLSLANG}/hlsl/*.cpp + ${GLSLANG}/hlsl/*.h + # + ${GLSLANG}/SPIRV/*.cpp + ${GLSLANG}/SPIRV/*.h + # + ${GLSLANG}/OGLCompilersDLL/*.cpp + ${GLSLANG}/OGLCompilersDLL/*.h +) + +if(WIN32) + list(FILTER GLSLANG_SOURCES EXCLUDE REGEX "glslang/OSDependent/Unix/.*.cpp") + list(FILTER GLSLANG_SOURCES EXCLUDE REGEX "glslang/OSDependent/Unix/.*.h") +else() + list(FILTER GLSLANG_SOURCES EXCLUDE REGEX "glslang/OSDependent/Windows/.*.cpp") + list(FILTER GLSLANG_SOURCES EXCLUDE REGEX "glslang/OSDependent/Windows/.*.h") +endif() + +add_library(glslang STATIC ${GLSLANG_SOURCES}) + +target_compile_definitions( + glslang + PRIVATE # + ENABLE_OPT=1 # spriv-tools + ENABLE_HLSL=1 # +) + +# Put in a "bgfx" folder in Visual Studio +set_target_properties(glslang PROPERTIES FOLDER "bgfx") + +target_include_directories( + glslang + PUBLIC ${GLSLANG} + ${GLSLANG}/glslang/Public + ${GLSLANG}/glslang/Include + PRIVATE ${GLSLANG}/.. + ${SPIRV_TOOLS}/include + ${SPIRV_TOOLS}/source +) diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/meshoptimizer.cmake b/engine/native/thirdparty/cmake/bgfx/3rdparty/meshoptimizer.cmake new file mode 100644 index 0000000..d6283af --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/3rdparty/meshoptimizer.cmake @@ -0,0 +1,25 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# 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 MESHOPTIMIZER_LIBRARIES) + file( + GLOB # + MESHOPTIMIZER_SOURCES # + ${BGFX_DIR}/3rdparty/meshoptimizer/src/*.cpp # + ${BGFX_DIR}/3rdparty/meshoptimizer/src/*.h # + ) + set(MESHOPTIMIZER_INCLUDE_DIR ${BGFX_DIR}/3rdparty) +endif() diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/spirv-cross.cmake b/engine/native/thirdparty/cmake/bgfx/3rdparty/spirv-cross.cmake new file mode 100644 index 0000000..7737e44 --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/3rdparty/spirv-cross.cmake @@ -0,0 +1,60 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# 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() + +set(SPIRV_CROSS ${BGFX_DIR}/3rdparty/spirv-cross) + +file( + GLOB + SPIRV_CROSS_SOURCES + # + ${SPIRV_CROSS}/spirv.hpp + ${SPIRV_CROSS}/spirv_cfg.cpp + ${SPIRV_CROSS}/spirv_cfg.hpp + ${SPIRV_CROSS}/spirv_common.hpp + ${SPIRV_CROSS}/spirv_cpp.cpp + ${SPIRV_CROSS}/spirv_cpp.hpp + ${SPIRV_CROSS}/spirv_cross.cpp + ${SPIRV_CROSS}/spirv_cross.hpp + ${SPIRV_CROSS}/spirv_cross_parsed_ir.cpp + ${SPIRV_CROSS}/spirv_cross_parsed_ir.hpp + ${SPIRV_CROSS}/spirv_cross_util.cpp + ${SPIRV_CROSS}/spirv_cross_util.hpp + ${SPIRV_CROSS}/spirv_glsl.cpp + ${SPIRV_CROSS}/spirv_glsl.hpp + ${SPIRV_CROSS}/spirv_hlsl.cpp + ${SPIRV_CROSS}/spirv_hlsl.hpp + ${SPIRV_CROSS}/spirv_msl.cpp + ${SPIRV_CROSS}/spirv_msl.hpp + ${SPIRV_CROSS}/spirv_parser.cpp + ${SPIRV_CROSS}/spirv_parser.hpp + ${SPIRV_CROSS}/spirv_reflect.cpp + ${SPIRV_CROSS}/spirv_reflect.hpp +) + +add_library(spirv-cross STATIC ${SPIRV_CROSS_SOURCES}) + +target_compile_definitions(spirv-cross PRIVATE SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS) + +# Put in a "bgfx" folder in Visual Studio +set_target_properties(spirv-cross PROPERTIES FOLDER "bgfx") + +target_include_directories( + spirv-cross # + PUBLIC # + ${SPIRV_CROSS} # + PRIVATE # + ${SPIRV_CROSS}/include # +) diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/spirv-opt.cmake b/engine/native/thirdparty/cmake/bgfx/3rdparty/spirv-opt.cmake new file mode 100644 index 0000000..b1d90b9 --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/3rdparty/spirv-opt.cmake @@ -0,0 +1,159 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# 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() + +set(SPIRV_HEADERS ${BGFX_DIR}/3rdparty/spirv-headers) +set(SPIRV_TOOLS ${BGFX_DIR}/3rdparty/spirv-tools) + +file( + GLOB + SPIRV_OPT_SOURCES + # libspirv + ${SPIRV_TOOLS}/source/opt/*.cpp + ${SPIRV_TOOLS}/source/opt/*.h + ${SPIRV_TOOLS}/source/reduce/*.cpp + ${SPIRV_TOOLS}/source/reduce/*.h + ${SPIRV_TOOLS}/source/assembly_grammar.cpp + ${SPIRV_TOOLS}/source/assembly_grammar.h + ${SPIRV_TOOLS}/source/binary.cpp + ${SPIRV_TOOLS}/source/binary.h + ${SPIRV_TOOLS}/source/cfa.h + ${SPIRV_TOOLS}/source/diagnostic.cpp + ${SPIRV_TOOLS}/source/diagnostic.h + ${SPIRV_TOOLS}/source/disassemble.cpp + ${SPIRV_TOOLS}/source/disassemble.h + ${SPIRV_TOOLS}/source/enum_set.h + ${SPIRV_TOOLS}/source/enum_string_mapping.cpp + ${SPIRV_TOOLS}/source/enum_string_mapping.h + ${SPIRV_TOOLS}/source/ext_inst.cpp + ${SPIRV_TOOLS}/source/ext_inst.h + ${SPIRV_TOOLS}/source/extensions.cpp + ${SPIRV_TOOLS}/source/extensions.h + ${SPIRV_TOOLS}/source/instruction.h + ${SPIRV_TOOLS}/source/latest_version_glsl_std_450_header.h + ${SPIRV_TOOLS}/source/latest_version_opencl_std_header.h + ${SPIRV_TOOLS}/source/latest_version_spirv_header.h + ${SPIRV_TOOLS}/source/libspirv.cpp + ${SPIRV_TOOLS}/source/macro.h + ${SPIRV_TOOLS}/source/name_mapper.cpp + ${SPIRV_TOOLS}/source/name_mapper.h + ${SPIRV_TOOLS}/source/opcode.cpp + ${SPIRV_TOOLS}/source/opcode.h + ${SPIRV_TOOLS}/source/operand.cpp + ${SPIRV_TOOLS}/source/operand.h + ${SPIRV_TOOLS}/source/parsed_operand.cpp + ${SPIRV_TOOLS}/source/parsed_operand.h + ${SPIRV_TOOLS}/source/print.cpp + ${SPIRV_TOOLS}/source/print.h + ${SPIRV_TOOLS}/source/software_version.cpp + ${SPIRV_TOOLS}/source/spirv_constant.h + ${SPIRV_TOOLS}/source/spirv_definition.h + ${SPIRV_TOOLS}/source/spirv_endian.cpp + ${SPIRV_TOOLS}/source/spirv_endian.h + ${SPIRV_TOOLS}/source/spirv_optimizer_options.cpp + ${SPIRV_TOOLS}/source/spirv_reducer_options.cpp + ${SPIRV_TOOLS}/source/spirv_target_env.cpp + ${SPIRV_TOOLS}/source/spirv_target_env.h + ${SPIRV_TOOLS}/source/spirv_validator_options.cpp + ${SPIRV_TOOLS}/source/spirv_validator_options.h + ${SPIRV_TOOLS}/source/table.cpp + ${SPIRV_TOOLS}/source/table.h + ${SPIRV_TOOLS}/source/table2.cpp + ${SPIRV_TOOLS}/source/table2.h + ${SPIRV_TOOLS}/source/text.cpp + ${SPIRV_TOOLS}/source/text.h + ${SPIRV_TOOLS}/source/text_handler.cpp + ${SPIRV_TOOLS}/source/text_handler.h + ${SPIRV_TOOLS}/source/to_string.cpp + ${SPIRV_TOOLS}/source/to_string.h + ${SPIRV_TOOLS}/source/util/bit_vector.cpp + ${SPIRV_TOOLS}/source/util/bit_vector.h + ${SPIRV_TOOLS}/source/util/bitutils.h + ${SPIRV_TOOLS}/source/util/hex_float.h + ${SPIRV_TOOLS}/source/util/parse_number.cpp + ${SPIRV_TOOLS}/source/util/parse_number.h + ${SPIRV_TOOLS}/source/util/status.h + ${SPIRV_TOOLS}/source/util/string_utils.cpp + ${SPIRV_TOOLS}/source/util/string_utils.h + ${SPIRV_TOOLS}/source/util/timer.h + ${SPIRV_TOOLS}/source/val/basic_block.cpp + ${SPIRV_TOOLS}/source/val/construct.cpp + ${SPIRV_TOOLS}/source/val/decoration.h + ${SPIRV_TOOLS}/source/val/function.cpp + ${SPIRV_TOOLS}/source/val/instruction.cpp + ${SPIRV_TOOLS}/source/val/validate.cpp + ${SPIRV_TOOLS}/source/val/validate.h + ${SPIRV_TOOLS}/source/val/validate_adjacency.cpp + ${SPIRV_TOOLS}/source/val/validate_annotation.cpp + ${SPIRV_TOOLS}/source/val/validate_arithmetics.cpp + ${SPIRV_TOOLS}/source/val/validate_atomics.cpp + ${SPIRV_TOOLS}/source/val/validate_barriers.cpp + ${SPIRV_TOOLS}/source/val/validate_bitwise.cpp + ${SPIRV_TOOLS}/source/val/validate_builtins.cpp + ${SPIRV_TOOLS}/source/val/validate_capability.cpp + ${SPIRV_TOOLS}/source/val/validate_cfg.cpp + ${SPIRV_TOOLS}/source/val/validate_composites.cpp + ${SPIRV_TOOLS}/source/val/validate_constants.cpp + ${SPIRV_TOOLS}/source/val/validate_conversion.cpp + ${SPIRV_TOOLS}/source/val/validate_debug.cpp + ${SPIRV_TOOLS}/source/val/validate_decorations.cpp + ${SPIRV_TOOLS}/source/val/validate_derivatives.cpp + ${SPIRV_TOOLS}/source/val/validate_dot_product.cpp + ${SPIRV_TOOLS}/source/val/validate_execution_limitations.cpp + ${SPIRV_TOOLS}/source/val/validate_extensions.cpp + ${SPIRV_TOOLS}/source/val/validate_function.cpp + ${SPIRV_TOOLS}/source/val/validate_graph.cpp + ${SPIRV_TOOLS}/source/val/validate_group.cpp + ${SPIRV_TOOLS}/source/val/validate_id.cpp + ${SPIRV_TOOLS}/source/val/validate_image.cpp + ${SPIRV_TOOLS}/source/val/validate_instruction.cpp + ${SPIRV_TOOLS}/source/val/validate_interfaces.cpp + ${SPIRV_TOOLS}/source/val/validate_invalid_type.cpp + ${SPIRV_TOOLS}/source/val/validate_layout.cpp + ${SPIRV_TOOLS}/source/val/validate_literals.cpp + ${SPIRV_TOOLS}/source/val/validate_logical_pointers.cpp + ${SPIRV_TOOLS}/source/val/validate_logicals.cpp + ${SPIRV_TOOLS}/source/val/validate_memory.cpp + ${SPIRV_TOOLS}/source/val/validate_memory_semantics.cpp + ${SPIRV_TOOLS}/source/val/validate_mesh_shading.cpp + ${SPIRV_TOOLS}/source/val/validate_misc.cpp + ${SPIRV_TOOLS}/source/val/validate_mode_setting.cpp + ${SPIRV_TOOLS}/source/val/validate_non_uniform.cpp + ${SPIRV_TOOLS}/source/val/validate_pipe.cpp + ${SPIRV_TOOLS}/source/val/validate_primitives.cpp + ${SPIRV_TOOLS}/source/val/validate_ray_query.cpp + ${SPIRV_TOOLS}/source/val/validate_ray_tracing.cpp + ${SPIRV_TOOLS}/source/val/validate_ray_tracing_reorder.cpp + ${SPIRV_TOOLS}/source/val/validate_scopes.cpp + ${SPIRV_TOOLS}/source/val/validate_small_type_uses.cpp + ${SPIRV_TOOLS}/source/val/validate_tensor.cpp + ${SPIRV_TOOLS}/source/val/validate_tensor_layout.cpp + ${SPIRV_TOOLS}/source/val/validate_type.cpp + ${SPIRV_TOOLS}/source/val/validation_state.cpp +) + +add_library(spirv-opt STATIC ${SPIRV_OPT_SOURCES}) + +# Put in a "bgfx" folder in Visual Studio +set_target_properties(spirv-opt PROPERTIES FOLDER "bgfx") + +target_include_directories( + spirv-opt + PUBLIC ${SPIRV_TOOLS}/include # + PRIVATE ${SPIRV_TOOLS} # + ${SPIRV_TOOLS}/include/generated # + ${SPIRV_TOOLS}/source # + ${SPIRV_HEADERS}/include # +) diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/tint.cmake b/engine/native/thirdparty/cmake/bgfx/3rdparty/tint.cmake new file mode 100644 index 0000000..eb86f57 --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/3rdparty/tint.cmake @@ -0,0 +1,98 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +if(TARGET tint) + return() +endif() + +if(NOT IS_DIRECTORY ${BGFX_DIR}) + message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}") + return() +endif() + +set(TINT_DIR ${BGFX_DIR}/3rdparty/dawn) +set(SPIRV_HEADERS ${BGFX_DIR}/3rdparty/spirv-headers) +set(SPIRV_TOOLS ${BGFX_DIR}/3rdparty/spirv-tools) + +file( + GLOB_RECURSE + TINT_SOURCES + ${TINT_DIR}/src/tint/utils/*.cc + ${TINT_DIR}/src/tint/utils/*.h + ${TINT_DIR}/src/tint/lang/core/*.cc + ${TINT_DIR}/src/tint/lang/core/*.h + ${TINT_DIR}/src/tint/lang/null/*.cc + ${TINT_DIR}/src/tint/lang/null/*.h + ${TINT_DIR}/src/tint/lang/spirv/*.cc + ${TINT_DIR}/src/tint/lang/spirv/*.h + ${TINT_DIR}/src/tint/lang/wgsl/*.cc + ${TINT_DIR}/src/tint/lang/wgsl/*.h + ${TINT_DIR}/src/tint/api/*.cc + ${TINT_DIR}/src/tint/api/*.h +) + +add_library(tint STATIC ${TINT_SOURCES}) + +set_target_properties(tint PROPERTIES FOLDER "bgfx") + +target_include_directories( + tint + PUBLIC ${TINT_DIR} + ${TINT_DIR}/src/tint + PRIVATE ${TINT_DIR}/third_party/protobuf/src + ${TINT_DIR}/third_party/abseil-cpp + ${SPIRV_TOOLS} + ${SPIRV_TOOLS}/include + ${SPIRV_TOOLS}/include/generated + ${SPIRV_HEADERS}/include +) + +target_compile_definitions( + tint + PRIVATE TINT_BUILD_GLSL_WRITER=0 + TINT_BUILD_HLSL_WRITER=0 + TINT_BUILD_MSL_WRITER=0 + TINT_BUILD_NULL_WRITER=0 + TINT_BUILD_SPV_READER=1 + TINT_BUILD_SPV_WRITER=0 + TINT_BUILD_WGSL_READER=0 + TINT_BUILD_WGSL_WRITER=1 + TINT_ENABLE_IR_VALIDATION=0 +) + +if(WIN32) + target_compile_definitions( + tint + PRIVATE TINT_BUILD_IS_LINUX=0 + TINT_BUILD_IS_MAC=0 + TINT_BUILD_IS_WIN=1 + ) +elseif(APPLE) + target_compile_definitions( + tint + PRIVATE TINT_BUILD_IS_LINUX=0 + TINT_BUILD_IS_MAC=1 + TINT_BUILD_IS_WIN=0 + ) +else() + target_compile_definitions( + tint + PRIVATE TINT_BUILD_IS_LINUX=1 + TINT_BUILD_IS_MAC=0 + TINT_BUILD_IS_WIN=0 + ) +endif() + +if(MSVC) + target_compile_options( + tint + PRIVATE "/Zc:preprocessor" + ) +endif() diff --git a/engine/native/thirdparty/cmake/bgfx/3rdparty/webgpu.cmake b/engine/native/thirdparty/cmake/bgfx/3rdparty/webgpu.cmake new file mode 100644 index 0000000..1de320a --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/3rdparty/webgpu.cmake @@ -0,0 +1,40 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover + +# 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 . + +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 +) + +# Library without sources is interface +#add_library( webgpu STATIC ${WEBGPU_SOURCES} ) +add_library(webgpu INTERFACE) +target_include_directories( + webgpu # PUBLIC + INTERFACE $ +) + +# These properties are not allowed on interface +# set_target_properties(webgpu PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-") + +if(BGFX_INSTALL AND 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() diff --git a/engine/native/thirdparty/cmake/bgfx/CMakeLists.txt b/engine/native/thirdparty/cmake/bgfx/CMakeLists.txt new file mode 100644 index 0000000..4537e95 --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/CMakeLists.txt @@ -0,0 +1,34 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +include(bgfx.cmake) +include(3rdparty/meshoptimizer.cmake) +include(3rdparty/dear-imgui.cmake) + +if(BGFX_BUILD_TOOLS_TEXTURE) + include(texturev.cmake) +endif() +if(BGFX_BUILD_TOOLS_GEOMETRY) + include(geometryc.cmake) + include(geometryv.cmake) +endif() +if(BGFX_BUILD_TOOLS_SHADER) + include(3rdparty/spirv-opt.cmake) + include(3rdparty/spirv-cross.cmake) + include(3rdparty/glslang.cmake) + include(3rdparty/glsl-optimizer.cmake) + include(3rdparty/fcpp.cmake) + include(3rdparty/webgpu.cmake) + include(3rdparty/tint.cmake) + include(shaderc.cmake) +endif() + +include(shared.cmake) +include(examples.cmake) diff --git a/engine/native/thirdparty/cmake/bgfx/bgfx.cmake b/engine/native/thirdparty/cmake/bgfx/bgfx.cmake new file mode 100644 index 0000000..06ca401 --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/bgfx.cmake @@ -0,0 +1,223 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# 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() + +# Grab the bgfx source files +file( + GLOB + BGFX_SOURCES + ${BGFX_DIR}/src/*.cpp + ${BGFX_DIR}/src/*.h + ${BGFX_DIR}/include/bgfx/*.h + ${BGFX_DIR}/include/bgfx/c99/*.h +) + +set(BGFX_AMALGAMATED_SOURCE ${BGFX_DIR}/src/amalgamated.cpp) + +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_AMALGAMATED_SOURCE} 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) + 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=$,${BGFX_CONFIG_DEFAULT_MAX_ENCODERS},1>" + ) +endif() + +if(BGFX_WITH_WAYLAND) + target_compile_definitions(bgfx PRIVATE "WL_EGL_PLATFORM=1") + target_link_libraries(bgfx PRIVATE wayland-egl) +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=$,$>" + "BGFX_CONFIG_DEBUG_ANNOTATION=$>,$,$>>" + "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 $ $ +) + +# 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 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 these files as objective-c++ (instead of renaming to .mm) +if(XCODE) + set_source_files_properties( + ${BGFX_DIR}/src/renderer_vk.cpp + ${BGFX_DIR}/src/renderer_webgpu.cpp + PROPERTIES + LANGUAGE OBJCXX + XCODE_EXPLICIT_FILE_TYPE sourcecode.cpp.objcpp + ) +endif() + +if(BGFX_INSTALL) + install( + TARGETS bgfx + EXPORT "${TARGETS_EXPORT_NAME}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + INCLUDES + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + ) + + install(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" + ) +endif() diff --git a/engine/native/thirdparty/cmake/bgfx/examples.cmake b/engine/native/thirdparty/cmake/bgfx/examples.cmake new file mode 100644 index 0000000..a4f4f3c --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/examples.cmake @@ -0,0 +1,365 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +include(CMakeParseArguments) + +include(${CMAKE_CURRENT_LIST_DIR}/util/ConfigureDebugging.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") + elseif("${TYPE}" STREQUAL "vs") + set(TYPE "VERTEX") + elseif("${TYPE}" STREQUAL "cs") + set(TYPE "COMPUTE") + else() + set(TYPE "") + endif() + + if(NOT "${TYPE}" STREQUAL "") + set(COMMON FILE ${FILE} ${TYPE} INCLUDES ${BGFX_DIR}/src) + set(OUTPUTS "") + set(OUTPUTS_PRETTY "") + set(OUTPUT_FILES "") + set(COMMANDS "") + + if(WIN32) + # dx11 + set(DX11_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/dx11/${FILENAME}.bin) + if(NOT "${TYPE}" STREQUAL "COMPUTE") + _bgfx_shaderc_parse( + DX11 ${COMMON} WINDOWS + PROFILE s_5_0 + O 3 + OUTPUT ${DX11_OUTPUT} + ) + else() + _bgfx_shaderc_parse( + DX11 ${COMMON} WINDOWS + PROFILE s_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 PROFILE 100_es 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 140 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, ") + endif() + + # wgsl + set(WGSL_OUTPUT ${BGFX_DIR}/examples/runtime/shaders/wgsl/${FILENAME}.bin) + _bgfx_shaderc_parse(WGSL ${COMMON} LINUX PROFILE wgsl OUTPUT ${WGSL_OUTPUT}) + list(APPEND OUTPUTS "WGSL") + set(OUTPUTS_PRETTY "${OUTPUTS_PRETTY}WGSL") + + foreach(OUT ${OUTPUTS}) + list(APPEND OUTPUT_FILES ${${OUT}_OUTPUT}) + list(APPEND COMMANDS COMMAND "bgfx::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} ${DEAR_IMGUI_SOURCES} ${MESHOPTIMIZER_SOURCES} + ) + target_include_directories( + example-${ARG_NAME} PUBLIC ${BGFX_DIR}/examples/common ${DEAR_IMGUI_INCLUDE_DIR} + ${MESHOPTIMIZER_INCLUDE_DIR} + ) + target_link_libraries( + example-${ARG_NAME} PUBLIC bgfx bx bimg bimg_decode ${DEAR_IMGUI_LIBRARIES} ${MESHOPTIMIZER_LIBRARIES} + ) + + if(BGFX_WITH_WAYLAND) + target_compile_definitions(example-${ARG_NAME} PUBLIC ENTRY_CONFIG_USE_WAYLAND=1) + endif() + + 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=1) + 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=1) + elseif(UNIX AND NOT APPLE AND NOT ANDROID) + target_link_libraries(example-${ARG_NAME} PUBLIC X11) + endif() + + if(ANDROID) + target_include_directories(example-${ARG_NAME} PRIVATE ${BGFX_DIR}/3rdparty/native_app_glue) + target_link_libraries(example-${ARG_NAME} INTERFACE android EGL GLESv2) + endif() + + if(BGFX_BUILD_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} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${BGFX_DIR}/examples/runtime/ + $ + ) + else() + # For everything else symlink some folders into our output directory + add_custom_command( + TARGET example-${ARG_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/font + $/font + ) + add_custom_command( + TARGET example-${ARG_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/images + $/images + ) + add_custom_command( + TARGET example-${ARG_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/meshes + $/meshes + ) + add_custom_command( + TARGET example-${ARG_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/shaders + $/shaders + ) + add_custom_command( + TARGET example-${ARG_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/text + $/text + ) + add_custom_command( + TARGET example-${ARG_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E create_symlink ${BGFX_DIR}/examples/runtime/textures + $/textures + ) + endif() + endif() + + else() + if(ANDROID) + add_library(example-${ARG_NAME} SHARED ${SOURCES}) + else() + add_executable(example-${ARG_NAME} WIN32 ${SOURCES}) + endif() + if(NOT BGFX_INSTALL_EXAMPLES) + set_property(TARGET example-${ARG_NAME} PROPERTY EXCLUDE_FROM_ALL ON) + endif() + target_link_libraries(example-${ARG_NAME} PUBLIC 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") +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 +if(BGFX_BUILD_EXAMPLE_COMMON) + 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 + ) +endif() + +# 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 + 48-drawindirect + 49-hextile + 50-headless + 51-gpufont + ) + + foreach(EXAMPLE ${BGFX_EXAMPLES}) + add_example(${EXAMPLE}) + endforeach() + + if(BGFX_INSTALL_EXAMPLES) + install(DIRECTORY ${BGFX_DIR}/examples/runtime/ DESTINATION examples) + foreach(EXAMPLE ${BGFX_EXAMPLES}) + install(TARGETS example-${EXAMPLE} DESTINATION examples) + endforeach() + endif() +endif() diff --git a/engine/native/thirdparty/cmake/bgfx/generated/bounds.cpp.in b/engine/native/thirdparty/cmake/bgfx/generated/bounds.cpp.in new file mode 100644 index 0000000..1e3029e --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/generated/bounds.cpp.in @@ -0,0 +1 @@ +#include "@BGFX_DIR@/examples/common/bounds.cpp" diff --git a/engine/native/thirdparty/cmake/bgfx/generated/shader.cpp.in b/engine/native/thirdparty/cmake/bgfx/generated/shader.cpp.in new file mode 100644 index 0000000..bbfce0d --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/generated/shader.cpp.in @@ -0,0 +1,3 @@ +#include "@BGFX_DIR@/src/shader.cpp" +#include "@BGFX_DIR@/src/shader_dxbc.cpp" +#include "@BGFX_DIR@/src/shader_spirv.cpp" diff --git a/engine/native/thirdparty/cmake/bgfx/generated/vertexlayout.cpp.in b/engine/native/thirdparty/cmake/bgfx/generated/vertexlayout.cpp.in new file mode 100644 index 0000000..a007bb5 --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/generated/vertexlayout.cpp.in @@ -0,0 +1 @@ +#include "@BGFX_DIR@/src/vertexlayout.cpp" diff --git a/engine/native/thirdparty/cmake/bgfx/geometryc.cmake b/engine/native/thirdparty/cmake/bgfx/geometryc.cmake new file mode 100644 index 0000000..e6efcd5 --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/geometryc.cmake @@ -0,0 +1,43 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Grab the geometryc source files +file( + GLOB_RECURSE + GEOMETRYC_SOURCES # + ${BGFX_DIR}/tools/geometryc/*.cpp # + ${BGFX_DIR}/tools/geometryc/*.h # + # + ${MESHOPTIMIZER_SOURCES} +) +add_executable(geometryc ${GEOMETRYC_SOURCES}) + +target_include_directories(geometryc PRIVATE ${MESHOPTIMIZER_INCLUDE_DIR}) +target_link_libraries(geometryc PRIVATE bx bgfx-vertexlayout ${MESHOPTIMIZER_LIBRARIES}) +target_compile_definitions(geometryc PRIVATE "-D_CRT_SECURE_NO_WARNINGS") +set_target_properties( + geometryc PROPERTIES FOLDER "bgfx/tools" # + OUTPUT_NAME ${BGFX_TOOLS_PREFIX}geometryc # +) + +if(BGFX_BUILD_TOOLS_GEOMETRY) + add_executable(bgfx::geometryc ALIAS geometryc) + if(BGFX_CUSTOM_TARGETS) + add_dependencies(tools geometryc) + endif() +endif() + +if(IOS) + set_target_properties(geometryc PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER geometryc) +endif() + +if(BGFX_INSTALL) + install(TARGETS geometryc EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}") +endif() diff --git a/engine/native/thirdparty/cmake/bgfx/geometryv.cmake b/engine/native/thirdparty/cmake/bgfx/geometryv.cmake new file mode 100644 index 0000000..764ff7c --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/geometryv.cmake @@ -0,0 +1,42 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Grab the geometryv source files +file(GLOB_RECURSE GEOMETRYV_SOURCES # + ${BGFX_DIR}/tools/geometryv/* +) + +if(ANDROID) + add_library(geometryv SHARED ${GEOMETRYV_SOURCES}) +else() + add_executable(geometryv ${GEOMETRYV_SOURCES}) +endif() + +target_link_libraries(geometryv PRIVATE example-common) +set_target_properties( + geometryv PROPERTIES FOLDER "bgfx/tools" # + OUTPUT_NAME ${BGFX_TOOLS_PREFIX}geometryv # +) + +if(BGFX_BUILD_TOOLS_GEOMETRY AND BGFX_CUSTOM_TARGETS) + add_dependencies(tools geometryv) +endif() + +if(ANDROID) + set_property(TARGET geometryv PROPERTY PREFIX "") +elseif(EMSCRIPTEN) + target_link_options(geometryv PRIVATE -sMAX_WEBGL_VERSION=2) +elseif(IOS) + set_target_properties(geometryv PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER geometryv) +endif() + +if(BGFX_INSTALL) + install(TARGETS geometryv EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}") +endif() diff --git a/engine/native/thirdparty/cmake/bgfx/shaderc.cmake b/engine/native/thirdparty/cmake/bgfx/shaderc.cmake new file mode 100644 index 0000000..7ecf472 --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/shaderc.cmake @@ -0,0 +1,95 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Grab the shaderc source files +file( + GLOB + SHADERC_SOURCES # + ${BGFX_DIR}/tools/shaderc/*.cpp # + ${BGFX_DIR}/tools/shaderc/*.h # + ${BGFX_DIR}/src/shader* # +) + +add_executable(shaderc ${SHADERC_SOURCES}) + +target_link_libraries( + shaderc + PRIVATE bx + bimg + bgfx-vertexlayout + fcpp + glslang + glsl-optimizer + spirv-opt + spirv-cross + webgpu + tint +) + +target_include_directories( + shaderc + PRIVATE ${BGFX_DIR}/3rdparty/dawn + ${BGFX_DIR}/3rdparty/dawn/src +) + +set(DXCOMPILER_RUNTIME) +if(UNIX + AND NOT APPLE + AND NOT EMSCRIPTEN + AND NOT ANDROID +) + target_include_directories( + shaderc + PRIVATE ${BGFX_DIR}/3rdparty/directx-headers/include/directx + ${BGFX_DIR}/3rdparty/directx-headers/include + ${BGFX_DIR}/3rdparty/directx-headers/include/wsl/stubs + ) + set(DXCOMPILER_RUNTIME ${BGFX_DIR}/tools/bin/linux/libdxcompiler.so) +elseif(WIN32) + set(DXCOMPILER_RUNTIME ${BGFX_DIR}/tools/bin/windows/dxcompiler.dll) +endif() + +if(BGFX_AMALGAMATED) + target_link_libraries(shaderc PRIVATE bgfx-shader) +endif() + +set_target_properties( + shaderc PROPERTIES FOLDER "bgfx/tools" # + OUTPUT_NAME ${BGFX_TOOLS_PREFIX}shaderc # +) + +if(BGFX_BUILD_TOOLS_SHADER) + add_executable(bgfx::shaderc ALIAS shaderc) + if(BGFX_CUSTOM_TARGETS) + add_dependencies(tools shaderc) + endif() +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() + +if(BGFX_INSTALL) + install(TARGETS shaderc EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}") +endif() + +# DXIL compiler will be dynamically loaded at runtime - no need +# to link, just install the needed binaries alongside shaderc.exe +if(DXCOMPILER_RUNTIME) + add_custom_command( + TARGET shaderc POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DXCOMPILER_RUNTIME} $ + ) + if(BGFX_INSTALL) + install(FILES ${DXCOMPILER_RUNTIME} DESTINATION "${CMAKE_INSTALL_BINDIR}") + endif() +endif() diff --git a/engine/native/thirdparty/cmake/bgfx/shared.cmake b/engine/native/thirdparty/cmake/bgfx/shared.cmake new file mode 100644 index 0000000..b8decaf --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/shared.cmake @@ -0,0 +1,29 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +add_library(bgfx-vertexlayout INTERFACE) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/generated/vertexlayout.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/generated/vertexlayout.cpp +) +target_sources(bgfx-vertexlayout INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/generated/vertexlayout.cpp) +target_include_directories(bgfx-vertexlayout INTERFACE ${BGFX_DIR}/include) + +add_library(bgfx-shader INTERFACE) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/generated/shader.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/generated/shader.cpp) +target_sources(bgfx-shader INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/generated/shader.cpp) +target_include_directories(bgfx-shader INTERFACE ${BGFX_DIR}/include) + +# Frameworks required on OS X +if(${CMAKE_SYSTEM_NAME} MATCHES Darwin) + find_library(COCOA_LIBRARY Cocoa) + mark_as_advanced(COCOA_LIBRARY) + target_link_libraries(bgfx-vertexlayout INTERFACE ${COCOA_LIBRARY}) +endif() diff --git a/engine/native/thirdparty/cmake/bgfx/texturev.cmake b/engine/native/thirdparty/cmake/bgfx/texturev.cmake new file mode 100644 index 0000000..a45447b --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/texturev.cmake @@ -0,0 +1,42 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Grab the texturev source files +file(GLOB_RECURSE TEXTUREV_SOURCES # + ${BGFX_DIR}/tools/texturev/* +) + +if(ANDROID) + add_library(texturev SHARED ${TEXTUREV_SOURCES}) +else() + add_executable(texturev ${TEXTUREV_SOURCES}) +endif() + +target_link_libraries(texturev PRIVATE example-common) +set_target_properties( + texturev PROPERTIES FOLDER "bgfx/tools" # + OUTPUT_NAME ${BGFX_TOOLS_PREFIX}texturev # +) + +if(BGFX_BUILD_TOOLS_TEXTURE AND BGFX_CUSTOM_TARGETS) + add_dependencies(tools texturev) +endif() + +if(ANDROID) + set_property(TARGET texturev PROPERTY PREFIX "") +elseif(EMSCRIPTEN) + target_link_options(texturev PRIVATE -sMAX_WEBGL_VERSION=2) +elseif(IOS) + set_target_properties(texturev PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER texturev) +endif() + +if(BGFX_INSTALL) + install(TARGETS texturev EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}") +endif() diff --git a/engine/native/thirdparty/cmake/bgfx/util/ConfigureDebugging.cmake b/engine/native/thirdparty/cmake/bgfx/util/ConfigureDebugging.cmake new file mode 100644 index 0000000..2df4fef --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfx/util/ConfigureDebugging.cmake @@ -0,0 +1,157 @@ +# ConfigureDebugging.cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# 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 + "\n" + ) + 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 " + ) + 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}") + endif() + set(ODD ON) + endif() + endforeach() + set(RESULT "${RESULT}\n ") + endif() + endforeach() + endforeach() + set(RESULT "${RESULT}\n") + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET}.vcxproj.user "${RESULT}") + endif() +endfunction() diff --git a/engine/native/thirdparty/cmake/bgfxToolUtils.cmake b/engine/native/thirdparty/cmake/bgfxToolUtils.cmake new file mode 100644 index 0000000..7f50445 --- /dev/null +++ b/engine/native/thirdparty/cmake/bgfxToolUtils.cmake @@ -0,0 +1,677 @@ +# If bgfx.cmake was compiled without tools or cross compiled without host having tools, +# then don't provide helper functions +if(TARGET bgfx::bin2c) + # _bgfx_bin2c_parse( + # INPUT_FILE filename + # OUTPUT_FILE filename + # ARRAY_NAME name + # ) + # Usage: bin2c -f -o -n + 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() +endif() + +# If bgfx.cmake was compiled without tools or cross compiled without host having tools, +# then don't provide helper functions +if(TARGET bgfx::texturec) + # _bgfx_texturec_parse( + # FILE filename + # OUTPUT filename + # [FORMAT format] + # [QUALITY default|fastest|highest] + # [MIPS] + # [MIPSKIP N] + # [NORMALMAP] + # [EQUIRECT] + # [STRIP] + # [SDF] + # [REF alpha] + # [IQA] + # [PMA] + # [LINEAR] + # [MAX max size] + # [RADIANCE model] + # [AS extension] + # ) + function(_bgfx_texturec_parse ARG_OUT) + cmake_parse_arguments( + ARG # + "MIPS;NORMALMAP;EQUIRECT;STRIP;SDF;IQA;PMA;LINEAR" # + "FILE;OUTPUT;FORMAT;QUALITY;MIPSKIP;REF;MAX;RADIANCE;AS" # + "" # + ${ARGN} # + ) + set(CLI "") + + # -f + if(ARG_FILE) + list(APPEND CLI "-f" "${ARG_FILE}") + endif() + + # -o + if(ARG_OUTPUT) + list(APPEND CLI "-o" "${ARG_OUTPUT}") + endif() + + # -t + if(ARG_FORMAT) + list(APPEND CLI "-t" "${ARG_FORMAT}") + endif() + + # -q + if(ARG_QUALITY) + list(APPEND CLI "-q" "${ARG_QUALITY}") + endif() + + # --mips + if(ARG_MIPS) + list(APPEND CLI "--mips") + endif() + + # --mipskip + if(ARG_MIPSKIP) + list(APPEND CLI "--mipskip" "${ARG_MIPSKIP}") + endif() + + # --normalmap + if(ARG_NORMALMAP) + list(APPEND CLI "--normalmap") + endif() + + # --equirect + if(ARG_EQUIRECT) + list(APPEND CLI "--equirect") + endif() + + # --strip + if(ARG_STRIP) + list(APPEND CLI "--strip") + endif() + + # --sdf + if(ARG_SDF) + list(APPEND CLI "--sdf") + endif() + + # --ref + if(ARG_REF) + list(APPEND CLI "--ref" "${ARG_REF}") + endif() + + # --iqa + if(ARG_IQA) + list(APPEND CLI "--iqa") + endif() + + # --pma + if(ARG_PMA) + list(APPEND CLI "--pma") + endif() + + # --linear + if(ARG_LINEAR) + list(APPEND CLI "--linear") + endif() + + # --max + if(ARG_MAX) + list(APPEND CLI "--max" "${ARG_MAX}") + endif() + + # --radiance + if(ARG_RADIANCE) + list(APPEND CLI "--radiance" "${ARG_RADIANCE}") + endif() + + # --as + if(ARG_AS) + list(APPEND CLI "--as" "${ARG_AS}") + endif() + + set(${ARG_OUT} ${CLI} PARENT_SCOPE) + endfunction() + + # bgfx_compile_texture( + # FILE filename + # OUTPUT filename + # [FORMAT format] + # [QUALITY default|fastest|highest] + # [MIPS] + # [MIPSKIP N] + # [NORMALMAP] + # [EQUIRECT] + # [STRIP] + # [SDF] + # [REF alpha] + # [IQA] + # [PMA] + # [LINEAR] + # [MAX max size] + # [RADIANCE model] + # [AS extension] + # ) + # + function(bgfx_compile_texture) + cmake_parse_arguments( + ARG # + "MIPS;NORMALMAP;EQUIRECT;STRIP;SDF;IQA;PMA;LINEAR" # + "FILE;OUTPUT;FORMAT;QUALITY;MIPSKIP;REF;MAX;RADIANCE;AS" # + "" # + ${ARGN} # + ) + _bgfx_texturec_parse(CLI ${ARGV}) + add_custom_command( + OUTPUT ${ARG_OUTPUT} # + COMMAND bgfx::texturec ${CLI} # + MAIN_DEPENDENCY ${ARG_FILE} # + ) + endfunction() +endif() + +# If bgfx.cmake was compiled without tools or cross compiled without host having tools, +# then don't provide helper functions +if(TARGET bgfx::geometryc) + # _bgfx_geometryc_parse( + # FILE filename + # OUTPUT filename + # [SCALE scale] + # [CCW] + # [FLIPV] + # [OBB num steps] + # [PACKNORMAL 0|1] + # [PACKUV 0|1] + # [TANGENT] + # [BARYCENTRIC] + # [COMPRESS] + # [LH_UP_Y|LH_UP_Z|RH_UP_Y|RH_UP_Z] + # ) + function(_bgfx_geometryc_parse ARG_OUT) + cmake_parse_arguments( + ARG # + "CCW;FLIPV;TANGENT;BARYCENTRIC;COMPRESS;LH_UP_Y;LH_UP_Z;RH_UP_Y;RH_UP_Z" # + "FILE;OUTPUT;SCALE;OBB;PACKNORMAL;PACKUV" # + "" # + ${ARGN} # + ) + set(CLI "") + + # -f + if(ARG_FILE) + list(APPEND CLI "-f" "${ARG_FILE}") + endif() + + # -o + if(ARG_OUTPUT) + list(APPEND CLI "-o" "${ARG_OUTPUT}") + endif() + + # -s + if(ARG_SCALE) + list(APPEND CLI "-s" "${ARG_SCALE}") + endif() + + # --cw + if(ARG_QUALITY) + list(APPEND CLI "--cw") + endif() + + # --flipv + if(ARG_FLIPV) + list(APPEND CLI "--flipv") + endif() + + # --obb + if(ARG_OBB) + list(APPEND CLI "--mipskip" "${ARG_OBB}") + endif() + + # --packnormal + if(ARG_PACKNORMAL) + list(APPEND CLI "--packnormal" "${ARG_PACKNORMAL}") + endif() + + # --packuv + if(ARG_PACKUV) + list(APPEND CLI "--packuv" "${ARG_PACKUV}") + endif() + + # --tangent + if(ARG_TANGENT) + list(APPEND CLI "--tangent") + endif() + + # --barycentric + if(ARG_BARYCENTRIC) + list(APPEND CLI "--barycentric") + endif() + + # --compress + if(ARG_REF) + list(APPEND CLI "--compress" "${ARG_COMPRESS}") + endif() + + # --lh-up+y + if(ARG_LH_UP_Y) + list(APPEND CLI "--lh-up+y") + endif() + + # --lh-up+z + if(ARG_LH_UP_Z) + list(APPEND CLI "--lh-up+z") + endif() + + # --rh-up+y + if(ARG_RH_UP_Y) + list(APPEND CLI "--rh-up+y") + endif() + + # --rh-up+z + if(ARG_RH_UP_Z) + list(APPEND CLI "--rh-up+z") + endif() + + set(${ARG_OUT} ${CLI} PARENT_SCOPE) + endfunction() + + # bgfx_compile_geometry( + # FILE filename + # OUTPUT filename + # [SCALE scale] + # [CCW] + # [FLIPV] + # [OBB num steps] + # [PACKNORMAL 0|1] + # [PACKUV 0|1] + # [TANGENT] + # [BARYCENTRIC] + # [COMPRESS] + # [LH_UP_Y|LH_UP_Z|RH_UP_Y|RH_UP_Z] + # ) + # + function(bgfx_compile_geometry) + cmake_parse_arguments( + ARG # + "CCW;FLIPV;TANGENT;BARYCENTRIC;COMPRESS;LH_UP_Y;LH_UP_Z;RH_UP_Y;RH_UP_Z" # + "FILE;OUTPUT;SCALE;OBB;PACKNORMAL;PACKUV" # + "" # + ${ARGN} # + ) + _bgfx_geometryc_parse(CLI ${ARGV}) + add_custom_command( + OUTPUT ${ARG_OUTPUT} # + COMMAND bgfx::geometryc ${CLI} # + MAIN_DEPENDENCY ${ARG_FILE} # + ) + endfunction() +endif() + +# If bgfx.cmake was compiled without tools or cross compiled without host having tools, +# then don't provide helper functions +if(TARGET bgfx::shaderc) + # _bgfx_shaderc_parse( + # FILE filename + # OUTPUT filename + # FRAGMENT|VERTEX|COMPUTE + # ANDROID|ASM_JS|IOS|LINUX|OSX|WINDOWS|ORBIS + # PROFILE profile + # [O 0|1|2|3] + # [VARYINGDEF filename] + # [BIN2C filename] + # [INCLUDES include;include] + # [DEFINES include;include] + # [DEPENDS] + # [PREPROCESS] + # [RAW] + # [VERBOSE] + # [DEBUG] + # [DISASM] + # [WERROR] + # ) + function(_bgfx_shaderc_parse ARG_OUT) + cmake_parse_arguments( + ARG + "DEPENDS;ANDROID;ASM_JS;IOS;LINUX;OSX;WINDOWS;ORBIS;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}") + else() + message(SEND_ERROR "Call to _bgfx_shaderc_parse() must have an input file path specified.") + endif() + + # -i + 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}") + else() + message(SEND_ERROR "Call to _bgfx_shaderc_parse() must have an output file path specified.") + endif() + + # --bin2c + if(ARG_BIN2C) + list(APPEND CLI "--bin2c" "${ARG_BIN2C}") + endif() + + # --depends + if(ARG_DEPENDS) + list(APPEND CLI "--depends") + endif() + + # --platform + set(PLATFORM "") + set(PLATFORMS "ANDROID;ASM_JS;IOS;LINUX;OSX;WINDOWS;ORBIS") + 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}") + endif() + endforeach() + 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 "OSX") + list(APPEND CLI "--platform" "osx") + elseif(PLATFORM STREQUAL "LINUX") + list(APPEND CLI "--platform" "linux") + elseif(PLATFORM STREQUAL "WINDOWS") + list(APPEND CLI "--platform" "windows") + elseif(PLATFORM STREQUAL "ORBIS") + list(APPEND CLI "--platform" "orbis") + endif() + + # --preprocess + if(ARG_PREPROCESS) + list(APPEND CLI "--preprocess") + endif() + + # --define + if(ARG_DEFINES) + # Add extra escapes or CMake will expand in the final CLI + string(REPLACE ";" "\\\\\\;" DEFINES "${ARG_DEFINES}") + # Also need to quote escape for Unix shells + list(APPEND CLI "--define" "\"${DEFINES}\"") + endif() + + # --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 _bgfx_shaderc_parse() cannot have both flags ${TYPE} and ${T}.") + return() + endif() + set(TYPE "${T}") + endif() + endforeach() + 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") + endif() + + # --varyingdef + if(ARG_VARYINGDEF) + list(APPEND CLI "--varyingdef" "${ARG_VARYINGDEF}") + endif() + + # --verbose + if(ARG_VERBOSE) + list(APPEND CLI "--verbose") + endif() + + # --debug + if(ARG_DEBUG) + list(APPEND CLI "--debug") + endif() + + # --disasm + if(ARG_DISASM) + list(APPEND CLI "--disasm") + endif() + + # --profile + if(ARG_PROFILE) + list(APPEND CLI "--profile" "${ARG_PROFILE}") + else() + message(SEND_ERROR "Call to _bgfx_shaderc_parse() must have a shader profile.") + endif() + + # -O + if(ARG_O) + list(APPEND CLI "-O" "${ARG_O}") + endif() + + # --Werror + if(ARG_WERROR) + list(APPEND CLI "--Werror") + endif() + + set(${ARG_OUT} ${CLI} PARENT_SCOPE) + endfunction() + + # extensions consistent with those listed under bgfx/runtime/shaders + function(_bgfx_get_profile_path_ext PROFILE PROFILE_PATH_EXT) + string(REPLACE 100_es essl PROFILE ${PROFILE}) + string(REPLACE 300_es essl PROFILE ${PROFILE}) + string(REPLACE 120 glsl PROFILE ${PROFILE}) + string(REPLACE 430 glsl PROFILE ${PROFILE}) + string(REPLACE s_5_0 dxbc PROFILE ${PROFILE}) + string(REPLACE s_6_0 dxil PROFILE ${PROFILE}) + set(${PROFILE_PATH_EXT} ${PROFILE} PARENT_SCOPE) + endfunction() + + # extensions consistent with embedded_shader.h + function(_bgfx_get_profile_ext PROFILE PROFILE_EXT) + string(REPLACE 100_es essl PROFILE ${PROFILE}) + string(REPLACE 300_es essl PROFILE ${PROFILE}) + string(REPLACE 120 glsl PROFILE ${PROFILE}) + string(REPLACE 430 glsl PROFILE ${PROFILE}) + string(REPLACE spirv spv PROFILE ${PROFILE}) + string(REPLACE metal mtl PROFILE ${PROFILE}) + string(REPLACE s_5_0 dxbc PROFILE ${PROFILE}) + string(REPLACE s_6_0 dxil PROFILE ${PROFILE}) + set(${PROFILE_EXT} ${PROFILE} PARENT_SCOPE) + endfunction() + + # bgfx_compile_shaders( + # TYPE VERTEX|FRAGMENT|COMPUTE + # SHADERS filenames + # VARYING_DEF filename + # OUTPUT_DIR directory + # OUT_FILES_VAR variable name + # INCLUDE_DIRS directories + # DEFINES defines + # [AS_HEADERS] + # ) + # + function(bgfx_compile_shaders) + set(options AS_HEADERS) + set(oneValueArgs TYPE VARYING_DEF OUTPUT_DIR OUT_FILES_VAR) + set(multiValueArgs SHADERS INCLUDE_DIRS DEFINES) + cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}") + + set(PROFILES spirv) + if(ARGS_TYPE STREQUAL "COMPUTE") + list(APPEND PROFILES 430 300_es) + else() + list(APPEND PROFILES 120 100_es) + endif() + if(BGFX_CONFIG_RENDERER_WEBGPU) + list(APPEND PROFILES wgsl) + endif() + if(IOS) + set(PLATFORM IOS) + list(APPEND PROFILES metal) + elseif(ANDROID) + set(PLATFORM ANDROID) + elseif(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) + list(APPEND PROFILES s_5_0) + list(APPEND PROFILES s_6_0) + elseif(ORBIS) # ORBIS should be defined by a PS4 CMake toolchain + set(PLATFORM ORBIS) + list(APPEND PROFILES pssl) + else() + # pssl for Agc and Gnm renderers + # nvn for Nvn renderer + message(error "shaderc: Unsupported platform") + endif() + + set(ALL_OUTPUTS "") + 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 "") + set(MKDIR_COMMANDS "") + foreach(PROFILE ${PROFILES}) + _bgfx_get_profile_path_ext(${PROFILE} PROFILE_PATH_EXT) + _bgfx_get_profile_ext(${PROFILE} PROFILE_EXT) + if(ARGS_AS_HEADERS) + set(HEADER_PREFIX .h) + endif() + set(OUTPUT ${ARGS_OUTPUT_DIR}/${PROFILE_PATH_EXT}/${SHADER_FILE_BASENAME}.bin${HEADER_PREFIX}) + set(PLATFORM_I ${PLATFORM}) + set(BIN2C_PART "") + if(ARGS_AS_HEADERS) + set(BIN2C_PART BIN2C ${SHADER_FILE_NAME_WE}_${PROFILE_EXT}) + endif() + _bgfx_shaderc_parse( + CLI # + ${BIN2C_PART} # + ${ARGS_TYPE} ${PLATFORM_I} WERROR "$<$:DEBUG>" + FILE ${SHADER_FILE_ABSOLUTE} + OUTPUT ${OUTPUT} + PROFILE ${PROFILE} + O "$:0,3>" + VARYINGDEF ${ARGS_VARYING_DEF} + INCLUDES ${BGFX_SHADER_INCLUDE_PATH} ${ARGS_INCLUDE_DIRS} + DEFINES ${ARGS_DEFINES} + ) + list(APPEND OUTPUTS ${OUTPUT}) + list(APPEND ALL_OUTPUTS ${OUTPUT}) + list( + APPEND + MKDIR_COMMANDS + COMMAND + ${CMAKE_COMMAND} + -E + make_directory + ${ARGS_OUTPUT_DIR}/${PROFILE_PATH_EXT} + ) + list(APPEND COMMANDS COMMAND bgfx::shaderc ${CLI}) + endforeach() + + add_custom_command( + OUTPUT ${OUTPUTS} + COMMAND ${MKDIR_COMMANDS} ${COMMANDS} + MAIN_DEPENDENCY ${SHADER_FILE_ABSOLUTE} + DEPENDS ${ARGS_VARYING_DEF} + ) + endforeach() + + if(DEFINED ARGS_OUT_FILES_VAR) + set(${ARGS_OUT_FILES_VAR} ${ALL_OUTPUTS} PARENT_SCOPE) + endif() + endfunction() +endif() diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/astc_encoder.cmake b/engine/native/thirdparty/cmake/bimg/3rdparty/astc_encoder.cmake new file mode 100644 index 0000000..a215595 --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/3rdparty/astc_encoder.cmake @@ -0,0 +1,25 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}") + return() +endif() + +if(NOT ASTC_ENCODER_LIBRARIES) + file( + GLOB_RECURSE # + ASTC_ENCODER_SOURCES # + ${BIMG_DIR}/3rdparty/astc-encoder/source/*.cpp # + ${BIMG_DIR}/3rdparty/astc-encoder/source/*.h # + ) + set(ASTC_ENCODER_INCLUDE_DIR ${BIMG_DIR}/3rdparty/astc-encoder/include) +endif() diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/edtaa3.cmake b/engine/native/thirdparty/cmake/bimg/3rdparty/edtaa3.cmake new file mode 100644 index 0000000..8b24397 --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/3rdparty/edtaa3.cmake @@ -0,0 +1,25 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}") + return() +endif() + +if(NOT EDTAA3_LIBRARIES) + file( + GLOB_RECURSE # + EDTAA3_SOURCES # + ${BIMG_DIR}/3rdparty/edtaa3/**.cpp # + ${BIMG_DIR}/3rdparty/edtaa3/**.h # + ) + set(EDTAA3_INCLUDE_DIR ${BIMG_DIR}/3rdparty) +endif() diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/etc1.cmake b/engine/native/thirdparty/cmake/bimg/3rdparty/etc1.cmake new file mode 100644 index 0000000..f16eba3 --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/3rdparty/etc1.cmake @@ -0,0 +1,22 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}") + return() +endif() + +if(NOT ETC1_LIBRARIES) + file(GLOB_RECURSE ETC1_SOURCES ${BIMG_DIR}/3rdparty/etc1/**.cpp # + ${BIMG_DIR}/3rdparty/etc1/**.hpp # + ) + set(ETC1_INCLUDE_DIR ${BIMG_DIR}/3rdparty) +endif() diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/etc2.cmake b/engine/native/thirdparty/cmake/bimg/3rdparty/etc2.cmake new file mode 100644 index 0000000..41bed01 --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/3rdparty/etc2.cmake @@ -0,0 +1,25 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}") + return() +endif() + +if(NOT ETC2_LIBRARIES) + file( + GLOB_RECURSE # + ETC2_SOURCES # + ${BIMG_DIR}/3rdparty/etc2/**.cpp # + ${BIMG_DIR}/3rdparty/etc2/**.hpp # + ) + set(ETC2_INCLUDE_DIR ${BIMG_DIR}/3rdparty) +endif() diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/iqa.cmake b/engine/native/thirdparty/cmake/bimg/3rdparty/iqa.cmake new file mode 100644 index 0000000..4e1c40a --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/3rdparty/iqa.cmake @@ -0,0 +1,25 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}") + return() +endif() + +if(NOT IQA_LIBRARIES) + file( + GLOB_RECURSE # + IQA_SOURCES # + ${BIMG_DIR}/3rdparty/iqa/include/**.h # + ${BIMG_DIR}/3rdparty/iqa/source/**.c # + ) + set(IQA_INCLUDE_DIR ${BIMG_DIR}/3rdparty/iqa/include) +endif() diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/libsquish.cmake b/engine/native/thirdparty/cmake/bimg/3rdparty/libsquish.cmake new file mode 100644 index 0000000..290df63 --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/3rdparty/libsquish.cmake @@ -0,0 +1,25 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}") + return() +endif() + +if(NOT LIBSQUISH_LIBRARIES) + file( + GLOB_RECURSE # + LIBSQUISH_SOURCES # + ${BIMG_DIR}/3rdparty/libsquish/**.cpp # + ${BIMG_DIR}/3rdparty/libsquish/**.h # + ) + set(LIBSQUISH_INCLUDE_DIR ${BIMG_DIR}/3rdparty) +endif() diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/loadpng.cmake b/engine/native/thirdparty/cmake/bimg/3rdparty/loadpng.cmake new file mode 100644 index 0000000..5f99436 --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/3rdparty/loadpng.cmake @@ -0,0 +1,26 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}") + return() +endif() + +if(NOT LOADPNG_LIBRARIES) + file( + GLOB_RECURSE # + LOADPNG_SOURCES # + ${BIMG_DIR}/3rdparty/lodepng/lodepng.cpp # + ${BIMG_DIR}/3rdparty/lodepng/lodepng.h # + ) + set_source_files_properties(${BIMG_DIR}/3rdparty/lodepng/lodepng.cpp PROPERTIES HEADER_FILE_ONLY ON) + set(LOADPNG_INCLUDE_DIR ${BIMG_DIR}/3rdparty) +endif() diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/miniz.cmake b/engine/native/thirdparty/cmake/bimg/3rdparty/miniz.cmake new file mode 100644 index 0000000..20d60f1 --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/3rdparty/miniz.cmake @@ -0,0 +1,23 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}") + return() +endif() + +if(NOT MINIZ_LIBRARIES) + file(GLOB_RECURSE # + MINIZ_SOURCES # + ${BIMG_DIR}/3rdparty/tinyexr/deps/miniz/miniz.* # + ) + set(MINIZ_INCLUDE_DIR ${BIMG_DIR}/3rdparty/tinyexr/deps) +endif() diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/nvtt.cmake b/engine/native/thirdparty/cmake/bimg/3rdparty/nvtt.cmake new file mode 100644 index 0000000..26a0b76 --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/3rdparty/nvtt.cmake @@ -0,0 +1,25 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}") + return() +endif() + +if(NOT NVTT_LIBRARIES) + file( + GLOB_RECURSE # + NVTT_SOURCES # + ${BIMG_DIR}/3rdparty/nvtt/**.cpp # + ${BIMG_DIR}/3rdparty/nvtt/**.h # + ) + set(NVTT_INCLUDE_DIR ${BIMG_DIR}/3rdparty/nvtt) +endif() diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/pvrtc.cmake b/engine/native/thirdparty/cmake/bimg/3rdparty/pvrtc.cmake new file mode 100644 index 0000000..c8974ed --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/3rdparty/pvrtc.cmake @@ -0,0 +1,25 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}") + return() +endif() + +if(NOT PVRTC_LIBRARIES) + file( + GLOB_RECURSE # + PVRTC_SOURCES # + ${BIMG_DIR}/3rdparty/pvrtc/**.cpp # + ${BIMG_DIR}/3rdparty/pvrtc/**.h # + ) + set(PVRTC_INCLUDE_DIR ${BIMG_DIR}/3rdparty) +endif() diff --git a/engine/native/thirdparty/cmake/bimg/3rdparty/tinyexr.cmake b/engine/native/thirdparty/cmake/bimg/3rdparty/tinyexr.cmake new file mode 100644 index 0000000..f3cbc55 --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/3rdparty/tinyexr.cmake @@ -0,0 +1,23 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}") + return() +endif() + +if(NOT TINYEXR_LIBRARIES) + file(GLOB_RECURSE # + TINYEXR_SOURCES # + ${BIMG_DIR}/3rdparty/tinyexr/**.h # + ) + set(TINYEXR_INCLUDE_DIR ${BIMG_DIR}/3rdparty) +endif() diff --git a/engine/native/thirdparty/cmake/bimg/CMakeLists.txt b/engine/native/thirdparty/cmake/bimg/CMakeLists.txt new file mode 100644 index 0000000..200b29b --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/CMakeLists.txt @@ -0,0 +1,28 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +include(3rdparty/loadpng.cmake) +include(3rdparty/libsquish.cmake) +include(3rdparty/astc_encoder.cmake) +include(3rdparty/edtaa3.cmake) +include(3rdparty/etc1.cmake) +include(3rdparty/etc2.cmake) +include(3rdparty/nvtt.cmake) +include(3rdparty/pvrtc.cmake) +include(3rdparty/tinyexr.cmake) +include(3rdparty/iqa.cmake) +include(3rdparty/miniz.cmake) +include(bimg.cmake) +include(bimg_decode.cmake) +include(bimg_encode.cmake) + +if(BGFX_BUILD_TOOLS_TEXTURE) + include(texturec.cmake) +endif() diff --git a/engine/native/thirdparty/cmake/bimg/bimg.cmake b/engine/native/thirdparty/cmake/bimg/bimg.cmake new file mode 100644 index 0000000..6f52fe1 --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/bimg.cmake @@ -0,0 +1,57 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg, directory does not exist. ${BIMG_DIR}") + return() +endif() + +file( + GLOB_RECURSE + BIMG_SOURCES + ${BIMG_DIR}/include/* # + ${BIMG_DIR}/src/image.* # + ${BIMG_DIR}/src/image_gnf.cpp # + # + ${ASTC_ENCODER_SOURCES} + ${MINIZ_SOURCES} +) + +add_library(bimg STATIC ${BIMG_SOURCES}) + +# Put in a "bgfx" folder in Visual Studio +set_target_properties(bimg PROPERTIES FOLDER "bgfx") + +target_include_directories( + bimg PUBLIC $$ + PRIVATE ${ASTC_ENCODER_INCLUDE_DIR} # + ${MINIZ_INCLUDE_DIR} # +) + +target_link_libraries( + bimg + PUBLIC bx # + ${ASTC_ENCODER_LIBRARIES} # + ${MINIZ_LIBRARIES} # +) + +if(BGFX_INSTALL) + install( + TARGETS bimg + EXPORT "${TARGETS_EXPORT_NAME}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + INCLUDES + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + ) + install(DIRECTORY ${BIMG_DIR}/include/bimg DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") +endif() diff --git a/engine/native/thirdparty/cmake/bimg/bimg_decode.cmake b/engine/native/thirdparty/cmake/bimg/bimg_decode.cmake new file mode 100644 index 0000000..a511e8f --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/bimg_decode.cmake @@ -0,0 +1,57 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg_decode, directory does not exist. ${BIMG_DIR}") + return() +endif() + +file( + GLOB_RECURSE + BIMG_DECODE_SOURCES # + ${BIMG_DIR}/include/* # + ${BIMG_DIR}/src/image_decode.* # + # + ${LOADPNG_SOURCES} # + ${MINIZ_SOURCES} # +) + +add_library(bimg_decode STATIC ${BIMG_DECODE_SOURCES}) + +# Put in a "bgfx" folder in Visual Studio +set_target_properties(bimg_decode PROPERTIES FOLDER "bgfx") +target_include_directories( + bimg_decode + PUBLIC $ $ + PRIVATE ${LOADPNG_INCLUDE_DIR} # + ${MINIZ_INCLUDE_DIR} # + ${TINYEXR_INCLUDE_DIR} # +) + +target_link_libraries( + bimg_decode + PUBLIC bx # + ${LOADPNG_LIBRARIES} # + ${MINIZ_LIBRARIES} # + ${TINYEXR_LIBRARIES} # +) + +if(BGFX_INSTALL AND NOT BGFX_LIBRARY_TYPE MATCHES "SHARED") + install( + TARGETS bimg_decode + 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() diff --git a/engine/native/thirdparty/cmake/bimg/bimg_encode.cmake b/engine/native/thirdparty/cmake/bimg/bimg_encode.cmake new file mode 100644 index 0000000..82d9fe0 --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/bimg_encode.cmake @@ -0,0 +1,99 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Ensure the directory exists +if(NOT IS_DIRECTORY ${BIMG_DIR}) + message(SEND_ERROR "Could not load bimg_encode, directory does not exist. ${BIMG_DIR}") + return() +endif() + +add_library(bimg_encode STATIC) + +# Put in a "bgfx" folder in Visual Studio +set_target_properties(bimg_encode PROPERTIES FOLDER "bgfx") + +target_include_directories( + bimg_encode + PUBLIC $ $ + PRIVATE ${LIBSQUISH_INCLUDE_DIR} # + ${ASTC_ENCODER_INCLUDE_DIR} # + ${EDTAA3_INCLUDE_DIR} # + ${ETC1_INCLUDE_DIR} # + ${ETC2_INCLUDE_DIR} # + ${NVTT_INCLUDE_DIR} # + ${PVRTC_INCLUDE_DIR} # + ${TINYEXR_INCLUDE_DIR} # + ${IQA_INCLUDE_DIR} # + ${MINIZ_INCLUDE_DIR} # +) + +file( + GLOB_RECURSE + BIMG_ENCODE_SOURCES + ${BIMG_DIR}/include/* # + ${BIMG_DIR}/src/image_encode.* # + ${BIMG_DIR}/src/image_cubemap_filter.* # + ${LIBSQUISH_SOURCES} # + ${EDTAA3_SOURCES} # + ${ETC1_SOURCES} # + ${ETC2_SOURCES} # + ${NVTT_SOURCES} # + ${PVRTC_SOURCES} # + ${TINYEXR_SOURCES} + ${IQA_SOURCES} # +) + +target_sources(bimg_encode PRIVATE ${BIMG_ENCODE_SOURCES}) + +target_link_libraries( + bimg_encode + PUBLIC bx # + ${LIBSQUISH_LIBRARIES} # + ${ASTC_ENCODER_LIBRARIES} # + ${EDTAA3_LIBRARIES} # + ${ETC1_LIBRARIES} # + ${ETC2_LIBRARIES} # + ${NVTT_LIBRARIES} # + ${PVRTC_LIBRARIES} # + ${TINYEXR_LIBRARIES} # + ${IQA_LIBRARIES} # +) + +include(CheckCXXCompilerFlag) +foreach(flag "-Wno-implicit-fallthrough" "-Wno-shadow" "-Wno-shift-negative-value" "-Wno-undef") + check_cxx_compiler_flag(${flag} flag_supported) + if(flag_supported) + target_compile_options(bimg_encode PRIVATE ${flag}) + endif() +endforeach() + +foreach(flag "-Wno-class-memaccess" "-Wno-deprecated-copy") + check_cxx_compiler_flag(${flag} flag_supported) + if(flag_supported) + foreach(file ${BIMG_ENCODE_SOURCES}) + get_source_file_property(lang ${file} LANGUAGE) + if(lang STREQUAL "CXX") + set_source_files_properties(${file} PROPERTIES COMPILE_OPTIONS ${flag}) + endif() + endforeach() + endif() +endforeach() + +if(BGFX_INSTALL AND NOT BGFX_LIBRARY_TYPE MATCHES "SHARED") + install( + TARGETS bimg_encode + 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() diff --git a/engine/native/thirdparty/cmake/bimg/texturec.cmake b/engine/native/thirdparty/cmake/bimg/texturec.cmake new file mode 100644 index 0000000..b6f7cac --- /dev/null +++ b/engine/native/thirdparty/cmake/bimg/texturec.cmake @@ -0,0 +1,40 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Grab the texturec source files +file(GLOB_RECURSE TEXTUREC_SOURCES # + ${BIMG_DIR}/tools/texturec/*.cpp # + ${BIMG_DIR}/tools/texturec/*.h # +) + +add_executable(texturec ${TEXTUREC_SOURCES}) + +target_link_libraries(texturec PRIVATE bimg_decode bimg_encode bimg) +set_target_properties( + texturec PROPERTIES FOLDER "bgfx/tools" # + OUTPUT_NAME ${BGFX_TOOLS_PREFIX}texturec # +) + +if(BGFX_BUILD_TOOLS_TEXTURE) + add_executable(bgfx::texturec ALIAS texturec) + if(BGFX_CUSTOM_TARGETS) + add_dependencies(tools texturec) + endif() +endif() + +if(ANDROID) + target_link_libraries(texturec PRIVATE log) +elseif(IOS) + set_target_properties(texturec PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER texturec) +endif() + +if(BGFX_INSTALL) + install(TARGETS texturec EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}") +endif() diff --git a/engine/native/thirdparty/cmake/bx/CMakeLists.txt b/engine/native/thirdparty/cmake/bx/CMakeLists.txt new file mode 100644 index 0000000..2ed7e28 --- /dev/null +++ b/engine/native/thirdparty/cmake/bx/CMakeLists.txt @@ -0,0 +1,41 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +include(bx.cmake) + +if(BGFX_BUILD_TOOLS_BIN2C) + include(bin2c.cmake) +endif() + +if(BGFX_BUILD_TESTS) + 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.* # + ) + add_executable(bx_test ${BX_TEST_SOURCES}) + target_compile_definitions(bx_test PRIVATE CATCH_AMALGAMATED_CUSTOM_MAIN) + target_link_libraries(bx_test PRIVATE bx) + add_test(NAME bx.test COMMAND bx_test) + + file( + GLOB + BX_BENCH_SOURCES # + ${BX_DIR}/tests/*_bench.cpp # + ${BX_DIR}/tests/*_bench.h # + ${BX_DIR}/tests/dbg.* # + ) + add_executable(bx_bench ${BX_BENCH_SOURCES}) + target_link_libraries(bx_bench PRIVATE bx) + add_test(NAME bx.bench COMMAND bx_bench) +endif() diff --git a/engine/native/thirdparty/cmake/bx/bin2c.cmake b/engine/native/thirdparty/cmake/bx/bin2c.cmake new file mode 100644 index 0000000..3c36159 --- /dev/null +++ b/engine/native/thirdparty/cmake/bx/bin2c.cmake @@ -0,0 +1,40 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# Grab the bin2c source files +file(GLOB_RECURSE BIN2C_SOURCES # + ${BX_DIR}/tools/bin2c/*.cpp # + ${BX_DIR}/tools/bin2c/*.h # +) + +add_executable(bin2c ${BIN2C_SOURCES}) + +target_link_libraries(bin2c PRIVATE bx) +set_target_properties( + bin2c PROPERTIES FOLDER "bgfx/tools" # + OUTPUT_NAME ${BGFX_TOOLS_PREFIX}bin2c # +) + +if(BGFX_BUILD_TOOLS_BIN2C) + add_executable(bgfx::bin2c ALIAS bin2c) + if(BGFX_CUSTOM_TARGETS) + add_dependencies(tools bin2c) + endif() +endif() + +if(ANDROID) + target_link_libraries(bin2c PRIVATE log) +elseif(IOS) + set_target_properties(bin2c PROPERTIES MACOSX_BUNDLE ON MACOSX_BUNDLE_GUI_IDENTIFIER bin2c) +endif() + +if(BGFX_INSTALL) + install(TARGETS bin2c EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${CMAKE_INSTALL_BINDIR}") +endif() diff --git a/engine/native/thirdparty/cmake/bx/bx.cmake b/engine/native/thirdparty/cmake/bx/bx.cmake new file mode 100644 index 0000000..bbca9e5 --- /dev/null +++ b/engine/native/thirdparty/cmake/bx/bx.cmake @@ -0,0 +1,143 @@ +# bgfx.cmake - bgfx building in cmake +# Written in 2017 by Joshua Brookover +# +# 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 . + +# 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) + +# 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_library(bx STATIC ${BX_SOURCES}) + +if(MSVC) + target_compile_options(bx PRIVATE /EHs-c-) + target_compile_definitions(bx PRIVATE _HAS_EXCEPTIONS=0) +endif() + +# 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 $ # + $ # + $ # + $ # + $ # +) + +# All configurations +target_compile_definitions(bx PUBLIC "BX_CONFIG_DEBUG=$,1,$>") +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 $<$:/Zc:__cplusplus /Zc:preprocessor>) + +# 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") + +if(BGFX_INSTALL) + install( + TARGETS bx + EXPORT "${TARGETS_EXPORT_NAME}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ) + # We will make sure tinystl and compat are not installed in /usr/include + install(DIRECTORY "${BX_DIR}/include/bx" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + install(DIRECTORY "${BX_DIR}/include/compat/${BX_COMPAT_PLATFORM}" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bx/compat" + ) + install(DIRECTORY "${BX_DIR}/include/tinystl" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bx") +endif() diff --git a/engine/native/thirdparty/cmake/version.cmake b/engine/native/thirdparty/cmake/version.cmake new file mode 100644 index 0000000..43d1573 --- /dev/null +++ b/engine/native/thirdparty/cmake/version.cmake @@ -0,0 +1,40 @@ +# bgfx versioning scheme: +# bgfx 1.104.7082 +# ^ ^^^ ^^^^ +# | | +--- Commit number (https://github.com/bkaradzic/bgfx / git rev-list --count HEAD) +# | +------- API version (from https://github.com/bkaradzic/bgfx/blob/master/scripts/bgfx.idl#L4) +# +--------- Major revision (always 1) +# +# BGFX_API_VERSION generated from https://github.com/bkaradzic/bgfx/blob/master/scripts/bgfx.idl#L4 +# bgfx/src/version.h: +# BGFX_REV_NUMBER +# BGFX_REV_SHA1 + +find_package(Git QUIET) + +execute_process( + COMMAND "${GIT_EXECUTABLE}" -C bgfx log --pretty=format:'%h' -n 1 + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE GIT_REV + ERROR_QUIET +) + +execute_process( + COMMAND "${GIT_EXECUTABLE}" -C bgfx rev-list --count HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE GIT_REV_COUNT + OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET +) + +# read version(100) from bgfx.idl +file(READ "${BGFX_DIR}/scripts/bgfx.idl" BGFX_IDL) +string(REGEX MATCH "version\\(([^\)]+)\\)" BGFX_API_VERSION ${BGFX_IDL}) +set(BGFX_API_VERSION ${CMAKE_MATCH_1}) +set(BGFX_REV_NUMBER ${GIT_REV_COUNT}) +set(BGFX_REV ${GIT_REV}) + +# set project specific versions +set(PROJECT_VERSION 1.${BGFX_API_VERSION}.${BGFX_REV_NUMBER}) +set(PROJECT_VERSION_MAJOR 1) +set(PROJECT_VERSION_MINOR ${BGFX_API_VERSION}) +set(PROJECT_VERSION_PATCH ${BGFX_REV_NUMBER})