Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor command-line tools to use shared header #514

Merged
merged 11 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,10 @@ if(BUILD_TOOLS AND WIN32)
add_executable(texassemble
Texassemble/texassemble.cpp
Texassemble/texassemble.rc
Texassemble/settings.manifest
Common/CmdLineHelpers.h
Common/settings.manifest
Texassemble/AnimatedGif.cpp)
target_include_directories(texassemble PRIVATE Common)
target_compile_features(texassemble PRIVATE cxx_std_17)
target_link_libraries(texassemble PRIVATE ${PROJECT_NAME} ole32.lib version.lib)
source_group(texassemble REGULAR_EXPRESSION Texassemble/*.*)
Expand All @@ -416,9 +418,11 @@ if(BUILD_TOOLS AND BUILD_DX11 AND WIN32)
add_executable(texconv
Texconv/texconv.cpp
Texconv/texconv.rc
Texconv/settings.manifest
Common/CmdLineHelpers.h
Common/settings.manifest
Texconv/ExtendedBMP.cpp
Texconv/PortablePixMap.cpp)
target_include_directories(texconv PRIVATE Common)
target_compile_features(texconv PRIVATE cxx_std_17)
target_link_libraries(texconv PRIVATE ${PROJECT_NAME} ole32.lib shell32.lib version.lib)
source_group(texconv REGULAR_EXPRESSION Texconv/*.*)
Expand All @@ -429,7 +433,9 @@ if(BUILD_TOOLS AND WIN32)
add_executable(texdiag
Texdiag/texdiag.cpp
Texdiag/texdiag.rc
Texdiag/settings.manifest)
Common/CmdLineHelpers.h
Common/settings.manifest)
target_include_directories(texdiag PRIVATE Common)
target_compile_features(texdiag PRIVATE cxx_std_17)
target_link_libraries(texdiag PRIVATE ${PROJECT_NAME} ole32.lib version.lib)
source_group(texdiag REGULAR_EXPRESSION Texdiag/*.*)
Expand Down Expand Up @@ -477,32 +483,22 @@ endif()
if(BUILD_SAMPLE AND BUILD_DX11 AND WIN32)
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_DDSVIEW_SHADERS}/ddsview_ps1D.inc)
${COMPILED_SHADERS}/ddsview_ps1D.inc)
target_link_libraries(ddsview PRIVATE ${PROJECT_NAME} d3d11.lib ole32.lib)
source_group(ddsview REGULAR_EXPRESSION DDSView/*.*)

target_include_directories(ddsview PRIVATE ${COMPILED_DDSVIEW_SHADERS})
target_include_directories(ddsview PRIVATE ${COMPILED_SHADERS})

if(NOT USE_PREBUILT_SHADERS)
add_custom_command(
OUTPUT "${COMPILED_DDSVIEW_SHADERS}/ddsview_ps1D.inc"
OUTPUT "${COMPILED_SHADERS}/ddsview_ps1D.inc"
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DDSView/hlsl.cmd"
DEPENDS "${PROJECT_SOURCE_DIR}/DDSView/ddsview.fx"
DEPENDS "DDSView/ddsview.hlsl"
COMMENT "Generating HLSL shaders for DDSView..."
COMMAND COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_DDSVIEW_SHADERS}" hlsl.cmd > "${COMPILED_DDSVIEW_SHADERS}/hlsl.log"
COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_SHADERS}" $<$<BOOL:${DIRECTX_FXC_TOOL}>:LegacyShaderCompiler=${DIRECTX_FXC_TOOL}> hlsl.cmd > "${COMPILED_SHADERS}/hlsl_ddsview.log"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/DDSView"
USES_TERMINAL)
endif()
Expand Down
Loading
Loading