Add cmLocalGenerator::GetCompileOptions.
Currently it only adds the contents of the COMPILE_FLAGS target property, but it can be extended to handle a new COMPILE_OPTIONS generator expression enabled property.
This commit is contained in:
parent
f3ad863ae6
commit
35496761a5
|
@ -429,7 +429,9 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
|
|||
lg->AppendFlags(flags, makefile->GetDefineFlags());
|
||||
|
||||
// Add target-specific flags.
|
||||
if(target->GetProperty("COMPILE_FLAGS"))
|
||||
std::string targetFlags;
|
||||
lg->GetCompileOptions(targetFlags, target, config);
|
||||
if (!targetFlags.empty())
|
||||
{
|
||||
std::string langIncludeExpr = "CMAKE_";
|
||||
langIncludeExpr += language;
|
||||
|
@ -440,7 +442,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
|
|||
cmsys::RegularExpression r(regex);
|
||||
std::vector<std::string> args;
|
||||
cmSystemTools::
|
||||
ParseWindowsCommandLine(target->GetProperty("COMPILE_FLAGS"), args);
|
||||
ParseWindowsCommandLine(targetFlags.c_str(), args);
|
||||
for(std::vector<std::string>::iterator i = args.begin();
|
||||
i != args.end(); ++i)
|
||||
{
|
||||
|
@ -452,7 +454,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
|
|||
}
|
||||
else
|
||||
{
|
||||
lg->AppendFlags(flags, target->GetProperty("COMPILE_FLAGS"));
|
||||
lg->AppendFlags(flags, targetFlags.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -681,9 +681,11 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
|
|||
{
|
||||
// Add flags from target and source file properties.
|
||||
std::string flags;
|
||||
if(cmtarget.GetProperty("COMPILE_FLAGS"))
|
||||
std::string targetFlags;
|
||||
lg->GetCompileOptions(targetFlags, &cmtarget, 0); // TODO: Config?
|
||||
if(!targetFlags.empty())
|
||||
{
|
||||
lg->AppendFlags(flags, cmtarget.GetProperty("COMPILE_FLAGS"));
|
||||
lg->AppendFlags(flags, targetFlags.c_str());
|
||||
}
|
||||
const char* srcfmt = sf->GetProperty("Fortran_FORMAT");
|
||||
switch(this->CurrentLocalGenerator->GetFortranFormat(srcfmt))
|
||||
|
|
|
@ -1324,6 +1324,18 @@ std::string cmLocalGenerator::GetIncludeFlags(
|
|||
return flags;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmLocalGenerator::GetCompileOptions(std::string& flags,
|
||||
cmTarget* target,
|
||||
const char *config)
|
||||
{
|
||||
// Add target-specific flags.
|
||||
if(const char *prop = target->GetProperty("COMPILE_FLAGS"))
|
||||
{
|
||||
this->AppendFlags(flags, prop);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
|
||||
cmGeneratorTarget* target,
|
||||
|
|
|
@ -215,6 +215,9 @@ public:
|
|||
cmGeneratorTarget* target,
|
||||
const char* lang = "C", const char *config = 0,
|
||||
bool stripImplicitInclDirs = true);
|
||||
void GetCompileOptions(std::string& flags,
|
||||
cmTarget* target,
|
||||
const char *config);
|
||||
|
||||
/** Compute the language used to compile the given source file. */
|
||||
const char* GetSourceFileLanguage(const cmSourceFile& source);
|
||||
|
|
|
@ -1686,12 +1686,31 @@ void cmLocalVisualStudio6Generator
|
|||
flags += " /D \"_MBCS\"";
|
||||
}
|
||||
|
||||
{
|
||||
std::string targetFlags;
|
||||
this->GetCompileOptions(targetFlags, &target, 0);
|
||||
// Add per-target flags.
|
||||
if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
|
||||
if(!targetFlags.empty())
|
||||
{
|
||||
flags += " ";
|
||||
flags += targetFlags;
|
||||
}
|
||||
}
|
||||
#define ADD_FLAGS(CONFIG) \
|
||||
{ \
|
||||
std::string targetFlags; \
|
||||
this->GetCompileOptions(targetFlags, &target, #CONFIG); \
|
||||
if(!targetFlags.empty()) \
|
||||
{ \
|
||||
flags ## CONFIG += " "; \
|
||||
flags ## CONFIG += targetFlags; \
|
||||
} \
|
||||
}
|
||||
|
||||
ADD_FLAGS(Debug)
|
||||
ADD_FLAGS(Release)
|
||||
ADD_FLAGS(MinSizeRel)
|
||||
ADD_FLAGS(RelWithDebInfo)
|
||||
|
||||
// Add per-target and per-configuration preprocessor definitions.
|
||||
std::set<std::string> definesSet;
|
||||
|
|
|
@ -723,8 +723,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
|
|||
}
|
||||
}
|
||||
|
||||
std::string targetFlags;
|
||||
this->GetCompileOptions(targetFlags, &target, configName);
|
||||
// Add the target-specific flags.
|
||||
if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
|
||||
if(!targetFlags.empty())
|
||||
{
|
||||
flags += " ";
|
||||
flags += targetFlags;
|
||||
|
|
|
@ -332,21 +332,25 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
|
|||
this->Makefile->GetSafeDefinition(compiler.c_str()) << "\n";
|
||||
}
|
||||
|
||||
std::string targetFlags;
|
||||
for(std::set<cmStdString>::const_iterator l = languages.begin();
|
||||
l != languages.end(); ++l)
|
||||
{
|
||||
*this->FlagFileStream << *l << "_FLAGS = " << this->GetFlags(*l) << "\n\n";
|
||||
*this->FlagFileStream << *l << "_DEFINES = " << this->GetDefines(*l) <<
|
||||
"\n\n";
|
||||
std::string targetLangFlags;
|
||||
this->LocalGenerator->GetCompileOptions(targetLangFlags, this->Target,
|
||||
this->LocalGenerator->ConfigurationName.c_str());
|
||||
if (!targetFlags.empty() && targetFlags != targetLangFlags)
|
||||
{
|
||||
targetFlags += " " + targetLangFlags;
|
||||
}
|
||||
}
|
||||
|
||||
// Add target-specific flags.
|
||||
if(this->Target->GetProperty("COMPILE_FLAGS"))
|
||||
if (!targetFlags.empty())
|
||||
{
|
||||
std::string flags;
|
||||
this->LocalGenerator->AppendFlags
|
||||
(flags, this->Target->GetProperty("COMPILE_FLAGS"));
|
||||
*this->FlagFileStream << "# TARGET_FLAGS = " << flags << "\n\n";
|
||||
*this->FlagFileStream << "# TARGET_FLAGS = " << targetFlags << "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -532,8 +536,13 @@ cmMakefileTargetGenerator
|
|||
langFlags += "_FLAGS)";
|
||||
this->LocalGenerator->AppendFlags(flags, langFlags.c_str());
|
||||
|
||||
// Add target-specific flags.
|
||||
if(this->Target->GetProperty("COMPILE_FLAGS"))
|
||||
std::string configUpper =
|
||||
cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
|
||||
|
||||
std::string targetFlags;
|
||||
this->LocalGenerator->GetCompileOptions(targetFlags, this->Target,
|
||||
configUpper.c_str());
|
||||
if (!targetFlags.empty())
|
||||
{
|
||||
std::string langIncludeExpr = "CMAKE_";
|
||||
langIncludeExpr += lang;
|
||||
|
@ -545,7 +554,7 @@ cmMakefileTargetGenerator
|
|||
cmsys::RegularExpression r(regex);
|
||||
std::vector<std::string> args;
|
||||
cmSystemTools::ParseWindowsCommandLine(
|
||||
this->Target->GetProperty("COMPILE_FLAGS"),
|
||||
targetFlags.c_str(),
|
||||
args);
|
||||
for(std::vector<std::string>::iterator i = args.begin();
|
||||
i != args.end(); ++i)
|
||||
|
@ -559,8 +568,7 @@ cmMakefileTargetGenerator
|
|||
}
|
||||
else
|
||||
{
|
||||
this->LocalGenerator->AppendFlags
|
||||
(flags, this->Target->GetProperty("COMPILE_FLAGS"));
|
||||
this->LocalGenerator->AppendFlags(flags, targetFlags.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -594,8 +602,6 @@ cmMakefileTargetGenerator
|
|||
<< compile_defs << "\n"
|
||||
<< "\n";
|
||||
}
|
||||
std::string configUpper =
|
||||
cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
|
||||
std::string defPropName = "COMPILE_DEFINITIONS_";
|
||||
defPropName += configUpper;
|
||||
if(const char* config_compile_defs =
|
||||
|
|
|
@ -151,9 +151,9 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
|
|||
this->GetConfigName());
|
||||
|
||||
// Add include directory flags.
|
||||
const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
|
||||
{
|
||||
std::vector<std::string> includes;
|
||||
const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
|
||||
this->LocalGenerator->GetIncludeDirectories(includes,
|
||||
this->GeneratorTarget,
|
||||
language.c_str(), config);
|
||||
|
@ -171,7 +171,9 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
|
|||
this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags());
|
||||
|
||||
// Add target-specific flags.
|
||||
if(this->Target->GetProperty("COMPILE_FLAGS"))
|
||||
std::string targetFlags;
|
||||
this->LocalGenerator->GetCompileOptions(targetFlags, this->Target, config);
|
||||
if(!targetFlags.empty())
|
||||
{
|
||||
std::string langIncludeExpr = "CMAKE_";
|
||||
langIncludeExpr += language;
|
||||
|
@ -183,7 +185,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
|
|||
cmsys::RegularExpression r(regex);
|
||||
std::vector<std::string> args;
|
||||
cmSystemTools::ParseWindowsCommandLine(
|
||||
this->Target->GetProperty("COMPILE_FLAGS"),
|
||||
targetFlags.c_str(),
|
||||
args);
|
||||
for(std::vector<std::string>::iterator i = args.begin();
|
||||
i != args.end(); ++i)
|
||||
|
@ -198,7 +200,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
|
|||
else
|
||||
{
|
||||
this->LocalGenerator->AppendFlags
|
||||
(flags, this->Target->GetProperty("COMPILE_FLAGS"));
|
||||
(flags, targetFlags.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1261,8 +1261,12 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
|||
flags += " /TP ";
|
||||
}
|
||||
}
|
||||
|
||||
std::string targetFlags;
|
||||
this->LocalGenerator->GetCompileOptions(targetFlags, this->Target,
|
||||
configName.c_str());
|
||||
// Add the target-specific flags.
|
||||
if(const char* targetFlags = this->Target->GetProperty("COMPILE_FLAGS"))
|
||||
if(!targetFlags.empty())
|
||||
{
|
||||
flags += " ";
|
||||
flags += targetFlags;
|
||||
|
|
Loading…
Reference in New Issue