Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Support granular selection of tools to build #60

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 37 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@ if( APPLE AND NOT IOS )
set( CMAKE_CXX_FLAGS "-ObjC++" )
endif()

option( BGFX_BUILD_TOOLS "Build bgfx tools." ON )
option( BGFX_BUILD_EXAMPLES "Build bgfx examples." ON )
option( BGFX_INSTALL "Create installation target." ON )
option( BGFX_INSTALL_EXAMPLES "Install examples and their runtimes." OFF )
option( BGFX_CUSTOM_TARGETS "Include convenience custom targets." ON )
option( BGFX_USE_OVR "Build with OVR support." OFF )
option( BGFX_AMALGAMATED "Amalgamated bgfx build for faster compilation" OFF )
option( BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF )
option( BGFX_CONFIG_DEBUG "Enables debug configuration on all builds" OFF )
option( BGFX_USE_DEBUG_SUFFIX "Add 'd' suffix to debug output targets" ON )
# Disable BGFX_BUILD_TOOLS in order to specify specific tools to build.
option( BGFX_BUILD_TOOLS "Build all bgfx tools (overwrites all)." ON )
option( BGFX_BUILD_TOOL_TEXTUREV "Build bgfx tool: texturev" ${BGFX_BUILD_TOOLS} )
option( BGFX_BUILD_TOOL_TEXTUREC "Build bgfx tool: texturec" ${BGFX_BUILD_TOOLS} )
option( BGFX_BUILD_TOOL_SHADERC "Build bgfx tool: shaderc" ${BGFX_BUILD_TOOLS} )
option( BGFX_BUILD_TOOL_GEOMETRYC "Build bgfx tool: geometryc" ${BGFX_BUILD_TOOLS} )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the idiomatic thing to do here is using cmake_dependent_option:

cmake_dependent_option(BGFX_BUILD_TOOL_TEXTUREV "Build bgfx tool: texturev" ON
                       "BGFX_BUILD_TOOLS" OFF)
cmake_dependent_option(BGFX_BUILD_TOOL_TEXTUREC "Build bgfx tool: texturec" ON
                       "BGFX_BUILD_TOOLS" OFF)
cmake_dependent_option(BGFX_BUILD_TOOL_SHADERC "Build bgfx tool: shaderc" ON
                       "BGFX_BUILD_TOOLS" OFF)
cmake_dependent_option(BGFX_BUILD_TOOL_GEOMETRYC "Build bgfx tool: geometryc" ON
                       "BGFX_BUILD_TOOLS" OFF)

https://cmake.org/cmake/help/v3.15/module/CMakeDependentOption.html#module:CMakeDependentOption

Copy link
Author

@Qix- Qix- Jan 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd have to bump the minimum CMake version in order to use that. If @JoshuaBrookover is okay with that, then this is indeed the correct way to do this.

Disregard.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's supported by CMake 3.0 as well, no reason to bump version

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @pezcode.

option( BGFX_BUILD_EXAMPLES "Build bgfx examples." ON )
option( BGFX_INSTALL "Create installation target." ON )
option( BGFX_INSTALL_EXAMPLES "Install examples and their runtimes." OFF )
option( BGFX_CUSTOM_TARGETS "Include convenience custom targets." ON )
option( BGFX_USE_OVR "Build with OVR support." OFF )
option( BGFX_AMALGAMATED "Amalgamated bgfx build for faster compilation" OFF )
option( BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF )
option( BGFX_CONFIG_DEBUG "Enables debug configuration on all builds" OFF )
option( BGFX_USE_DEBUG_SUFFIX "Add 'd' suffix to debug output targets" ON )
set( BGFX_OPENGL_VERSION "" CACHE STRING "Specify minimum opengl version" )

if( NOT BX_DIR )
Expand Down Expand Up @@ -57,11 +62,30 @@ include( cmake/bx.cmake )
include( cmake/bimg.cmake )
include( cmake/bgfx.cmake )

if( BGFX_BUILD_TOOLS )
include( cmake/tools.cmake )
if( BGFX_CUSTOM_TARGETS )
add_custom_target( tools )

This comment was marked as resolved.

This comment was marked as resolved.

set_target_properties( tools PROPERTIES FOLDER "bgfx/tools" )
endif()

include( cmake/examples.cmake )
if( BGFX_BUILD_TOOL_GEOMETRYC )
include( cmake/tools/geometryc.cmake )
endif()

if( BGFX_BUILD_TOOL_SHADERC )
include( cmake/tools/shaderc.cmake )
endif()

if( BGFX_BUILD_TOOL_TEXTUREC )
include( cmake/tools/texturec.cmake )
endif()

if( BGFX_BUILD_TOOL_TEXTUREV )
include( cmake/tools/texturev.cmake )
endif()

if( BGFX_BUILD_EXAMPLES )
include( cmake/examples.cmake )
endif()

if( BGFX_INSTALL )
include(GNUInstallDirs)
Expand Down
19 changes: 0 additions & 19 deletions cmake/tools.cmake

This file was deleted.