This is an automated email from the ASF dual-hosted git repository. alexey pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 056308c978e97e3ec550f04ca2d842f833e93cee Author: Alexey Serbin <[email protected]> AuthorDate: Fri Aug 5 19:24:11 2022 -0700 [macos] fix build on macOS (Xcode 12.4 and earlier) The change introduced by [1] broke build on my macOS laptop with Xcode 12.4. This patch addresses the issue: as it turned out, starting with Xcode 12.5 the location of the libc++ headers changed, so it's necessary to use different approaches for different Xcode versions (for details, see the comment added in src/kudu/codegen/CMakeLists.txt). I verified the new approach works on my Intel-based laptop: * macOS Catalina 10.15.7 with Xcode 11.7, 12.4 * macOS BigSur 11.6.8 with Xcode 11.7, 12.4, 12.5, 13.2.1. [1] https://github.com/apache/kudu/commit/543e128d473f8f7836e605bba8cd6512fa918550 Change-Id: Ib47f2d04cb87a3fc9c9a8b8c10c17d4f502c47c0 Reviewed-on: http://gerrit.cloudera.org:8080/18820 Tested-by: Alexey Serbin <[email protected]> Reviewed-by: Attila Bukor <[email protected]> Tested-by: Attila Bukor <[email protected]> --- src/kudu/codegen/CMakeLists.txt | 46 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/src/kudu/codegen/CMakeLists.txt b/src/kudu/codegen/CMakeLists.txt index c87b0047a..eb32a41d5 100644 --- a/src/kudu/codegen/CMakeLists.txt +++ b/src/kudu/codegen/CMakeLists.txt @@ -65,11 +65,47 @@ foreach(noprefix ${IR_INCLUDES}) endforeach() if (APPLE) - # OS X keeps the libc++ headers in a non-standard location that the thirdparty - # Clang does not know about by default. - set(PREFIXED_IR_INCLUDES - ${PREFIXED_IR_INCLUDES} - -cxx-isystem "${CMAKE_OSX_SYSROOT}") + # The macOS keeps the libc++ headers in a non-standard location so + # that the thirdparty CLANG does not know about by default. + # + # Xcode starting with version 12.5 has the libc++ headers under + # Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk, + # which corresponds to CMAKE_OSX_SYSROOT, so it's enough to add -isysroot + # pointing to CMAKE_OSX_SYSROOT. + # + # Xcode prior to version 12.5 (12.4 and earlier, inclusive) doesn't have the + # libc++ headers under CMAKE_OSX_SYSROOT, but instead keeps those under + # Contents/Developer/Toolchains/XcodeDefault.xctoolchain: with that, + # it's easy to deduce the path to the libc++ headers from the output + # produced by `clang++ --version`. + # + # For non-clang compilers, assume the libc++ include directory provided + # with the Xcode command line tools. + if (NOT "${COMPILER_FAMILY}" STREQUAL "clang") + set(PREFIXED_IR_INCLUDES + ${PREFIXED_IR_INCLUDES} + -cxx-isystem "/Library/Developer/CommandLineTools/usr/include/c++/v1") + elseif (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 12.0.5) + execute_process( + COMMAND ${CMAKE_CXX_COMPILER} --version + COMMAND grep -E "^InstalledDir: " + COMMAND sed "s/^InstalledDir: \\(.*\\)$/\\1/" + RESULT_VARIABLE CXX_INSTALLED_DIR_CMD_EXIT_CODE + OUTPUT_VARIABLE CXX_INSTALLED_DIR_CMD_OUT + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (${CXX_INSTALLED_DIR_CMD_EXIT_CODE} EQUAL 0 AND + NOT ${CXX_INSTALLED_DIR_CMD_OUT} STREQUAL "") + set(PREFIXED_IR_INCLUDES + ${PREFIXED_IR_INCLUDES} + -cxx-isystem "${CXX_INSTALLED_DIR_CMD_OUT}/../include/c++/v1") + else() + message(FATAL_ERROR "failed to deduce path to libc++ headers") + endif() + else() + set(PREFIXED_IR_INCLUDES + ${PREFIXED_IR_INCLUDES} + -isysroot "${CMAKE_OSX_SYSROOT}") + endif() endif() # Get preprocessing definitions, which enable directives for glog and gtest.
