CMakeLists.txt 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. project(dx12_sample)
  2. set_property(GLOBAL PROPERTY USE_FOLDERS ON)
  3. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /UMBCS /D_UNICODE /DUNICODE")
  4. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin/DX12/)
  5. set(IMGUI_PATH "${CMAKE_SOURCE_DIR}/third_party/imgui/")
  6. set(IMGUI_INCLUDE "${IMGUI_PATH}" "${IMGUI_PATH}/backends/")
  7. set(IMGUI_SRC "${IMGUI_PATH}/backends/imgui_impl_dx12.cpp"
  8. "${IMGUI_PATH}/backends/imgui_impl_win32.cpp"
  9. "${IMGUI_PATH}/imgui.cpp"
  10. "${IMGUI_PATH}/imgui_demo.cpp"
  11. "${IMGUI_PATH}/imgui_draw.cpp"
  12. "${IMGUI_PATH}/imgui_tables.cpp"
  13. "${IMGUI_PATH}/imgui_widgets.cpp"
  14. )
  15. set(TINYEXR_PATH "${CMAKE_SOURCE_DIR}/third_party/tinyexr/")
  16. set(TINYEXR_INCLUDE "${TINYEXR_PATH}" "${TINYEXR_PATH}/deps/miniz")
  17. set(TINYEXR_SRC "${TINYEXR_PATH}/deps/miniz/miniz.c")
  18. set(STB_PATH "${CMAKE_SOURCE_DIR}/third_party/stb/")
  19. set(STB_INCLUDE "${STB_PATH}")
  20. set(DXC_PATH "${CMAKE_SOURCE_DIR}/third_party/DXC/")
  21. set(DXC_INCLUDE "${CMAKE_SOURCE_DIR}/third_party/DXC/inc/")
  22. set(DXC_LIB "${CMAKE_SOURCE_DIR}/third_party/DXC/lib/x64/dxcompiler.lib")
  23. set(DXC_BIN "${CMAKE_SOURCE_DIR}/third_party/DXC/bin/x64/")
  24. set(NIS_PATH "${CMAKE_SOURCE_DIR}/../NIS")
  25. set(SAMPLES_PATH "${CMAKE_SOURCE_DIR}")
  26. set(DX_SAMPLE_SRC "src/Sample.cpp"
  27. "src/AppRenderer.cpp"
  28. "src/UIRenderer.cpp"
  29. "src/DeviceResources.cpp"
  30. "src/NVScaler.cpp"
  31. "src/NVSharpen.cpp"
  32. "src/BilinearUpscale.cpp"
  33. "${SAMPLES_PATH}/common/Image.cpp"
  34. "src/dpi.manifest"
  35. )
  36. set(DX_SAMPLE_HEADERS "include/AppRenderer.h"
  37. "include/DeviceResources.h"
  38. "include/NVScaler.h"
  39. "include/NVSharpen.h"
  40. "include/UIRenderer.h"
  41. "include/BilinearUpscale.h"
  42. "include/DXUtilities.h"
  43. "include/d3dx12.h"
  44. "${NIS_PATH}/NIS_Config.h"
  45. "${SAMPLES_PATH}/common/Image.h"
  46. "${SAMPLES_PATH}/common/Utilities.h"
  47. )
  48. set(DX_SAMPLE_SHADERS "${NIS_PATH}/NIS_Scaler.h"
  49. "${NIS_PATH}/NIS_Main.hlsl"
  50. "src/bilinearUpscale.hlsl"
  51. )
  52. set(DX_SAMPLE_MEDIA "${SAMPLES_PATH}/media/images/1080.png"
  53. "${SAMPLES_PATH}/media/images/1440.png"
  54. "${SAMPLES_PATH}/media/images/1660.png"
  55. )
  56. set_source_files_properties(${DX_SAMPLE_SHADERS} PROPERTIES VS_COPY_TO_OUT_DIR TRUE)
  57. source_group("external" FILES ${IMGUI_SRC} ${TINYEXR_SRC})
  58. source_group("shaders" FILES ${DX_SAMPLE_SHADERS})
  59. add_executable(${PROJECT_NAME} ${DX_SAMPLE_SRC} ${IMGUI_SRC} ${TINYEXR_SRC} ${DX_SAMPLE_HEADERS} ${DX_SAMPLE_SHADERS})
  60. target_link_libraries(${PROJECT_NAME} PUBLIC ${DXC_LIB})
  61. target_include_directories(${PROJECT_NAME} PUBLIC include ${IMGUI_INCLUDE} ${TINYEXR_INCLUDE} ${STB_INCLUDE} ${NIS_PATH} ${SAMPLES_PATH}/common)
  62. add_custom_command(
  63. TARGET ${PROJECT_NAME} POST_BUILD
  64. COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${PROJECT_NAME}>/NIS
  65. COMMAND ${CMAKE_COMMAND} -E copy_directory ${NIS_PATH} $<TARGET_FILE_DIR:${PROJECT_NAME}>/NIS
  66. COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SAMPLES_PATH}"/DX12/src/bilinearUpscale.hlsl" $<TARGET_FILE_DIR:${PROJECT_NAME}>/NIS
  67. )
  68. add_custom_command(
  69. TARGET ${PROJECT_NAME} POST_BUILD
  70. COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DXC_BIN}/dxcompiler.dll $<TARGET_FILE_DIR:${PROJECT_NAME}>/
  71. COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DXC_BIN}/dxil.dll $<TARGET_FILE_DIR:${PROJECT_NAME}>/
  72. )
  73. add_custom_command(
  74. TARGET ${PROJECT_NAME} POST_BUILD
  75. COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:${PROJECT_NAME}>/media/images
  76. COMMAND ${CMAKE_COMMAND} -E copy_directory ${SAMPLES_PATH}/media/images $<TARGET_FILE_DIR:${PROJECT_NAME}>/media/images
  77. )