I am creating a NuGet package of a C++ CMake project using CPack.
cmake -S . -B build
cmake --build build --config Release
cd build
cpack -G NuGet -C 'Release'
I have defined several cpack variables, e.g.:
CPACK_PACKAGE_NAME
CPACK_PACKAGE_VENDOR
CPACK_PACKAGE_DESCRIPTION
install()
commands it to.How do I add this info? Or am I missing something?
The meta info I was looking for can be found in a .targets file. See here for more info.
So I manually created such a file and added it with a cmake install()
instruction, so cpack would include it in the NuGet package. Important: Visual Studio looks for it in a subdirectory called build
, more specifically: <nuget root>/build/**/<nuget name>.targets
. It looks something like this:
<Project>
<ItemDefinitionGroup>
<Link>
<AdditionalDependencies>
$(MSBuildThisFileDirectory)../lib/foo.lib;
[...]
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>
$(MSBuildThisFileDirectory)../include;
[...]
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)../bin/foo.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
[...]
I mostly reverse engineered the syntax from random nuget packages. I'm not 100% happy with this solution. But it works.
Fee free to tell me more about it if you know anything :-)