mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-03 14:20:27 +00:00
ALIAS: Add support for add_dependencies for ALIAS targets
The add_dependencies command currently accepts ALIAS targets for <target-dependencies> which resolve to the referenced target. This further relaxes the command to accept an ALIAS <target> where the command will add the dependencies to the target which the alias references.
This commit is contained in:
@@ -35,6 +35,10 @@ transitively in its place since the target itself does not build.
|
||||
The command may be called with no dependencies.
|
||||
Previously, at least one dependency was required.
|
||||
|
||||
.. versionchanged:: 4.5
|
||||
If ``<target>`` is an :ref:`Alias Target <Alias Targets>`, dependencies are
|
||||
added to the target which the alias references.
|
||||
|
||||
See Also
|
||||
^^^^^^^^
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ alias-transparency
|
||||
:command:`target_link_directories`, :command:`target_link_libraries`,
|
||||
:command:`target_link_options`, :command:`target_precompile_headers`,
|
||||
and :command:`target_sources` commands now accept :ref:`Alias Targets`.
|
||||
The commands operate on the target which the alias references.
|
||||
The command operates on the target which the alias references.
|
||||
|
||||
* The :command:`add_dependencies` command now accepts :ref:`Alias Targets`.
|
||||
Dependencies are added to the target which the alias references.
|
||||
|
||||
* The :prop_tgt:`ALIASED_TARGET` target property is now read-only.
|
||||
|
||||
@@ -19,12 +19,6 @@ bool cmAddDependenciesCommand(std::vector<std::string> const& args,
|
||||
|
||||
cmMakefile& mf = status.GetMakefile();
|
||||
std::string const& target_name = args[0];
|
||||
if (mf.IsAlias(target_name)) {
|
||||
mf.IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
cmStrCat("Cannot add target-level dependencies to alias target \"",
|
||||
target_name, "\".\n"));
|
||||
}
|
||||
if (cmTarget* target = mf.FindTargetToUse(target_name)) {
|
||||
|
||||
// skip over target_name
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1,5 +0,0 @@
|
||||
CMake Error at add_dependencies\.cmake:9 \(add_dependencies\):
|
||||
Cannot add target-level dependencies to alias target "alias"\.
|
||||
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:3 \(include\)
|
||||
@@ -7,3 +7,8 @@ add_library(bar empty.cpp)
|
||||
add_library(alias ALIAS foo)
|
||||
|
||||
add_dependencies(alias bar)
|
||||
|
||||
get_property(DEPS TARGET foo PROPERTY MANUALLY_ADDED_DEPENDENCIES)
|
||||
if(NOT DEPS STREQUAL "bar")
|
||||
message(SEND_ERROR "add_dependencies(): Expected 'bar' as dependency of 'foo' but got: '${DEPS}' instead of 'bar'.")
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user