Factor CMakeLists backend ProcTable generation
This commit is contained in:
parent
8d6b5d2337
commit
7d95c40163
|
@ -19,23 +19,28 @@ set(NULL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/null)
|
|||
set(OPENGL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/opengl)
|
||||
set(VULKAN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vulkan)
|
||||
|
||||
function(GenerateProcTable backend)
|
||||
Generate(
|
||||
LIB_NAME ${backend}_autogen
|
||||
LIB_TYPE STATIC
|
||||
FOLDER "backend"
|
||||
PRINT_NAME "${backend} backend autogenerated files"
|
||||
COMMAND_LINE_ARGS
|
||||
${GENERATOR_COMMON_ARGS}
|
||||
-T ${backend}
|
||||
)
|
||||
target_link_libraries(${backend}_autogen nxtcpp)
|
||||
target_include_directories(${backend}_autogen PRIVATE ${SRC_DIR})
|
||||
target_include_directories(${backend}_autogen PUBLIC ${GENERATED_DIR})
|
||||
endfunction()
|
||||
|
||||
################################################################################
|
||||
# OpenGL Backend
|
||||
################################################################################
|
||||
|
||||
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})
|
||||
GenerateProcTable(opengl)
|
||||
target_link_libraries(opengl_autogen glfw glad)
|
||||
|
||||
list(APPEND BACKEND_SOURCES
|
||||
${OPENGL_DIR}/BlendStateGL.cpp
|
||||
|
@ -76,18 +81,7 @@ endif()
|
|||
################################################################################
|
||||
|
||||
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})
|
||||
GenerateProcTable(null)
|
||||
|
||||
list(APPEND BACKEND_SOURCES
|
||||
${NULL_DIR}/NullBackend.cpp
|
||||
|
@ -100,18 +94,8 @@ endif()
|
|||
################################################################################
|
||||
|
||||
if (NXT_ENABLE_METAL)
|
||||
Generate(
|
||||
LIB_NAME metal_autogen
|
||||
LIB_TYPE STATIC
|
||||
FOLDER "backend"
|
||||
PRINT_NAME "Metal backend autogenerated files"
|
||||
COMMAND_LINE_ARGS
|
||||
${GENERATOR_COMMON_ARGS}
|
||||
-T metal
|
||||
)
|
||||
target_link_libraries(metal_autogen glfw glad nxtcpp "-framework QuartzCore" "-framework Metal")
|
||||
target_include_directories(metal_autogen PRIVATE ${SRC_DIR})
|
||||
target_include_directories(metal_autogen PUBLIC ${GENERATED_DIR})
|
||||
GenerateProcTable(metal)
|
||||
target_link_libraries(metal_autogen "-framework QuartzCore" "-framework Metal")
|
||||
|
||||
list(APPEND BACKEND_SOURCES
|
||||
${METAL_DIR}/BlendStateMTL.mm
|
||||
|
@ -150,15 +134,8 @@ endif()
|
|||
################################################################################
|
||||
|
||||
if (NXT_ENABLE_D3D12)
|
||||
Generate(
|
||||
LIB_NAME d3d12_autogen
|
||||
LIB_TYPE STATIC
|
||||
FOLDER "backend"
|
||||
PRINT_NAME "D3D12 backend autogenerated files"
|
||||
COMMAND_LINE_ARGS
|
||||
${GENERATOR_COMMON_ARGS}
|
||||
-T d3d12
|
||||
)
|
||||
GenerateProcTable(d3d12)
|
||||
|
||||
# WIN10_SDK_PATH will be something like C:\Program Files (x86)\Windows Kits\10
|
||||
get_filename_component(WIN10_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0;InstallationFolder]" ABSOLUTE CACHE)
|
||||
|
||||
|
@ -214,10 +191,8 @@ if (NXT_ENABLE_D3D12)
|
|||
list(APPEND D3D12_LIBRARIES ${DXGUID_LIBRARY})
|
||||
endif()
|
||||
|
||||
target_link_libraries(d3d12_autogen glfw nxtcpp ${D3D12_LIBRARIES})
|
||||
target_link_libraries(d3d12_autogen ${D3D12_LIBRARIES})
|
||||
target_include_directories(d3d12_autogen SYSTEM PRIVATE ${D3D12_INCLUDE_DIR} ${DXGI_INCLUDE_DIR})
|
||||
target_include_directories(d3d12_autogen PRIVATE ${SRC_DIR})
|
||||
target_include_directories(d3d12_autogen PUBLIC ${GENERATED_DIR})
|
||||
|
||||
list(APPEND BACKEND_SOURCES
|
||||
${D3D12_DIR}/d3d12_platform.h
|
||||
|
@ -275,19 +250,8 @@ endif()
|
|||
################################################################################
|
||||
|
||||
if (NXT_ENABLE_VULKAN)
|
||||
Generate(
|
||||
LIB_NAME vulkan_autogen
|
||||
LIB_TYPE STATIC
|
||||
FOLDER "backend"
|
||||
PRINT_NAME "Vulkan backend autogenerated files"
|
||||
COMMAND_LINE_ARGS
|
||||
${GENERATOR_COMMON_ARGS}
|
||||
-T vulkan
|
||||
)
|
||||
target_link_libraries(vulkan_autogen nxtcpp)
|
||||
target_include_directories(vulkan_autogen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
GenerateProcTable(vulkan)
|
||||
target_include_directories(vulkan_autogen PUBLIC ${VULKAN_HEADERS_INCLUDE_DIR})
|
||||
target_include_directories(vulkan_autogen PUBLIC ${SRC_DIR})
|
||||
|
||||
list(APPEND BACKEND_SOURCES
|
||||
${VULKAN_DIR}/BindGroupVk.cpp
|
||||
|
|
Loading…
Reference in New Issue