[CMake] C# and cmake ?

Bradley Lowekamp blowekamp at mail.nih.gov
Wed Aug 22 10:48:18 EDT 2012


Hello Gerhard,

With the SimpleITK project I am working on we are using C#, SWIG and a lot of C++ ( along with a variety of other languages). We are using Swig to generate C# libraries, and compile a large number of C# executables to test our interface. We have quite a bit of CMake code, but I hope that you'll be able to wade through it to find the bits you may need. Here is a summary of some of the interesting bits that you may find useful:

CMake Find and Use files:

https://github.com/SimpleITK/SimpleITK/blob/master/CMake/FindCSharp.cmake
https://github.com/SimpleITK/SimpleITK/blob/master/CMake/UseCSharp.cmake
https://github.com/SimpleITK/SimpleITK/blob/master/CMake/FindMono.cmake
https://github.com/SimpleITK/SimpleITK/blob/master/CMake/UseMono.cmake

Here is macro we use for testing:
https://github.com/SimpleITK/SimpleITK/blob/master/Testing/Unit/CMakeLists.txt#L326

And here is the code that we use to run SWIG and generate the managed library:
https://github.com/SimpleITK/SimpleITK/blob/master/Wrapping/CMakeLists.txt#L206


Most of the CMake code has been contributed by another developer, so I am not an expert of C#.  While this is a rather complicated build process,  it may give an indication of what would be needed for cmake to build the C# targets.

Hope this helps,
Brad


On Aug 22, 2012, at 7:03 AM, Gerhard den Hollander wrote:

> We have a large code base, that consists of a large number of C++ file
> and a smaller number of C# files.
> 
> Most fo the C++ code is being build using CMake,
> the C# code is build using the msbuild tools.
> 
> I know that currently there is no C# support planned in CMake,
> but reading through the google results, it sounds like people have had
> various degrees of success using custom_command(..) or other CMake
> tricks to kick of C# builds using msbuild/devenv.
> 
> For those who have succesfully build mixed code projects (so C# and
> C/C++ ), would you mind explainign how this is done ?
> 
> Preferably with some example CMake files ?
> 
> Thanks
> 
> --
> 
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

========================================================
Bradley Lowekamp  
Medical Science and Computing for
Office of High Performance Computing and Communications
National Library of Medicine 
blowekamp at mail.nih.gov



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120822/99d0e46f/attachment-0001.htm>


More information about the CMake mailing list