diff --git a/CMakeLists.txt b/CMakeLists.txt index c2cd5d5..0da7059 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ if(APPLE) include_directories(/usr/local/opt/gettext/include) set(CMAKE_MACOSX_RPATH 1) - set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/libsigc++@2/lib/pkgconfig:/usr/local/opt/zlib/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig") + set(ENV{PKG_CONFIG_PATH} "/opt/homebrew/opt/fontconfig/lib/pkgconfig:/usr/local/opt/fontconfig/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/libsigc++@2/lib/pkgconfig:/usr/local/opt/zlib/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig") endif() if(${CMAKE_SYSTEM_NAME} MATCHES FreeBSD) link_directories(/usr/local/lib) diff --git a/src/compile_commands.cpp b/src/compile_commands.cpp index 3fb4fd9..ace761a 100644 --- a/src/compile_commands.cpp +++ b/src/compile_commands.cpp @@ -123,6 +123,14 @@ std::vector CompileCommands::get_arguments(const boost::filesystem: arguments.emplace_back(resource_path); } +#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"); + } +#endif + // Do not add -fretain-comments-from-system-headers if pch is used, since the pch was most likely made without this flag if(std::none_of(arguments.begin(), arguments.end(), [](const std::string &argument) { return argument == "-include-pch"; })) arguments.emplace_back("-fretain-comments-from-system-headers");