2023-06-28 19:52:14 +10:00
|
|
|
set(SOURCES_COMMON
|
2022-11-19 03:03:02 +11:00
|
|
|
maths.h
|
|
|
|
draw.h
|
|
|
|
draw_common.c
|
|
|
|
stick.h
|
|
|
|
stick.c
|
|
|
|
analogue.c)
|
2023-06-28 19:52:14 +10:00
|
|
|
set(SOURCES_SDL_RENDERER draw.c)
|
|
|
|
set(SOURCES_METAL draw_metal.m metal_shader_types.h)
|
|
|
|
set(SOURCES_OPENGL draw_opengl_core.c)
|
|
|
|
set(SOURCES_OPENGL_LEGACY draw_opengl.c)
|
2022-11-19 03:03:02 +11:00
|
|
|
|
2023-06-28 19:52:14 +10:00
|
|
|
function (common_setup _TARGET)
|
|
|
|
target_link_libraries(${_TARGET}
|
|
|
|
$<$<PLATFORM_ID:Windows>:SDL2::SDL2main>
|
|
|
|
SDL2::SDL2
|
|
|
|
$<$<BOOL:${GNU}>:m>)
|
|
|
|
target_compile_options(${_TARGET} PRIVATE
|
|
|
|
$<$<BOOL:${GNU}>:-Wall -Wextra -pedantic -Wno-unused-parameter>)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
add_executable(${TARGET} ${SOURCES_COMMON} ${SOURCES_SDL_RENDERER})
|
|
|
|
common_setup(${TARGET})
|
|
|
|
|
|
|
|
if (BUILD_METAL OR BUILD_OPENGL)
|
|
|
|
include(BinHelper)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (BUILD_METAL)
|
|
|
|
enable_language(OBJC)
|
2022-11-19 00:42:33 +11:00
|
|
|
find_library(METAL Metal REQUIRED)
|
|
|
|
find_library(FOUNDATION Foundation REQUIRED)
|
|
|
|
find_library(QUARTZCORE QuartzCore REQUIRED)
|
|
|
|
include(MetalHelper)
|
|
|
|
metal_compile(OUTPUT shader.metallib SOURCES shader.metal)
|
|
|
|
bin2h_compile(OUTPUT metalShader.h BIN ${CMAKE_CURRENT_BINARY_DIR}/shader.metallib)
|
2023-06-28 19:52:14 +10:00
|
|
|
add_executable(${TARGET}_metal ${SOURCES_COMMON} ${SOURCES_METAL} ${CMAKE_CURRENT_BINARY_DIR}/metalShader.h)
|
|
|
|
target_include_directories(${TARGET}_metal PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
target_link_libraries(${TARGET}_metal ${METAL} ${QUARTZCORE} ${FOUNDATION})
|
|
|
|
common_setup(${TARGET}_metal)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (BUILD_OPENGL)
|
2022-11-19 03:03:02 +11:00
|
|
|
include(GL3WHelper)
|
|
|
|
add_gl3w(gl3w)
|
2022-11-28 02:17:07 +11:00
|
|
|
bin2h_compile(OUTPUT glslShaders.h TXT vert.glsl geom.glsl frag.glsl)
|
2023-06-28 19:52:14 +10:00
|
|
|
add_executable(${TARGET}_glcore ${SOURCES_COMMON} ${SOURCES_OPENGL} ${CMAKE_CURRENT_BINARY_DIR}/glslShaders.h)
|
|
|
|
target_include_directories(${TARGET}_glcore PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
target_link_libraries(${TARGET}_glcore OpenGL::GL gl3w)
|
|
|
|
target_compile_definitions(${TARGET}_glcore PRIVATE USE_OPENGL)
|
|
|
|
common_setup(${TARGET}_glcore)
|
2022-11-19 03:03:02 +11:00
|
|
|
endif()
|
|
|
|
|
2023-06-28 19:52:14 +10:00
|
|
|
if (BUILD_OPENGL_LEGACY)
|
|
|
|
add_executable(${TARGET}_gl ${SOURCES_COMMON} ${SOURCES_OPENGL_LEGACY})
|
|
|
|
target_link_libraries(${TARGET}_gl OpenGL::GL)
|
|
|
|
target_compile_definitions(${TARGET}_gl PRIVATE USE_OPENGL)
|
|
|
|
common_setup(${TARGET}_gl)
|
|
|
|
endif()
|