Skip to content

Commit 73aa2f3

Browse files
authored
Refactor command-line tools to use shared header (#514)
1 parent 1deadd3 commit 73aa2f3

File tree

67 files changed

+1133
-1604
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1133
-1604
lines changed

CMakeLists.txt

+21-20
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ elseif((BUILD_XBOX_EXTS_XBOXONE OR BUILD_XBOX_EXTS_SCARLETT) AND WIN32)
143143
Auxiliary/DirectXTexXboxTile.cpp)
144144
endif()
145145

146-
147146
if(BUILD_DX11 AND WIN32 AND (NOT (XBOX_CONSOLE_TARGET STREQUAL "durango")))
148147
set(SHADER_SOURCES
149148
DirectXTex/Shaders/BC6HEncode.hlsl
@@ -160,7 +159,7 @@ if(BUILD_DX12)
160159
list(APPEND LIBRARY_SOURCES DirectXTex/DirectXTexD3D12.cpp)
161160

162161
if(NOT (DEFINED XBOX_CONSOLE_TARGET))
163-
list(APPEND LIBRARY_SOURCES DirectXTex/d3dx12.h)
162+
list(APPEND LIBRARY_SOURCES Common/d3dx12.h)
164163
endif()
165164
endif()
166165

@@ -404,7 +403,8 @@ if(BUILD_TOOLS AND WIN32)
404403
add_executable(texassemble
405404
Texassemble/texassemble.cpp
406405
Texassemble/texassemble.rc
407-
Texassemble/settings.manifest
406+
Common/CmdLineHelpers.h
407+
Common/settings.manifest
408408
Texassemble/AnimatedGif.cpp)
409409
target_compile_features(texassemble PRIVATE cxx_std_17)
410410
target_link_libraries(texassemble PRIVATE ${PROJECT_NAME} ole32.lib version.lib)
@@ -416,7 +416,8 @@ if(BUILD_TOOLS AND BUILD_DX11 AND WIN32)
416416
add_executable(texconv
417417
Texconv/texconv.cpp
418418
Texconv/texconv.rc
419-
Texconv/settings.manifest
419+
Common/CmdLineHelpers.h
420+
Common/settings.manifest
420421
Texconv/ExtendedBMP.cpp
421422
Texconv/PortablePixMap.cpp)
422423
target_compile_features(texconv PRIVATE cxx_std_17)
@@ -429,13 +430,18 @@ if(BUILD_TOOLS AND WIN32)
429430
add_executable(texdiag
430431
Texdiag/texdiag.cpp
431432
Texdiag/texdiag.rc
432-
Texdiag/settings.manifest)
433+
Common/CmdLineHelpers.h
434+
Common/settings.manifest)
433435
target_compile_features(texdiag PRIVATE cxx_std_17)
434436
target_link_libraries(texdiag PRIVATE ${PROJECT_NAME} ole32.lib version.lib)
435437
source_group(texdiag REGULAR_EXPRESSION Texdiag/*.*)
436438
list(APPEND TOOL_EXES texdiag)
437439
endif()
438440

441+
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
442+
target_include_directories(${t} PRIVATE Common)
443+
endforeach()
444+
439445
if(BUILD_TOOLS AND WIN32)
440446
if(ENABLE_OPENEXR_SUPPORT)
441447
foreach(t IN LISTS TOOL_EXES)
@@ -477,32 +483,22 @@ endif()
477483
if(BUILD_SAMPLE AND BUILD_DX11 AND WIN32)
478484
list(APPEND TOOL_EXES ddsview)
479485

480-
if(NOT COMPILED_DDSVIEW_SHADERS)
481-
if(USE_PREBUILT_SHADERS)
482-
message(FATAL_ERROR "ERROR: Using prebuilt shaders requires the COMPILED_DDSVIEW_SHADERS variable is set")
483-
endif()
484-
set(COMPILED_DDSVIEW_SHADERS ${CMAKE_CURRENT_BINARY_DIR}/Shaders/Compiled)
485-
file(MAKE_DIRECTORY ${COMPILED_DDSVIEW_SHADERS})
486-
else()
487-
file(TO_CMAKE_PATH ${COMPILED_DDSVIEW_SHADERS} COMPILED_DDSVIEW_SHADERS)
488-
endif()
489-
490486
add_executable(ddsview WIN32
491487
DDSView/ddsview.cpp
492488
DDSView/ddsview.rc
493-
${COMPILED_DDSVIEW_SHADERS}/ddsview_ps1D.inc)
489+
${COMPILED_SHADERS}/ddsview_ps1D.inc)
494490
target_link_libraries(ddsview PRIVATE ${PROJECT_NAME} d3d11.lib ole32.lib)
495491
source_group(ddsview REGULAR_EXPRESSION DDSView/*.*)
496492

497-
target_include_directories(ddsview PRIVATE ${COMPILED_DDSVIEW_SHADERS})
493+
target_include_directories(ddsview PRIVATE ${COMPILED_SHADERS})
498494

499495
if(NOT USE_PREBUILT_SHADERS)
500496
add_custom_command(
501-
OUTPUT "${COMPILED_DDSVIEW_SHADERS}/ddsview_ps1D.inc"
497+
OUTPUT "${COMPILED_SHADERS}/ddsview_ps1D.inc"
502498
MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DDSView/hlsl.cmd"
503-
DEPENDS "${PROJECT_SOURCE_DIR}/DDSView/ddsview.fx"
499+
DEPENDS "DDSView/ddsview.hlsl"
504500
COMMENT "Generating HLSL shaders for DDSView..."
505-
COMMAND COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_DDSVIEW_SHADERS}" hlsl.cmd > "${COMPILED_DDSVIEW_SHADERS}/hlsl.log"
501+
COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_SHADERS}" $<$<BOOL:${DIRECTX_FXC_TOOL}>:LegacyShaderCompiler=${DIRECTX_FXC_TOOL}> hlsl.cmd > "${COMPILED_SHADERS}/hlsl_ddsview.log"
506502
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/DDSView"
507503
USES_TERMINAL)
508504
endif()
@@ -514,6 +510,10 @@ if(directxmath_FOUND)
514510
endforeach()
515511
endif()
516512

513+
if(TOOL_EXES)
514+
message(STATUS "Building tools: ${TOOL_EXES}")
515+
endif()
516+
517517
if(MSVC)
518518
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
519519
target_compile_options(${t} PRIVATE /Wall /GR-)
@@ -574,6 +574,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
574574
endif()
575575

576576
if(ENABLE_CODE_ANALYSIS)
577+
message(STATUS "Building with Code Analysis (PREFIX)")
577578
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
578579
target_compile_options(${t} PRIVATE /analyze /WX)
579580
endforeach()

CMakePresets.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,8 @@
353353
{ "name": "x64-Debug-ICX" , "description": "Intel oneAPI Compiler (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "IntelLLVM" ] },
354354
{ "name": "x64-Release-ICX" , "description": "Intel oneAPI Compiler (Release) with DX12", "inherits": [ "base", "x64", "Release", "IntelLLVM" ] },
355355

356-
{ "name": "x64-Fuzzing" , "description": "MSVC for x64 (Release) with ASan", "inherits": [ "base", "x64", "Release", "MSVC", "Fuzzing" ] }
356+
{ "name": "x64-Fuzzing" , "description": "MSVC for x64 (Release) with ASan", "inherits": [ "base", "x64", "Release", "MSVC", "Fuzzing" ] },
357+
{ "name": "x64-Analyze" , "description": "MSVC for x64 (Debug) with DX12 using /analyze", "inherits": [ "base", "x64", "Debug", "MSVC" ], "cacheVariables": { "ENABLE_CODE_ANALYSIS": true } }
357358
],
358359
"testPresets": [
359360
{ "name": "x64-Debug" , "configurePreset": "x64-Debug" },

0 commit comments

Comments
 (0)