Merge topic 'add_dependencies-INTERFACE-libraries'
ac14cbf0
Allow add_dependencies() on INTERFACE libraries (#15414)817d31db
Help: Format add_dependencies documentation
This commit is contained in:
commit
c117c2bb5e
|
@ -7,13 +7,16 @@ Add a dependency between top-level targets.
|
||||||
|
|
||||||
add_dependencies(<target> [<target-dependency>]...)
|
add_dependencies(<target> [<target-dependency>]...)
|
||||||
|
|
||||||
Make a top-level <target> depend on other top-level targets to ensure
|
Make a top-level ``<target>`` depend on other top-level targets to
|
||||||
that they build before <target> does. A top-level target is one
|
ensure that they build before ``<target>`` does. A top-level target
|
||||||
created by ADD_EXECUTABLE, ADD_LIBRARY, or ADD_CUSTOM_TARGET.
|
is one created by one of the :command:`add_executable`,
|
||||||
Dependencies added to an IMPORTED target are followed transitively in
|
:command:`add_library`, or :command:`add_custom_target` commands.
|
||||||
its place since the target itself does not build.
|
|
||||||
|
|
||||||
See the DEPENDS option of ADD_CUSTOM_TARGET and ADD_CUSTOM_COMMAND for
|
Dependencies added to an :ref:`imported target <Imported Targets>`
|
||||||
adding file-level dependencies in custom rules. See the
|
or an :ref:`interface library <Interface Libraries>` are followed
|
||||||
OBJECT_DEPENDS option in SET_SOURCE_FILES_PROPERTIES to add file-level
|
transitively in its place since the target itself does not build.
|
||||||
dependencies to object files.
|
|
||||||
|
See the ``DEPENDS`` option of :command:`add_custom_target` and
|
||||||
|
:command:`add_custom_command` commands for adding file-level
|
||||||
|
dependencies in custom rules. See the :prop_sf:`OBJECT_DEPENDS`
|
||||||
|
source file property to add file-level dependencies to object files.
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
add_dependencies-INTERFACE-libraries
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
* The :command:`add_dependencies` command learned to allow dependencies
|
||||||
|
to be added to :ref:`interface libraries <Interface Libraries>`.
|
||||||
|
Dependencies added to an interface library are followed transitively
|
||||||
|
in its place since the target itself does not build.
|
|
@ -33,15 +33,6 @@ bool cmAddDependenciesCommand
|
||||||
}
|
}
|
||||||
if(cmTarget* target = this->Makefile->FindTargetToUse(target_name))
|
if(cmTarget* target = this->Makefile->FindTargetToUse(target_name))
|
||||||
{
|
{
|
||||||
if (target->GetType() == cmTarget::INTERFACE_LIBRARY)
|
|
||||||
{
|
|
||||||
std::ostringstream e;
|
|
||||||
e << "Cannot add target-level dependencies to INTERFACE library "
|
|
||||||
"target \"" << target_name << "\".\n";
|
|
||||||
this->SetError(e.str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string>::const_iterator s = args.begin();
|
std::vector<std::string>::const_iterator s = args.begin();
|
||||||
++s; // skip over target_name
|
++s; // skip over target_name
|
||||||
for (; s != args.end(); ++s)
|
for (; s != args.end(); ++s)
|
||||||
|
|
|
@ -418,9 +418,11 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
|
||||||
cmTarget const* dependee,
|
cmTarget const* dependee,
|
||||||
bool linking)
|
bool linking)
|
||||||
{
|
{
|
||||||
if(dependee->IsImported())
|
if(dependee->IsImported() ||
|
||||||
|
dependee->GetType() == cmTarget::INTERFACE_LIBRARY)
|
||||||
{
|
{
|
||||||
// Skip imported targets but follow their utility dependencies.
|
// Skip IMPORTED and INTERFACE targets but follow their utility
|
||||||
|
// dependencies.
|
||||||
std::set<cmLinkItem> const& utils = dependee->GetUtilityItems();
|
std::set<cmLinkItem> const& utils = dependee->GetUtilityItems();
|
||||||
for(std::set<cmLinkItem>::const_iterator i = utils.begin();
|
for(std::set<cmLinkItem>::const_iterator i = utils.begin();
|
||||||
i != utils.end(); ++i)
|
i != utils.end(); ++i)
|
||||||
|
|
|
@ -3,6 +3,11 @@ set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
|
||||||
|
|
||||||
add_library(headeriface INTERFACE)
|
add_library(headeriface INTERFACE)
|
||||||
|
|
||||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/iface_header_builddir.h"
|
add_custom_target(headeriface_gen
|
||||||
"#define IFACE_HEADER_BUILDDIR\n"
|
COMMENT "Generating iface_header_builddir.h"
|
||||||
)
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/iface_header_builddir.h.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/iface_header_builddir.h
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
add_dependencies(headeriface headeriface_gen)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
#define IFACE_HEADER_BUILDDIR
|
|
@ -7,5 +7,4 @@ run_cmake(whitelist)
|
||||||
run_cmake(invalid_signature)
|
run_cmake(invalid_signature)
|
||||||
run_cmake(global-interface)
|
run_cmake(global-interface)
|
||||||
run_cmake(genex_link)
|
run_cmake(genex_link)
|
||||||
run_cmake(add_dependencies)
|
|
||||||
run_cmake(add_custom_command-TARGET)
|
run_cmake(add_custom_command-TARGET)
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
1
|
|
|
@ -1,6 +0,0 @@
|
||||||
CMake Error at add_dependencies.cmake:4 \(add_dependencies\):
|
|
||||||
add_dependencies Cannot add target-level dependencies to INTERFACE library
|
|
||||||
target "iface".
|
|
||||||
|
|
||||||
Call Stack \(most recent call first\):
|
|
||||||
CMakeLists.txt:3 \(include\)
|
|
|
@ -1,4 +0,0 @@
|
||||||
|
|
||||||
add_library(foo empty.cpp)
|
|
||||||
add_library(iface INTERFACE)
|
|
||||||
add_dependencies(iface foo)
|
|
Loading…
Reference in New Issue