diff --git a/cmake/3rdparty/glsl-optimizer.cmake b/cmake/3rdparty/glsl-optimizer.cmake
index c537e72..6e5f8fe 100755
--- a/cmake/3rdparty/glsl-optimizer.cmake
+++ b/cmake/3rdparty/glsl-optimizer.cmake
@@ -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} )
diff --git a/cmake/bgfx.cmake b/cmake/bgfx.cmake
index f562169..3665a32 100755
--- a/cmake/bgfx.cmake
+++ b/cmake/bgfx.cmake
@@ -8,27 +8,44 @@
# You should have received a copy of the CC0 Public Domain Dedication along with
# this software. If not, see .
+# 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 "$<$: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" )
diff --git a/cmake/bx.cmake b/cmake/bx.cmake
index 73f4071..2349de1 100644
--- a/cmake/bx.cmake
+++ b/cmake/bx.cmake
@@ -8,21 +8,27 @@
# You should have received a copy of the CC0 Public Domain Dedication along with
# this software. If not, see .
+# 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 )