From 7bb528186f9be2d1c8b236eebe68ce9814406159 Mon Sep 17 00:00:00 2001 From: Timo de Kort Date: Sun, 26 May 2019 19:46:43 +0200 Subject: [PATCH] add DX11 support --- examples/hello_triangle_c/CMakeLists.txt | 28 ++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/examples/hello_triangle_c/CMakeLists.txt b/examples/hello_triangle_c/CMakeLists.txt index 128c85663..c61737ae6 100644 --- a/examples/hello_triangle_c/CMakeLists.txt +++ b/examples/hello_triangle_c/CMakeLists.txt @@ -1,19 +1,23 @@ cmake_minimum_required(VERSION 3.11b) +set(BACKEND_VULKAN "vulkan") +set(BACKEND_METAL "metal") +set(BACKEND_DX11 "dx11") +set(BACKEND_DX12 "dx12") +set(AVAILABLE_BACKENDS + ${BACKEND_VULKAN} + ${BACKEND_METAL} + ${BACKEND_DX11} + ${BACKEND_DX12}) + +if(NOT DEFINED BACKEND OR NOT "${BACKEND}" IN_LIST AVAILABLE_BACKENDS) + message(FATAL_ERROR "BACKEND invalid or undefined, available backends: ${AVAILABLE_BACKENDS}") +endif() + project(hello_triangle) set(TARGET_NAME hello_triangle) -set(BACKEND_VULKAN "vulkan") -set(BACKEND_METAL "metal") -set(BACKEND_DX12 "dx12") -set(AVAILABLE_BACKENDS ${BACKEND_VULKAN} ${BACKEND_METAL} ${BACKEND_DX12}) - -if(NOT DEFINED BACKEND) - message(FATAL_ERROR "Backend has not been set, please do so by using the -DBACKEND= argument. \ - Available backends: ${AVAILABLE_BACKENDS}") -endif() - add_executable(hello_triangle main.c) if(MSVC) @@ -21,7 +25,9 @@ if(MSVC) target_compile_options(${TARGET_NAME} PRIVATE /W4) set(GLFW_LIBRARY glfw3) set(OS_LIBRARIES "userenv" "ws2_32" "Dwmapi" "dbghelp") - if("${BACKEND}" STREQUAL "${BACKEND_DX12}") + if("${BACKEND}" STREQUAL "${BACKEND_DX11}") + list(APPEND OS_LIBRARIES "d3dcompiler" "D3D11" "DXGI") + elseif("${BACKEND}" STREQUAL "${BACKEND_DX12}") list(APPEND OS_LIBRARIES "d3dcompiler" "D3D12" "DXGI") endif() elseif(APPLE)