From 5ee179c940903faa98d28d86cf5c56eba1decb1d Mon Sep 17 00:00:00 2001 From: Joshua Brookover Date: Thu, 22 Jun 2017 21:50:36 -0500 Subject: [PATCH] Added BGFX_INSTALL_EXAMPLES --- CMakeLists.txt | 23 +++++++++---- cmake/examples.cmake | 81 +++++++++++++++++++++++++------------------- 2 files changed, 62 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3d97a7..6a0e13a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,13 +19,14 @@ elseif(UNIX) set(CMAKE_CXX_STANDARD_REQUIRED ON) 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_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_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 ) if( NOT BX_DIR ) set( BX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bx" CACHE STRING "Location of bx." ) @@ -72,4 +73,12 @@ if( BGFX_INSTALL ) install( TARGETS shaderc DESTINATION bin ) install( TARGETS geometryc DESTINATION bin ) endif() + + # install examples + if( BGFX_BUILD_EXAMPLES AND BGFX_INSTALL_EXAMPLES ) + install( DIRECTORY ${BGFX_DIR}/examples/runtime/ DESTINATION examples ) + foreach( EXAMPLE ${BGFX_EXAMPLES} ) + install( TARGETS example-${EXAMPLE} DESTINATION examples ) + endforeach() + endif() endif() diff --git a/cmake/examples.cmake b/cmake/examples.cmake index 158dea8..8e2ed38 100755 --- a/cmake/examples.cmake +++ b/cmake/examples.cmake @@ -110,7 +110,11 @@ function( add_example ARG_NAME ) target_link_libraries( example-${ARG_NAME} PUBLIC X11 ) endif() else() - add_executable( example-${ARG_NAME} WIN32 EXCLUDE_FROM_ALL ${SOURCES} ) + if( BGFX_INSTALL_EXAMPLES ) + add_executable( example-${ARG_NAME} WIN32 ${SOURCES} ) + else() + add_executable( example-${ARG_NAME} WIN32 EXCLUDE_FROM_ALL ${SOURCES} ) + endif() target_compile_definitions( example-${ARG_NAME} PRIVATE "-D_CRT_SECURE_NO_WARNINGS" "-D__STDC_FORMAT_MACROS" ) target_link_libraries( example-${ARG_NAME} example-common ) configure_debugging( example-${ARG_NAME} WORKING_DIR ${BGFX_DIR}/examples/runtime ) @@ -154,37 +158,44 @@ add_example( ) # Add examples -add_example( 00-helloworld ) -add_example( 01-cubes ) -add_example( 02-metaballs ) -add_example( 03-raymarch ) -add_example( 04-mesh ) -add_example( 05-instancing ) -add_example( 06-bump ) -add_example( 07-callback ) -add_example( 08-update ) -add_example( 09-hdr ) -add_example( 10-font ) -add_example( 11-fontsdf ) -add_example( 12-lod ) -add_example( 13-stencil ) -add_example( 14-shadowvolumes ) -add_example( 15-shadowmaps-simple ) -add_example( 16-shadowmaps ) -add_example( 17-drawstress ) -add_example( 18-ibl ) -add_example( 19-oit ) -add_example( 20-nanovg ) -add_example( 21-deferred ) -add_example( 22-windows ) -add_example( 23-vectordisplay ) -add_example( 24-nbody ) -add_example( 25-c99 ) -add_example( 26-occlusion ) -add_example( 27-terrain ) -add_example( 28-wireframe ) -add_example( 29-debugdraw ) -add_example( 30-picking ) -add_example( 31-rsm ) -add_example( 32-particles ) -add_example( 33-pom ) +set( + BGFX_EXAMPLES + 00-helloworld + 01-cubes + 02-metaballs + 03-raymarch + 04-mesh + 05-instancing + 06-bump + 07-callback + 08-update + 09-hdr + 10-font + 11-fontsdf + 12-lod + 13-stencil + 14-shadowvolumes + 15-shadowmaps-simple + 16-shadowmaps + 17-drawstress + 18-ibl + 19-oit + 20-nanovg + 21-deferred + 22-windows + 23-vectordisplay + 24-nbody + 25-c99 + 26-occlusion + 27-terrain + 28-wireframe + 29-debugdraw + 30-picking + 31-rsm + 32-particles + 33-pom +) + +foreach( EXAMPLE ${BGFX_EXAMPLES} ) + add_example( ${EXAMPLE} ) +endforeach()