-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
140 lines (122 loc) · 6.53 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# This file is part of D3d12info project:
# https://github.com/sawickiap/D3d12info
#
# Copyright (c) 2018-2024 Adam Sawicki, https://asawicki.info
# License: MIT
#
# For more information, see files README.md, LICENSE.txt.
cmake_minimum_required(VERSION 3.17)
project(D3d12info LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
file(GLOB CPP_FILES "Src/*.cpp")
file(GLOB HPP_FILES "Src/*.hpp")
set(RAPIDJSON_NATVIS_FILE "Src/ThirdParty/rapidjson/contrib/natvis/rapidjson.natvis")
set(INTEL_GPUDETECT_CFG_FILE "Src/ThirdParty/gpudetect/IntelGfx.cfg")
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/Src/ThirdParty/rapidjson/include/rapidjson/rapidjson.h")
message(FATAL_ERROR "rapidjson library not found. This is likely due to missing submodule. Please initialize submodules.")
endif()
option(ENABLE_AGS "Enables usage of AMD GPU Services (AGS) library." ON)
if(ENABLE_AGS)
if(EXISTS "${PROJECT_SOURCE_DIR}/Src/ThirdParty/AGS_SDK/ags_lib/inc/amd_ags.h")
message(STATUS "AMD AGS library used.")
else()
message(STATUS "AMD AGS library not found. This is likely due to missing submodule. Please initialize submodules or set ENABLE_AGS to OFF.")
set(ENABLE_AGS OFF)
endif()
else()
message(STATUS "AMD AGS library not used.")
endif()
option(ENABLE_NVAPI "Enables usage of NVAPI library." ON)
if(ENABLE_NVAPI)
if(EXISTS "${PROJECT_SOURCE_DIR}/Src/ThirdParty/nvapi/nvapi.h")
message(STATUS "NVAPI library used.")
else()
message(STATUS "NVAPI library not found. This is likely due to missing submodule. Please initialize submodules or set ENABLE_NVAPI to OFF.")
set(ENABLE_NVAPI OFF)
endif()
else()
message(STATUS "NVAPI library not used.")
endif()
option(ENABLE_VULKAN "Enables usage of Vulkan SDK." ON)
if(ENABLE_VULKAN)
# 1.3.231 is oldest tested Vulkan SDK version
# if Cmake finds older version, it will print warning and set Vulkan_FOUND to false
find_package(Vulkan 1.3.231)
if (Vulkan_FOUND)
message(STATUS "Vulkan SDK found. Include directory is \"${Vulkan_INCLUDE_DIRS}\".")
else()
message(STATUS "Vulkan SDK not found. Please install Vulkan SDK or set ENABLE_VULKAN to OFF.")
endif()
else()
message(STATUS "Vulkan SDK not used.")
endif()
option(ENABLE_INTEL_GPUDETECT "Enable usage of Intel GPU Detect library." ON)
if(ENABLE_INTEL_GPUDETECT)
if(EXISTS "${PROJECT_SOURCE_DIR}/Src/ThirdParty/gpudetect/GPUDetect.h")
message(STATUS "Intel GPU Detect library used.")
else()
message(STATUS "Intel GPU Detect library not found. This is likely due to missing submodule. Please initialize submodules or set ENABLE_INTEL_GPUDETECT to OFF.")
set(ENABLE_INTEL_GPUDETECT OFF)
endif()
else()
message(STATUS "Intel GPU Detect library not used.")
endif()
function(add_my_executable USE_PREVIEW_AGILITY_SDK)
set(EXE_NAME "D3d12info")
if(USE_PREVIEW_AGILITY_SDK)
set(EXE_NAME "${EXE_NAME}_preview")
endif()
add_executable(${EXE_NAME} ${CPP_FILES} ${HPP_FILES})
# Change Visual C++ runtime library to get rid of dependency on Visual C++ Redistributable
set_property(TARGET ${EXE_NAME} PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_compile_options(${EXE_NAME} PRIVATE /W4 /wd4100 /wd4189)
target_compile_definitions(${EXE_NAME} PRIVATE UNICODE _UNICODE)
target_precompile_headers(${EXE_NAME} PRIVATE "Src/pch.hpp")
target_sources(${EXE_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/${RAPIDJSON_NATVIS_FILE}")
source_group("ThirdParty" FILES ${RAPIDJSON_NATVIS_FILE})
if(USE_PREVIEW_AGILITY_SDK)
target_compile_definitions(${EXE_NAME} PRIVATE USE_PREVIEW_AGILITY_SDK=1)
set(AGILITY_SDK_DIRECTORY "${PROJECT_SOURCE_DIR}/Src/ThirdParty/microsoft.direct3d.d3d12.1.715.1-preview")
add_custom_command(TARGET ${EXE_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:${EXE_NAME}>/D3D12_preview"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${AGILITY_SDK_DIRECTORY}/build/native/bin/x64/D3D12Core.dll"
"$<TARGET_FILE_DIR:${EXE_NAME}>/D3D12_preview/"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${AGILITY_SDK_DIRECTORY}/build/native/bin/x64/DirectSR.dll"
"$<TARGET_FILE_DIR:${EXE_NAME}>/D3D12_preview/")
else()
set(AGILITY_SDK_DIRECTORY "${PROJECT_SOURCE_DIR}/Src/ThirdParty/microsoft.direct3d.d3d12.1.614.1")
add_custom_command(TARGET ${EXE_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:${EXE_NAME}>/D3D12"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${AGILITY_SDK_DIRECTORY}/build/native/bin/x64/D3D12Core.dll"
"$<TARGET_FILE_DIR:${EXE_NAME}>/D3D12/")
endif()
if(ENABLE_AGS)
target_compile_definitions(${EXE_NAME} PRIVATE USE_AGS=1)
target_include_directories(${EXE_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/Src/ThirdParty/AGS_SDK/ags_lib/inc")
target_link_libraries(${EXE_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/Src/ThirdParty/AGS_SDK/ags_lib/lib/amd_ags_x64.lib")
add_custom_command(TARGET ${EXE_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/Src/ThirdParty/AGS_SDK/ags_lib/lib/amd_ags_x64.dll" "$<TARGET_FILE_DIR:${EXE_NAME}>/")
endif()
if(ENABLE_NVAPI)
target_compile_definitions(${EXE_NAME} PRIVATE USE_NVAPI=1)
target_include_directories(${EXE_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/Src/ThirdParty/nvapi")
target_link_libraries(${EXE_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/Src/ThirdParty/nvapi/amd64/nvapi64.lib")
endif()
if (Vulkan_FOUND)
target_compile_definitions(${EXE_NAME} PRIVATE USE_VULKAN=1)
target_include_directories(${EXE_NAME} PRIVATE ${Vulkan_INCLUDE_DIRS})
target_link_libraries(${EXE_NAME} PRIVATE ${Vulkan_LIBRARIES})
endif()
if(ENABLE_INTEL_GPUDETECT)
target_compile_definitions(${EXE_NAME} PRIVATE USE_INTEL_GPUDETECT=1)
target_link_libraries(${EXE_NAME} PRIVATE "d3d11.lib")
target_sources(${EXE_NAME} PRIVATE
"${PROJECT_SOURCE_DIR}/Src/Resources.rc"
"${PROJECT_SOURCE_DIR}/${INTEL_GPUDETECT_CFG_FILE}")
source_group("ThirdParty" FILES "${PROJECT_SOURCE_DIR}/${INTEL_GPUDETECT_CFG_FILE}")
endif()
endfunction()
add_my_executable(FALSE)
add_my_executable(TRUE)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT "D3d12info")