diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-06-07 17:20:43 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2019-06-07 17:20:43 +0200 |
commit | ac02c47e001cb297bda1d6684d7dd95ae1a23469 (patch) | |
tree | c4a5464632853bb09b7a8959c36857690928bfbb | |
parent | 8a52dd10fc105cce54afd3a0cf7a16b10990c9e2 (diff) |
Fix /usr/local/{include,lib} logic for Mac OS 10.14
Turns out there /usr/include is no more.
-rw-r--r-- | build2/cc/module.cxx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx index e06ddb8..436688a 100644 --- a/build2/cc/module.cxx +++ b/build2/cc/module.cxx @@ -276,6 +276,10 @@ namespace build2 static const dir_path usr_inc ("/usr/include"); static const dir_path usr_loc_lib ("/usr/local/lib"); static const dir_path usr_loc_inc ("/usr/local/include"); +# ifdef __APPLE__ + static const dir_path a_usr_inc ( + "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"); +# endif #endif void config_module:: @@ -350,6 +354,47 @@ namespace build2 bool ui (find (is.begin (), is.end (), usr_inc) != is.end ()); bool uli (find (is.begin (), is.end (), usr_loc_inc) != is.end ()); +#ifdef __APPLE__ + // On Mac OS starting from 10.14 there is no longer /usr/include. + // Instead we get the following: + // + // Homebrew GCC 9: + // + // /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include + // + // Apple Clang 10.0.1: + // + // /Library/Developer/CommandLineTools/usr/include + // /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include + // + // What exactly all this means is anyone's guess, of course. So for + // now we will assume that anything that is or resolves (like that + // MacOSX10.14.sdk symlink) to: + // + // /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include + // + // Is Apple's /usr/include. + // + if (!ui && !uli) + { + for (const dir_path& d: inc_dirs) + { + // Both Clang and GCC skip non-existent paths but let's handle + // (and ignore) directories that cause any errors, for good + // measure. + // + try + { + if (d == a_usr_inc || dir_path (d).realize () == a_usr_inc) + { + ui = true; + break; + } + } + catch (...) {} + } + } +#endif if (ui || uli) { bool ull (find (ls.begin (), ls.end (), usr_loc_lib) != ls.end ()); |