Factor CMakeLists backend ProcTable generation

This commit is contained in:
Corentin Wallez 2018-05-18 14:47:59 -04:00 committed by Corentin Wallez
parent 8d6b5d2337
commit 7d95c40163
1 changed files with 24 additions and 60 deletions

View File

@ -19,23 +19,28 @@ set(NULL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/null)
set(OPENGL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/opengl) set(OPENGL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/opengl)
set(VULKAN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vulkan) 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 # OpenGL Backend
################################################################################ ################################################################################
if (NXT_ENABLE_OPENGL) if (NXT_ENABLE_OPENGL)
Generate( GenerateProcTable(opengl)
LIB_NAME opengl_autogen target_link_libraries(opengl_autogen glfw glad)
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 list(APPEND BACKEND_SOURCES
${OPENGL_DIR}/BlendStateGL.cpp ${OPENGL_DIR}/BlendStateGL.cpp
@ -76,18 +81,7 @@ endif()
################################################################################ ################################################################################
if (NXT_ENABLE_NULL) if (NXT_ENABLE_NULL)
Generate( GenerateProcTable(null)
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 list(APPEND BACKEND_SOURCES
${NULL_DIR}/NullBackend.cpp ${NULL_DIR}/NullBackend.cpp
@ -100,18 +94,8 @@ endif()
################################################################################ ################################################################################
if (NXT_ENABLE_METAL) if (NXT_ENABLE_METAL)
Generate( GenerateProcTable(metal)
LIB_NAME metal_autogen target_link_libraries(metal_autogen "-framework QuartzCore" "-framework Metal")
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})
list(APPEND BACKEND_SOURCES list(APPEND BACKEND_SOURCES
${METAL_DIR}/BlendStateMTL.mm ${METAL_DIR}/BlendStateMTL.mm
@ -150,15 +134,8 @@ endif()
################################################################################ ################################################################################
if (NXT_ENABLE_D3D12) if (NXT_ENABLE_D3D12)
Generate( GenerateProcTable(d3d12)
LIB_NAME d3d12_autogen
LIB_TYPE STATIC
FOLDER "backend"
PRINT_NAME "D3D12 backend autogenerated files"
COMMAND_LINE_ARGS
${GENERATOR_COMMON_ARGS}
-T d3d12
)
# WIN10_SDK_PATH will be something like C:\Program Files (x86)\Windows Kits\10 # 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) 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}) list(APPEND D3D12_LIBRARIES ${DXGUID_LIBRARY})
endif() 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 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 list(APPEND BACKEND_SOURCES
${D3D12_DIR}/d3d12_platform.h ${D3D12_DIR}/d3d12_platform.h
@ -275,19 +250,8 @@ endif()
################################################################################ ################################################################################
if (NXT_ENABLE_VULKAN) if (NXT_ENABLE_VULKAN)
Generate( GenerateProcTable(vulkan)
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})
target_include_directories(vulkan_autogen PUBLIC ${VULKAN_HEADERS_INCLUDE_DIR}) target_include_directories(vulkan_autogen PUBLIC ${VULKAN_HEADERS_INCLUDE_DIR})
target_include_directories(vulkan_autogen PUBLIC ${SRC_DIR})
list(APPEND BACKEND_SOURCES list(APPEND BACKEND_SOURCES
${VULKAN_DIR}/BindGroupVk.cpp ${VULKAN_DIR}/BindGroupVk.cpp