This is shipped by SDL2 itself, so it should be the preferred way of finding it. Since SDL2 does not ship it in their Windows development libraries, we still need to use the regular Find module.
66 lines
2.5 KiB
CMake
66 lines
2.5 KiB
CMake
include(../../cmake/AddPlatformExecutable.cmake)
|
|
|
|
if(ENABLE_MACOS)
|
|
find_library(METAL Metal)
|
|
|
|
set(EXTRA_LIBRARIES GFXMetal ${METAL})
|
|
set(EXTRA_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sdl_metal.mm)
|
|
endif()
|
|
|
|
if(TARGET SDL2::Main)
|
|
set(EXTRA_LIBRARIES SDL2::Main)
|
|
endif()
|
|
|
|
if(TARGET SDL2::SDL2main)
|
|
set(EXTRA_LIBRARIES SDL2::SDL2main)
|
|
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
|
|
GFXVulkan
|
|
SDL2::SDL2
|
|
${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()
|