145 lines
4.1 KiB
CMake
145 lines
4.1 KiB
CMake
cmake_minimum_required(VERSION 3.15)
|
|
|
|
project(D3D12_Integration)
|
|
|
|
set(ENGINE_ROOT_DIR ${CMAKE_SOURCE_DIR}/../engine)
|
|
|
|
find_package(Python3 REQUIRED)
|
|
|
|
enable_testing()
|
|
|
|
# Minimal test - just verifies initialization and render loop
|
|
add_executable(D3D12_Minimal
|
|
WIN32
|
|
main_minimal.cpp
|
|
)
|
|
|
|
target_include_directories(D3D12_Minimal PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
${CMAKE_CURRENT_SOURCE_DIR}/stbi
|
|
${ENGINE_ROOT_DIR}/include
|
|
)
|
|
|
|
target_compile_definitions(D3D12_Minimal PRIVATE
|
|
UNICODE
|
|
_UNICODE
|
|
)
|
|
|
|
target_include_directories(D3D12_Minimal PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
${ENGINE_ROOT_DIR}/third_party
|
|
${ENGINE_ROOT_DIR}/include
|
|
)
|
|
|
|
target_link_libraries(D3D12_Minimal PRIVATE
|
|
d3d12
|
|
dxgi
|
|
d3dcompiler
|
|
winmm
|
|
XCEngine
|
|
)
|
|
|
|
# Render model test - complete rendering with model, shader, texture
|
|
add_executable(D3D12_RenderModel
|
|
WIN32
|
|
main_render.cpp
|
|
${CMAKE_CURRENT_SOURCE_DIR}/stbi/stb_image.cpp
|
|
)
|
|
|
|
target_include_directories(D3D12_RenderModel PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
${CMAKE_CURRENT_SOURCE_DIR}/stbi
|
|
${ENGINE_ROOT_DIR}/include
|
|
)
|
|
|
|
target_compile_definitions(D3D12_RenderModel PRIVATE
|
|
UNICODE
|
|
_UNICODE
|
|
)
|
|
|
|
target_include_directories(D3D12_RenderModel PRIVATE
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
${ENGINE_ROOT_DIR}/third_party
|
|
${ENGINE_ROOT_DIR}/include
|
|
)
|
|
|
|
target_link_libraries(D3D12_RenderModel PRIVATE
|
|
d3d12
|
|
dxgi
|
|
d3dcompiler
|
|
winmm
|
|
XCEngine
|
|
)
|
|
|
|
# Copy Res folder to output directory for Minimal test
|
|
add_custom_command(TARGET D3D12_Minimal POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Res
|
|
$<TARGET_FILE_DIR:D3D12_Minimal>/Res
|
|
)
|
|
|
|
# Copy Res folder to output directory for RenderModel test
|
|
add_custom_command(TARGET D3D12_RenderModel POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Res
|
|
$<TARGET_FILE_DIR:D3D12_RenderModel>/Res
|
|
)
|
|
|
|
# Copy test scripts to output directory for Minimal test
|
|
add_custom_command(TARGET D3D12_Minimal POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
${CMAKE_CURRENT_SOURCE_DIR}/run.bat
|
|
$<TARGET_FILE_DIR:D3D12_Minimal>/run.bat
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
${CMAKE_CURRENT_SOURCE_DIR}/compare_ppm.py
|
|
$<TARGET_FILE_DIR:D3D12_Minimal>/compare_ppm.py
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
${CMAKE_CURRENT_SOURCE_DIR}/GT.ppm
|
|
$<TARGET_FILE_DIR:D3D12_Minimal>/GT.ppm
|
|
)
|
|
|
|
# Copy test scripts to output directory for RenderModel test
|
|
add_custom_command(TARGET D3D12_RenderModel POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
${CMAKE_CURRENT_SOURCE_DIR}/run.bat
|
|
$<TARGET_FILE_DIR:D3D12_RenderModel>/run.bat
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
${CMAKE_CURRENT_SOURCE_DIR}/compare_ppm.py
|
|
$<TARGET_FILE_DIR:D3D12_RenderModel>/compare_ppm.py
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
${CMAKE_CURRENT_SOURCE_DIR}/GT.ppm
|
|
$<TARGET_FILE_DIR:D3D12_RenderModel>/GT.ppm
|
|
)
|
|
|
|
# Copy run_integration_test.py to output directories
|
|
add_custom_command(TARGET D3D12_Minimal POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
${CMAKE_CURRENT_SOURCE_DIR}/run_integration_test.py
|
|
$<TARGET_FILE_DIR:D3D12_Minimal>/run_integration_test.py
|
|
)
|
|
|
|
add_custom_command(TARGET D3D12_RenderModel POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
${CMAKE_CURRENT_SOURCE_DIR}/run_integration_test.py
|
|
$<TARGET_FILE_DIR:D3D12_RenderModel>/run_integration_test.py
|
|
)
|
|
|
|
# Register integration tests with CTest
|
|
add_test(NAME D3D12_Minimal_Integration
|
|
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/run_integration_test.py
|
|
$<TARGET_FILE:D3D12_Minimal>
|
|
minimal.ppm
|
|
${CMAKE_CURRENT_SOURCE_DIR}/GT.ppm
|
|
5
|
|
WORKING_DIRECTORY $<TARGET_FILE_DIR:D3D12_Minimal>
|
|
)
|
|
|
|
add_test(NAME D3D12_RenderModel_Integration
|
|
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/run_integration_test.py
|
|
$<TARGET_FILE:D3D12_RenderModel>
|
|
screenshot.ppm
|
|
${CMAKE_CURRENT_SOURCE_DIR}/GT.ppm
|
|
5
|
|
WORKING_DIRECTORY $<TARGET_FILE_DIR:D3D12_RenderModel>
|
|
)
|