Add proper defines for backend enablement

This commit is contained in:
Corentin Wallez
2017-07-12 12:43:24 -04:00
committed by Corentin Wallez
parent a7bfc9d2ac
commit 275817a93a
6 changed files with 232 additions and 145 deletions

View File

@@ -19,109 +19,75 @@ set(OPENGL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/opengl)
set(D3D12_DIR ${CMAKE_CURRENT_SOURCE_DIR}/d3d12)
set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests)
list(APPEND BACKEND_SOURCES
${BACKEND_DIR}/BindGroup.cpp
${BACKEND_DIR}/BindGroup.h
${BACKEND_DIR}/BindGroupLayout.cpp
${BACKEND_DIR}/BindGroupLayout.h
${BACKEND_DIR}/Builder.cpp
${BACKEND_DIR}/Builder.h
${BACKEND_DIR}/Buffer.cpp
${BACKEND_DIR}/Buffer.h
${BACKEND_DIR}/CommandAllocator.cpp
${BACKEND_DIR}/CommandAllocator.h
${BACKEND_DIR}/CommandBuffer.cpp
${BACKEND_DIR}/CommandBuffer.h
${BACKEND_DIR}/DepthStencilState.cpp
${BACKEND_DIR}/DepthStencilState.h
${BACKEND_DIR}/CommandBufferStateTracker.cpp
${BACKEND_DIR}/CommandBufferStateTracker.h
${BACKEND_DIR}/Device.cpp
${BACKEND_DIR}/Device.h
${BACKEND_DIR}/Forward.h
${BACKEND_DIR}/Framebuffer.cpp
${BACKEND_DIR}/Framebuffer.h
${BACKEND_DIR}/InputState.cpp
${BACKEND_DIR}/InputState.h
${BACKEND_DIR}/PerStage.cpp
${BACKEND_DIR}/PerStage.h
${BACKEND_DIR}/Pipeline.cpp
${BACKEND_DIR}/Pipeline.h
${BACKEND_DIR}/PipelineLayout.cpp
${BACKEND_DIR}/PipelineLayout.h
${BACKEND_DIR}/Queue.cpp
${BACKEND_DIR}/Queue.h
${BACKEND_DIR}/RenderPass.cpp
${BACKEND_DIR}/RenderPass.h
${BACKEND_DIR}/RefCounted.cpp
${BACKEND_DIR}/RefCounted.h
${BACKEND_DIR}/Sampler.cpp
${BACKEND_DIR}/Sampler.h
${BACKEND_DIR}/ShaderModule.cpp
${BACKEND_DIR}/ShaderModule.h
${BACKEND_DIR}/Texture.cpp
${BACKEND_DIR}/Texture.h
${BACKEND_DIR}/ToBackend.h
)
################################################################################
# OpenGL Backend
################################################################################
Generate(
LIB_NAME opengl_autogen
LIB_TYPE STATIC
FOLDER "backend"
PRINT_NAME "OpenGL backend autogenerated files"
COMMAND_LINE_ARGS
${GENERATOR_COMMON_ARGS}
-T opengl
)
target_link_libraries(opengl_autogen glfw glad nxtcpp)
target_include_directories(opengl_autogen PRIVATE ${SRC_DIR})
target_include_directories(opengl_autogen PUBLIC ${GENERATED_DIR})
if (NXT_ENABLE_OPENGL)
Generate(
LIB_NAME opengl_autogen
LIB_TYPE STATIC
FOLDER "backend"
PRINT_NAME "OpenGL backend autogenerated files"
COMMAND_LINE_ARGS
${GENERATOR_COMMON_ARGS}
-T opengl
)
target_link_libraries(opengl_autogen glfw glad nxtcpp)
target_include_directories(opengl_autogen PRIVATE ${SRC_DIR})
target_include_directories(opengl_autogen PUBLIC ${GENERATED_DIR})
list(APPEND BACKEND_SOURCES
${OPENGL_DIR}/CommandBufferGL.cpp
${OPENGL_DIR}/CommandBufferGL.h
${OPENGL_DIR}/DepthStencilStateGL.cpp
${OPENGL_DIR}/DepthStencilStateGL.h
${OPENGL_DIR}/OpenGLBackend.cpp
${OPENGL_DIR}/OpenGLBackend.h
${OPENGL_DIR}/PersistentPipelineStateGL.cpp
${OPENGL_DIR}/PersistentPipelineStateGL.h
${OPENGL_DIR}/PipelineGL.cpp
${OPENGL_DIR}/PipelineGL.h
${OPENGL_DIR}/PipelineLayoutGL.cpp
${OPENGL_DIR}/PipelineLayoutGL.h
${OPENGL_DIR}/SamplerGL.cpp
${OPENGL_DIR}/SamplerGL.h
${OPENGL_DIR}/ShaderModuleGL.cpp
${OPENGL_DIR}/ShaderModuleGL.h
${OPENGL_DIR}/TextureGL.cpp
${OPENGL_DIR}/TextureGL.h
)
list(APPEND BACKEND_SOURCES
${OPENGL_DIR}/CommandBufferGL.cpp
${OPENGL_DIR}/CommandBufferGL.h
${OPENGL_DIR}/DepthStencilStateGL.cpp
${OPENGL_DIR}/DepthStencilStateGL.h
${OPENGL_DIR}/OpenGLBackend.cpp
${OPENGL_DIR}/OpenGLBackend.h
${OPENGL_DIR}/PersistentPipelineStateGL.cpp
${OPENGL_DIR}/PersistentPipelineStateGL.h
${OPENGL_DIR}/PipelineGL.cpp
${OPENGL_DIR}/PipelineGL.h
${OPENGL_DIR}/PipelineLayoutGL.cpp
${OPENGL_DIR}/PipelineLayoutGL.h
${OPENGL_DIR}/SamplerGL.cpp
${OPENGL_DIR}/SamplerGL.h
${OPENGL_DIR}/ShaderModuleGL.cpp
${OPENGL_DIR}/ShaderModuleGL.h
${OPENGL_DIR}/TextureGL.cpp
${OPENGL_DIR}/TextureGL.h
)
endif()
# Null backend
Generate(
LIB_NAME null_autogen
LIB_TYPE STATIC
FOLDER "backend"
PRINT_NAME "Null backend autogenerated files"
COMMAND_LINE_ARGS
${GENERATOR_COMMON_ARGS}
-T null
)
target_link_libraries(null_autogen nxtcpp)
target_include_directories(null_autogen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(null_autogen PUBLIC ${SRC_DIR})
################################################################################
# Null Backend
################################################################################
list(APPEND BACKEND_SOURCES
${NULL_DIR}/NullBackend.cpp
${NULL_DIR}/NullBackend.h
)
if (NXT_ENABLE_NULL)
Generate(
LIB_NAME null_autogen
LIB_TYPE STATIC
FOLDER "backend"
PRINT_NAME "Null backend autogenerated files"
COMMAND_LINE_ARGS
${GENERATOR_COMMON_ARGS}
-T null
)
target_link_libraries(null_autogen nxtcpp)
target_include_directories(null_autogen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(null_autogen PUBLIC ${SRC_DIR})
list(APPEND BACKEND_SOURCES
${NULL_DIR}/NullBackend.cpp
${NULL_DIR}/NullBackend.h
)
endif()
################################################################################
# Metal Backend
################################################################################
if (APPLE)
if (NXT_ENABLE_METAL)
Generate(
LIB_NAME metal_autogen
LIB_TYPE STATIC
@@ -161,9 +127,11 @@ if (APPLE)
)
endif()
################################################################################
# D3D12 Backend
################################################################################
if (WIN32)
if (NXT_ENABLE_D3D12)
Generate(
LIB_NAME d3d12_autogen
LIB_TYPE STATIC
@@ -266,13 +234,68 @@ if (WIN32)
)
endif()
################################################################################
# Common sources definition of the library
################################################################################
list(APPEND BACKEND_SOURCES
${BACKEND_DIR}/BindGroup.cpp
${BACKEND_DIR}/BindGroup.h
${BACKEND_DIR}/BindGroupLayout.cpp
${BACKEND_DIR}/BindGroupLayout.h
${BACKEND_DIR}/Builder.cpp
${BACKEND_DIR}/Builder.h
${BACKEND_DIR}/Buffer.cpp
${BACKEND_DIR}/Buffer.h
${BACKEND_DIR}/CommandAllocator.cpp
${BACKEND_DIR}/CommandAllocator.h
${BACKEND_DIR}/CommandBuffer.cpp
${BACKEND_DIR}/CommandBuffer.h
${BACKEND_DIR}/DepthStencilState.cpp
${BACKEND_DIR}/DepthStencilState.h
${BACKEND_DIR}/CommandBufferStateTracker.cpp
${BACKEND_DIR}/CommandBufferStateTracker.h
${BACKEND_DIR}/Device.cpp
${BACKEND_DIR}/Device.h
${BACKEND_DIR}/Forward.h
${BACKEND_DIR}/Framebuffer.cpp
${BACKEND_DIR}/Framebuffer.h
${BACKEND_DIR}/InputState.cpp
${BACKEND_DIR}/InputState.h
${BACKEND_DIR}/PerStage.cpp
${BACKEND_DIR}/PerStage.h
${BACKEND_DIR}/Pipeline.cpp
${BACKEND_DIR}/Pipeline.h
${BACKEND_DIR}/PipelineLayout.cpp
${BACKEND_DIR}/PipelineLayout.h
${BACKEND_DIR}/Queue.cpp
${BACKEND_DIR}/Queue.h
${BACKEND_DIR}/RenderPass.cpp
${BACKEND_DIR}/RenderPass.h
${BACKEND_DIR}/RefCounted.cpp
${BACKEND_DIR}/RefCounted.h
${BACKEND_DIR}/Sampler.cpp
${BACKEND_DIR}/Sampler.h
${BACKEND_DIR}/ShaderModule.cpp
${BACKEND_DIR}/ShaderModule.h
${BACKEND_DIR}/Texture.cpp
${BACKEND_DIR}/Texture.h
${BACKEND_DIR}/ToBackend.h
)
add_library(nxt_backend STATIC ${BACKEND_SOURCES})
NXTInternalTarget("backend" nxt_backend)
target_link_libraries(nxt_backend nxt_common glfw glad spirv_cross)
target_link_libraries(nxt_backend nxt_common opengl_autogen null_autogen glfw glad spirv_cross)
if (APPLE)
target_link_libraries(nxt_backend metal_autogen)
endif()
if (WIN32)
if (NXT_ENABLE_D3D12)
target_link_libraries(nxt_backend d3d12_autogen)
endif()
if (NXT_ENABLE_METAL)
target_link_libraries(nxt_backend metal_autogen)
endif()
if (NXT_ENABLE_NULL)
target_link_libraries(nxt_backend null_autogen)
endif()
if (NXT_ENABLE_OPENGL)
target_link_libraries(nxt_backend opengl_autogen)
endif()