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.
- 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 withset_target_properties()
? I just couldn't find the appropriate property for associating arbitrary file dependencies to a target. - 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:
- In the config file, simply create one or more variables for the files/dirs you want to install. Then install those using
install(FILES)
and/orinstall(DIRECTORY)
. More info: https://stackoverflow.com/a/46361538/189341 - Use
file(GET_RUNTIME_DEPENDENCIES)
. More info:
Answered By - Kevin Answer Checked By - Dawn Plyler (WPSolving Volunteer)