CMake and C ++ / CLI, C #

I would like to use CMake to compile code consisting of C ++, C ++ / CLI and C # code. I know that there are some unofficial macros to support C # code. Has anyone used them? What is their quality? Are they reliable? Do they replicate VS9 / MSBuild functions?

+5
source share
3 answers

I studied ways to configure C # projects using cmake here . Unfortunately, cmake is limited only by being able to create projects in C ++. Although the solution can be built just fine, you will miss a lot from a regular cs project like Intellisense.

+3
source

Here is an example C # macro file for CMake - click here . Honestly, I have not tried it myself, but everything looks fine.

0
source

Starting with CMake 3.8 , CMake now fully supports C # as a language if you build with Visual Studio 2010 or later. Now you can relatively easily create assemblies or executable targets in C #. Here is a complete example for a simple WinForm C # application:

cmake_minimum_required(VERSION 3.8) project(TestApp LANGUAGES CSharp) # Include CMake utilities for CSharp, for WinForm and WPF application support. include(CSharpUtilities) # Define the executable, including any .cs files. The .resx and other Properties files are optional here, but including them makes them visible in the VS solution for easy editing. add_executable(${PROJECT_NAME} App.config Form1.cs Form1.Designer.cs Form1.resx Program.cs Properties/AssemblyInfo.cs Properties/Resources.Designer.cs Properties/Resources.resx Properties/Settings.Designer.cs Properties/Settings.settings ) # Set the .NET Framework version for the executable. set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.6.1") # Set the executable to be 32-bit. set_property(TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE TRUE) # Set the C# language version (defaults to 3.0). set(CMAKE_CSharp_FLAGS "/langversion:latest") # Set the source file properties for Windows Forms use. csharp_set_windows_forms_properties( Form1.cs Form1.Designer.cs Form1.resx Program.cs Properties/AssemblyInfo.cs Properties/Resources.Designer.cs Properties/Resources.resx Properties/Settings.Designer.cs Properties/Settings.settings ) # Add in the .NET reference libraries. set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES "Microsoft.CSharp" "System" "System.Core" "System.Data" "System.Deployment" "System.Drawing" "System.Net.Http" "System.Windows.Forms" "System.Xml" "System.Xml.Linq" ) 

For assemblies or DLLs, simply use add_library instead of add_executable .

0
source

All Articles