Visual Studio 2017: Test CSharpLinkFromCxx failes
HI,
I tried to create a CLI-based project solution, which has to link a C++-based static lib and a CSharp-library. To figure out how to do this I read the test-case CSharpLinkFromCxx from your repository.
I get a build failure with the CSharp-reference, because cmake added the reference to the list of references and to the list of libs to link ( the ones from C++ ). It seems that within the CMake-logic the reference will not detected as a reference. It thinks it needs to add the import lib as well.
To reproduce the failing test I used the following environment: Windows 10 ( latest SDK ), 64 bit Visual Studio 2017 Version 15.7.1 CMake 3.11.3 Example CSharpLinkFromCxx from latest master
The output from my cmake-run:
λ cmake CMakeLists.txt
-- Building for: Visual Studio 15 2017
-- Selecting Windows SDK version 10.0.17134.0 to target Windows 10.0.10586.
-- The CXX compiler identification is MSVC 19.14.26428.1
-- The CSharp compiler identification is Microsoft Visual Studio 2017
-- The CSharp compiler version is 2.8.0.62830
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.14.26428/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C# compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin/Roslyn/csc.exe
-- Check for working C# compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin/Roslyn/csc.exe -- works
-- Configuring done
-- Generating done
-- Build files have been written to: C:/projects/CMake/Tests/CSharpLinkFromCxx
The build output from Visual Studio:
1>------ Neues Erstellen gestartet: Projekt: ZERO_CHECK, Konfiguration: Release Win32 ------
1>Checking Build System
1>CMake does not need to re-run because C:/projects/CMake/Tests/CSharpLinkFromCxx/CMakeFiles/generate.stamp is up-to-date.
2>------ Neues Erstellen gestartet: Projekt: CSharpLibrary, Konfiguration: Release Win32 ------
2> CSharpLibrary -> C:\projects\CMake\Tests\CSharpLinkFromCxx\Release\CSharpLibrary.dll
3>------ Neues Erstellen gestartet: Projekt: ManagedCppLibrary, Konfiguration: Release Win32 ------
3>Building Custom Rule C:/projects/CMake/Tests/CSharpLinkFromCxx/CMakeLists.txt
3>CMake does not need to re-run because C:/projects/CMake/Tests/CSharpLinkFromCxx/CMakeFiles/generate.stamp is up-to-date.
3>UsefulManagedCppClass.cpp
3>LINK : fatal error LNK1181: Eingabedatei "Release\CSharpLibrary.lib" kann nicht geöffnet werden.
3>Die Erstellung des Projekts "ManagedCppLibrary.vcxproj" ist abgeschlossen -- FEHLER.
4>------ Neues Erstellen gestartet: Projekt: CSharpLinkFromCxx, Konfiguration: Release Win32 ------
4>CSC : error CS0006: Metadatendatei "C:\projects\CMake\Tests\CSharpLinkFromCxx\Release\ManagedCppLibrary.dll" wurde nicht gefunden.
5>------ Neues Erstellen übersprungen: Projekt: ALL_BUILD, Konfiguration: Release Win32 ------
5>Für diese Projektmappenkonfiguration wurde kein zu erstellendes Projekt ausgewählt.
========== Alles neu erstellen: 2 erfolgreich, 2 fehlerhaft, 1 übersprungen ==========
( Sorry german version )