From eb9fc4d9e6b998dc320aa7afb8ba0d1b73764718 Mon Sep 17 00:00:00 2001 From: eidheim Date: Tue, 4 Mar 2025 18:42:18 +0100 Subject: [PATCH] Fixed isysroot settings on MacOS --- src/compile_commands.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/compile_commands.cpp b/src/compile_commands.cpp index ace761a..94a91e7 100644 --- a/src/compile_commands.cpp +++ b/src/compile_commands.cpp @@ -126,8 +126,16 @@ std::vector CompileCommands::get_arguments(const boost::filesystem: #ifdef __APPLE__ // Add -isysroot argument if it is missing on MacOS, which is needed by newer libclang if(std::none_of(arguments.begin(), arguments.end(), [](const std::string &argument) { return argument == "-isysroot"; })) { - arguments.emplace_back("-isysroot"); - arguments.emplace_back("/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"); + auto sysroots = {"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk", + "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"}; + boost::system::error_code ec; + for(auto &sysroot : sysroots) { + if(boost::filesystem::exists(sysroot, ec)) { + arguments.emplace_back("-isysroot"); + arguments.emplace_back(sysroot); + break; + } + } } #endif