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:
parent
39e830a98e
commit
4ce9742ae3
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
add_library(tgt STATIC empty.cpp)
|
||||
add_library(Sub::tgt ALIAS tgt)
|
|
@ -0,0 +1,7 @@
|
|||
#ifdef _WIN32
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
int main(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue