bkaradzic / bgfx.cmake

CMake build scripts for bgfx. Released under public domain.
Creative Commons Zero v1.0 Universal
210 stars 111 forks source link

ew option to allow "example-common" project to not be included in build. #225

Closed JimmyLord closed 6 months ago

JimmyLord commented 7 months ago

I added a new option BGFX_BUILD_EXAMPLE_COMMON to allow users to opt out of the example-common project from being added to their solutions. It defaults to On to match the default for BGFX_BUILD_EXAMPLES which relies on it.

I created a new option to allow users to continue to use example-common in their project without adding the rest of the examples and to preserve the existing behaviour.

Fixes #224

bwrsandman commented 6 months ago

Thanks for your PR. It's missing one piece though. Example common is used in the tools (geometryc, geometryv, shaderc, texturev) etc.

I would really like to see this as a cmake_dependent_option too.

JimmyLord commented 6 months ago

I took another look and changed the code to:

cmake_dependent_option(BGFX_BUILD_EXAMPLE_COMMON "Build bgfx example-common project." ON "NOT BGFX_BUILD_EXAMPLES;NOT BGFX_BUILD_TOOLS" ON)

Ideally, that first "ON" should be an "OFF", so if both the examples and tools were off the common project would also be off, but that would change the old behaviour. So, at the moment, people still need to explicitly disable example-common.

Which do you think is the better default?

bwrsandman commented 6 months ago

Makes sense to only compile what's needed. I think ideally, there shouldn't be an option and cmake should figure it out. Have you considered using EXCLUDE_FROM_ALL?

JimmyLord commented 6 months ago

Okay, I set it up as a dependent option that only includes example-common if either the tools or examples projects are included in the build.

This produces a minimum set of projects in the solution if those options are disabled.

bwrsandman commented 6 months ago

EXCLUDE_FROM_ALL doesn't do this for you?

JimmyLord commented 6 months ago

Thanks, since I use visual studio for development, I can work around the issue with EXCLUDE_FROM_DEFAULT_BUILD instead, it's more or less the same option.

Even with this, I still end up with an extra project in the solution that isn't needed. It's not a big deal, but it clutters searches and file opening with files that aren't in use in the project.

bwrsandman commented 6 months ago

I see what you mean.