mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
Merge topic 'fix-csharp-target-type'
375b420fdfCSharp: Fix regression in VS project type selection8b21aa0af0VS: Fix CSharp flag selection when linking to a static C++ library Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2427
This commit is contained in:
@@ -5600,10 +5600,14 @@ bool cmGeneratorTarget::HasLanguage(std::string const& language,
|
||||
{
|
||||
std::set<std::string> languages;
|
||||
this->GetLanguages(languages, config);
|
||||
// The "exclusive" check applies only to source files and not
|
||||
// the linker language which may be affected by dependencies.
|
||||
if (exclusive && languages.size() > 1) {
|
||||
return false;
|
||||
}
|
||||
// add linker language (if it is different from compiler languages)
|
||||
languages.insert(this->GetLinkerLanguage(config));
|
||||
return (languages.size() == 1 || !exclusive) &&
|
||||
languages.count(language) > 0;
|
||||
return languages.count(language) > 0;
|
||||
}
|
||||
|
||||
void cmGeneratorTarget::ComputeLinkImplementationLanguages(
|
||||
|
||||
@@ -374,7 +374,7 @@ public:
|
||||
|
||||
// Evaluate if the target uses the given language for compilation
|
||||
// and/or linking. If 'exclusive' is true, 'language' is expected
|
||||
// to be the only language used for the target.
|
||||
// to be the only language used in source files for the target.
|
||||
bool HasLanguage(std::string const& language, std::string const& config,
|
||||
bool exclusive = true) const;
|
||||
|
||||
|
||||
@@ -2452,10 +2452,12 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
||||
}
|
||||
|
||||
// Choose a language whose flags to use for ClCompile.
|
||||
static const char* clLangs[] = { "CXX", "C", "Fortran", "CSharp" };
|
||||
static const char* clLangs[] = { "CXX", "C", "Fortran" };
|
||||
std::string langForClCompile;
|
||||
if (std::find(cm::cbegin(clLangs), cm::cend(clLangs), linkLanguage) !=
|
||||
cm::cend(clLangs)) {
|
||||
if (this->ProjectType == csproj) {
|
||||
langForClCompile = "CSharp";
|
||||
} else if (std::find(cm::cbegin(clLangs), cm::cend(clLangs), linkLanguage) !=
|
||||
cm::cend(clLangs)) {
|
||||
langForClCompile = linkLanguage;
|
||||
} else {
|
||||
std::set<std::string> languages;
|
||||
|
||||
@@ -21,3 +21,9 @@ target_link_libraries(CSharpLinkToCxx CLIApp)
|
||||
# because it is unmanaged
|
||||
add_library(CppNativeApp SHARED cpp_native.hpp cpp_native.cpp)
|
||||
target_link_libraries(CSharpLinkToCxx CppNativeApp)
|
||||
|
||||
# Link a static C++ library into the CSharp executable.
|
||||
# We do not actually use any symbols but this helps cover
|
||||
# link language selection.
|
||||
add_library(CppStaticLib STATIC cpp_static.cpp)
|
||||
target_link_libraries(CSharpLinkToCxx CppStaticLib)
|
||||
|
||||
3
Tests/CSharpLinkToCxx/cpp_static.cpp
Normal file
3
Tests/CSharpLinkToCxx/cpp_static.cpp
Normal file
@@ -0,0 +1,3 @@
|
||||
void cpp_static()
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user