mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2026-05-24 08:17:53 -04:00
CMake: define _GNU_SOURCE for Clang, as well
Building with these will fail for Clang because _GNU_SOURCE is not
defined.
-Werror=implicit-function-declaration
-Werror=implicit-int
-Werror=strict-prototypes
Also added fix to use "MATCHES" instead of "EQUALS" in FindLLVM where
the same sort of logic is used.
This commit is contained in:
committed by
Micah Snyder
parent
e0be839e09
commit
e8a1fa6d53
@@ -188,8 +188,14 @@ if (NOT DEFINED CMAKE_INSTALL_RPATH)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
set(USING_CLANG ON)
|
||||
else()
|
||||
set(USING_CLANG OFF)
|
||||
endif()
|
||||
|
||||
if(C_LINUX)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR USING_CLANG)
|
||||
# Set _GNU_SOURCE for O_LARGEFILE, O_CLOEXEC, O_DIRECTORY, O_NOFOLLOW, etc flags on older systems
|
||||
# (pre POSIX.1-2008: glibc 2.11 and earlier). #4042
|
||||
set(_GNU_SOURCE 1)
|
||||
|
||||
@@ -113,7 +113,7 @@ else()
|
||||
)
|
||||
if(result_code)
|
||||
_LLVM_FAIL("Failed to execute llvm-config ('${LLVM_CONFIG}', result code: '${result_code})'")
|
||||
else()
|
||||
else()
|
||||
file(TO_CMAKE_PATH "${tmplibs}" tmplibs)
|
||||
string(REGEX MATCHALL "${pattern}[^ ]+" LLVM_${var} ${tmplibs})
|
||||
endif()
|
||||
@@ -163,9 +163,15 @@ else()
|
||||
set(LLVM_NATIVE_ARCH ${CMAKE_MATCH_1})
|
||||
message(STATUS "LLVM_NATIVE_ARCH: ${LLVM_NATIVE_ARCH}")
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
set(USING_CLANG ON)
|
||||
else()
|
||||
set(USING_CLANG OFF)
|
||||
endif()
|
||||
|
||||
# On CMake builds of LLVM, the output of llvm-config --cxxflags does not
|
||||
# include -fno-rtti, leading to linker errors. Be sure to add it.
|
||||
if(NOT MSVC AND (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")))
|
||||
if(NOT MSVC AND (CMAKE_COMPILER_IS_GNUCXX OR USING_CLANG))
|
||||
if(NOT ${LLVM_CXXFLAGS} MATCHES "-fno-rtti")
|
||||
set(LLVM_CXXFLAGS "${LLVM_CXXFLAGS} -fno-rtti")
|
||||
endif()
|
||||
@@ -181,7 +187,7 @@ else()
|
||||
endif()
|
||||
|
||||
# Remove gcc-specific flags for clang.
|
||||
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||
if(USING_CLANG)
|
||||
string(REPLACE "-Wno-maybe-uninitialized " "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS})
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user