Sunday, April 3, 2022

[SOLVED] cmake: package config for installing arbitrary file dependencies for a target

Issue

I am creating a cmake package config file (a Foo-config.cmake) for a pre-existing .dll not created by cmake.

The annoying thing is that the .dll depends on some data files.

When a user consumes my package in his own cmake project, I want the INSTALL target to install both the .dll and data files to his specified install location. I don't want him to have to write extra install() rules to do that.

  1. Is it good practice to write the install() rules directly in my Foo-config.cmake? Or is there a better way to do this, maybe with set_target_properties()? I just couldn't find the appropriate property for associating arbitrary file dependencies to a target.
  2. In an alternate universe where this .dll didn't already exist and I had to create it myself using cmake, would I need to create a custom Foo-config.cmake, or is there something in cmake that can automatically generate it for me to achieve the same thing?

FWIW the .dll is an internal legacy library and is normally built by Visual Studio and uploaded in a .zip file to our internal artifactory. I want us to migrate away from manually pulling down .zip files from artifactory and manually integrating the files into Visual Studio projects.


Solution

I've since found that there are a couple different ways to do this:



Answered By - Kevin
Answer Checked By - Dawn Plyler (WPSolving Volunteer)