This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 68dc40a10b GH-14917: [C++] Error out when GTest is compiled with a C++ 
standard lower than 17 (#34765)
68dc40a10b is described below

commit 68dc40a10bc752d8b577f57976873d087714d486
Author: Haocheng Liu <[email protected]>
AuthorDate: Fri Mar 31 04:28:45 2023 -0400

    GH-14917: [C++] Error out when GTest is compiled with a C++ standard lower 
than 17 (#34765)
    
    ### Rationale for this change
    On MacOS, the system GTest from brew uses C++14 while arrow is default to 
C++17.
    The build will fail at the linking stage unless users explicity uses 
bundled GTest.
    
    Users are often confused by unclear linking errors.
    
    ### What changes are included in this PR?
    At CMake configuration time, the CMake code will automatically detect and
    compare the C++ standard used by GTest and arrow. If a mismatch is detected,
    CMake will error out and privide meaningful guidance. It will apply both to
    linux and MacOS.
    
    ### Are these changes tested?
    Covered by Arrow github test worker and tested on local host.
    
    ### Are there any user-facing changes?
    Yes, now users are given better guidance when building Arrow against the 
system
    GTest.
    
    * Closes: #14917
    * Closes: #14779
    
    Authored-by: Haocheng Liu <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 cpp/cmake_modules/ThirdpartyToolchain.cmake | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake 
b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 1e1b876c7b..bee62f3b90 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -2229,6 +2229,13 @@ if(ARROW_TESTING)
                      1.10.0
                      USE_CONFIG
                      ${GTEST_USE_CONFIG})
+  get_target_property(gtest_cxx_standard GTest::gtest 
INTERFACE_COMPILE_FEATURES)
+
+  if((${gtest_cxx_standard} STREQUAL "cxx_std_11") OR (${gtest_cxx_standard} 
STREQUAL
+                                                       "cxx_std_14"))
+    message(FATAL_ERROR "System GTest is built with a C++ standard lower than 
17. Use bundled GTest via passing in CMake flag
+-DGTest_SOURCE=\"BUNDLED\"")
+  endif()
 
   if(GTest_SOURCE STREQUAL "SYSTEM")
     find_package(PkgConfig QUIET)

Reply via email to