@@ -2,7 +2,35 @@ cmake_minimum_required (VERSION 3.10)
22
33project (Diligent-GraphicsEngineD3DBase CXX )
44
5- set (DILIGENT_NVAPI_PATH "" CACHE PATH "Path to NVAPI to enable D3D11/D3D12 extensions" )
5+ if (PLATFORM_WIN32)
6+ if (DILIGENT_NVAPI_PATH)
7+ if (NOT EXISTS "${DILIGENT_NVAPI_PATH} /nvapi.h" )
8+ message (WARNING
9+ "DILIGENT_NVAPI_PATH does not look like NVAPI (missing nvapi.h): ${DILIGENT_NVAPI_PATH} \n "
10+ "Will ignore it and download NVAPI instead."
11+ )
12+ unset (DILIGENT_NVAPI_PATH CACHE )
13+ endif ()
14+ endif ()
15+
16+ if (NOT DILIGENT_NVAPI_PATH AND (TARGET_CPU STREQUAL "x86_64" OR TARGET_CPU STREQUAL "x86" ))
17+ message (STATUS "Downloading NVAPI repository..." )
18+
19+ include (FetchContent )
20+ FetchContent_Declare (
21+ nvapi
22+ GIT_REPOSITORY https://github.com/NVIDIA/nvapi
23+ GIT_TAG 9296d67 # R590
24+ )
25+ FetchContent_MakeAvailable (nvapi)
26+
27+ set (DILIGENT_NVAPI_PATH
28+ "${nvapi_SOURCE_DIR} "
29+ CACHE PATH "Path to NVAPI to enable D3D11/D3D12 extensions"
30+ FORCE
31+ )
32+ endif ()
33+ endif ()
634
735set (INCLUDE
836 include/D3DCommonTypeConversions.hpp
@@ -74,10 +102,12 @@ endif()
74102
75103if (EXISTS "${DILIGENT_NVAPI_PATH} /nvapi.h" )
76104 message (STATUS "Using NVApi from ${DILIGENT_NVAPI_PATH} " )
77- if (${CMAKE_SIZEOF_VOID_P} EQUAL 8 )
105+ if (TARGET_CPU STREQUAL "x86_64" )
78106 set (DILIGENT_NVAPI_LIB_PATH "${DILIGENT_NVAPI_PATH} /amd64/nvapi64.lib" CACHE INTERNAL "NVAPI lib path" )
79- else ( )
107+ elseif (TARGET_CPU STREQUAL "x86" )
80108 set (DILIGENT_NVAPI_LIB_PATH "${DILIGENT_NVAPI_PATH} /x86/nvapi.lib" CACHE INTERNAL "NVAPI lib path" )
109+ else ()
110+ message (WARNING "Unsupported target CPU for NVAPI: ${TARGET_CPU} ." )
81111 endif ()
82112 target_include_directories (Diligent-GraphicsEngineD3DBase PUBLIC ${DILIGENT_NVAPI_PATH} )
83113 target_link_libraries (Diligent-GraphicsEngineD3DBase PRIVATE ${DILIGENT_NVAPI_LIB_PATH} )
0 commit comments