Update CMake to work with Intel compilers (#127)
This commit is contained in:
Родитель
02cfa72796
Коммит
352b900b08
136
CMakeLists.txt
136
CMakeLists.txt
|
@ -125,25 +125,29 @@ include(CheckIncludeFileCXX)
|
|||
if(DEFINED XBOX_CONSOLE_TARGET)
|
||||
message(STATUS "Building for Xbox Console Target: ${XBOX_CONSOLE_TARGET}")
|
||||
set(CMAKE_REQUIRED_QUIET ON)
|
||||
CHECK_INCLUDE_FILE_CXX(gxdk.h GXDK_HEADER)
|
||||
if(NOT GXDK_HEADER)
|
||||
message(FATAL_ERROR "Microsoft GDK with Xbox Extensions required to build for Xbox. See https://aka.ms/gdkx")
|
||||
endif()
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC WINAPI_FAMILY=WINAPI_FAMILY_GAMES)
|
||||
if(XBOX_CONSOLE_TARGET STREQUAL "scarlett")
|
||||
CHECK_INCLUDE_FILE_CXX(d3d12_xs.h D3D12XS_HEADER)
|
||||
if(NOT D3D12XS_HEADER)
|
||||
message(FATAL_ERROR "Microsoft GDK with Xbox Extensions environment needs to be set for Xbox Series X|S.")
|
||||
endif()
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC _GAMING_XBOX _GAMING_XBOX_SCARLETT)
|
||||
elseif(XBOX_CONSOLE_TARGET STREQUAL "xboxone")
|
||||
CHECK_INCLUDE_FILE_CXX(d3d12_x.h D3D12X_HEADER)
|
||||
if(NOT D3D12X_HEADER)
|
||||
message(FATAL_ERROR "Microsoft GDK with Xbox Extensions environment needs to be set for Xbox One.")
|
||||
endif()
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC _GAMING_XBOX _GAMING_XBOX_XBOXONE)
|
||||
if(XBOX_CONSOLE_TARGET STREQUAL "durango")
|
||||
message(FATAL_ERROR "This library no longer supports legacy Xbox One XDK.")
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown XBOX_CONSOLE_TARGET")
|
||||
CHECK_INCLUDE_FILE_CXX(gxdk.h GXDK_HEADER)
|
||||
if(NOT GXDK_HEADER)
|
||||
message(FATAL_ERROR "Microsoft GDK with Xbox Extensions required to build for Xbox. See https://aka.ms/gdkx")
|
||||
endif()
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC WINAPI_FAMILY=WINAPI_FAMILY_GAMES)
|
||||
if(XBOX_CONSOLE_TARGET STREQUAL "scarlett")
|
||||
CHECK_INCLUDE_FILE_CXX(d3d12_xs.h D3D12XS_HEADER)
|
||||
if(NOT D3D12XS_HEADER)
|
||||
message(FATAL_ERROR "Microsoft GDK with Xbox Extensions environment needs to be set for Xbox Series X|S.")
|
||||
endif()
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC _GAMING_XBOX _GAMING_XBOX_SCARLETT)
|
||||
elseif(XBOX_CONSOLE_TARGET STREQUAL "xboxone")
|
||||
CHECK_INCLUDE_FILE_CXX(d3d12_x.h D3D12X_HEADER)
|
||||
if(NOT D3D12X_HEADER)
|
||||
message(FATAL_ERROR "Microsoft GDK with Xbox Extensions environment needs to be set for Xbox One.")
|
||||
endif()
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC _GAMING_XBOX _GAMING_XBOX_XBOXONE)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown XBOX_CONSOLE_TARGET")
|
||||
endif()
|
||||
endif()
|
||||
elseif(WINDOWS_STORE)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC WINAPI_FAMILY=WINAPI_FAMILY_APP)
|
||||
|
@ -249,6 +253,7 @@ if(BUILD_TOOLS AND WIN32)
|
|||
Meshconvert/Mesh.h
|
||||
Meshconvert/Mesh.cpp
|
||||
Meshconvert/SDKMesh.h)
|
||||
target_compile_features(meshconvert PRIVATE cxx_std_17)
|
||||
target_include_directories(meshconvert PRIVATE MeshConvert Utilities)
|
||||
target_link_libraries(meshconvert PRIVATE ${PROJECT_NAME} version.lib)
|
||||
source_group(meshconvert REGULAR_EXPRESSION meshconvert/*.*)
|
||||
|
@ -270,30 +275,13 @@ if(MSVC)
|
|||
endforeach()
|
||||
endif()
|
||||
|
||||
if(ENABLE_SPECTRE_MITIGATION
|
||||
AND (MSVC_VERSION GREATER_EQUAL 1913)
|
||||
AND (NOT WINDOWS_STORE)
|
||||
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 (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) 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>")
|
||||
endforeach()
|
||||
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>")
|
||||
endforeach()
|
||||
endif()
|
||||
else()
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
|
@ -307,9 +295,9 @@ elseif(XBOX_CONSOLE_TARGET STREQUAL "xboxone")
|
|||
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})
|
||||
|
@ -323,7 +311,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(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)
|
||||
list(APPEND WarningsLib "-Wno-unsafe-buffer-usage")
|
||||
|
@ -338,6 +332,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)
|
||||
|
@ -356,39 +355,54 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|||
endforeach()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26)
|
||||
if(ENABLE_SPECTRE_MITIGATION
|
||||
AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.13)
|
||||
AND (NOT WINDOWS_STORE))
|
||||
message(STATUS "Building Spectre-mitigated libraries")
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_options(${t} PRIVATE /Zc:preprocessor /wd5105)
|
||||
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)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) AND (NOT (${DIRECTX_ARCH} MATCHES "^arm")))
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_link_options(${t} PRIVATE /CETCOMPAT)
|
||||
endforeach()
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_link_options(${t} PRIVATE /CETCOMPAT)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.28)
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_options(${t} PRIVATE /Zc:lambda)
|
||||
endforeach()
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_options(${t} PRIVATE /Zc:lambda)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.35)
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_options(${t} PRIVATE /Zc:checkGwOdr)
|
||||
endforeach()
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_options(${t} PRIVATE /Zc:checkGwOdr)
|
||||
endforeach()
|
||||
|
||||
if(NOT (DEFINED XBOX_CONSOLE_TARGET))
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_options(${t} PRIVATE $<$<VERSION_GREATER_EQUAL:${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION},10.0.22000>:/Zc:templateScope>)
|
||||
endforeach()
|
||||
endif()
|
||||
if(NOT (DEFINED XBOX_CONSOLE_TARGET))
|
||||
foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME})
|
||||
target_compile_options(${t} PRIVATE $<$<VERSION_GREATER_EQUAL:${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION},10.0.22000>:/Zc:templateScope>)
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(WarningsEXE "/wd4061" "/wd4365" "/wd4514" "/wd4625" "/wd4626" "/wd4627" "/wd4668" "/wd4710" "/wd4711" "/wd4751" "/wd4820" "/wd5026" "/wd5027" "/wd5039" "/wd5045" "/wd5219")
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.34)
|
||||
list(APPEND WarningsEXE "/wd5262" "/wd5264")
|
||||
list(APPEND WarningsEXE "/wd5262" "/wd5264")
|
||||
endif()
|
||||
foreach(t IN LISTS TOOL_EXES)
|
||||
target_compile_options(${t} PRIVATE ${WarningsEXE})
|
||||
|
@ -418,7 +432,7 @@ if(WIN32)
|
|||
endif()
|
||||
|
||||
if(BUILD_TOOLS AND WIN32)
|
||||
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT meshconvert)
|
||||
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT meshconvert)
|
||||
endif()
|
||||
|
||||
if(BUILD_TOOLS AND (NOT VCPKG_TOOLCHAIN))
|
||||
|
|
|
@ -152,6 +152,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": "x64-Debug" , "description": "MSVC for x64 (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "MSVC" ] },
|
||||
{ "name": "x64-Release" , "description": "MSVC for x64 (Release) with DX12", "inherits": [ "base", "x64", "Release", "MSVC" ] },
|
||||
|
@ -209,6 +232,12 @@
|
|||
{ "name": "x86-Debug-MinGW" , "description": "MinG-W32 (Debug)", "inherits": [ "base", "x86", "Debug", "GNUC", "VCPKG", "MinGW32" ] },
|
||||
{ "name": "x86-Release-MinGW", "description": "MinG-W32 (Release)", "inherits": [ "base", "x86", "Release", "GNUC", "VCPKG", "MinGW32" ] },
|
||||
|
||||
{ "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-Debug-Linux", "description": "WSL Linux x64 (Debug)", "inherits": [ "base", "x64", "Debug", "VCPKG" ] },
|
||||
{ "name": "x64-Release-Linux", "description": "WSL Linux x64 (Release)", "inherits": [ "base", "x64", "Release", "VCPKG" ] },
|
||||
{ "name": "arm64-Debug-Linux", "description": "WSL Linux ARM64 (Debug)", "inherits": [ "base", "ARM64", "Debug", "VCPKG" ] },
|
||||
|
@ -232,6 +261,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" }
|
||||
]
|
||||
}
|
|
@ -52,6 +52,11 @@
|
|||
// C4643 Forward declaring in namespace std is not permitted by the C++ Standard
|
||||
#endif
|
||||
|
||||
#ifdef __INTEL_COMPILER
|
||||
#pragma warning(disable : 161)
|
||||
// warning #161: unrecognized #pragma
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wc++98-compat"
|
||||
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
||||
|
|
Загрузка…
Ссылка в новой задаче