macOS: Revert finding tools inside Xcode that are not in the PATH

Since commit 03ab170fe0 (OS X: Enable command-line build without tools in
PATH, 2013-08-05, v2.8.12~111^2) we find compilers such as

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc

when there is no corresponding compiler in the PATH.  However, modern
macOS versions always have `/usr/bin/cc` in the PATH, so this code path is
never taken (similarly for `make`).  Even if it were, the compilers in
Xcode cannot be used by build systems that do not add an `-isysroot` flag.
Instead, they should be used through the `/usr/bin/cc` wrapper, which
internally calls Xcode's compiler with a default `-isysroot` flag.
This commit is contained in:
Brad King
2024-11-06 08:20:28 -05:00
parent 77fcee9204
commit c55c113076
2 changed files with 0 additions and 31 deletions

View File

@@ -82,27 +82,6 @@ macro(_cmake_find_compiler lang)
endif()
unset(_${lang}_COMPILER_HINTS)
unset(_languages)
# Look for a make tool provided by Xcode
if(CMAKE_${lang}_COMPILER STREQUAL "CMAKE_${lang}_COMPILER-NOTFOUND" AND CMAKE_HOST_APPLE)
macro(_query_xcrun compiler_name result_var_keyword result_var)
if(NOT "x${result_var_keyword}" STREQUAL "xRESULT_VAR")
message(FATAL_ERROR "Bad arguments to macro")
endif()
execute_process(COMMAND xcrun --find ${compiler_name}
OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE _xcrun_err)
set("${result_var}" "${_xcrun_out}")
endmacro()
foreach(comp IN LISTS CMAKE_${lang}_COMPILER_LIST)
_query_xcrun("${comp}" RESULT_VAR xcrun_result)
if(xcrun_result)
set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${xcrun_result}")
break()
endif()
endforeach()
endif()
endmacro()
macro(_cmake_find_compiler_path lang)

View File

@@ -4,13 +4,3 @@
find_program(CMAKE_MAKE_PROGRAM NAMES gmake make smake)
mark_as_advanced(CMAKE_MAKE_PROGRAM)
# Look for a make tool provided by Xcode
if(NOT CMAKE_MAKE_PROGRAM AND CMAKE_HOST_APPLE)
execute_process(COMMAND xcrun --find make
OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE _xcrun_err)
if(_xcrun_out)
set_property(CACHE CMAKE_MAKE_PROGRAM PROPERTY VALUE "${_xcrun_out}")
endif()
endif()