[CMake] Project referring to CSharp project generates incorrectly?

J. Caleb Wherry calebwherry at gmail.com
Thu Aug 16 18:55:24 EDT 2018


FWIW: I do almost this exact thing currently and have no issues (even mix
in Managed C++ wrappers around naive code). The only difference is that I
don’t compile any C# modules, only Shared libs. Not sure if that could be a
problem or not.

I’m using CMake 3.11 and VS 2015.

-Caleb

On Thu, Aug 16, 2018 at 5:46 PM Craig Scott <craig.scott at crascit.com> wrote:

> Philip, thanks for the concise description of the problem. Would you be
> willing to report this in CMake's gitlab as an issue so we can better track
> it and refer to it in merge requests, etc.? You can report a new issue here:
>
> https://gitlab.kitware.com/cmake/cmake/issues/new
>
> Thanks
>
>
> On Fri, Aug 17, 2018 at 1:59 AM, Tessier, Philip @ Engility via CMake <
> cmake at cmake.org> wrote:
>
>> 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
>>
>>
>> --
>>
>> Powered by www.kitware.com
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Kitware offers various services to support the CMake community. For more
>> information on each offering, please visit:
>>
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> https://cmake.org/mailman/listinfo/cmake
>>
>>
>
>
> --
> Craig Scott
> Melbourne, Australia
> https://crascit.com
>
> New book released: Professional CMake: A Practical Guide
> <https://crascit.com/professional-cmake/>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake
>
-- 
Sent from my iPhone 4s
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180816/047cc2e9/attachment.html>


More information about the CMake mailing list