[CMake] C# project integration with CMake 3.1

Robert Dailey rcdailey.lists at gmail.com
Thu Jan 15 10:29:01 EST 2015


I have a managed C++ (CLI) project that I build using CMake. I have
another C# project (Visual Studio 2013) that I maintain outside of
CMake that needs to reference the managed C++ DLL output by CMake.
What is the best approach for this?

The C# project is technically a completely separate product (tool) and
wouldn't be in the same solution with the CMake projects.

I've read that the C# project can be setup for use with
configure_file() and then output somewhere in the binary dir. However,
updates to the project (settings modifications through VIsual Studio,
and adding C# files) would be lost, as they would not affect the
original file that was used by configure_file(). If configure_file()
is the best option, how do I overcome the issue of updating the visual
studio project? Might not matter anyway since this will require the C#
project to be accessible to CMake which it may not be in the future
(once the Tool is moved into its own Git repository as a separate
product, which will happen soon).

I've also thought of creating an install project for the managed C++
project. This would definitely allow the tool to be disconnected, but
how do I create a predictable install path for the C# project? Each
developer may have their own drive letters on Windows, or maybe set
CMAKE_INSTALL_PREFIX to something other than Program Files.

Any advice is greatly appreciated. I'm pretty much blocked on this.


More information about the CMake mailing list