2019-03-28 00:02:36 +00:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
|
|
|
project(renderers LANGUAGES C)
|
|
|
|
|
2019-03-28 08:56:14 +00:00
|
|
|
set(RENDERER_H "${CMAKE_BINARY_DIR}/include/dynamic/renderers.h")
|
|
|
|
set(RENDERER_C "${CMAKE_BINARY_DIR}/src/renderers.c")
|
2019-03-28 00:02:36 +00:00
|
|
|
|
2019-03-28 08:56:14 +00:00
|
|
|
file(WRITE ${RENDERER_H} "#include \"interface/renderer.h\"\n\n")
|
2021-08-08 04:43:04 +00:00
|
|
|
file(APPEND ${RENDERER_H} "extern LG_RendererOps * LG_Renderers[];\n\n")
|
2019-03-28 08:56:14 +00:00
|
|
|
|
|
|
|
file(WRITE ${RENDERER_C} "#include \"interface/renderer.h\"\n\n")
|
|
|
|
file(APPEND ${RENDERER_C} "#include <stddef.h>\n\n")
|
|
|
|
|
2019-03-28 09:12:18 +00:00
|
|
|
set(RENDERERS "_")
|
|
|
|
set(RENDERERS_LINK "_")
|
2019-03-28 08:56:14 +00:00
|
|
|
function(add_renderer name)
|
|
|
|
set(RENDERERS "${RENDERERS};${name}" PARENT_SCOPE)
|
|
|
|
set(RENDERERS_LINK "${RENDERERS_LINK};renderer_${name}" PARENT_SCOPE)
|
|
|
|
add_subdirectory(${name})
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# Add/remove renderers here!
|
2019-03-28 09:12:18 +00:00
|
|
|
if(ENABLE_EGL)
|
|
|
|
add_renderer(EGL)
|
|
|
|
endif()
|
|
|
|
if (ENABLE_OPENGL)
|
|
|
|
add_renderer(OpenGL)
|
|
|
|
endif()
|
2019-03-28 08:56:14 +00:00
|
|
|
|
|
|
|
list(REMOVE_AT RENDERERS 0)
|
|
|
|
list(REMOVE_AT RENDERERS_LINK 0)
|
|
|
|
|
|
|
|
list(LENGTH RENDERERS RENDERER_COUNT)
|
|
|
|
file(APPEND ${RENDERER_H} "#define LG_RENDERER_COUNT ${RENDERER_COUNT}\n")
|
|
|
|
|
|
|
|
foreach(renderer ${RENDERERS})
|
2021-08-08 04:43:04 +00:00
|
|
|
file(APPEND ${RENDERER_C} "extern LG_RendererOps LGR_${renderer};\n")
|
2019-03-28 08:56:14 +00:00
|
|
|
endforeach()
|
|
|
|
|
2021-08-08 04:43:04 +00:00
|
|
|
file(APPEND ${RENDERER_C} "\nconst LG_RendererOps * LG_Renderers[] =\n{\n")
|
2019-03-28 08:56:14 +00:00
|
|
|
foreach(renderer ${RENDERERS})
|
|
|
|
file(APPEND ${RENDERER_C} " &LGR_${renderer},\n")
|
|
|
|
endforeach()
|
|
|
|
file(APPEND ${RENDERER_C} " NULL\n};")
|
|
|
|
|
2019-03-28 09:15:13 +00:00
|
|
|
add_library(renderers STATIC ${RENDERER_C})
|
|
|
|
target_link_libraries(renderers ${RENDERERS_LINK})
|