Just like -I flag has its -isystem counterpart which marks an include
directory as a system directory and prevents unwanted warnings, on Apple
systems there is -iframework -- a system directory replacement for -F.
Use this flag to implement include_directories(SYSTEM) for frameworks.
We detect the implicit link directories for the toolchain by adding a
flag to get verbose output from the compiler front-end while linking the
ABI detection binary. Newer OS X toolchains based on Clang do not add
the implicit link directories with -L options to their internal
invocation of "ld". Instead they use a linker that comes with the
toolchain and is already configured with the proper directories.
Add the "-Wl,-v" option to ask "ld" to print its implicit directories.
It displays them in a block such as:
Library search paths:
/...
Parse this block to extract the implicit link directories.
While at it, remove the checks introduced by commit efaf335b (Skip
implicit link information on Xcode, 2009-07-23) and commit 5195a664
(Skip implicit link info for multiple OS X archs, 2009-09-22). Discard
the non-system link directories added by Xcode. Discard all detected
implicit libraries in the multi-architecture case but keep the
directories. The directories are still useful without the libraries
just to suppress addition of explicit -L options for them.
Drop the last use of CMAKE_OSX_SYSROOT_DEFAULT. Replace internal
platform variable CMAKE_${lang}_HAS_ISYSROOT with a more general
CMAKE_${lang}_SYSROOT_FLAG variable. If the -isysroot flag exists and
CMAKE_OSX_SYSROOT points to an SDK (not "/") then always add it to
compiler command lines. This is already done in the Xcode IDE.
The Mac linker defines flag -headerpad_max_install_names but not all
front-ends recognize the flag and pass it through (many did in the past,
such as the Apple port of GCC). Use the -Wl, option prefix to tell
front-ends to pass it through without trying to interpret it.
The commit "Split GNU compiler information files" broke the settings of
CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS
CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS
and started using just "-shared" for them. This worked when tested on newer
Mac machines, but older ones really need "-dynamiclib" and "-bundle" (which are
the documented flags anyway).
Previously we checked for this flag by parsing the version number of GCC
out of 'gcc --version', but this is not reliable because the format can
vary greatly. Now we run 'gcc -v --help' and look for '-isysroot' in
the list of options.
We also now store the result on a per-language basis in the per-compiler
info file "CMake<LANG>Compiler.cmake". This is necessary to make it
accessible from try-compile projects so that they generate correctly.