Alias: Fix access at generate-time (#15832)

Commit c389f8bb (cmLocalGenerator: Port Find method away from
GetGeneratorTarget, 2015-10-25) ported the implementation of
FindGeneratorTargetToUse away from the FindTargetToUse method,
but neglected to handle alias targets.

The latter method has a parameter to determine whether to
include alias targets in the search, but as that is only
needed at configure time, this generate-time equivalent does
not need the condition.
This commit is contained in:
Stephen Kelly 2015-11-08 13:31:25 +01:00
parent 39e830a98e
commit 4ce9742ae3
4 changed files with 19 additions and 1 deletions

View File

@ -2274,6 +2274,12 @@ cmGlobalGenerator::FindTarget(const std::string& name,
cmGeneratorTarget*
cmGlobalGenerator::FindGeneratorTarget(const std::string& name) const
{
std::map<std::string, std::string>::const_iterator ai =
this->AliasTargets.find(name);
if (ai != this->AliasTargets.end())
{
return this->FindGeneratorTargetImpl(ai->second);
}
if (cmGeneratorTarget* tgt = this->FindGeneratorTargetImpl(name))
{
return tgt;

View File

@ -37,7 +37,9 @@ target_include_directories(bat PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
add_executable(targetgenerator targetgenerator.cpp)
add_executable(Generator::Target ALIAS targetgenerator)
add_custom_target(usealias Generator::Target)
add_subdirectory(subdir)
add_custom_target(usealias Generator::Target $<TARGET_FILE:Sub::tgt>)
add_dependencies(bat usealias)
if (NOT TARGET Another::Alias)

View File

@ -0,0 +1,3 @@
add_library(tgt STATIC empty.cpp)
add_library(Sub::tgt ALIAS tgt)

View File

@ -0,0 +1,7 @@
#ifdef _WIN32
__declspec(dllexport)
#endif
int main(void)
{
return 0;
}