[CMake] Project referring to CSharp project generates incorrectly?

Tessier, Philip @ Engility Philip.Tessier at Engility.com
Thu Aug 16 11:59:15 EDT 2018


All,

Thank you in advance,


I'm an experienced CMake user, in the C++ realm. I'm presently working outside that realm, porting a 200-project solution from Visual Studio (.vcxproj, .csproj) files to CMake. I'm very pleased that CMake has adopted CSharp! Thank you!


I seem to have uncovered a bug where one CSharp project depends on another.


The first CMakeLists.txt:

cmake_minimum_required(VERSION 3.12)
project(DockPanel CSharp)
...
add_library(DockPanel MODULE ${SOURCES_files_Compile} ${SOURCES_files_EmbeddedResource})
set_property(TARGET DockPanel APPEND PROPERTY VS_DOTNET_REFERENCES "System")


The second CMakeLists.txt:
cmake_minimum_required(VERSION 3.12)
project(CSharpFramework CSharp)
...
add_library(CSharpFramework MODULE ${SOURCES_files_Compile} ${SOURCES_files_EmbeddedResource})
target_link_libraries(CSharpFramework PUBLIC $<$<CONFIG:Debug>:DockPanel>  )
set_property(TARGET CSharpFramework APPEND PROPERTY VS_DOTNET_REFERENCES "System")

(I haven't shown everything, as I'm extracting these from a huge system, but I can elaborate if necessary...)

CMake configures and generates (to VS2015) without error. Things proceed as expected until it's time to link the second project.
Then, I get:
..\DockPanel\Debug\DockPanel.dll : fatal error LNK1107: invalid or corrupt file: cannot read at 0x358

A bit of investigative work shows that the generated CSharpFramework.vcxproj contains, as expected:
    <ProjectReference Include="D:\Havok\hk2014_2_5_Simulation\Source\build-x64-msvc-v140-\Vision\Editor\vForge\DockPanel\DockPanel.vcxproj">
      <Project>{DCCB7EE9-726F-3D42-A673-D6CCB4EF6675}</Project>
      <Name>DockPanel</Name>
    </ProjectReference>

But, it also contains:
    <Link>
    <AdditionalDependencies>..\DockPanel\Release\DockPanel.dll; ...</AdditionalDependencies>
    ...
    </Link>

The inclusion of DockPanel.dll in the AdditionalDependencies section is, I believe, causing Visual Studio to try to open it as a '.lib', and failing. I expected the generated .vcxproj to contain only the ProjectReference section for DockPanel, and not include it in AdditionalDependencies.

Can you confirm that this is a bug?

Thank you,
Phil

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180816/a305a8f8/attachment.html>


More information about the CMake mailing list