mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-20 12:53:55 +08:00
remove TargetIsCSharpOnly() and use methods from cmGeneratorTarget
This commit is contained in:
@@ -98,7 +98,7 @@ 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)) {
|
if (t->HasLanguage("CSharp", "")) {
|
||||||
ext = ".csproj";
|
ext = ".csproj";
|
||||||
project = "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"";
|
project = "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"";
|
||||||
}
|
}
|
||||||
|
@@ -734,33 +734,10 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmGlobalVisualStudioGenerator::TargetIsCSharpOnly(
|
|
||||||
cmGeneratorTarget const* gt)
|
|
||||||
{
|
|
||||||
// C# targets can be defined with add_library() (using SHARED or STATIC) and
|
|
||||||
// also using add_executable(). We do not treat imported C# targets the same
|
|
||||||
// (these come in as UTILITY)
|
|
||||||
if (gt->GetType() != cmStateEnums::SHARED_LIBRARY &&
|
|
||||||
gt->GetType() != cmStateEnums::STATIC_LIBRARY &&
|
|
||||||
gt->GetType() != cmStateEnums::EXECUTABLE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Issue diagnostic if the source files depend on the config.
|
|
||||||
std::vector<cmSourceFile*> sources;
|
|
||||||
if (!gt->GetConfigCommonSourceFiles(sources)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<std::string> languages;
|
|
||||||
gt->GetLanguages(languages, "");
|
|
||||||
return languages.size() == 1 && languages.count("CSharp") > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cmGlobalVisualStudioGenerator::TargetCanBeReferenced(
|
bool cmGlobalVisualStudioGenerator::TargetCanBeReferenced(
|
||||||
cmGeneratorTarget const* gt)
|
cmGeneratorTarget const* gt)
|
||||||
{
|
{
|
||||||
if (this->TargetIsCSharpOnly(gt)) {
|
if (gt->GetManagedType("") != cmGeneratorTarget::ManagedType::Native) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (gt->GetType() != cmStateEnums::SHARED_LIBRARY &&
|
if (gt->GetType() != cmStateEnums::SHARED_LIBRARY &&
|
||||||
|
@@ -81,9 +81,6 @@ 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);
|
|
||||||
|
|
||||||
// return true if target can be referenced by C# targets
|
// return true if target can be referenced by C# targets
|
||||||
bool TargetCanBeReferenced(cmGeneratorTarget const* gt);
|
bool TargetCanBeReferenced(cmGeneratorTarget const* gt);
|
||||||
|
|
||||||
|
@@ -188,9 +188,7 @@ static std::string computeProjectFileExtension(cmGeneratorTarget const* t,
|
|||||||
{
|
{
|
||||||
std::string res;
|
std::string res;
|
||||||
res = ".vcxproj";
|
res = ".vcxproj";
|
||||||
std::string lang = t->GetLinkerLanguage(config);
|
if (t->HasLanguage("CSharp", config)) {
|
||||||
if (cmGlobalVisualStudioGenerator::TargetIsCSharpOnly(t) ||
|
|
||||||
lang == "CSharp") {
|
|
||||||
res = ".csproj";
|
res = ".csproj";
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
@@ -3483,15 +3481,17 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
|
|||||||
std::string currentBinDir =
|
std::string currentBinDir =
|
||||||
this->LocalGenerator->GetCurrentBinaryDirectory();
|
this->LocalGenerator->GetCurrentBinaryDirectory();
|
||||||
for (cmComputeLinkInformation::Item const& l : libs) {
|
for (cmComputeLinkInformation::Item const& l : libs) {
|
||||||
// Do not allow C# targets to be added to the LIB listing. LIB files are
|
if (l.Target) {
|
||||||
// used for linking C++ dependencies. C# libraries do not have lib files.
|
auto managedType = l.Target->GetManagedType("");
|
||||||
// Instead, they compile down to C# reference libraries (DLL files). The
|
// Do not allow C# targets to be added to the LIB listing. LIB files are
|
||||||
// `<ProjectReference>` elements added to the vcxproj are enough for the
|
// used for linking C++ dependencies. C# libraries do not have lib files.
|
||||||
// IDE to deduce the DLL file required by other C# projects that need its
|
// Instead, they compile down to C# reference libraries (DLL files). The
|
||||||
// reference library.
|
// `<ProjectReference>` elements added to the vcxproj are enough for the
|
||||||
if (l.Target &&
|
// IDE to deduce the DLL file required by other C# projects that need its
|
||||||
cmGlobalVisualStudioGenerator::TargetIsCSharpOnly(l.Target)) {
|
// reference library.
|
||||||
continue;
|
if (managedType == cmGeneratorTarget::ManagedType::Managed) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (l.IsPath) {
|
if (l.IsPath) {
|
||||||
|
Reference in New Issue
Block a user