[cmake] unify clang detection
* Move Clang detection to own CMake file * Check for Clang and AppleClang * Use CMAKE_COMPILER_IS_CLANG to check for Clang in code
This commit is contained in:
parent
55258cd9eb
commit
26e570e9fe
@ -73,6 +73,7 @@ include(CheckLibraryExists)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckStructHasMember)
|
||||
include(TestBigEndian)
|
||||
include(CompilerDetect)
|
||||
|
||||
include(FindFeature)
|
||||
include(ShowCMakeVars)
|
||||
@ -249,7 +250,7 @@ if (CMAKE_GENERATOR MATCHES "Unix Makefile*")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
|
||||
if(CMAKE_COMPILER_IS_CLANG)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-c11-extensions -Wno-gnu")
|
||||
endif()
|
||||
|
||||
@ -260,7 +261,7 @@ if(NOT IOS)
|
||||
endif()
|
||||
|
||||
# Enable address sanitizer, where supported and when required
|
||||
if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCC)
|
||||
if(CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCC)
|
||||
CHECK_C_COMPILER_FLAG ("-fno-omit-frame-pointer" fno-omit-frame-pointer)
|
||||
|
||||
if (fno-omit-frame-pointer)
|
||||
|
6
cmake/CompilerDetect.cmake
Normal file
6
cmake/CompilerDetect.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(CMAKE_COMPILER_IS_CLANG 1)
|
||||
endif()
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
|
||||
set(CMAKE_COMPILER_IS_CLANG 1)
|
||||
endif()
|
@ -27,9 +27,7 @@ option(WITH_NEON "Enable NEON optimization." OFF)
|
||||
|
||||
option(WITH_JPEG "Use JPEG decoding." OFF)
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(CMAKE_COMPILER_IS_CLANG 1)
|
||||
endif()
|
||||
include(CompilerDetect)
|
||||
|
||||
if(NOT WIN32)
|
||||
CMAKE_DEPENDENT_OPTION(WITH_VALGRIND_MEMCHECK "Compile with valgrind helpers." OFF
|
||||
|
@ -59,8 +59,10 @@ set(CODEC_LIBS "")
|
||||
list(APPEND CODEC_SRCS ${CODEC_SSE2_SRCS})
|
||||
list(APPEND CODEC_SRCS ${CODEC_NEON_SRCS})
|
||||
|
||||
include(CompilerDetect)
|
||||
|
||||
if(WITH_SSE2)
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
|
||||
if (CODEC_SSE2_SRCS)
|
||||
set_source_files_properties(${CODEC_SSE2_SRCS} PROPERTIES COMPILE_FLAGS "-msse2" )
|
||||
endif()
|
||||
|
@ -86,8 +86,9 @@ add_library(freerdp-primitives OBJECT
|
||||
${PRIMITIVES_SRCS}
|
||||
)
|
||||
|
||||
include(CompilerDetect)
|
||||
if(WITH_SSE2)
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
|
||||
if(PRIMITIVES_SSE2_SRCS)
|
||||
set_source_files_properties(${PRIMITIVES_SSE2_SRCS} PROPERTIES COMPILE_FLAGS "-msse2" )
|
||||
endif()
|
||||
@ -112,7 +113,7 @@ if(WITH_SSE2)
|
||||
set_source_files_properties(${PRIMITIVES_OPT_SRCS} PROPERTIES COMPILE_FLAGS "/arch:SSE2")
|
||||
endif()
|
||||
elseif(WITH_NEON)
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
|
||||
if (NOT MSVC_ARM64 AND NOT ARCH_ARM64)
|
||||
set_source_files_properties(${PRIMITIVES_OPT_SRCS} PROPERTIES COMPILE_FLAGS "-mfpu=neon")
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user