From dd6538ba78f731bc81aa461dd8e78629ee85a66c Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Tue, 21 Jan 2025 18:06:31 -0500 Subject: [PATCH] GH-45325: [C++] Improved error message when using clang++ without clang --- cpp/cmake_modules/SetupCxxFlags.cmake | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake b/cpp/cmake_modules/SetupCxxFlags.cmake index fdb28b540e2d2..3f38b517e8edd 100644 --- a/cpp/cmake_modules/SetupCxxFlags.cmake +++ b/cpp/cmake_modules/SetupCxxFlags.cmake @@ -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")