Added BGFX_CUSTOM_TARGETS and BGFX_AMALGAMATED

Custom targets can be annoying if you have a tools or examples target.
Amalgamated builds are now defaulted to off to ensure useful debugging
info.
This commit is contained in:
Joshua Brookover
2017-03-29 22:10:51 -05:00
parent 4966244011
commit 2f42712efd
6 changed files with 31 additions and 11 deletions

View File

@@ -22,8 +22,10 @@ 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( BX_AMALGAMATED "Amalgamate bx source files for faster compilation" ON )
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." )

View File

@@ -16,6 +16,15 @@ endif()
# Grab the bgfx source files
file( GLOB BGFX_SOURCES ${BGFX_DIR}/src/*.cpp ${BGFX_DIR}/src/*.mm ${BGFX_DIR}/src/*.h ${BGFX_DIR}/include/bgfx/*.h ${BGFX_DIR}/include/bgfx/c99/*.h )
if(BGFX_AMALGAMATED)
set(BGFX_NOBUILD ${BGFX_SOURCES})
list(REMOVE_ITEM BGFX_NOBUILD ${BGFX_DIR}/src/amalgamated.cpp)
foreach(BGFX_SRC ${BGFX_NOBUILD})
set_source_files_properties( ${BGFX_SRC} PROPERTIES HEADER_FILE_ONLY ON )
endforeach()
else()
set_source_files_properties( ${BGFX_DIR}/src/amalgamated.cpp PROPERTIES HEADER_FILE_ONLY ON )
endif()
# Create the bgfx target
add_library( bgfx STATIC ${BGFX_SOURCES} )
@@ -56,7 +65,6 @@ if( UNIX AND NOT APPLE )
endif()
# Excluded files from compilation
set_source_files_properties( ${BGFX_DIR}/src/amalgamated.cpp PROPERTIES HEADER_FILE_ONLY ON )
set_source_files_properties( ${BGFX_DIR}/src/amalgamated.mm PROPERTIES HEADER_FILE_ONLY ON )
set_source_files_properties( ${BGFX_DIR}/src/glcontext_ppapi.cpp PROPERTIES HEADER_FILE_ONLY ON )
set_source_files_properties( ${BGFX_DIR}/src/glcontext_egl.cpp PROPERTIES HEADER_FILE_ONLY ON )

View File

@@ -117,8 +117,10 @@ function( add_example ARG_NAME )
if( MSVC )
set_target_properties( example-${ARG_NAME} PROPERTIES LINK_FLAGS "/ENTRY:\"mainCRTStartup\"" )
endif()
if( BGFX_CUSTOM_TARGETS )
add_dependencies( examples example-${ARG_NAME} )
endif()
endif()
# Configure shaders
if( NOT ARG_COMMON )
@@ -133,7 +135,9 @@ function( add_example ARG_NAME )
endfunction()
# Build all examples target
add_custom_target( examples )
if( BGFX_CUSTOM_TARGETS )
add_custom_target( examples )
endif()
# Add common library for examples
add_example(

View File

@@ -8,7 +8,9 @@
# You should have received a copy of the CC0 Public Domain Dedication along with
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
add_custom_target( tools )
if( BGFX_CUSTOM_TARGETS )
add_custom_target( tools )
endif()
include( cmake/tools/geometryc.cmake )
include( cmake/tools/shaderc.cmake )

View File

@@ -17,4 +17,6 @@ add_executable( geometryc ${BGFX_DIR}/tools/geometryc/geometryc.cpp )
target_compile_definitions( geometryc PRIVATE "-D_CRT_SECURE_NO_WARNINGS" )
set_target_properties( geometryc PROPERTIES FOLDER "bgfx/tools" )
target_link_libraries( geometryc bx bgfx-bounds bgfx-vertexdecl forsyth-too ib-compress )
add_dependencies( tools geometryc )
if( BGFX_CUSTOM_TARGETS )
add_dependencies( tools geometryc )
endif()

View File

@@ -18,7 +18,9 @@ add_executable( shaderc ${BGFX_DIR}/tools/shaderc/shaderc.cpp ${BGFX_DIR}/tools/
target_compile_definitions( shaderc PRIVATE "-D_CRT_SECURE_NO_WARNINGS" )
set_target_properties( shaderc PROPERTIES FOLDER "bgfx/tools" )
target_link_libraries( shaderc bx bgfx-vertexdecl bgfx-shader-spirv fcpp glsl-optimizer glslang )
add_dependencies( tools shaderc )
if( BGFX_CUSTOM_TARGETS )
add_dependencies( tools shaderc )
endif()
function( add_shader ARG_FILE )
# Parse arguments