Skip to content

Commit

Permalink
GH-45325: [C++] Improved error message when using clang++ without clang
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAyd committed Jan 21, 2025
1 parent 984519d commit 51e2039
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions cpp/cmake_modules/SetupCxxFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ include(CheckCXXSourceCompiles)

message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}")

if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(UsingClang TRUE)
else()
set(UsingClang FALSE)
endif()

# Check for Clang C++ compiler
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(UsingClangPlusPlus TRUE)
else()
set(UsingClangPlusPlus FALSE)
endif()

if(${UsingClangPlusPlus} AND NOT ${UsingClang})
message(FATAL_ERROR "When using clang++ you must also use clang")
endif()

if(NOT DEFINED ARROW_CPU_FLAG)
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(ARROW_CPU_FLAG "emscripten")
Expand Down Expand Up @@ -430,14 +447,6 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STRE
"Clang")
# Clang options for all builds

# Using Clang with ccache causes a bunch of spurious warnings that are
# purportedly fixed in the next version of ccache. See the following for details:
#
# http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html
# http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")

# Avoid error when an unknown warning flag is passed
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-unknown-warning-option")
# Add colors when paired with ninja
Expand Down

0 comments on commit 51e2039

Please sign in to comment.