There's now more checks to prevent crashing when the mapped buffer is actually null, like when running with the dummy backend.
74 lines
2.8 KiB
CMake
74 lines
2.8 KiB
CMake
include(../../cmake/AddPlatformExecutable.cmake)
|
|
|
|
if(ENABLE_METAL)
|
|
find_library(METAL Metal)
|
|
|
|
set(EXTRA_LIBRARIES GFXMetal ${METAL} ${EXTRA_LIBRARIES})
|
|
set(EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sdl_metal.mm ${EXTRA_SRC})
|
|
endif()
|
|
|
|
if(ENABLE_VULKAN)
|
|
set(EXTRA_LIBRARIES GFXVulkan ${EXTRA_LIBRARIES})
|
|
set(EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sdl_vulkan.cpp ${EXTRA_SRC})
|
|
endif()
|
|
|
|
if(TARGET SDL2::SDL2)
|
|
set(EXTRA_LIBRARIES SDL2::SDL2 ${EXTRA_LIBRARIES})
|
|
endif()
|
|
|
|
if(TARGET SDL2::Main)
|
|
set(EXTRA_LIBRARIES SDL2::Main ${EXTRA_LIBRARIES})
|
|
endif()
|
|
|
|
if(TARGET SDL2::SDL2main)
|
|
set(EXTRA_LIBRARIES SDL2::SDL2main ${EXTRA_LIBRARIES})
|
|
endif()
|
|
|
|
add_platform(
|
|
SRC
|
|
${CMAKE_CURRENT_SOURCE_DIR}/file.cpp
|
|
${EXTRA_SRC}
|
|
MAIN_FILE
|
|
main.cpp.in
|
|
EXECUTABLE_PROPERTIES
|
|
MACOSX_BUNDLE ON
|
|
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in"
|
|
LINK_LIBRARIES
|
|
Core
|
|
GFXDummy
|
|
${EXTRA_LIBRARIES}
|
|
)
|
|
|
|
function(add_platform_commands target)
|
|
if(NOT SKIP_DATA)
|
|
if(ENABLE_MACOS)
|
|
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/data $<TARGET_FILE_DIR:${target}>/../Resources/data)
|
|
else()
|
|
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/data $<TARGET_FILE_DIR:${target}>/data)
|
|
endif()
|
|
endif()
|
|
|
|
# we HAVE to create this dummy target to convince CMake to properly copy over shader files.
|
|
# before you ask, we have used POST_BUILD before but that only runs if the TARGET specified is built.
|
|
# when you change a shader source file on disk, BuildShaders is triggered but that doesn't retrigger your actual
|
|
# app target to be rebuilt, so the shaders are never copied correctly. With this (dumb) system, we ensure they
|
|
# always are. WHY CMAKE WHY
|
|
set(DUMMY_NAME ${target}-CopyShaders)
|
|
|
|
add_custom_target(${DUMMY_NAME} ALL DEPENDS ${CMAKE_BINARY_DIR}/${target}-dummy)
|
|
|
|
if(ENABLE_MACOS)
|
|
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${target}-dummy
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target}>/../Resources/shaders
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/shaders $<TARGET_FILE_DIR:${target}>/../Resources/shaders
|
|
)
|
|
else()
|
|
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${target}-dummy
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${target}>/shaders
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/shaders $<TARGET_FILE_DIR:${target}>/shaders
|
|
)
|
|
endif()
|
|
|
|
|
|
add_dependencies(${target} ${DUMMY_NAME})
|
|
endfunction()
|