[cmake-developers] C# support?

James Johnston JamesJ at motionview3d.com
Mon Jun 29 14:30:04 EDT 2015


> -----Original Message-----
> From: cmake-developers [mailto:cmake-developers-bounces at cmake.org]
> On Behalf Of David Cole via cmake-developers
> Sent: Monday, June 29, 2015 17:31
> To: Brad King
> Cc: cmake-developers at cmake.org
> Subject: Re: [cmake-developers] C# support?
> 
> The C# compiler, csc.exe, takes all its arguments at once in one call to
build a
> library or executable. Listing all the sources, and its references (other
libraries
> it depends on) all at once. You can do it as command line arguments, or as
> contents of a response file, or a combination or arguments plus response
file.
> 
> Conceptually, it's "just like Java."

Exactly right; it's like a combined compiler+linker.  It's also worth noting
that the C# and VB .NET languages doesn't have the concept of "#include"
preprocessor directives.  Header files are a non-issue.  (Once you got that
working, I'd imagine Java language support would be easy, too...)

> They do have separate project files for it with VS, though. The generators
will
> need code to generate *.csproj files, rather than custom commands in a
> vcxproj file, to make it seem like it's really well-integrated with VS.
Not sure if
> *.csproj files have evolved much over the last few releases of VS -- I'd
expect
> the major challenge with this to be making sure CMake generates proper
> *.csproj files for however many versions of VS it would take to make it
> acceptable.

Csproj files are MSBuild compatible, like how Visual C++ 2010 vcxproj files
are.  While Visual C++ went to MSBuild recently (VS2010), Visual C# has been
MSBuild compatible since MSBuild's inception - Visual Studio 2005 if I
remember right.  Visual Studio 2002/2003 might be different since they
pre-date MSBuild but since the VC++ 2002 generator was recently deprecated
I'd argue these versions can be ignored. (if someone uses that version
still, they could at least use csc.exe directly via a Makefile generator)

So, since VS2005, I think you'd find small changes (new flags introduced,
etc.) but no major file format overhaul like from VC++ 2008 to VC++ 2010.

I'd also like to take this opportunity to point out that whoever does this
might want to consider supporting VB .NET also.  Everything in this
discussion is EXACTLY the same, except that the compiler name is different,
and project/source code file extensions are different.  It would be
relatively trivial to support VB .NET once you have C# working, if you wrote
the generator right.  (vbc.exe instead of csc.exe, vbproj instead of csproj,
.vb file instead of .cs file.  Compiler switches are probably almost
identical...  It's also MSBuild-based and also does a combined
"compile+link".)

Best regards,

James Johnston



More information about the cmake-developers mailing list