Fix Windows build by guarding -Wno-c2y-extensions flag for Clang only
The -Wno-c2y-extensions flag is Clang-specific. Adding it to CMAKE_CXX_FLAGS unconditionally breaks Windows builds with MSVC, as MSVC doesn't recognize this flag and causes CMake compile tests (including Google Benchmark's regex detection) to fail.
This commit is contained in:
committed by
aneshlya
parent
ae507b3d03
commit
bf8de4f3d8
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2020-2025, Intel Corporation
|
||||
# Copyright (c) 2020-2026, Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
@@ -32,7 +32,7 @@ set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Suppressing benchmark's tests" FORC
|
||||
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Suppressing benchmark's install" FORCE)
|
||||
|
||||
# Suppress C2y extension warnings from LLVM trunk before including Google Benchmark
|
||||
if (${LLVM_VERSION_NUMBER} VERSION_GREATER_EQUAL "22.0.0")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND ${LLVM_VERSION_NUMBER} VERSION_GREATER_EQUAL "21.0.0")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c2y-extensions")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ else()
|
||||
endif()
|
||||
|
||||
# LLVM 21+ has stricter warnings about C2y extensions (__COUNTER__ in benchmark library)
|
||||
if (NOT WIN32 AND (${LLVM_VERSION_MAJOR} VERSION_GREATER_EQUAL 21 OR ${LLVM_VERSION} STREQUAL "trunk"))
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND (${LLVM_VERSION_MAJOR} VERSION_GREATER_EQUAL 21 OR ${LLVM_VERSION} STREQUAL "trunk"))
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c2y-extensions")
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user