cmake: add support for building with Intel C compiler

main
Anonymous Maarten 2023-03-21 20:38:36 +01:00 committed by Anonymous Maarten
parent 97c3077678
commit 345d1cd355
1 changed files with 17 additions and 14 deletions

View File

@ -186,7 +186,7 @@ else()
endif()
# Compiler info
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_C_COMPILER_ID MATCHES "Clang|IntelLLVM")
set(USE_CLANG TRUE)
set(SDL_ASSEMBLY_DEFAULT TRUE)
# Visual Studio 2019 v16.2 added support for Clang/LLVM.
@ -199,11 +199,14 @@ elseif(CMAKE_COMPILER_IS_GNUCC)
set(SDL_ASSEMBLY_DEFAULT TRUE)
elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+
set(SDL_ASSEMBLY_DEFAULT TRUE)
elseif(CMAKE_C_COMPILER_ID MATCHES "^Intel$")
set(SDL_ASSEMBLY_DEFAULT TRUE)
set(USE_INTELCC TRUE)
else()
set(SDL_ASSEMBLY_DEFAULT FALSE)
endif()
if(USE_GCC OR USE_CLANG)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
set(OPT_DEF_GCC_ATOMICS ON)
endif()
@ -296,7 +299,7 @@ target_include_directories(sdl-build-options
"${SDL3_SOURCE_DIR}/include"
)
# Note: The clang toolset for Visual Studio does not support the '-idirafter' option.
if(USE_GCC OR (USE_CLANG AND NOT MSVC_CLANG))
if(USE_GCC OR USE_INTELCC OR (USE_CLANG AND NOT MSVC_CLANG))
if(CMAKE_VERSION VERSION_LESS 3.12)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -idirafter \"${SDL3_SOURCE_DIR}/src/video/khronos\"")
else()
@ -530,7 +533,7 @@ if(NOT SDL_FOREGROUNDING_SIGNAL STREQUAL "OFF")
endif()
# Compiler option evaluation
if(USE_GCC OR USE_CLANG)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
# Check for -Wall first, so later things can override pieces of it.
# Note: clang-cl treats -Wall as -Weverything (which is very loud),
# /W3 as -Wall, and /W4 as -Wall -Wextra. So: /W3 is enough.
@ -731,7 +734,7 @@ if(SDL_ASSEMBLY)
endif()
if(SDL_MMX)
cmake_push_check_state()
if(USE_GCC OR USE_CLANG)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mmmx")
endif()
check_c_source_compiles("
@ -752,7 +755,7 @@ if(SDL_ASSEMBLY)
endif()
if(SDL_SSE)
cmake_push_check_state()
if(USE_GCC OR USE_CLANG)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -msse")
endif()
check_c_source_compiles("
@ -773,7 +776,7 @@ if(SDL_ASSEMBLY)
endif()
if(SDL_SSE2)
cmake_push_check_state()
if(USE_GCC OR USE_CLANG)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -msse2")
endif()
check_c_source_compiles("
@ -794,7 +797,7 @@ if(SDL_ASSEMBLY)
endif()
if(SDL_SSE3)
cmake_push_check_state()
if(USE_GCC OR USE_CLANG)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -msse3")
endif()
check_c_source_compiles("
@ -815,7 +818,7 @@ if(SDL_ASSEMBLY)
endif()
if(SDL_SSE4_1)
cmake_push_check_state()
if(USE_GCC OR USE_CLANG)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -msse4.1")
endif()
check_c_source_compiles("
@ -836,7 +839,7 @@ if(SDL_ASSEMBLY)
endif()
if(SDL_SSE4_2)
cmake_push_check_state()
if(USE_GCC OR USE_CLANG)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -msse4.2")
endif()
check_c_source_compiles("
@ -859,7 +862,7 @@ if(SDL_ASSEMBLY)
endif()
if(SDL_AVX)
cmake_push_check_state()
if(USE_GCC OR USE_CLANG)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mavx")
endif()
check_c_source_compiles("
@ -880,7 +883,7 @@ if(SDL_ASSEMBLY)
endif()
if(SDL_AVX2)
cmake_push_check_state()
if(USE_GCC OR USE_CLANG)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mavx2")
endif()
check_c_source_compiles("
@ -901,7 +904,7 @@ if(SDL_ASSEMBLY)
endif()
if(SDL_AVX512)
cmake_push_check_state()
if(USE_GCC OR USE_CLANG)
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mavx512f")
endif()
check_c_source_compiles("
@ -2957,7 +2960,7 @@ if(SDL_WERROR)
if(HAVE_WX)
target_compile_options(sdl-global-options INTERFACE "/WX")
endif()
elseif(USE_GCC OR USE_CLANG)
elseif(USE_GCC OR USE_CLANG OR USE_INTELCC)
check_c_compiler_flag(-Werror HAVE_WERROR)
if(HAVE_WERROR)
target_compile_options(sdl-global-options INTERFACE "-Werror")