bgfx: Move example to bgfx and split off imgui

This commit is contained in:
Sandy Carter
2023-01-14 22:30:59 -05:00
committed by Sandy
parent 8d130b923d
commit 10501b78f4
7 changed files with 49 additions and 40 deletions

View File

@@ -1,23 +0,0 @@
# bgfx.cmake - bgfx building in cmake
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along with
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
if(TARGET dear-imgui)
return()
endif()
file(GLOB dear_IMGUI_SOURCES ${BGFX_DIR}/3rdparty/dear-imgui/*.cpp ${BGFX_DIR}/3rdparty/dear-imgui/*.h
${BGFX_DIR}/3rdparty/dear-imgui/*.inl
)
add_library(dear-imgui STATIC EXCLUDE_FROM_ALL ${dear_IMGUI_SOURCES})
target_compile_definitions(dear-imgui PRIVATE "-D_CRT_SECURE_NO_WARNINGS" "-D__STDC_FORMAT_MACROS")
target_include_directories(dear-imgui PUBLIC ${BGFX_DIR}/3rdparty)
target_link_libraries(dear-imgui PUBLIC bx)
set_target_properties(dear-imgui PROPERTIES FOLDER "bgfx/3rdparty" PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}bgfx-")

26
cmake/bgfx/3rdparty/dear-imgui.cmake vendored Normal file
View File

@@ -0,0 +1,26 @@
# bgfx.cmake - bgfx building in cmake
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty.
#
# You should have received a copy of the CC0 Public Domain Dedication along with
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
# 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()

View File

@@ -10,15 +10,16 @@
# Ensure the directory exists
if(NOT IS_DIRECTORY ${BGFX_DIR})
message(SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}")
return()
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)
file(
GLOB #
MESHOPTIMIZER_SOURCES #
${BGFX_DIR}/3rdparty/meshoptimizer/src/*.cpp #
${BGFX_DIR}/3rdparty/meshoptimizer/src/*.h #
)
set(MESHOPTIMIZER_INCLUDE_DIR ${BGFX_DIR}/3rdparty)
endif()

View File

@@ -10,6 +10,9 @@
include(bgfx.cmake)
include(3rdparty/meshoptimizer.cmake)
include(3rdparty/dear-imgui.cmake)
include(examples.cmake)
if(BGFX_BUILD_TOOLS_TEXTURE)
include(texturev.cmake)

View File

@@ -12,8 +12,7 @@ include(CMakeParseArguments)
include(${CMAKE_CURRENT_LIST_DIR}/util/ConfigureDebugging.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/dear-imgui.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../bgfxToolUtils.cmake)
function(add_bgfx_shader FILE FOLDER)
get_filename_component(FILENAME "${FILE}" NAME_WE)
@@ -143,9 +142,16 @@ function(add_example ARG_NAME)
# Add target
if(ARG_COMMON)
add_library(example-${ARG_NAME} STATIC EXCLUDE_FROM_ALL ${SOURCES} ${MESHOPTIMIZER_SOURCES})
target_include_directories(example-${ARG_NAME} PUBLIC ${BGFX_DIR}/examples/common ${MESHOPTIMIZER_INCLUDE_DIR})
target_link_libraries(example-${ARG_NAME} PUBLIC bgfx bx bimg bimg_decode dear-imgui ${MESHOPTIMIZER_LIBRARIES})
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_GLFW)
find_package(glfw3 REQUIRED)
target_link_libraries(example-${ARG_NAME} PUBLIC glfw)