1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-21 12:00:06 +00:00

Update CMake to work with Intel compilers (#451)

This commit is contained in:
Chuck Walbourn 2024-02-09 11:52:49 -08:00 committed by GitHub
parent 416c2364e0
commit 7fbe35ff34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 146 additions and 63 deletions

View File

@ -456,6 +456,7 @@ if(BUILD_TOOLS AND WIN32)
Texassemble/texassemble.rc
Texassemble/settings.manifest
Texassemble/AnimatedGif.cpp)
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/*.*)
list(APPEND TOOL_EXES texassemble)
@ -468,6 +469,7 @@ if(BUILD_TOOLS AND BUILD_DX11 AND WIN32)
Texconv/settings.manifest
Texconv/ExtendedBMP.cpp
Texconv/PortablePixMap.cpp)
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/*.*)
list(APPEND TOOL_EXES texconv)
@ -478,6 +480,7 @@ if(BUILD_TOOLS AND WIN32)
Texdiag/texdiag.cpp
Texdiag/texdiag.rc
Texdiag/settings.manifest)
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/*.*)
list(APPEND TOOL_EXES texdiag)
@ -573,28 +576,10 @@ if(MSVC)
endforeach()
endif()
if(ENABLE_SPECTRE_MITIGATION
AND (MSVC_VERSION GREATER_EQUAL 1913)
AND (NOT WINDOWS_STORE)
AND (NOT ENABLE_OPENEXR_SUPPORT)
AND (NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")))
message(STATUS "Building Spectre-mitigated libraries")
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE "/Qspectre")
endforeach()
endif()
if((MSVC_VERSION GREATER_EQUAL 1924)
AND ((NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)))
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /ZH:SHA_256)
endforeach()
endif()
if((MSVC_VERSION GREATER_EQUAL 1928)
AND (CMAKE_SIZEOF_VOID_P EQUAL 8)
AND NOT ENABLE_OPENEXR_SUPPORT
AND ((NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)))
AND ((NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang|IntelLLVM")) OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)))
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE "$<$<NOT:$<CONFIG:DEBUG>>:/guard:ehcont>")
target_link_options(${t} PRIVATE "$<$<NOT:$<CONFIG:DEBUG>>:/guard:ehcont>")
@ -619,9 +604,9 @@ elseif(XBOX_CONSOLE_TARGET MATCHES "(xboxone|durango)")
target_compile_options(${PROJECT_NAME} PRIVATE $<IF:$<CXX_COMPILER_ID:MSVC>,/favor:AMD64 /arch:AVX,-march=btver2>)
elseif(NOT (${DIRECTX_ARCH} MATCHES "^arm"))
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ARCH_SSE2 $<$<CXX_COMPILER_ID:MSVC>:/arch:SSE2> $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-msse2>)
set(ARCH_SSE2 $<$<CXX_COMPILER_ID:MSVC,Intel>:/arch:SSE2> $<$<NOT:$<CXX_COMPILER_ID:MSVC,Intel>>:-msse2>)
else()
set(ARCH_SSE2 $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-msse2>)
set(ARCH_SSE2 $<$<NOT:$<CXX_COMPILER_ID:MSVC,Intel>>:-msse2>)
endif()
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
@ -635,7 +620,13 @@ if(MINGW)
endforeach()
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|IntelLLVM")
if(MSVC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0))
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /ZH:SHA_256)
endforeach()
endif()
set(WarningsLib -Wall -Wpedantic -Wextra)
if((BUILD_XBOX_EXTS_XBOXONE OR BUILD_XBOX_EXTS_SCARLETT) AND WIN32)
@ -657,6 +648,11 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE "-Wno-ignored-attributes" "-Walloc-size-larger-than=4GB")
endforeach()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /Zc:__cplusplus /Zc:inline /fp:fast /Qdiag-disable:161)
endforeach()
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /sdl /permissive- /JMC- /Zc:__cplusplus /Zc:inline /fp:fast)
@ -675,6 +671,22 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
endforeach()
endif()
if(ENABLE_SPECTRE_MITIGATION
AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.13)
AND (NOT ENABLE_OPENEXR_SUPPORT)
AND (NOT WINDOWS_STORE))
message(STATUS "Building Spectre-mitigated libraries")
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE "/Qspectre")
endforeach()
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.24)
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /ZH:SHA_256)
endforeach()
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26)
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /Zc:preprocessor /wd5105)
@ -723,7 +735,9 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(${t} PRIVATE ${WarningsEXE})
endforeach()
if (BUILD_FUZZING AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.32)
if(BUILD_FUZZING
AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.32)
AND (NOT WINDOWS_STORE))
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
target_compile_options(${t} PRIVATE /fsanitize=address /fsanitize-coverage=inline-8bit-counters /fsanitize-coverage=edge /fsanitize-coverage=trace-cmp /fsanitize-coverage=trace-div)
target_link_libraries(${t} PRIVATE sancov.lib)

View File

@ -202,6 +202,29 @@
"VCPKG_HOST_TRIPLET": "x64-mingw-static"
}
},
{
"name": "Intel",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_COMPILER": "icl.exe",
"BUILD_TOOLS": false
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{
"name": "IntelLLVM",
"hidden": true,
"cacheVariables": {
"CMAKE_CXX_COMPILER": "icx.exe"
},
"toolset": {
"value": "host=x64",
"strategy": "external"
}
},
{
"name": "Fuzzing",
"cacheVariables": {
@ -301,6 +324,12 @@
{ "name": "arm64-Debug-Linux", "description": "WSL Linux ARM64 (Debug)", "inherits": [ "base", "ARM64", "Debug", "VCPKG", "JPEG_PNG" ] },
{ "name": "arm64-Release-Linux", "description": "WSL Linux ARM64 (Release)", "inherits": [ "base", "ARM64", "Release", "VCPKG", "JPEG_PNG" ] },
{ "name": "x64-Debug-ICC" , "description": "Intel Classic Compiler (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "Intel" ] },
{ "name": "x64-Release-ICC" , "description": "Intel Classic Compiler (Release) with DX12", "inherits": [ "base", "x64", "Release", "Intel" ] },
{ "name": "x64-Debug-ICX" , "description": "Intel oneAPI Compiler (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "IntelLLVM" ] },
{ "name": "x64-Release-ICX" , "description": "Intel oneAPI Compiler (Release) with DX12", "inherits": [ "base", "x64", "Release", "IntelLLVM" ] },
{ "name": "x64-Fuzzing" , "description": "MSVC for x64 (Release) with ASan", "inherits": [ "base", "x64", "Release", "MSVC", "Fuzzing" ] }
],
"testPresets": [
@ -321,6 +350,12 @@
{ "name": "x64-Debug-MinGW" , "configurePreset": "x64-Debug-MinGW" },
{ "name": "x64-Release-MinGW" , "configurePreset": "x64-Release-MinGW" },
{ "name": "x86-Debug-MinGW" , "configurePreset": "x86-Debug-MinGW" },
{ "name": "x86-Release-MinGW" , "configurePreset": "x86-Release-MinGW" }
{ "name": "x86-Release-MinGW" , "configurePreset": "x86-Release-MinGW" },
{ "name": "x64-Debug-ICC" , "configurePreset": "x64-Debug-ICC" },
{ "name": "x64-Release-ICC" , "configurePreset": "x64-Release-ICC"},
{ "name": "x64-Debug-ICX" , "configurePreset": "x64-Debug-ICX" },
{ "name": "x64-Release-ICX" , "configurePreset": "x64-Release-ICX"}
]
}

View File

@ -41,6 +41,11 @@ namespace
const GUID& wic;
DXGI_FORMAT format;
bool srgb;
constexpr WICTranslate(const GUID& wg, DXGI_FORMAT fmt, bool isrgb) noexcept :
wic(wg),
format(fmt),
srgb(isrgb) {}
};
constexpr WICTranslate g_WICFormats[] =

View File

@ -25,6 +25,11 @@ namespace
const GUID& source;
const GUID& target;
TEX_ALPHA_MODE alphaMode;
constexpr WICConvert(const GUID& src, const GUID& tgt, TEX_ALPHA_MODE mode) noexcept :
source(src),
target(tgt),
alphaMode(mode) {}
};
constexpr WICConvert g_WICConvert[] =

View File

@ -84,6 +84,10 @@ namespace
{
const GUID& wic;
DXGI_FORMAT format;
constexpr WICTranslate(const GUID& wg, DXGI_FORMAT fmt) noexcept :
wic(wg),
format(fmt) {}
};
constexpr WICTranslate g_WICFormats[] =
@ -118,6 +122,10 @@ namespace
{
const GUID& source;
const GUID& target;
constexpr WICConvert(const GUID& src, const GUID& tgt) noexcept :
source(src),
target(tgt) {}
};
constexpr WICConvert g_WICConvert[] =

View File

@ -75,6 +75,10 @@ namespace
{
const GUID& wic;
DXGI_FORMAT format;
constexpr WICTranslate(const GUID& wg, DXGI_FORMAT fmt) noexcept :
wic(wg),
format(fmt) {}
};
constexpr WICTranslate g_WICFormats[] =
@ -111,6 +115,10 @@ namespace
{
const GUID& source;
const GUID& target;
constexpr WICConvert(const GUID& src, const GUID& tgt) noexcept :
source(src),
target(tgt) {}
};
constexpr WICConvert g_WICConvert[] =

View File

@ -63,6 +63,10 @@ namespace
{
const GUID& wic;
D3DFORMAT format;
constexpr WICTranslate(const GUID& wg, D3DFORMAT fmt) noexcept :
wic(wg),
format(fmt) {}
};
constexpr WICTranslate g_WICFormats[] =
@ -95,6 +99,10 @@ namespace
{
const GUID& source;
const GUID& target;
constexpr WICConvert(const GUID& src, const GUID& tgt) noexcept :
source(src),
target(tgt) {}
};
constexpr WICConvert g_WICConvert[] =