Support for Windows Subsystem for Linux (#208)

This commit is contained in:
Chuck Walbourn
2021-01-08 02:20:55 -08:00
committed by GitHub
parent 705a8e3766
commit 234eee8a01
27 changed files with 1101 additions and 379 deletions

View File

@@ -53,7 +53,6 @@ set(LIBRARY_SOURCES
DirectXTex/DirectXTexCompress.cpp
DirectXTex/DirectXTexConvert.cpp
DirectXTex/DirectXTexDDS.cpp
DirectXTex/DirectXTexFlipRotate.cpp
DirectXTex/DirectXTexHDR.cpp
DirectXTex/DirectXTexImage.cpp
DirectXTex/DirectXTexMipmaps.cpp
@@ -62,20 +61,26 @@ set(LIBRARY_SOURCES
DirectXTex/DirectXTexPMAlpha.cpp
DirectXTex/DirectXTexResize.cpp
DirectXTex/DirectXTexTGA.cpp
DirectXTex/DirectXTexUtil.cpp
DirectXTex/DirectXTexWIC.cpp)
DirectXTex/DirectXTexUtil.cpp)
if(WIN32)
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
DirectXTex/DirectXTexFlipRotate.cpp
DirectXTex/DirectXTexWIC.cpp)
endif()
set(SHADER_SOURCES
DirectXTex/Shaders/BC6HEncode.hlsl
DirectXTex/Shaders/BC7Encode.hlsl)
if(BUILD_DX11)
if(BUILD_DX11 AND WIN32)
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
DirectXTex/BCDirectCompute.h
DirectXTex/BCDirectCompute.cpp
DirectXTex/DirectXTexCompressGPU.cpp
DirectXTex/DirectXTexD3D11.cpp)
endif()
if(BUILD_DX12)
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
DirectXTex/d3dx12.h
@@ -91,7 +96,7 @@ if(ENABLE_OPENEXR_SUPPORT)
DirectXTex/DirectXTexEXR.cpp)
endif()
if(BUILD_DX11)
if(BUILD_DX11 AND WIN32)
set(LIBRARY_SOURCES ${LIBRARY_SOURCES}
DirectXTex/Shaders/Compiled/BC6HEncode_EncodeBlockCS.inc)
@@ -134,6 +139,12 @@ if(MSVC)
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
endif()
if (NOT WIN32)
find_package(directx-headers CONFIG REQUIRED)
find_package(directxmath CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft::DirectX-Headers Microsoft::DirectXMath)
endif()
#--- Package
include(CMakePackageConfigHelpers)
@@ -168,7 +179,7 @@ install(FILES
DESTINATION cmake/)
#--- Command-line tools
if(BUILD_TOOLS)
if(BUILD_TOOLS AND WIN32)
add_executable(texassemble
Texassemble/texassemble.cpp
Texassemble/AnimatedGif.cpp)
@@ -199,7 +210,7 @@ endif()
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast)
if(BUILD_TOOLS)
if(BUILD_TOOLS AND WIN32)
target_compile_options(texassemble PRIVATE /fp:fast)
target_compile_options(texconv PRIVATE /fp:fast)
target_compile_options(texdiag PRIVATE /fp:fast)
@@ -207,7 +218,7 @@ if(MSVC)
if (${CMAKE_SIZEOF_VOID_P} EQUAL "4")
target_compile_options(${PROJECT_NAME} PRIVATE /arch:SSE2)
if(BUILD_TOOLS)
if(BUILD_TOOLS AND WIN32)
target_compile_options(texassemble PRIVATE /arch:SSE2)
target_compile_options(texconv PRIVATE /arch:SSE2)
target_compile_options(texdiag PRIVATE /arch:SSE2)
@@ -215,22 +226,22 @@ if(MSVC)
endif()
endif()
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(WarningsLib "-Wpedantic" "-Wextra")
target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib})
# OpenMP is not supported for clang for Windows by default
if(BUILD_TOOLS)
if(BUILD_TOOLS AND WIN32)
set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-switch" "-Wno-switch-enum" "-Wno-language-extension-token" "-Wno-missing-prototypes")
target_compile_options(texassemble PRIVATE ${WarningsEXE})
target_compile_options(texconv PRIVATE ${WarningsEXE} "-Wno-global-constructors")
target_compile_options(texdiag PRIVATE ${WarningsEXE} "-Wno-double-promotion")
endif()
endif()
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(${PROJECT_NAME} PRIVATE /permissive- /JMC- /Zc:__cplusplus)
if(BUILD_TOOLS)
if(BUILD_TOOLS AND WIN32)
target_compile_options(texassemble PRIVATE /permissive- /Zc:__cplusplus)
target_compile_options(texconv PRIVATE /permissive- /Zc:__cplusplus)
target_compile_options(texdiag PRIVATE /permissive- /Zc:__cplusplus)
@@ -238,7 +249,7 @@ if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
if(ENABLE_CODE_ANALYSIS)
target_compile_options(${PROJECT_NAME} PRIVATE /analyze)
if(BUILD_TOOLS)
if(BUILD_TOOLS AND WIN32)
target_compile_options(texassemble PRIVATE /analyze)
target_compile_options(texconv PRIVATE /analyze)
target_compile_options(texdiag PRIVATE /analyze)
@@ -247,7 +258,7 @@ if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26)
target_compile_options(${PROJECT_NAME} PRIVATE /Zc:preprocessor /wd5105)
if(BUILD_TOOLS)
if(BUILD_TOOLS AND WIN32)
target_compile_options(texassemble PRIVATE /Zc:preprocessor /wd5105)
target_compile_options(texconv PRIVATE /Zc:preprocessor /wd5105)
target_compile_options(texdiag PRIVATE /Zc:preprocessor /wd5105)
@@ -256,12 +267,12 @@ if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
if(BC_USE_OPENMP)
target_compile_options(${PROJECT_NAME} PRIVATE /openmp /Zc:twoPhase-)
if(BUILD_TOOLS)
if(BUILD_TOOLS AND WIN32)
target_compile_options(texconv PRIVATE /openmp /Zc:twoPhase-)
endif()
endif()
if(BUILD_TOOLS)
if(BUILD_TOOLS AND WIN32)
set(WarningsEXE "/wd4061" "/wd4062" "/wd4365" "/wd4668" "/wd4710" "/wd4820" "/wd5039" "/wd5045" "/wd5219")
target_compile_options(texassemble PRIVATE ${WarningsEXE})
target_compile_options(texconv PRIVATE ${WarningsEXE})
@@ -284,6 +295,6 @@ if(WIN32)
endif()
endif()
if(BUILD_TOOLS)
if(BUILD_TOOLS AND WIN32)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT texconv)
endif()