The "debug", "optimized", and "general" link library type specifier
arguments to the target_link_library commands are sometimes repeated in
user code due to variable expansion and other complications. Instead of
silently accepting the duplicates and trying to link to a bogus library
like "optimized.lib", warn and ignore the earlier specifiers.
The add_subdirectory() command's EXCLUDE_FROM_ALL option does not
override inter-target dependencies. This change clarifies the
documentation accordingly.
When an executable target within the project is named in
target_link_libraries for another target, but the executable does not
have the ENABLE_EXPORTS property set, then the executable cannot really
be linked. This is probably a case where the user intends to link to a
third-party library that happens to have the same name as an executable
target in the project (or else will get an error at build time). We
need to avoid making the other target depend on the executable target
incorrectly, since the executable may actually want to link to that
target and this is not a circular depenency.
After reporting an error about circular target dependencies do not try
to continue generation because the dependency computation object is not
in a useful state.
Custom command dependencies that are not full paths or targets may also
match source files. When one does, the full information about the
source file's location and name may be used. This fixes the case when a
custom commands depends by relative path on a source file generated by
another custom command specifying its output by relative path.
A name with an ambiguous extension may only match an unambiguous name
that is extended by one of the fixed set of extensions tried when
finding the source file on disk. This rule makes matching of source
files with ambiguous extensions much less aggressive but still
sufficient.
When generating RPATH entries on the link line using a repeated linker
flag (-R ... -R ... style) do not convert individual entries to a full
path. We need to preserve what the user requested.
When generating escape sequences for the native build tool do not put in
Makefile escapes for paths generated into link scripts. This fixes
putting "$ORIGIN" into the RPATH, and probably some other subtle
problems.
Creation of archive libraries with the unix 'ar' tool should be done
incrementally when the number of object files is large. This avoids
problems with the command line getting too many arguments.
When attempting to load the RPATH out of a non-ELF file cmELF would
crash because the check for a valid file was done with in correct
operator precedence. See bug#7392.
For historical reasons we still support naming of source files without
their extension. Sources without known extensions are located on disk
by iterating through a fixed set of possible extensions. We now want
users to always specify the extension, so the fixed set will not be
expanded and is preserved for compatibility with older projects.
This change adds recognition of extensions of all enabled languages to
avoid checking the disk for files whose extensions are unambiguous but
not in the original fixed set.
In CMake 2.4 the generated link line for a target always preserved the
originally specified libraries in their original order. Dependencies
were satisfied by inserting extra libraries into the line, though it had
some bugs. In CMake 2.6.0 we preserved only the items on the link line
that are not known to be shared libraries. This reduced excess
libraries on the link line. However, since we link to system libraries
(such as /usr/lib/libm.so) by asking the linker to search (-lm), some
linkers secretly replace the library with a static library in another
implicit search directory (developers can override this by using an
imported target to force linking by full path). When this happens the
order still matters.
To avoid this and other potential subtle issues this commit restores
preservation of all non-target items and static library targets. This
will create cases of unnecessary, duplicate shared libraries on the link
line if the user specifies them, but at least it will work. In the
future we can attempt a more advanced analysis to safely remove
duplicate shared libraries from the link line.
We preserve the order and multiplicity of libraries directly linked by a
target as specified by the user. Items known to be shared libraries may
be safely skipped because order preservation is only needed for static
libraries. However, CMake 2.4 did not skip shared libs, so we do the
same when in 2.4 compatibility mode.
We never explicitly specify system library directories in linker or
runtime search paths. Furthermore, libraries in these directories are
always linked by asking the linker to search for them. We need to
generate a warning when explicitly specified search directories contain
files that may hide the system libraries during the search.