From d7f59648a82fdc09ed843350eaafec1b1933f7a1 Mon Sep 17 00:00:00 2001 From: Jimmy Lord Date: Sat, 18 May 2024 20:42:20 -0400 Subject: [PATCH] ew option to allow "example-common" project to not be included in build. (#225) * Added a new option to allow "example-common" project to not be included in build. * Set BGFX_BUILD_EXAMPLE_COMMON as a dependent option, it will be set ON if either tools or examples are included in the build, OFF otherwise. * cmake format Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: Sandy Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CMakeLists.txt | 4 ++++ cmake/bgfx/examples.cmake | 24 +++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 78c5edfe..ea5eb339 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,10 @@ cmake_dependent_option(BGFX_BUILD_TOOLS_GEOMETRY "Build bgfx geometry tools." ON cmake_dependent_option(BGFX_BUILD_TOOLS_TEXTURE "Build bgfx texture tools." ON BGFX_BUILD_TOOLS OFF) set(BGFX_TOOLS_PREFIX "" CACHE STRING "Prefix name to add to name of tools (to avoid clashes)") option(BGFX_BUILD_EXAMPLES "Build bgfx examples." ON) +cmake_dependent_option( + BGFX_BUILD_EXAMPLE_COMMON "Build bgfx example-common project." OFF "NOT BGFX_BUILD_EXAMPLES;NOT BGFX_BUILD_TOOLS" + ON +) option(BGFX_BUILD_TESTS "Build bgfx tests." OFF) option(BGFX_INSTALL "Create installation target." ON) cmake_dependent_option( diff --git a/cmake/bgfx/examples.cmake b/cmake/bgfx/examples.cmake index fcb61856..0c66fa2f 100755 --- a/cmake/bgfx/examples.cmake +++ b/cmake/bgfx/examples.cmake @@ -263,17 +263,19 @@ if(BGFX_CUSTOM_TARGETS) endif() # Add common library for examples -add_example( - common - COMMON - DIRECTORIES - ${BGFX_DIR}/examples/common/debugdraw - ${BGFX_DIR}/examples/common/entry - ${BGFX_DIR}/examples/common/font - ${BGFX_DIR}/examples/common/imgui - ${BGFX_DIR}/examples/common/nanovg - ${BGFX_DIR}/examples/common/ps -) +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)