mirror of
https://github.com/bkaradzic/bgfx.cmake.git
synced 2026-02-17 21:12:35 +01:00
Improved Linux support
This commit is contained in:
@@ -51,11 +51,14 @@ if( APPLE )
|
||||
target_link_libraries( bgfx PUBLIC ${COCOA_LIBRARY} ${METAL_LIBRARY} ${QUARTZCORE_LIBRARY} )
|
||||
endif()
|
||||
|
||||
if( UNIX )
|
||||
target_link_libraries( bgfx PUBLIC GL )
|
||||
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_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
|
||||
@@ -65,6 +68,11 @@ if( NOT APPLE )
|
||||
set_source_files_properties( ${BGFX_DIR}/src/renderer_mtl.mm PROPERTIES HEADER_FILE_ONLY ON )
|
||||
endif()
|
||||
|
||||
# Exclude glx context on non-unix
|
||||
if( NOT UNIX )
|
||||
set_source_files_properties( ${BGFX_DIR}/src/glcontext_glx.cpp PROPERTIES HEADER_FILE_ONLY ON )
|
||||
endif()
|
||||
|
||||
# Put in a "bgfx" folder in Visual Studio
|
||||
set_target_properties( bgfx PROPERTIES FOLDER "bgfx" )
|
||||
|
||||
|
||||
@@ -38,5 +38,11 @@ elseif( APPLE )
|
||||
target_include_directories( bx PUBLIC ${BX_DIR}/include/compat/osx )
|
||||
endif()
|
||||
|
||||
# Threads
|
||||
if( UNIX )
|
||||
find_package( Threads )
|
||||
target_link_libraries( bx ${CMAKE_THREAD_LIBS_INIT} dl )
|
||||
endif()
|
||||
|
||||
# Put in a "bgfx" folder in Visual Studio
|
||||
set_target_properties( bx PROPERTIES FOLDER "bgfx" )
|
||||
|
||||
@@ -66,6 +66,8 @@ function( add_bgfx_shader FILE FOLDER )
|
||||
foreach( OUT ${OUTPUTS} )
|
||||
list( APPEND OUTPUT_FILES ${${OUT}_OUTPUT} )
|
||||
list( APPEND COMMANDS COMMAND "$<TARGET_FILE:shaderc>" ${${OUT}} )
|
||||
get_filename_component( OUT_DIR ${${OUT}_OUTPUT} DIRECTORY )
|
||||
file( MAKE_DIRECTORY ${OUT_DIR} )
|
||||
endforeach()
|
||||
file( RELATIVE_PATH PRINT_NAME ${BGFX_DIR}/examples ${FILE} )
|
||||
add_custom_command(
|
||||
@@ -104,6 +106,9 @@ function( add_example ARG_NAME )
|
||||
target_compile_definitions( example-${ARG_NAME} PRIVATE "-D_CRT_SECURE_NO_WARNINGS" "-D__STDC_FORMAT_MACROS" )
|
||||
target_include_directories( example-${ARG_NAME} PUBLIC ${BGFX_DIR}/examples/common )
|
||||
target_link_libraries( example-${ARG_NAME} PUBLIC bgfx ib-compress ocornut-imgui )
|
||||
if( UNIX )
|
||||
target_link_libraries( example-${ARG_NAME} PUBLIC X11 )
|
||||
endif()
|
||||
else()
|
||||
add_executable( example-${ARG_NAME} WIN32 EXCLUDE_FROM_ALL ${SOURCES} )
|
||||
target_compile_definitions( example-${ARG_NAME} PRIVATE "-D_CRT_SECURE_NO_WARNINGS" "-D__STDC_FORMAT_MACROS" )
|
||||
|
||||
@@ -14,13 +14,10 @@ include( cmake/3rdparty/fcpp.cmake )
|
||||
include( cmake/3rdparty/glsl-optimizer.cmake )
|
||||
include( cmake/3rdparty/glslang.cmake )
|
||||
|
||||
find_package(Threads)
|
||||
|
||||
add_executable( shaderc ${BGFX_DIR}/tools/shaderc/shaderc.cpp ${BGFX_DIR}/tools/shaderc/shaderc.h ${BGFX_DIR}/tools/shaderc/shaderc_glsl.cpp ${BGFX_DIR}/tools/shaderc/shaderc_hlsl.cpp ${BGFX_DIR}/tools/shaderc/shaderc_pssl.cpp ${BGFX_DIR}/tools/shaderc/shaderc_spirv.cpp )
|
||||
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 )
|
||||
target_link_libraries( shaderc ${CMAKE_THREAD_LIBS_INIT})
|
||||
add_dependencies( tools shaderc )
|
||||
|
||||
function( add_shader ARG_FILE )
|
||||
|
||||
Reference in New Issue
Block a user