1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-24 05:10:17 +00:00

Fixes for CMake USE_PREBUILT_SHADERS option

This commit is contained in:
Chuck Walbourn 2022-05-06 00:29:00 -07:00
parent 8215747e05
commit ea977860c2

View File

@ -121,6 +121,8 @@ if(BUILD_DX11 AND WIN32)
endif()
set(COMPILED_SHADERS ${CMAKE_CURRENT_BINARY_DIR}/Shaders/Compiled)
file(MAKE_DIRECTORY ${COMPILED_SHADERS})
else()
file(TO_CMAKE_PATH ${COMPILED_SHADERS} COMPILED_SHADERS)
endif()
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
@ -246,23 +248,33 @@ endif()
if(BUILD_SAMPLE AND BUILD_DX11 AND WIN32 AND (NOT WINDOWS_STORE))
list(APPEND TOOL_EXES ddsview)
if (NOT COMPILED_DDSVIEW_SHADERS)
if (USE_PREBUILT_SHADERS)
message(FATAL_ERROR "ERROR: Using prebuilt shaders requires the COMPILED_DDSVIEW_SHADERS variable is set")
endif()
set(COMPILED_DDSVIEW_SHADERS ${CMAKE_CURRENT_BINARY_DIR}/Shaders/Compiled)
file(MAKE_DIRECTORY ${COMPILED_DDSVIEW_SHADERS})
else()
file(TO_CMAKE_PATH ${COMPILED_DDSVIEW_SHADERS} COMPILED_DDSVIEW_SHADERS)
endif()
add_executable(ddsview WIN32
DDSView/ddsview.cpp
DDSView/ddsview.rc
${COMPILED_SHADERS}/ddsview_ps1D.inc)
${COMPILED_DDSVIEW_SHADERS}/ddsview_ps1D.inc)
target_link_libraries(ddsview ${PROJECT_NAME} d3d11.lib)
source_group(ddsview REGULAR_EXPRESSION DDSView/*.*)
target_include_directories(ddsview PRIVATE ${COMPILED_SHADERS})
target_include_directories(ddsview PRIVATE ${COMPILED_DDSVIEW_SHADERS})
if (NOT USE_PREBUILT_SHADERS)
add_custom_command(
OUTPUT "${COMPILED_SHADERS}/ddsview_ps1D.inc"
OUTPUT "${COMPILED_DDSVIEW_SHADERS}/ddsview_ps1D.inc"
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DDSView/hlsl.cmd"
DEPENDS "${PROJECT_SOURCE_DIR}/DDSView/ddsview.fx"
COMMENT "Generating HLSL shaders for DDSView..."
COMMAND set CompileShadersOutput=${COMPILED_SHADERS}
COMMAND hlsl.cmd > ${COMPILED_SHADERS}/hlsl.log
COMMAND set CompileShadersOutput=${COMPILED_DDSVIEW_SHADERS}
COMMAND hlsl.cmd > ${COMPILED_DDSVIEW_SHADERS}/hlsl.log
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/DDSView"
USES_TERMINAL)
endif()