Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget package from CMake

Tags:

c#

nuget

cmake

I am generating an C# WPF project using CMake. I followed this CMakeLists.txt example from Github.

My question is: How can add a Nuget package to this project using CMake?

like image 491
Humam Helfawi Avatar asked Jul 18 '18 10:07

Humam Helfawi


1 Answers

CMake 3.15 and above supports referencing Nuget packages with VS_PACKAGE_REFERENCES. To add a Nuget package reference to a CMake target, use the package name and package version separated by an underscore _. Here is an example for BouncyCastle version 1.8.5:

set_property(TARGET MyApplication
    PROPERTY VS_PACKAGE_REFERENCES "BouncyCastle_1.8.5"
)

The documentation shows how you can add multiple Nuget packages by semicolon-delimiting ; the packages.

For older CMake versions, you could try the proposed work-around suggested here.

like image 140
Kevin Avatar answered Oct 20 '22 06:10

Kevin