add DX11 support
cmake_minimum_required(VERSION 3.11b)
-project(hello_triangle)
-
-set(TARGET_NAME hello_triangle)
-
set(BACKEND_VULKAN "vulkan")
set(BACKEND_METAL "metal")
+set(BACKEND_DX11 "dx11")
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}")
+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)
+
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)
