diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f55e36..aa60b27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,10 +108,6 @@ if(BGFX_BUILD_TOOLS) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/tools.cmake) endif() -if(BGFX_BUILD_TOOLS OR BGFX_BUILD_EXAMPLES) - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/examples.cmake) -endif() - if(BGFX_INSTALL) include(GNUInstallDirs) diff --git a/cmake/3rdparty/dear-imgui.cmake b/cmake/3rdparty/dear-imgui.cmake deleted file mode 100644 index 7f0c7dc..0000000 --- a/cmake/3rdparty/dear-imgui.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# 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 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-") diff --git a/cmake/bgfx/3rdparty/dear-imgui.cmake b/cmake/bgfx/3rdparty/dear-imgui.cmake new file mode 100644 index 0000000..baaa9fd --- /dev/null +++ b/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/cmake/bgfx/3rdparty/meshoptimizer.cmake b/cmake/bgfx/3rdparty/meshoptimizer.cmake index 27bf0ba..d6283af 100644 --- a/cmake/bgfx/3rdparty/meshoptimizer.cmake +++ b/cmake/bgfx/3rdparty/meshoptimizer.cmake @@ -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() diff --git a/cmake/bgfx/CMakeLists.txt b/cmake/bgfx/CMakeLists.txt index eeb6964..56f857d 100644 --- a/cmake/bgfx/CMakeLists.txt +++ b/cmake/bgfx/CMakeLists.txt @@ -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) diff --git a/cmake/examples.cmake b/cmake/bgfx/examples.cmake similarity index 95% rename from cmake/examples.cmake rename to cmake/bgfx/examples.cmake index f069126..39faa53 100755 --- a/cmake/examples.cmake +++ b/cmake/bgfx/examples.cmake @@ -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) diff --git a/cmake/util/ConfigureDebugging.cmake b/cmake/bgfx/util/ConfigureDebugging.cmake similarity index 100% rename from cmake/util/ConfigureDebugging.cmake rename to cmake/bgfx/util/ConfigureDebugging.cmake