Fix build with clang-13

This commit is contained in:
Alexey Milovidov 2021-08-16 03:16:45 +03:00
parent 5c56d3a734
commit 9a4a8d3943
2 changed files with 22 additions and 9 deletions

View File

@ -9,10 +9,6 @@ if (GLIBC_COMPATIBILITY)
check_include_file("sys/random.h" HAVE_SYS_RANDOM_H) check_include_file("sys/random.h" HAVE_SYS_RANDOM_H)
if(COMPILER_CLANG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-builtin-requires-header")
endif()
add_headers_and_sources(glibc_compatibility .) add_headers_and_sources(glibc_compatibility .)
add_headers_and_sources(glibc_compatibility musl) add_headers_and_sources(glibc_compatibility musl)
if (ARCH_AARCH64) if (ARCH_AARCH64)
@ -35,11 +31,9 @@ if (GLIBC_COMPATIBILITY)
add_library(glibc-compatibility STATIC ${glibc_compatibility_sources}) add_library(glibc-compatibility STATIC ${glibc_compatibility_sources})
if (COMPILER_CLANG) target_no_warning(glibc-compatibility unused-command-line-argument)
target_compile_options(glibc-compatibility PRIVATE -Wno-unused-command-line-argument) target_no_warning(glibc-compatibility unused-but-set-variable)
elseif (COMPILER_GCC) target_no_warning(glibc-compatibility builtin-requires-header)
target_compile_options(glibc-compatibility PRIVATE -Wno-unused-but-set-variable)
endif ()
target_include_directories(glibc-compatibility PRIVATE libcxxabi ${musl_arch_include_dir}) target_include_directories(glibc-compatibility PRIVATE libcxxabi ${musl_arch_include_dir})

View File

@ -27,3 +27,22 @@ endmacro ()
macro (no_warning flag) macro (no_warning flag)
add_warning(no-${flag}) add_warning(no-${flag})
endmacro () endmacro ()
# The same but only for specified target.
macro (target_add_warning target flag)
string (REPLACE "-" "_" underscored_flag ${flag})
string (REPLACE "+" "x" underscored_flag ${underscored_flag})
check_cxx_compiler_flag("-W${flag}" SUPPORTS_CXXFLAG_${underscored_flag})
if (SUPPORTS_CXXFLAG_${underscored_flag})
target_compile_options (${target} PRIVATE "-W${flag}")
else ()
message (WARNING "Flag -W${flag} is unsupported")
endif ()
endmacro ()
macro (target_no_warning target flag)
target_add_warning(${target} no-${flag})
endmacro ()