-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
70 lines (51 loc) · 2.11 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
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
# Enable Hot Reload for MSVC compilers if supported.
if(POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()
project("SimpleFSR1")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(BUILD_SHARED_LIBS "Build as a shared library" OFF)
if(MSVC)
set(CMAKE_GENERATOR_PLATFORM x64)
endif()
include_directories("Src/include")
add_library(SimpleFSR1 "Src/source/SimpleFSR1.cpp" "Src/include/SimpleFSR1.h" "Src/include/FSR1.h")
target_include_directories(SimpleFSR1 PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Src/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(SimpleFSR1 PRIVATE PRIVATEd3d11.lib dxgi.lib dxguid.lib d3dcompiler.lib)
install(TARGETS SimpleFSR1
EXPORT SimpleFSR1Targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
install(EXPORT SimpleFSR1Targets
FILE SimpleFSR1Targets.cmake
NAMESPACE SimpleFSR1::
DESTINATION lib/cmake/SimpleFSR1)
install(DIRECTORY include/
DESTINATION include)
MESSAGE(STATUS "Generating shaders header file...")
set(HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Src/include/FSR1.h")
set(SHADERS_NAME
fsr1.hlsl
)
set(SHADERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Shader")
file(WRITE ${HEADER_FILE} "#pragma once\n\n")
file(APPEND ${HEADER_FILE} "// Auto-generated file: Do not modify\n\n")
file(APPEND ${HEADER_FILE} "namespace DefaultShader {\n")
foreach(SHADER ${SHADERS_NAME})
file(READ "${SHADERS_DIR}/${SHADER}" SHADER_CONTENT)
# Remove the ".hlsl" extension from the shader name
string(REGEX REPLACE ".hlsl" "" SHADER ${SHADER})
file(APPEND ${HEADER_FILE} "static const char *${SHADER} = R\"(\n")
file(APPEND ${HEADER_FILE} "${SHADER_CONTENT}\n")
file(APPEND ${HEADER_FILE} ")\";\n")
endforeach()
file(APPEND ${HEADER_FILE} "}\n\n")
MESSAGE(STATUS "Shaders header file generated")