Merge topic 'vs-csharp-prep'

f27492a4 VS: Add internal API for detecting "managed" projects
4f78b9ff VS: Add CSharp project uuid and file extension
This commit is contained in:
Brad King 2016-10-20 08:51:24 -04:00 committed by CMake Topic Stage
commit 7aa9961939
5 changed files with 34 additions and 0 deletions

View File

@ -159,6 +159,10 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
ext = ".vfproj"; ext = ".vfproj";
project = "Project(\"{6989167D-11E4-40FE-8C1A-2192A86A7E90}\") = \""; project = "Project(\"{6989167D-11E4-40FE-8C1A-2192A86A7E90}\") = \"";
} }
if (this->TargetIsCSharpOnly(t)) {
ext = ".csproj";
project = "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"";
}
const char* targetExt = t->GetProperty("GENERATOR_FILE_NAME_EXT"); const char* targetExt = t->GetProperty("GENERATOR_FILE_NAME_EXT");
if (targetExt) { if (targetExt) {
ext = targetExt; ext = targetExt;

View File

@ -736,6 +736,27 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(
return false; return false;
} }
bool cmGlobalVisualStudioGenerator::TargetIsCSharpOnly(
cmGeneratorTarget const* gt)
{
// check to see if this is a C# build
std::set<std::string> languages;
{
// Issue diagnostic if the source files depend on the config.
std::vector<cmSourceFile*> sources;
if (!gt->GetConfigCommonSourceFiles(sources)) {
return false;
}
}
gt->GetLanguages(languages, "");
if (languages.size() == 1) {
if (*languages.begin() == "CSharp") {
return true;
}
}
return false;
}
bool cmGlobalVisualStudioGenerator::TargetCompare::operator()( bool cmGlobalVisualStudioGenerator::TargetCompare::operator()(
cmGeneratorTarget const* l, cmGeneratorTarget const* r) const cmGeneratorTarget const* l, cmGeneratorTarget const* r) const
{ {

View File

@ -69,6 +69,9 @@ public:
// return true if target is fortran only // return true if target is fortran only
bool TargetIsFortranOnly(const cmGeneratorTarget* gt); bool TargetIsFortranOnly(const cmGeneratorTarget* gt);
// return true if target is C# only
static bool TargetIsCSharpOnly(cmGeneratorTarget const* gt);
/** Get the top-level registry key for this VS version. */ /** Get the top-level registry key for this VS version. */
std::string GetRegistryBase(); std::string GetRegistryBase();

View File

@ -137,6 +137,11 @@ bool cmVisualStudioGeneratorOptions::IsWinRt() const
return this->FlagMap.find("CompileAsWinRT") != this->FlagMap.end(); return this->FlagMap.find("CompileAsWinRT") != this->FlagMap.end();
} }
bool cmVisualStudioGeneratorOptions::IsManaged() const
{
return this->FlagMap.find("CompileAsManaged") != this->FlagMap.end();
}
bool cmVisualStudioGeneratorOptions::UsingUnicode() const bool cmVisualStudioGeneratorOptions::UsingUnicode() const
{ {
// Look for the a _UNICODE definition. // Look for the a _UNICODE definition.

View File

@ -49,6 +49,7 @@ public:
bool IsDebug() const; bool IsDebug() const;
bool IsWinRt() const; bool IsWinRt() const;
bool IsManaged() const;
// Write options to output. // Write options to output.
void OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix, void OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix,
const char* suffix, const char* suffix,