Cleanup and added BGFX_CONFIG_DEBUG=1 for Debug configuration

This commit is contained in:
Joshua Brookover
2016-09-15 20:17:27 -05:00
parent 9d2b302598
commit 12f5519ce1
3 changed files with 31 additions and 2 deletions

View File

@@ -34,7 +34,7 @@ if( MSVC )
endif()
set_target_properties( mesa PROPERTIES FOLDER "bgfx/3rdparty" )
# glsl_optimizer
# glsl-optimizer
file( GLOB GLSL-OPTIMIZER_SOURCES ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/*.cpp ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/*.c )
file( GLOB GLSL-OPTIMIZER_SOURCES_REMOVE ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/main.cpp ${BGFX_DIR}/3rdparty/glsl-optimizer/src/glsl/builtin_stubs.cpp )
list( REMOVE_ITEM GLSL-OPTIMIZER_SOURCES ${GLSL-OPTIMIZER_SOURCES_REMOVE} )

View File

@@ -8,27 +8,44 @@
# 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/>.
# The bgfx location is customizable via cache variable BGFX_DIR
if( NOT BGFX_DIR )
set( BGFX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bgfx" CACHE STRING "Location of bgfx." )
endif()
# Ensure the directory exists
if( NOT IS_DIRECTORY ${BGFX_DIR} )
message( SEND_ERROR "Could not load bgfx, directory does not exist. ${BGFX_DIR}" )
return()
endif()
# Grab the bgfx source files
file( GLOB BGFX_SOURCES ${BGFX_DIR}/src/*.cpp ${BGFX_DIR}/src/*.mm ${BGFX_DIR}/src/*.h )
# Create the bgfx target
add_library( bgfx STATIC ${BGFX_SOURCES} )
# Enable BGFX_CONFIG_DEBUG in Debug configuration
target_compile_definitions( bgfx PRIVATE "$<$<CONFIG:Debug>:BGFX_CONFIG_DEBUG=1>" )
# Special Visual Studio Flags
if( MSVC )
target_compile_definitions( bgfx PRIVATE "-D_CRT_SECURE_NO_WARNINGS" )
target_compile_definitions( bgfx PRIVATE "_CRT_SECURE_NO_WARNINGS" )
endif()
# Includes
target_include_directories( bgfx PRIVATE ${BGFX_DIR}/3rdparty ${BGFX_DIR}/3rdparty/dxsdk/include ${BGFX_DIR}/3rdparty/khronos )
target_include_directories( bgfx PUBLIC ${BGFX_DIR}/include )
# bgfx depends on bx
target_link_libraries( bgfx PUBLIC bx )
# Link against psapi in Visual Studio
if( MSVC )
target_link_libraries( bgfx PUBLIC psapi )
endif()
# Frameworks required on OS X
if( APPLE )
find_library( CARBON_LIBRARY Carbon )
find_library( COCOA_LIBRARY Cocoa )
@@ -40,15 +57,21 @@ if( APPLE )
mark_as_advanced( QUARTZCORE_LIBRARY )
target_link_libraries( bgfx PUBLIC ${CARBON_LIBRARY} ${COCOA_LIBRARY} ${METAL_LIBRARY} ${QUARTZCORE_LIBRARY} )
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/hmd_ovr.cpp 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_glx.cpp PROPERTIES HEADER_FILE_ONLY ON )
set_source_files_properties( ${BGFX_DIR}/src/glcontext_egl.cpp PROPERTIES HEADER_FILE_ONLY ON )
# Exclude mm files if not on OS X
if( NOT APPLE )
set_source_files_properties( ${BGFX_DIR}/src/glcontext_eagl.mm PROPERTIES HEADER_FILE_ONLY ON )
set_source_files_properties( ${BGFX_DIR}/src/glcontext_nsgl.mm PROPERTIES HEADER_FILE_ONLY ON )
set_source_files_properties( ${BGFX_DIR}/src/renderer_mtl.mm PROPERTIES HEADER_FILE_ONLY ON )
endif()
# Put in a "bgfx" folder in Visual Studio
set_target_properties( bgfx PROPERTIES FOLDER "bgfx" )

View File

@@ -8,21 +8,27 @@
# 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/>.
# The bx location is customizable via cache variable BX_DIR
if( NOT BX_DIR )
set( BX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bx" CACHE STRING "Location of bgfx." )
endif()
# Ensure the directory exists
if( NOT IS_DIRECTORY ${BX_DIR} )
message( SEND_ERROR "Could not load bx, directory does not exist. ${BX_DIR}" )
return()
endif()
# Create the bx target
add_library( bx INTERFACE )
# Add include directory of bx
target_include_directories( bx INTERFACE ${BX_DIR}/include )
# Build system specific configurations
if( MSVC )
target_include_directories( bx INTERFACE ${BX_DIR}/include/compat/msvc )
target_compile_definitions( bx INTERFACE "__STDC_FORMAT_MACROS" )
elseif( MINGW )
target_include_directories( bx INTERFACE ${BX_DIR}/include/compat/mingw )
elseif( APPLE )