Re: Project referring to CSharp project generates incorrectly?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Project referring to CSharp project generates incorrectly?

CMake mailing list

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
Reply | Threaded
Open this post in threaded view
|

Re: Project referring to CSharp project generates incorrectly?

Craig Scott-3
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:


Thanks


On Fri, Aug 17, 2018 at 1:59 AM, Tessier, Philip @ Engility via CMake <[hidden email]> 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


--

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
Reply | Threaded
Open this post in threaded view
|

Re: Project referring to CSharp project generates incorrectly?

J. Caleb Wherry
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 <[hidden email]> 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:


Thanks


On Fri, Aug 17, 2018 at 1:59 AM, Tessier, Philip @ Engility via CMake <[hidden email]> 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

--

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

--

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
Reply | Threaded
Open this post in threaded view
|

Re: Project referring to CSharp project generates incorrectly?

J. Caleb Wherry
Also, this ticket seems to be very similar to what you are seeing if you dig down a bit:


But again, I do this exact same thing with Shared instead of Module libraries and it works. I would think that modules shouldn’t even be allowed for C# targets as that is a specific notion to open native libs with dlopen(). That ticket even hints at only allowing specific target types, possible module was just overlooked?

-Caleb

On Thu, Aug 16, 2018 at 6:55 PM J. Caleb Wherry <[hidden email]> wrote:
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 <[hidden email]> 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:


Thanks


On Fri, Aug 17, 2018 at 1:59 AM, Tessier, Philip @ Engility via CMake <[hidden email]> 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

--

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
--
Sent from my iPhone 4s

--

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