cpm
cpm copied to clipboard
Location of children's artifacts, copying artifacts, etc
What is the proper way to gather source files and generated artifacts (*.dll, *.lib, etc) from CPM modules my top-level CMake project depends on?
Due to the way CPM organizes source repositories and artifacts, it seems to be a bit difficult to reliably do things like copy *.dll files to where my main executable resides (for easier debugging, packaging, etc).
Some examples:
- My top-level CMake project (main product) depends on a shared library generated by a child (CPM module), which must be bundled with the product when released.
- The linker input file (*.lib) and source header files for the same shared library must also be released independently for use by third parties.
I have seen some solutions for CMake which involves...
- Setting CMAKE_RUNTIME_OUTPUT_DIRECTORY in the parent; however, CPM overrides it.
- Setting the same variable in the CPM modules; the result is the same.
My next idea was to set a cached variable in each child, e.g. something like this:
set(${CPM_MODULE_NAME}_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" CACHE INTERNAL "")
My issues with this approach are:
- The desired path differs depending on whether there is a single or there are multiple possible build types (debug, release, etc) (Visual Studio).
- This only works for modules I created/modified myself.
- I would actually prefer each module/child to be as ignorant as possible about all this.
Thank you for any assistance you can provide!