Skip to content

Commit 68dc40a

Browse files
authored
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 <lbtinglb@gmail.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent 5dde5d4 commit 68dc40a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,13 @@ if(ARROW_TESTING)
22292229
1.10.0
22302230
USE_CONFIG
22312231
${GTEST_USE_CONFIG})
2232+
get_target_property(gtest_cxx_standard GTest::gtest INTERFACE_COMPILE_FEATURES)
2233+
2234+
if((${gtest_cxx_standard} STREQUAL "cxx_std_11") OR (${gtest_cxx_standard} STREQUAL
2235+
"cxx_std_14"))
2236+
message(FATAL_ERROR "System GTest is built with a C++ standard lower than 17. Use bundled GTest via passing in CMake flag
2237+
-DGTest_SOURCE=\"BUNDLED\"")
2238+
endif()
22322239

22332240
if(GTest_SOURCE STREQUAL "SYSTEM")
22342241
find_package(PkgConfig QUIET)

0 commit comments

Comments
 (0)