Merge topic 'add_custom_command-target-alias'
3b07ec631d
add_custom_command: Allow adding build event via ALIAS target
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9201
This commit is contained in:
commit
58d424bca1
@ -554,6 +554,9 @@ one of the keywords to make clear the behavior they expect.
|
||||
.. versionadded:: 3.21
|
||||
Support for target-dependent generator expressions.
|
||||
|
||||
.. versionadded:: 3.29
|
||||
The ``<target>`` may be an :ref:`ALIAS target <Alias Targets>`.
|
||||
|
||||
Examples: Build Events
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
5
Help/release/dev/add_custom_command-target-alias.rst
Normal file
5
Help/release/dev/add_custom_command-target-alias.rst
Normal file
@ -0,0 +1,5 @@
|
||||
add_custom_command-target-alias
|
||||
-------------------------------
|
||||
|
||||
* The :ref:`add_custom_command(TARGET) <add_custom_command(TARGET)>`
|
||||
signature now supports adding build events through :ref:`Alias Targets`.
|
@ -1144,9 +1144,15 @@ cmTarget* cmMakefile::GetCustomCommandTarget(
|
||||
const std::string& target, cmObjectLibraryCommands objLibCommands,
|
||||
const cmListFileBacktrace& lfbt) const
|
||||
{
|
||||
// Find the target to which to add the custom command.
|
||||
auto ti = this->Targets.find(target);
|
||||
auto realTarget = target;
|
||||
|
||||
auto ai = this->AliasTargets.find(target);
|
||||
if (ai != this->AliasTargets.end()) {
|
||||
realTarget = ai->second;
|
||||
}
|
||||
|
||||
// Find the target to which to add the custom command.
|
||||
auto ti = this->Targets.find(realTarget);
|
||||
if (ti == this->Targets.end()) {
|
||||
MessageType messageType = MessageType::AUTHOR_WARNING;
|
||||
bool issueMessage = false;
|
||||
|
@ -214,11 +214,13 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated_extern.cxx
|
||||
|
||||
add_executable(CustomCommandUsingTargetTest main.cxx ${CMAKE_CURRENT_BINARY_DIR}/generated_extern.cxx )
|
||||
|
||||
add_executable(CustomCommandUsingTargetTestAlias ALIAS CustomCommandUsingTargetTest )
|
||||
|
||||
add_custom_target(RunTarget
|
||||
COMMAND generator_extern ${CMAKE_CURRENT_BINARY_DIR}/run_target.cxx
|
||||
)
|
||||
|
||||
add_custom_command(TARGET CustomCommandUsingTargetTest POST_BUILD
|
||||
add_custom_command(TARGET CustomCommandUsingTargetTestAlias POST_BUILD
|
||||
COMMAND dummy_generator ${CMAKE_CURRENT_BINARY_DIR}/generated_dummy.cxx)
|
||||
|
||||
add_subdirectory(GeneratorInExtraDir)
|
||||
|
Loading…
Reference in New Issue
Block a user