Merge topic 'compile-defs-debugging'
d7dd010
Add target property debugging for COMPILE_DEFINITIONS1841215
Refactor cmTarget::GetCompileDefinitions to use an out-vector, not a string.afc9243
Add an overload of cmIDEOptions::AddDefines taking a vector of strings.d95651e
Overload cmLocalGenerator::AppendDefines to add a list.
This commit is contained in:
commit
d5d54b4629
|
@ -621,20 +621,16 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
|
||||||
->GetGeneratorTarget(target);
|
->GetGeneratorTarget(target);
|
||||||
|
|
||||||
// the compilerdefines for this target
|
// the compilerdefines for this target
|
||||||
std::string cdefs = target->GetCompileDefinitions(buildType);
|
std::vector<std::string> cdefs;
|
||||||
|
target->GetCompileDefinitions(cdefs, buildType);
|
||||||
|
|
||||||
if(!cdefs.empty())
|
|
||||||
{
|
|
||||||
// Expand the list.
|
// Expand the list.
|
||||||
std::vector<std::string> defs;
|
for(std::vector<std::string>::const_iterator di = cdefs.begin();
|
||||||
cmSystemTools::ExpandListArgument(cdefs.c_str(), defs);
|
di != cdefs.end(); ++di)
|
||||||
for(std::vector<std::string>::const_iterator di = defs.begin();
|
|
||||||
di != defs.end(); ++di)
|
|
||||||
{
|
{
|
||||||
cmXMLSafe safedef(di->c_str());
|
cmXMLSafe safedef(di->c_str());
|
||||||
fout <<" <Add option=\"-D" << safedef.str() << "\" />\n";
|
fout <<" <Add option=\"-D" << safedef.str() << "\" />\n";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// the include directories for this target
|
// the include directories for this target
|
||||||
std::set<std::string> uniqIncludeDirs;
|
std::set<std::string> uniqIncludeDirs;
|
||||||
|
|
|
@ -463,7 +463,7 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add preprocessor definitions for this target and configuration.
|
// Add preprocessor definitions for this target and configuration.
|
||||||
lg->AppendDefines(defines, target->GetCompileDefinitions(config));
|
lg->AddCompileDefinitions(defines, target, config);
|
||||||
lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS"));
|
lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS"));
|
||||||
{
|
{
|
||||||
std::string defPropName = "COMPILE_DEFINITIONS_";
|
std::string defPropName = "COMPILE_DEFINITIONS_";
|
||||||
|
|
|
@ -1137,8 +1137,9 @@ void cmGlobalGenerator::CreateGeneratorTargets()
|
||||||
cmGeneratorTargetsType generatorTargets;
|
cmGeneratorTargetsType generatorTargets;
|
||||||
|
|
||||||
cmMakefile *mf = this->LocalGenerators[i]->GetMakefile();
|
cmMakefile *mf = this->LocalGenerators[i]->GetMakefile();
|
||||||
const char *noconfig_compile_definitions =
|
|
||||||
mf->GetProperty("COMPILE_DEFINITIONS");
|
const std::vector<cmValueWithOrigin> noconfig_compile_definitions =
|
||||||
|
mf->GetCompileDefinitionsEntries();
|
||||||
|
|
||||||
std::vector<std::string> configs;
|
std::vector<std::string> configs;
|
||||||
mf->GetConfigurations(configs);
|
mf->GetConfigurations(configs);
|
||||||
|
@ -1150,7 +1151,13 @@ void cmGlobalGenerator::CreateGeneratorTargets()
|
||||||
cmTarget* t = &ti->second;
|
cmTarget* t = &ti->second;
|
||||||
|
|
||||||
{
|
{
|
||||||
t->AppendProperty("COMPILE_DEFINITIONS", noconfig_compile_definitions);
|
for (std::vector<cmValueWithOrigin>::const_iterator it
|
||||||
|
= noconfig_compile_definitions.begin();
|
||||||
|
it != noconfig_compile_definitions.end(); ++it)
|
||||||
|
{
|
||||||
|
t->InsertCompileDefinition(*it);
|
||||||
|
}
|
||||||
|
|
||||||
for(std::vector<std::string>::const_iterator ci = configs.begin();
|
for(std::vector<std::string>::const_iterator ci = configs.begin();
|
||||||
ci != configs.end(); ++ci)
|
ci != configs.end(); ++ci)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1741,8 +1741,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
||||||
this->AppendDefines(ppDefs, exportMacro);
|
this->AppendDefines(ppDefs, exportMacro);
|
||||||
}
|
}
|
||||||
cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target);
|
cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target);
|
||||||
this->AppendDefines(ppDefs,
|
std::vector<std::string> targetDefines;
|
||||||
target.GetCompileDefinitions(configName).c_str());
|
target.GetCompileDefinitions(targetDefines, configName);
|
||||||
|
this->AppendDefines(ppDefs, targetDefines);
|
||||||
buildSettings->AddAttribute
|
buildSettings->AddAttribute
|
||||||
("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList());
|
("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList());
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,11 @@ void cmIDEOptions::AddDefines(const char* defines)
|
||||||
cmSystemTools::ExpandListArgument(defines, this->Defines);
|
cmSystemTools::ExpandListArgument(defines, this->Defines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmIDEOptions::AddDefines(const std::vector<std::string> &defines)
|
||||||
|
{
|
||||||
|
this->Defines.insert(this->Defines.end(), defines.begin(), defines.end());
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmIDEOptions::AddFlag(const char* flag, const char* value)
|
void cmIDEOptions::AddFlag(const char* flag, const char* value)
|
||||||
|
|
|
@ -27,6 +27,7 @@ public:
|
||||||
// Store definitions and flags.
|
// Store definitions and flags.
|
||||||
void AddDefine(const std::string& define);
|
void AddDefine(const std::string& define);
|
||||||
void AddDefines(const char* defines);
|
void AddDefines(const char* defines);
|
||||||
|
void AddDefines(const std::vector<std::string> &defines);
|
||||||
void AddFlag(const char* flag, const char* value);
|
void AddFlag(const char* flag, const char* value);
|
||||||
void RemoveFlag(const char* flag);
|
void RemoveFlag(const char* flag);
|
||||||
const char* GetFlag(const char* flag);
|
const char* GetFlag(const char* flag);
|
||||||
|
|
|
@ -1338,6 +1338,17 @@ std::string cmLocalGenerator::GetIncludeFlags(
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines,
|
||||||
|
cmTarget* target,
|
||||||
|
const char* config)
|
||||||
|
{
|
||||||
|
std::vector<std::string> targetDefines;
|
||||||
|
target->GetCompileDefinitions(targetDefines,
|
||||||
|
config);
|
||||||
|
this->AppendDefines(defines, targetDefines);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmLocalGenerator::AddCompileOptions(
|
void cmLocalGenerator::AddCompileOptions(
|
||||||
std::string& flags, cmTarget* target,
|
std::string& flags, cmTarget* target,
|
||||||
|
@ -2297,7 +2308,13 @@ void cmLocalGenerator::AppendDefines(std::set<std::string>& defines,
|
||||||
// Expand the list of definitions.
|
// Expand the list of definitions.
|
||||||
std::vector<std::string> defines_vec;
|
std::vector<std::string> defines_vec;
|
||||||
cmSystemTools::ExpandListArgument(defines_list, defines_vec);
|
cmSystemTools::ExpandListArgument(defines_list, defines_vec);
|
||||||
|
this->AppendDefines(defines, defines_vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmLocalGenerator::AppendDefines(std::set<std::string>& defines,
|
||||||
|
const std::vector<std::string> &defines_vec)
|
||||||
|
{
|
||||||
for(std::vector<std::string>::const_iterator di = defines_vec.begin();
|
for(std::vector<std::string>::const_iterator di = defines_vec.begin();
|
||||||
di != defines_vec.end(); ++di)
|
di != defines_vec.end(); ++di)
|
||||||
{
|
{
|
||||||
|
|
|
@ -166,6 +166,9 @@ public:
|
||||||
{
|
{
|
||||||
this->AppendDefines(defines, defines_list.c_str());
|
this->AppendDefines(defines, defines_list.c_str());
|
||||||
}
|
}
|
||||||
|
void AppendDefines(std::set<std::string>& defines,
|
||||||
|
const std::vector<std::string> &defines_vec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Join a set of defines into a definesString with a space separator.
|
* Join a set of defines into a definesString with a space separator.
|
||||||
*/
|
*/
|
||||||
|
@ -220,6 +223,8 @@ public:
|
||||||
bool stripImplicitInclDirs = true);
|
bool stripImplicitInclDirs = true);
|
||||||
void AddCompileOptions(std::string& flags, cmTarget* target,
|
void AddCompileOptions(std::string& flags, cmTarget* target,
|
||||||
const char* lang, const char* config);
|
const char* lang, const char* config);
|
||||||
|
void AddCompileDefinitions(std::set<std::string>& defines, cmTarget* target,
|
||||||
|
const char* config);
|
||||||
|
|
||||||
/** Compute the language used to compile the given source file. */
|
/** Compute the language used to compile the given source file. */
|
||||||
const char* GetSourceFileLanguage(const cmSourceFile& source);
|
const char* GetSourceFileLanguage(const cmSourceFile& source);
|
||||||
|
|
|
@ -1962,8 +1962,8 @@ void cmLocalUnixMakefileGenerator3
|
||||||
|
|
||||||
// Build a list of preprocessor definitions for the target.
|
// Build a list of preprocessor definitions for the target.
|
||||||
std::set<std::string> defines;
|
std::set<std::string> defines;
|
||||||
this->AppendDefines(defines, target.GetCompileDefinitions(
|
this->AddCompileDefinitions(defines, &target,
|
||||||
this->ConfigurationName.c_str()));
|
this->ConfigurationName.c_str());
|
||||||
if(!defines.empty())
|
if(!defines.empty())
|
||||||
{
|
{
|
||||||
cmakefileStream
|
cmakefileStream
|
||||||
|
|
|
@ -1701,21 +1701,11 @@ void cmLocalVisualStudio6Generator
|
||||||
std::set<std::string> minsizeDefinesSet;
|
std::set<std::string> minsizeDefinesSet;
|
||||||
std::set<std::string> debugrelDefinesSet;
|
std::set<std::string> debugrelDefinesSet;
|
||||||
|
|
||||||
this->AppendDefines(
|
this->AddCompileDefinitions(definesSet, &target, 0);
|
||||||
definesSet,
|
this->AddCompileDefinitions(debugDefinesSet, &target, "DEBUG");
|
||||||
target.GetCompileDefinitions(0));
|
this->AddCompileDefinitions(releaseDefinesSet, &target, "RELEASE");
|
||||||
this->AppendDefines(
|
this->AddCompileDefinitions(minsizeDefinesSet, &target, "MINSIZEREL");
|
||||||
debugDefinesSet,
|
this->AddCompileDefinitions(debugrelDefinesSet, &target, "RELWITHDEBINFO");
|
||||||
target.GetCompileDefinitions("DEBUG"));
|
|
||||||
this->AppendDefines(
|
|
||||||
releaseDefinesSet,
|
|
||||||
target.GetCompileDefinitions("RELEASE"));
|
|
||||||
this->AppendDefines(
|
|
||||||
minsizeDefinesSet,
|
|
||||||
target.GetCompileDefinitions("MINSIZEREL"));
|
|
||||||
this->AppendDefines(
|
|
||||||
debugrelDefinesSet,
|
|
||||||
target.GetCompileDefinitions("RELWITHDEBINFO"));
|
|
||||||
|
|
||||||
std::string defines = " ";
|
std::string defines = " ";
|
||||||
std::string debugDefines = " ";
|
std::string debugDefines = " ";
|
||||||
|
|
|
@ -746,7 +746,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
|
||||||
targetOptions.ParseFinish();
|
targetOptions.ParseFinish();
|
||||||
cmGeneratorTarget* gt =
|
cmGeneratorTarget* gt =
|
||||||
this->GlobalGenerator->GetGeneratorTarget(&target);
|
this->GlobalGenerator->GetGeneratorTarget(&target);
|
||||||
targetOptions.AddDefines(target.GetCompileDefinitions(configName).c_str());
|
std::vector<std::string> targetDefines;
|
||||||
|
target.GetCompileDefinitions(targetDefines, configName);
|
||||||
|
targetOptions.AddDefines(targetDefines);
|
||||||
targetOptions.SetVerboseMakefile(
|
targetOptions.SetVerboseMakefile(
|
||||||
this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
|
this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
|
||||||
|
|
||||||
|
|
|
@ -1505,6 +1505,12 @@ void cmMakefile::InitializeFromParent()
|
||||||
parentOptions.begin(),
|
parentOptions.begin(),
|
||||||
parentOptions.end());
|
parentOptions.end());
|
||||||
|
|
||||||
|
const std::vector<cmValueWithOrigin> parentDefines =
|
||||||
|
parent->GetCompileDefinitionsEntries();
|
||||||
|
this->CompileDefinitionsEntries.insert(this->CompileDefinitionsEntries.end(),
|
||||||
|
parentDefines.begin(),
|
||||||
|
parentDefines.end());
|
||||||
|
|
||||||
this->SystemIncludeDirectories = parent->SystemIncludeDirectories;
|
this->SystemIncludeDirectories = parent->SystemIncludeDirectories;
|
||||||
|
|
||||||
// define flags
|
// define flags
|
||||||
|
@ -3493,6 +3499,19 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
|
||||||
this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt));
|
this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (propname == "COMPILE_DEFINITIONS")
|
||||||
|
{
|
||||||
|
this->CompileDefinitionsEntries.clear();
|
||||||
|
if (!value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cmListFileBacktrace lfbt;
|
||||||
|
this->GetBacktrace(lfbt);
|
||||||
|
cmValueWithOrigin entry(value, lfbt);
|
||||||
|
this->CompileDefinitionsEntries.push_back(entry);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( propname == "INCLUDE_REGULAR_EXPRESSION" )
|
if ( propname == "INCLUDE_REGULAR_EXPRESSION" )
|
||||||
{
|
{
|
||||||
|
@ -3540,6 +3559,14 @@ void cmMakefile::AppendProperty(const char* prop, const char* value,
|
||||||
cmValueWithOrigin(value, lfbt));
|
cmValueWithOrigin(value, lfbt));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (propname == "COMPILE_DEFINITIONS")
|
||||||
|
{
|
||||||
|
cmListFileBacktrace lfbt;
|
||||||
|
this->GetBacktrace(lfbt);
|
||||||
|
this->CompileDefinitionsEntries.push_back(
|
||||||
|
cmValueWithOrigin(value, lfbt));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ( propname == "LINK_DIRECTORIES" )
|
if ( propname == "LINK_DIRECTORIES" )
|
||||||
{
|
{
|
||||||
std::vector<std::string> varArgsExpanded;
|
std::vector<std::string> varArgsExpanded;
|
||||||
|
@ -3679,6 +3706,20 @@ const char *cmMakefile::GetProperty(const char* prop,
|
||||||
}
|
}
|
||||||
return output.c_str();
|
return output.c_str();
|
||||||
}
|
}
|
||||||
|
else if (!strcmp("COMPILE_DEFINITIONS",prop))
|
||||||
|
{
|
||||||
|
std::string sep;
|
||||||
|
for (std::vector<cmValueWithOrigin>::const_iterator
|
||||||
|
it = this->CompileDefinitionsEntries.begin(),
|
||||||
|
end = this->CompileDefinitionsEntries.end();
|
||||||
|
it != end; ++it)
|
||||||
|
{
|
||||||
|
output += sep;
|
||||||
|
output += it->Value;
|
||||||
|
sep = ";";
|
||||||
|
}
|
||||||
|
return output.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
bool chain = false;
|
bool chain = false;
|
||||||
const char *retVal =
|
const char *retVal =
|
||||||
|
|
|
@ -871,6 +871,10 @@ public:
|
||||||
{
|
{
|
||||||
return this->CompileOptionsEntries;
|
return this->CompileOptionsEntries;
|
||||||
}
|
}
|
||||||
|
std::vector<cmValueWithOrigin> GetCompileDefinitionsEntries() const
|
||||||
|
{
|
||||||
|
return this->CompileDefinitionsEntries;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsGeneratingBuildSystem(){ return this->GeneratingBuildSystem; }
|
bool IsGeneratingBuildSystem(){ return this->GeneratingBuildSystem; }
|
||||||
void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; }
|
void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; }
|
||||||
|
@ -925,6 +929,7 @@ protected:
|
||||||
|
|
||||||
std::vector<cmValueWithOrigin> IncludeDirectoriesEntries;
|
std::vector<cmValueWithOrigin> IncludeDirectoriesEntries;
|
||||||
std::vector<cmValueWithOrigin> CompileOptionsEntries;
|
std::vector<cmValueWithOrigin> CompileOptionsEntries;
|
||||||
|
std::vector<cmValueWithOrigin> CompileDefinitionsEntries;
|
||||||
|
|
||||||
// Track the value of the computed DEFINITIONS property.
|
// Track the value of the computed DEFINITIONS property.
|
||||||
void AddDefineFlag(const char*, std::string&);
|
void AddDefineFlag(const char*, std::string&);
|
||||||
|
|
|
@ -309,9 +309,8 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add preprocessor definitions for this target and configuration.
|
// Add preprocessor definitions for this target and configuration.
|
||||||
this->LocalGenerator->AppendDefines
|
this->LocalGenerator->AddCompileDefinitions(defines, this->Target,
|
||||||
(defines, this->Target->GetCompileDefinitions(
|
this->LocalGenerator->ConfigurationName.c_str());
|
||||||
this->LocalGenerator->ConfigurationName.c_str()));
|
|
||||||
|
|
||||||
std::string definesString;
|
std::string definesString;
|
||||||
this->LocalGenerator->JoinDefines(defines, definesString, lang);
|
this->LocalGenerator->JoinDefines(defines, definesString, lang);
|
||||||
|
|
|
@ -201,9 +201,8 @@ ComputeDefines(cmSourceFile *source, const std::string& language)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add preprocessor definitions for this target and configuration.
|
// Add preprocessor definitions for this target and configuration.
|
||||||
this->LocalGenerator->AppendDefines
|
this->LocalGenerator->AddCompileDefinitions(defines, this->Target,
|
||||||
(defines,
|
this->GetConfigName());
|
||||||
this->Target->GetCompileDefinitions(this->GetConfigName()));
|
|
||||||
this->LocalGenerator->AppendDefines
|
this->LocalGenerator->AppendDefines
|
||||||
(defines,
|
(defines,
|
||||||
source->GetProperty("COMPILE_DEFINITIONS"));
|
source->GetProperty("COMPILE_DEFINITIONS"));
|
||||||
|
|
|
@ -175,15 +175,17 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target,
|
||||||
incs += *incDirIt;
|
incs += *incDirIt;
|
||||||
}
|
}
|
||||||
|
|
||||||
defs = target->GetCompileDefinitions(config);
|
std::set<std::string> defines;
|
||||||
|
localGen->AddCompileDefinitions(defines, target, config);
|
||||||
|
|
||||||
const char *tmp = makefile->GetProperty("COMPILE_DEFINITIONS");
|
|
||||||
sep = "";
|
sep = "";
|
||||||
if (tmp)
|
for(std::set<std::string>::const_iterator defIt = defines.begin();
|
||||||
|
defIt != defines.end();
|
||||||
|
++defIt)
|
||||||
{
|
{
|
||||||
defs += sep;
|
defs += sep;
|
||||||
sep = ";";
|
sep = ";";
|
||||||
defs += tmp;
|
defs += *defIt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,13 +141,15 @@ public:
|
||||||
};
|
};
|
||||||
std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
|
std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
|
||||||
std::vector<TargetPropertyEntry*> CompileOptionsEntries;
|
std::vector<TargetPropertyEntry*> CompileOptionsEntries;
|
||||||
|
std::vector<TargetPropertyEntry*> CompileDefinitionsEntries;
|
||||||
std::vector<cmValueWithOrigin> LinkInterfacePropertyEntries;
|
std::vector<cmValueWithOrigin> LinkInterfacePropertyEntries;
|
||||||
|
|
||||||
std::map<std::string, std::vector<TargetPropertyEntry*> >
|
std::map<std::string, std::vector<TargetPropertyEntry*> >
|
||||||
CachedLinkInterfaceIncludeDirectoriesEntries;
|
CachedLinkInterfaceIncludeDirectoriesEntries;
|
||||||
std::map<std::string, std::vector<TargetPropertyEntry*> >
|
std::map<std::string, std::vector<TargetPropertyEntry*> >
|
||||||
CachedLinkInterfaceCompileOptionsEntries;
|
CachedLinkInterfaceCompileOptionsEntries;
|
||||||
std::map<std::string, std::string> CachedLinkInterfaceCompileDefinitions;
|
std::map<std::string, std::vector<TargetPropertyEntry*> >
|
||||||
|
CachedLinkInterfaceCompileDefinitionsEntries;
|
||||||
|
|
||||||
std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone;
|
std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone;
|
||||||
std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone;
|
std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone;
|
||||||
|
@ -186,6 +188,7 @@ cmTargetInternals::~cmTargetInternals()
|
||||||
{
|
{
|
||||||
deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries);
|
deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries);
|
||||||
deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries);
|
deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries);
|
||||||
|
deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -207,6 +210,7 @@ cmTarget::cmTarget()
|
||||||
this->BuildInterfaceIncludesAppended = false;
|
this->BuildInterfaceIncludesAppended = false;
|
||||||
this->DebugIncludesDone = false;
|
this->DebugIncludesDone = false;
|
||||||
this->DebugCompileOptionsDone = false;
|
this->DebugCompileOptionsDone = false;
|
||||||
|
this->DebugCompileDefinitionsDone = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -2877,6 +2881,17 @@ void cmTarget::SetProperty(const char* prop, const char* value)
|
||||||
new cmTargetInternals::TargetPropertyEntry(cge));
|
new cmTargetInternals::TargetPropertyEntry(cge));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
|
||||||
|
{
|
||||||
|
cmListFileBacktrace lfbt;
|
||||||
|
this->Makefile->GetBacktrace(lfbt);
|
||||||
|
cmGeneratorExpression ge(lfbt);
|
||||||
|
deleteAndClear(this->Internal->CompileDefinitionsEntries);
|
||||||
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
|
||||||
|
this->Internal->CompileDefinitionsEntries.push_back(
|
||||||
|
new cmTargetInternals::TargetPropertyEntry(cge));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
|
if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
|
||||||
{
|
{
|
||||||
cmOStringStream e;
|
cmOStringStream e;
|
||||||
|
@ -2928,6 +2943,15 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
|
||||||
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
|
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
|
||||||
|
{
|
||||||
|
cmListFileBacktrace lfbt;
|
||||||
|
this->Makefile->GetBacktrace(lfbt);
|
||||||
|
cmGeneratorExpression ge(lfbt);
|
||||||
|
this->Internal->CompileDefinitionsEntries.push_back(
|
||||||
|
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
|
if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
|
||||||
{
|
{
|
||||||
cmOStringStream e;
|
cmOStringStream e;
|
||||||
|
@ -3031,6 +3055,20 @@ void cmTarget::InsertCompileOption(const cmValueWithOrigin &entry,
|
||||||
new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value)));
|
new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmTarget::InsertCompileDefinition(const cmValueWithOrigin &entry,
|
||||||
|
bool before)
|
||||||
|
{
|
||||||
|
cmGeneratorExpression ge(entry.Backtrace);
|
||||||
|
|
||||||
|
std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position
|
||||||
|
= before ? this->Internal->CompileDefinitionsEntries.begin()
|
||||||
|
: this->Internal->CompileDefinitionsEntries.end();
|
||||||
|
|
||||||
|
this->Internal->CompileDefinitionsEntries.insert(position,
|
||||||
|
new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value)));
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
static void processIncludeDirectories(cmTarget *tgt,
|
static void processIncludeDirectories(cmTarget *tgt,
|
||||||
const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
|
const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
|
||||||
|
@ -3263,12 +3301,12 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
static void processCompileOptions(cmTarget *tgt,
|
static void processCompileOptionsInternal(cmTarget *tgt,
|
||||||
const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
|
const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
|
||||||
std::vector<std::string> &options,
|
std::vector<std::string> &options,
|
||||||
std::set<std::string> &uniqueOptions,
|
std::set<std::string> &uniqueOptions,
|
||||||
cmGeneratorExpressionDAGChecker *dagChecker,
|
cmGeneratorExpressionDAGChecker *dagChecker,
|
||||||
const char *config, bool debugOptions)
|
const char *config, bool debugOptions, const char *logName)
|
||||||
{
|
{
|
||||||
cmMakefile *mf = tgt->GetMakefile();
|
cmMakefile *mf = tgt->GetMakefile();
|
||||||
|
|
||||||
|
@ -3313,13 +3351,26 @@ static void processCompileOptions(cmTarget *tgt,
|
||||||
if (!usedOptions.empty())
|
if (!usedOptions.empty())
|
||||||
{
|
{
|
||||||
mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
|
mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
|
||||||
std::string("Used compile options for target ")
|
std::string("Used compile ") + logName
|
||||||
|
+ std::string(" for target ")
|
||||||
+ tgt->GetName() + ":\n"
|
+ tgt->GetName() + ":\n"
|
||||||
+ usedOptions, (*it)->ge->GetBacktrace());
|
+ usedOptions, (*it)->ge->GetBacktrace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
static void processCompileOptions(cmTarget *tgt,
|
||||||
|
const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
|
||||||
|
std::vector<std::string> &options,
|
||||||
|
std::set<std::string> &uniqueOptions,
|
||||||
|
cmGeneratorExpressionDAGChecker *dagChecker,
|
||||||
|
const char *config, bool debugOptions)
|
||||||
|
{
|
||||||
|
processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
|
||||||
|
dagChecker, config, debugOptions, "options");
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmTarget::GetCompileOptions(std::vector<std::string> &result,
|
void cmTarget::GetCompileOptions(std::vector<std::string> &result,
|
||||||
const char *config)
|
const char *config)
|
||||||
|
@ -3416,90 +3467,128 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::string cmTarget::GetCompileDefinitions(const char *config)
|
static void processCompileDefinitions(cmTarget *tgt,
|
||||||
|
const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
|
||||||
|
std::vector<std::string> &options,
|
||||||
|
std::set<std::string> &uniqueOptions,
|
||||||
|
cmGeneratorExpressionDAGChecker *dagChecker,
|
||||||
|
const char *config, bool debugOptions)
|
||||||
{
|
{
|
||||||
const char *configProp = 0;
|
processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
|
||||||
if (config)
|
dagChecker, config, debugOptions,
|
||||||
{
|
"definitions");
|
||||||
std::string configPropName;
|
|
||||||
configPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config);
|
|
||||||
configProp = this->GetProperty(configPropName.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *noconfigProp = this->GetProperty("COMPILE_DEFINITIONS");
|
//----------------------------------------------------------------------------
|
||||||
|
void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
|
||||||
|
const char *config)
|
||||||
|
{
|
||||||
|
std::set<std::string> uniqueOptions;
|
||||||
cmListFileBacktrace lfbt;
|
cmListFileBacktrace lfbt;
|
||||||
|
|
||||||
cmGeneratorExpressionDAGChecker dagChecker(lfbt,
|
cmGeneratorExpressionDAGChecker dagChecker(lfbt,
|
||||||
this->GetName(),
|
this->GetName(),
|
||||||
"COMPILE_DEFINITIONS", 0, 0);
|
"COMPILE_DEFINITIONS", 0, 0);
|
||||||
|
|
||||||
std::string defsString = (noconfigProp ? noconfigProp : "");
|
std::vector<std::string> debugProperties;
|
||||||
if (configProp && noconfigProp)
|
const char *debugProp =
|
||||||
|
this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
|
||||||
|
if (debugProp)
|
||||||
{
|
{
|
||||||
defsString += ";";
|
cmSystemTools::ExpandListArgument(debugProp, debugProperties);
|
||||||
}
|
}
|
||||||
defsString += (configProp ? configProp : "");
|
|
||||||
|
|
||||||
cmGeneratorExpression ge(lfbt);
|
bool debugDefines = !this->DebugCompileDefinitionsDone
|
||||||
std::string result = ge.Parse(defsString.c_str())->Evaluate(this->Makefile,
|
&& std::find(debugProperties.begin(),
|
||||||
|
debugProperties.end(),
|
||||||
|
"COMPILE_DEFINITIONS")
|
||||||
|
!= debugProperties.end();
|
||||||
|
|
||||||
|
if (this->Makefile->IsGeneratingBuildSystem())
|
||||||
|
{
|
||||||
|
this->DebugCompileDefinitionsDone = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
processCompileDefinitions(this,
|
||||||
|
this->Internal->CompileDefinitionsEntries,
|
||||||
|
list,
|
||||||
|
uniqueOptions,
|
||||||
|
&dagChecker,
|
||||||
config,
|
config,
|
||||||
false,
|
debugDefines);
|
||||||
this,
|
|
||||||
&dagChecker);
|
|
||||||
|
|
||||||
std::vector<std::string> libs;
|
|
||||||
this->GetDirectLinkLibraries(config, libs, this);
|
|
||||||
|
|
||||||
if (libs.empty())
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string sep;
|
|
||||||
std::string depString;
|
|
||||||
for (std::vector<std::string>::const_iterator it = libs.begin();
|
|
||||||
it != libs.end(); ++it)
|
|
||||||
{
|
|
||||||
if ((cmGeneratorExpression::IsValidTargetName(it->c_str())
|
|
||||||
|| cmGeneratorExpression::Find(it->c_str()) != std::string::npos)
|
|
||||||
&& this->Makefile->FindTargetToUse(it->c_str()))
|
|
||||||
{
|
|
||||||
depString += sep + "$<TARGET_PROPERTY:"
|
|
||||||
+ *it + ",INTERFACE_COMPILE_DEFINITIONS>";
|
|
||||||
sep = ";";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string configString = config ? config : "";
|
std::string configString = config ? config : "";
|
||||||
if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString])
|
if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString])
|
||||||
{
|
{
|
||||||
cmGeneratorExpression ge2(lfbt);
|
for (std::vector<cmValueWithOrigin>::const_iterator
|
||||||
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge2 =
|
it = this->Internal->LinkInterfacePropertyEntries.begin(),
|
||||||
ge2.Parse(depString);
|
end = this->Internal->LinkInterfacePropertyEntries.end();
|
||||||
this->Internal->CachedLinkInterfaceCompileDefinitions[configString] =
|
it != end; ++it)
|
||||||
cge2->Evaluate(this->Makefile,
|
|
||||||
config,
|
|
||||||
false,
|
|
||||||
this,
|
|
||||||
&dagChecker);
|
|
||||||
}
|
|
||||||
if (!this->Internal->CachedLinkInterfaceCompileDefinitions[configString]
|
|
||||||
.empty())
|
|
||||||
{
|
{
|
||||||
result += (result.empty() ? "" : ";")
|
{
|
||||||
+ this->Internal->CachedLinkInterfaceCompileDefinitions[configString];
|
cmGeneratorExpression ge(lfbt);
|
||||||
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
|
||||||
|
ge.Parse(it->Value);
|
||||||
|
std::string targetResult = cge->Evaluate(this->Makefile, config,
|
||||||
|
false, this, 0, 0);
|
||||||
|
if (!this->Makefile->FindTargetToUse(targetResult.c_str()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
std::string defsGenex = "$<TARGET_PROPERTY:" +
|
||||||
|
it->Value + ",INTERFACE_COMPILE_DEFINITIONS>";
|
||||||
|
if (cmGeneratorExpression::Find(it->Value) != std::string::npos)
|
||||||
|
{
|
||||||
|
// Because it->Value is a generator expression, ensure that it
|
||||||
|
// evaluates to the non-empty string before being used in the
|
||||||
|
// TARGET_PROPERTY expression.
|
||||||
|
defsGenex = "$<$<BOOL:" + it->Value + ">:" + defsGenex + ">";
|
||||||
|
}
|
||||||
|
cmGeneratorExpression ge(it->Backtrace);
|
||||||
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
|
||||||
|
defsGenex);
|
||||||
|
|
||||||
|
this->Internal
|
||||||
|
->CachedLinkInterfaceCompileDefinitionsEntries[configString].push_back(
|
||||||
|
new cmTargetInternals::TargetPropertyEntry(cge,
|
||||||
|
it->Value));
|
||||||
|
}
|
||||||
|
if (config)
|
||||||
|
{
|
||||||
|
std::string configPropName = "COMPILE_DEFINITIONS_"
|
||||||
|
+ cmSystemTools::UpperCase(config);
|
||||||
|
const char *configProp = this->GetProperty(configPropName.c_str());
|
||||||
|
std::string defsString = (configProp ? configProp : "");
|
||||||
|
|
||||||
|
cmGeneratorExpression ge(lfbt);
|
||||||
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
|
||||||
|
ge.Parse(defsString);
|
||||||
|
this->Internal
|
||||||
|
->CachedLinkInterfaceCompileDefinitionsEntries[configString].push_back(
|
||||||
|
new cmTargetInternals::TargetPropertyEntry(cge));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
processCompileDefinitions(this,
|
||||||
|
this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[configString],
|
||||||
|
list,
|
||||||
|
uniqueOptions,
|
||||||
|
&dagChecker,
|
||||||
|
config,
|
||||||
|
debugDefines);
|
||||||
|
|
||||||
if (!this->Makefile->IsGeneratingBuildSystem())
|
if (!this->Makefile->IsGeneratingBuildSystem())
|
||||||
{
|
{
|
||||||
this->Internal->CachedLinkInterfaceCompileDefinitions[configString] = "";
|
deleteAndClear(this->Internal
|
||||||
|
->CachedLinkInterfaceCompileDefinitionsEntries);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString]
|
this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString]
|
||||||
= true;
|
= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -3901,6 +3990,24 @@ const char *cmTarget::GetProperty(const char* prop,
|
||||||
}
|
}
|
||||||
return output.c_str();
|
return output.c_str();
|
||||||
}
|
}
|
||||||
|
if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
|
||||||
|
{
|
||||||
|
static std::string output;
|
||||||
|
output = "";
|
||||||
|
std::string sep;
|
||||||
|
typedef cmTargetInternals::TargetPropertyEntry
|
||||||
|
TargetPropertyEntry;
|
||||||
|
for (std::vector<TargetPropertyEntry*>::const_iterator
|
||||||
|
it = this->Internal->CompileDefinitionsEntries.begin(),
|
||||||
|
end = this->Internal->CompileDefinitionsEntries.end();
|
||||||
|
it != end; ++it)
|
||||||
|
{
|
||||||
|
output += sep;
|
||||||
|
output += (*it)->ge->GetInput();
|
||||||
|
sep = ";";
|
||||||
|
}
|
||||||
|
return output.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
if (strcmp(prop,"IMPORTED") == 0)
|
if (strcmp(prop,"IMPORTED") == 0)
|
||||||
{
|
{
|
||||||
|
@ -6754,6 +6861,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer()
|
||||||
{
|
{
|
||||||
deleteAndClear(this->Pointer->IncludeDirectoriesEntries);
|
deleteAndClear(this->Pointer->IncludeDirectoriesEntries);
|
||||||
deleteAndClear(this->Pointer->CompileOptionsEntries);
|
deleteAndClear(this->Pointer->CompileOptionsEntries);
|
||||||
|
deleteAndClear(this->Pointer->CompileDefinitionsEntries);
|
||||||
delete this->Pointer;
|
delete this->Pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -441,7 +441,8 @@ public:
|
||||||
If no macro should be defined null is returned. */
|
If no macro should be defined null is returned. */
|
||||||
const char* GetExportMacro();
|
const char* GetExportMacro();
|
||||||
|
|
||||||
std::string GetCompileDefinitions(const char *config);
|
void GetCompileDefinitions(std::vector<std::string> &result,
|
||||||
|
const char *config);
|
||||||
|
|
||||||
// Compute the set of languages compiled by the target. This is
|
// Compute the set of languages compiled by the target. This is
|
||||||
// computed every time it is called because the languages can change
|
// computed every time it is called because the languages can change
|
||||||
|
@ -512,6 +513,8 @@ public:
|
||||||
bool before = false);
|
bool before = false);
|
||||||
void InsertCompileOption(const cmValueWithOrigin &entry,
|
void InsertCompileOption(const cmValueWithOrigin &entry,
|
||||||
bool before = false);
|
bool before = false);
|
||||||
|
void InsertCompileDefinition(const cmValueWithOrigin &entry,
|
||||||
|
bool before = false);
|
||||||
|
|
||||||
void AppendBuildInterfaceIncludes();
|
void AppendBuildInterfaceIncludes();
|
||||||
|
|
||||||
|
@ -648,6 +651,7 @@ private:
|
||||||
bool IsImportedTarget;
|
bool IsImportedTarget;
|
||||||
bool DebugIncludesDone;
|
bool DebugIncludesDone;
|
||||||
bool DebugCompileOptionsDone;
|
bool DebugCompileOptionsDone;
|
||||||
|
bool DebugCompileDefinitionsDone;
|
||||||
mutable std::set<std::string> LinkImplicitNullProperties;
|
mutable std::set<std::string> LinkImplicitNullProperties;
|
||||||
bool BuildInterfaceIncludesAppended;
|
bool BuildInterfaceIncludesAppended;
|
||||||
|
|
||||||
|
|
|
@ -1337,8 +1337,9 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
||||||
clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
|
clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
|
||||||
clOptions.Parse(flags.c_str());
|
clOptions.Parse(flags.c_str());
|
||||||
clOptions.Parse(defineFlags.c_str());
|
clOptions.Parse(defineFlags.c_str());
|
||||||
clOptions.AddDefines(this->Target->GetCompileDefinitions(
|
std::vector<std::string> targetDefines;
|
||||||
configName.c_str()).c_str());
|
this->Target->GetCompileDefinitions(targetDefines, configName.c_str());
|
||||||
|
clOptions.AddDefines(targetDefines);
|
||||||
clOptions.SetVerboseMakefile(
|
clOptions.SetVerboseMakefile(
|
||||||
this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
|
this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue