summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalVisualStudioGenerator.cxx
diff options
context:
space:
mode:
authorRobert Dailey <rcdailey@gmail.com>2018-02-05 21:43:25 (GMT)
committerRobert Dailey <rcdailey@gmail.com>2018-02-23 14:53:17 (GMT)
commit076a356cd1972a149898fdba77d1dd83981447b4 (patch)
treeb0ea4574fba9ccb786b699973f94e611f2f70fd3 /Source/cmGlobalVisualStudioGenerator.cxx
parentebf0a0827992be5cc03e530f9dc06bd1d05c1aa6 (diff)
downloadCMake-076a356cd1972a149898fdba77d1dd83981447b4.zip
CMake-076a356cd1972a149898fdba77d1dd83981447b4.tar.gz
CMake-076a356cd1972a149898fdba77d1dd83981447b4.tar.bz2
VS: Support C# project references
When specifying a pure C# target in the `target_link_libraries()` call to another C++ target, a `<ProjectReference>` was setup for it (we wanted this) but also a corresponding `.lib` was added under `<AdditionalDependencies>` (we didn't want this). This change introduces a check that prevents `.lib` linker options from being used when the corresponding target for that library is a C# target. Fixes: #17678
Diffstat (limited to 'Source/cmGlobalVisualStudioGenerator.cxx')
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx34
1 files changed, 16 insertions, 18 deletions
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index a4570e1..fa7dc51 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -737,26 +737,24 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(
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;
- }
- // Only "real" targets are allowed to be C# targets.
- if (gt->Target->GetType() > cmStateEnums::OBJECT_LIBRARY) {
- return false;
- }
+ // 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;
}
- gt->GetLanguages(languages, "");
- if (languages.size() == 1) {
- if (*languages.begin() == "CSharp") {
- return true;
- }
+
+ // Issue diagnostic if the source files depend on the config.
+ std::vector<cmSourceFile*> sources;
+ if (!gt->GetConfigCommonSourceFiles(sources)) {
+ return false;
}
- return false;
+
+ std::set<std::string> languages;
+ gt->GetLanguages(languages, "");
+ return languages.size() == 1 && languages.count("CSharp") > 0;
}
bool cmGlobalVisualStudioGenerator::TargetCanBeReferenced(