This property was added by commit v2.8.9~204^2~2 (Support building
shared libraries or modules without soname, 2012-04-22). A test for
using the property on MODULE libraries was added by commit
v2.8.9~204^2~1 (Test NO_SONAME property, 2012-04-23). Add such a test
for SHARED libraries too.
If {ARCHIVE,LIBRARY,RUNTIME}_OUTPUT_DIRECTORY is set with a genex then
do not add the per-config subdirectory on multi-config generators.
This will allow projects to use $<CONFIG> to place the per-config
part of the directory path somewhere other than the end.
When writing export files, correctly encode property values that contain
characters special to the CMake language parser. We must ensure that
they parse correctly when loaded on the consuming side.
Reported-by: Dan Liew <dan@su-root.co.uk>
The iface_test_bld gets the excludedFromAll include directory with
"-isystem" because it is added indirectly through an imported target.
On AIX with GCC the -isystem flag causes sources to be preprocessed as:
# 3 "/.../excludedFromAll.h" 2 3 4
The flags after the file name are documented here:
https://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html
and the "4" flag says that following content is extern "C". This
causes the excludedFromAll function to be declared as a C symbol
and not mangled for C++, which fails to link later because the
symbol is really provided as C++.
Work around this by setting the NO_SYSTEM_FROM_IMPORTED target property
on iface_test_bld. Somehow iface_test_exp does not end up with -isystem
so we do not need this workaround for that target.
This will allow per-config destinations for targets in EXPORT sets.
Using multiple install(TARGETS) with separate CONFIGURATIONS is
rejected as a target appearing more than once in an export set.
Now instead one can write
install(TARGETS foo EXPORT exp DESTINATION lib/$<CONFIG>)
to get a single logical membership of the target in the export set
while still having a per-config destination.
When install(EXPORT) is given an absolute destination we cannot compute
the install prefix relative to the installed export file location.
Previously we disallowed installation of targets in such exports with a
relative destination, but did not enforce this for target property
values besides the location of the main target file. This could lead to
broken installations when the EXPORT is installed to an absolute path
but usage requirements are specified relative to the install prefix.
Since an EXPORT installed to an absolute destination cannot be relocated
we can just hard-code the value of CMAKE_INSTALL_PREFIX as the base for
relative paths. This will allow absolute install(EXPORT) destinations
to work with relative destinations for targets and usage requirements.
Extend the ExportImport test with a case covering this behavior.
Add properties and variables corresponding to CXX equivalents.
Add features for c_function_prototypes (C90), c_restrict (C99),
c_variadic_macros (C99) and c_static_assert (C11). This feature
set can be extended later.
Add a <PREFIX>_RESTRICT symbol define to WriteCompilerDetectionHeader
to conditionally represent the c_restrict feature.
Teach the install(FILES) and install(PROGRAMS) commands to evaluate
generator expressions in the list of files.
Extend the ExportImport test to cover installation cases involving
generator expressions.
Code such as
target_include_directories(foo INTERFACE
$<INSTALL_INTERFACE:include$<FOO>>
)
should be treated as a relative directory, despite the genex, after
the INSTALL_INTERFACE is stripped away.
Previously, this would generate a relative directory on export, which
would be an error on import, so no policy is needed.
Code such as
install(TARGETS ...
INCLUDES DESTINATION $<INSTALL_INTERFACE:include>
)
should behave as if the INSTALL_INTERFACE wrapper were not present.
In code such as
install(TARGETS ...
INCLUDES DESTINATION $<FOO>include
)
the generator expressions are evaluated at generate-time. Delay
determining whether each entry is a relative path until after
the generator expressions are evaluated. Such relative paths
are based relative to the CMAKE_INSTALL_PREFIX.
Introduce a policy to control the behavior.
The AliasTargets unit test already tests that using a
double-semicolon in the name is not an error. Change the ExportImport
test to use a namespace with a double-semicolon too.
Export the INCLUDES DESTINATION without appending to the
INTERFACE_INCLUDE_DIRECTORIES of the target itself. That way, a target
can be exported multiple times with different INCLUDES DESTINATION
without unintended cross-pollution of export sets.
3e30d9e TLL: Don't populate old link interface if CMP0022 is NEW.
574fec9 Export: Generate INTERFACE_LINK_LIBRARIES property on targets.
d0a76ea Introduce the INTERFACE_LINK_LIBRARIES property.
ddde61c Introduce the LINK_ONLY generator expression.
5aa9731 GenexEval: Add abstracted access to link interface for a target.
This property is generated only for targets which have recorded
policy CMP0022 as NEW, and a compatibility mode is added to
additionally export the old interfaces in that case too.
If the old interfaces are not exported, the generated export files
require CMake 2.8.12. Because the unit tests use a version which
is not yet called 2.8.12, temporarily require a lower version.
If a non-IMPORTED library is added to the INTERFACE_LINK_LIBRARIES
of a IMPORTED target, the non-IMPORTED target needs to become a
target dependency and link dependency of the consuming target.
This is already the case since commit 30962029 (Make targets depend
on the link interface of their dependees, 2012-12-26), and fixed in
the parent commit, so test that it works.
This allows for example, the buildsystem to use names like 'boost_any'
instead of the overly generic 'any', and still be able to generate
IMPORTED targets called 'boost::any'.
Imported targets are re-exported so that they can be used by the
try_compile generated code with target_link_libraries.
This makes the use of the cmake_expand_imported_targets macro
obsolete. The macro is not able to expand the generator expressions
which may appear in the IMPORTED_LINK_INTERFACE_LIBRARIES content.
Instead it just sees them as 'not a target'.
This reverts commit 2c3654c3de.
The removal of some tests added in commit 77cecb77 (Add includes and compile
definitions with target_link_libraries., 2012-11-05) are also squashed
into this commit.
This establishes that linking is used to propagate usage-requirements
between targets in CMake code. The use of the target_link_libraries
command as the API for this is chosen because introducing a new command
would introduce confusion due to multiple commands which differ only in
a subtle way.
The Config and IMPORTED_ variants may also contain generator
expressions.
If 'the implementation is the interface', then the result of
evaluating the expressions at generate time is used to populate
the IMPORTED_LINK_INTERFACE_LIBRARIES property.
1) In the case of non-static libraries, this is fine because the
user still has the option to populate the LINK_INTERFACE_LIBRARIES
with generator expressions if that is what is wanted.
2) In the case of static libraries, this prevents a footgun,
enforcing that the interface and the implementation are really
the same.
Otherwise, the LINK_LIBRARIES could contain a generator
expression which is evaluated with a different context at build
time, and when used as an imported target. That would mean that the
result of evaluating the INTERFACE_LINK_LIBRARIES property for
a static library would not necessarily be the 'link implementation'.
For example:
add_library(libone STATIC libone.cpp)
add_library(libtwo STATIC libtwo.cpp)
add_library(libthree STATIC libthree.cpp)
target_link_libraries(libtwo
$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,STATIC_LIBRARY>:libone>)
target_link_libraries(libthree libtwo)
If the LINK_LIBRARIES content was simply copied to the
IMPORTED_LINK_INTERFACE_LIBRARIES, then libthree links to libone, but
executables linking to libthree will not link to libone.
3) As the 'implementation is the interface' concept is to be
deprecated in the future anyway, this should be fine.
Make a C executable instead of attempting to make a C++ static
library (and not really succeeding). This was introduced in
commit 894f52f3 (Handle INTERFACE properties transitively for
includes and defines., 2012-09-23).
Ancient versions of CMake required else(), endif(), and similar block
termination commands to have arguments matching the command starting the
block. This is no longer the preferred style.
Run the following shell code:
for c in else endif endforeach endfunction endmacro endwhile; do
echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/'
done >convert.sed &&
git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' |
egrep -z -v '^(Utilities/cm|Source/kwsys/)' |
egrep -z -v 'Tests/CMakeTests/While-Endwhile-' |
xargs -0 sed -i -f convert.sed &&
rm convert.sed