Reputation: 21
I'm using CMake for the first time in my life to build a C# DLL. This CMake fits into a larger workflow. Otherwise, I use Visual Studio 2017 for authoring and debugging.
So far my CMakeLists.txt looks something like this, the product of looking at and cutting and pasting from the few examples I could find.
cmake_minimum_required(VERSION 3.8)
project("galapagos" CSharp)
add_executable("galapagos"
tortoise1.cs
tortoise2.cs
tortoiseForm.cs
packages.config
runTortoiseReport.cs
... etc ...
tortoiseTest.cs)
set_property(TARGET "galapagos" PROPERTY DOTNET_TARGET_FRAMEWORK_VERSION "v4.6.1")
set_property(TARGET "galapagos" PROPERTY WIN32_EXECUTABLE FALSE)
set_property(TARGET "galapagos" PROPERTY VS_CONFIGURATION_TYPE ClassLibrary)
set_property(TARGET "galapagos" PROPERTY VS_DOTNET_REFERENCES
"Microsoft.CSharp"
"PresentationCore"
"PresentationFramework"
"System"
"System.Core"
"System.Data"
"System.Data.DataSetExtensions"
"System.Windows.Forms"
"System.Net.Http"
"System.Xaml"
"System.Xml"
"System.Xml.Linq"
"WindowsBase"
.. etc ...
"C:/galapagos/galapagos.dll"
)
Further, attempting to build results in changes to my .csprog file where
Class Library
to
Console Application
The disappearing form sometimes can be made to reappear by excluding the corresponding file from the project, then adding it in again.
There is no DLL produced. The change to the .csprog file where the application is now a Console Application
is strange at best.
Apparently,
set_property(TARGET "galapagos" PROPERTY VS_CONFIGURATION_TYPE BeefChowMein)
has the same effect as
set_property(TARGET "galapagos" PROPERTY VS_CONFIGURATION_TYPE ClassLibrary)
which possibly explains that ClassLibrary
is not understood by CMake and assumed to be the default ConsoleApplication
.
As the build process has apparently trashed the form definition, I now have a whole raft of errors like
tortoise1.cs(16,25): error CS1061: 'TortoiseForm' does not contain a definition for 'carapace' and no accessible
extension method 'carapace' accepting a first argument of type 'TortoiseForm' could be found (are you missing a using directive or an assembly reference?) [......csproj]
where the project otherwise built correctly in VS seconds before.
Are there co-existence issues with VS and CMake?
What am I still missing?
Upvotes: 2
Views: 3755
Reputation: 83
Please add ADD_LIBRARY , rather than using add_executable.
ADD_LIBRARY(${PROJECT_NAME} SHARED
..sources..
)
Upvotes: 4