mirror of
https://github.com/reactos/CMake.git
synced 2024-11-28 05:50:42 +00:00
Merge branch 'backport-vs-csharp-ref-no-asm' into vs-csharp-ref-no-asm
This commit is contained in:
commit
94e70e5329
@ -782,6 +782,19 @@ bool cmGlobalVisualStudioGenerator::TargetIsCSharpOnly(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cmGlobalVisualStudioGenerator::TargetCanBeReferenced(
|
||||
cmGeneratorTarget const* gt)
|
||||
{
|
||||
if (this->TargetIsCSharpOnly(gt)) {
|
||||
return true;
|
||||
}
|
||||
if (gt->GetType() != cmStateEnums::SHARED_LIBRARY &&
|
||||
gt->GetType() != cmStateEnums::EXECUTABLE) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cmGlobalVisualStudioGenerator::TargetCompare::operator()(
|
||||
cmGeneratorTarget const* l, cmGeneratorTarget const* r) const
|
||||
{
|
||||
|
@ -85,6 +85,9 @@ public:
|
||||
// return true if target is C# only
|
||||
static bool TargetIsCSharpOnly(cmGeneratorTarget const* gt);
|
||||
|
||||
// return true if target can be referenced by C# targets
|
||||
bool TargetCanBeReferenced(cmGeneratorTarget const* gt);
|
||||
|
||||
/** Get the top-level registry key for this VS version. */
|
||||
std::string GetRegistryBase();
|
||||
|
||||
|
@ -3607,6 +3607,13 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
|
||||
this->WriteString("<Name>", 3);
|
||||
(*this->BuildFileStream) << name << "</Name>\n";
|
||||
this->WriteDotNetReferenceCustomTags(name);
|
||||
if (csproj == this->ProjectType) {
|
||||
if (!static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
|
||||
->TargetCanBeReferenced(dt)) {
|
||||
this->WriteString(
|
||||
"<ReferenceOutputAssembly>false</ReferenceOutputAssembly>\n", 3);
|
||||
}
|
||||
}
|
||||
this->WriteString("</ProjectReference>\n", 2);
|
||||
}
|
||||
this->WriteString("</ItemGroup>\n", 1);
|
||||
|
@ -15,3 +15,9 @@ target_compile_options(CLIApp PRIVATE "/clr")
|
||||
add_executable(CSharpLinkToCxx csharp.cs)
|
||||
|
||||
target_link_libraries(CSharpLinkToCxx CLIApp)
|
||||
|
||||
# this unmanaged C++ library will be added to the C#/.NET
|
||||
# references of CSharpLinkToCxx but it will show a warning
|
||||
# because it is unmanaged
|
||||
add_library(CppNativeApp SHARED cpp_native.hpp cpp_native.cpp)
|
||||
target_link_libraries(CSharpLinkToCxx CppNativeApp)
|
||||
|
10
Tests/CSharpLinkToCxx/cpp_native.cpp
Normal file
10
Tests/CSharpLinkToCxx/cpp_native.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "cpp_native.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace CppApp {
|
||||
void MyCpp::testMyCpp()
|
||||
{
|
||||
std::cout << "#message from CppApp" << std::endl;
|
||||
}
|
||||
}
|
9
Tests/CSharpLinkToCxx/cpp_native.hpp
Normal file
9
Tests/CSharpLinkToCxx/cpp_native.hpp
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
namespace CppApp {
|
||||
class MyCpp
|
||||
{
|
||||
public:
|
||||
void testMyCpp();
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user