cmTarget: Make the SOURCES origin tracable.
This commit is contained in:
parent
3676fb4963
commit
6e636f2eba
|
@ -6,7 +6,8 @@ Enables tracing output for target properties.
|
||||||
This variable can be populated with a list of properties to generate
|
This variable can be populated with a list of properties to generate
|
||||||
debug output for when evaluating target properties. Currently it can
|
debug output for when evaluating target properties. Currently it can
|
||||||
only be used when evaluating the :prop_tgt:`INCLUDE_DIRECTORIES`,
|
only be used when evaluating the :prop_tgt:`INCLUDE_DIRECTORIES`,
|
||||||
:prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`, :prop_tgt:`AUTOUIC_OPTIONS`,
|
:prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`,
|
||||||
|
:prop_tgt:`AUTOUIC_OPTIONS`, :prop_tgt:`SOURCES`,
|
||||||
:prop_tgt:`POSITION_INDEPENDENT_CODE` target properties and any other property
|
:prop_tgt:`POSITION_INDEPENDENT_CODE` target properties and any other property
|
||||||
listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other ``COMPATIBLE_INTERFACE_``
|
listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other ``COMPATIBLE_INTERFACE_``
|
||||||
properties. It outputs an origin for each entry in the target property.
|
properties. It outputs an origin for each entry in the target property.
|
||||||
|
|
|
@ -224,6 +224,7 @@ cmTarget::cmTarget()
|
||||||
this->DebugIncludesDone = false;
|
this->DebugIncludesDone = false;
|
||||||
this->DebugCompileOptionsDone = false;
|
this->DebugCompileOptionsDone = false;
|
||||||
this->DebugCompileDefinitionsDone = false;
|
this->DebugCompileDefinitionsDone = false;
|
||||||
|
this->DebugSourcesDone = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -553,7 +554,7 @@ static void processSources(cmTarget const* tgt,
|
||||||
std::set<std::string> &uniqueSrcs,
|
std::set<std::string> &uniqueSrcs,
|
||||||
cmGeneratorExpressionDAGChecker *dagChecker,
|
cmGeneratorExpressionDAGChecker *dagChecker,
|
||||||
cmTarget const* head,
|
cmTarget const* head,
|
||||||
std::string const& config)
|
std::string const& config, bool debugSources)
|
||||||
{
|
{
|
||||||
cmMakefile *mf = tgt->GetMakefile();
|
cmMakefile *mf = tgt->GetMakefile();
|
||||||
|
|
||||||
|
@ -601,6 +602,7 @@ static void processSources(cmTarget const* tgt,
|
||||||
(*it)->CachedEntries = entrySources;
|
(*it)->CachedEntries = entrySources;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::string usedSources;
|
||||||
for(std::vector<std::string>::iterator
|
for(std::vector<std::string>::iterator
|
||||||
li = entrySources.begin(); li != entrySources.end(); ++li)
|
li = entrySources.begin(); li != entrySources.end(); ++li)
|
||||||
{
|
{
|
||||||
|
@ -609,8 +611,19 @@ static void processSources(cmTarget const* tgt,
|
||||||
if(uniqueSrcs.insert(src).second)
|
if(uniqueSrcs.insert(src).second)
|
||||||
{
|
{
|
||||||
srcs.push_back(src);
|
srcs.push_back(src);
|
||||||
|
if (debugSources)
|
||||||
|
{
|
||||||
|
usedSources += " * " + src + "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!usedSources.empty())
|
||||||
|
{
|
||||||
|
mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
|
||||||
|
std::string("Used sources for target ")
|
||||||
|
+ tgt->GetName() + ":\n"
|
||||||
|
+ usedSources, (*it)->ge->GetBacktrace());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,6 +634,24 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files,
|
||||||
{
|
{
|
||||||
assert(this->GetType() != INTERFACE_LIBRARY);
|
assert(this->GetType() != INTERFACE_LIBRARY);
|
||||||
|
|
||||||
|
std::vector<std::string> debugProperties;
|
||||||
|
const char *debugProp =
|
||||||
|
this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
|
||||||
|
if (debugProp)
|
||||||
|
{
|
||||||
|
cmSystemTools::ExpandListArgument(debugProp, debugProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool debugSources = !this->DebugSourcesDone
|
||||||
|
&& std::find(debugProperties.begin(),
|
||||||
|
debugProperties.end(),
|
||||||
|
"SOURCES")
|
||||||
|
!= debugProperties.end();
|
||||||
|
|
||||||
|
if (this->Makefile->IsGeneratingBuildSystem())
|
||||||
|
{
|
||||||
|
this->DebugSourcesDone = true;
|
||||||
|
}
|
||||||
|
|
||||||
cmListFileBacktrace lfbt;
|
cmListFileBacktrace lfbt;
|
||||||
|
|
||||||
|
@ -635,7 +666,8 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files,
|
||||||
uniqueSrcs,
|
uniqueSrcs,
|
||||||
&dagChecker,
|
&dagChecker,
|
||||||
head,
|
head,
|
||||||
config);
|
config,
|
||||||
|
debugSources);
|
||||||
|
|
||||||
if (!this->Internal->CacheLinkInterfaceSourcesDone[config])
|
if (!this->Internal->CacheLinkInterfaceSourcesDone[config])
|
||||||
{
|
{
|
||||||
|
@ -686,7 +718,8 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files,
|
||||||
uniqueSrcs,
|
uniqueSrcs,
|
||||||
&dagChecker,
|
&dagChecker,
|
||||||
head,
|
head,
|
||||||
config);
|
config,
|
||||||
|
debugSources);
|
||||||
|
|
||||||
if (!this->Makefile->IsGeneratingBuildSystem())
|
if (!this->Makefile->IsGeneratingBuildSystem())
|
||||||
{
|
{
|
||||||
|
|
|
@ -710,6 +710,7 @@ private:
|
||||||
mutable std::map<std::string, bool> DebugCompatiblePropertiesDone;
|
mutable std::map<std::string, bool> DebugCompatiblePropertiesDone;
|
||||||
mutable bool DebugCompileOptionsDone;
|
mutable bool DebugCompileOptionsDone;
|
||||||
mutable bool DebugCompileDefinitionsDone;
|
mutable bool DebugCompileDefinitionsDone;
|
||||||
|
mutable bool DebugSourcesDone;
|
||||||
mutable std::set<std::string> LinkImplicitNullProperties;
|
mutable std::set<std::string> LinkImplicitNullProperties;
|
||||||
bool BuildInterfaceIncludesAppended;
|
bool BuildInterfaceIncludesAppended;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
0
|
|
@ -0,0 +1,15 @@
|
||||||
|
CMake Debug Log at OriginDebug.cmake:13 \(add_library\):
|
||||||
|
Used sources for target OriginDebug:
|
||||||
|
|
||||||
|
\* .*Tests/RunCMake/TargetSources/empty_2.cpp
|
||||||
|
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
||||||
|
+
|
||||||
|
CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\):
|
||||||
|
Used sources for target OriginDebug:
|
||||||
|
|
||||||
|
\* .*Tests/RunCMake/TargetSources/empty_1.cpp
|
||||||
|
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
|
project(OriginDebug)
|
||||||
|
|
||||||
|
set(CMAKE_DEBUG_TARGET_PROPERTIES SOURCES)
|
||||||
|
|
||||||
|
add_library(iface INTERFACE)
|
||||||
|
set_property(TARGET iface PROPERTY INTERFACE_SOURCES
|
||||||
|
empty_1.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(OriginDebug empty_2.cpp)
|
||||||
|
target_link_libraries(OriginDebug iface)
|
|
@ -0,0 +1 @@
|
||||||
|
0
|
|
@ -0,0 +1,22 @@
|
||||||
|
CMake Debug Log at OriginDebug.cmake:13 \(add_library\):
|
||||||
|
Used sources for target OriginDebug:
|
||||||
|
|
||||||
|
\* .*Tests/RunCMake/TargetSources/empty_2.cpp
|
||||||
|
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
OriginDebugIDE.cmake:4 \(include\)
|
||||||
|
CMakeLists.txt:3 \(include\)
|
||||||
|
+
|
||||||
|
CMake Debug Log:
|
||||||
|
Used sources for target OriginDebug:
|
||||||
|
|
||||||
|
* .*CMakeLists.txt
|
||||||
|
+
|
||||||
|
CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\):
|
||||||
|
Used sources for target OriginDebug:
|
||||||
|
|
||||||
|
\* .*Tests/RunCMake/TargetSources/empty_1.cpp
|
||||||
|
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
OriginDebugIDE.cmake:4 \(include\)
|
||||||
|
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
# Separate test for the IDEs, because they show the CMakeLists.txt file
|
||||||
|
# as a source file.
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/OriginDebug.cmake)
|
|
@ -3,4 +3,7 @@ include(RunCMake)
|
||||||
if(RunCMake_GENERATOR MATCHES Xcode
|
if(RunCMake_GENERATOR MATCHES Xcode
|
||||||
OR RunCMake_GENERATOR MATCHES "Visual Studio")
|
OR RunCMake_GENERATOR MATCHES "Visual Studio")
|
||||||
run_cmake(ConfigNotAllowed)
|
run_cmake(ConfigNotAllowed)
|
||||||
|
run_cmake(OriginDebugIDE)
|
||||||
|
else()
|
||||||
|
run_cmake(OriginDebug)
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Reference in New Issue