ExternalProject: add `INSTALL_BYPRODUCTS` for install step byproducts
This is a feature request proposal for adding a INSTALL_BYPRODUCTS
option to ExternalProject_Add()
to declare BYPRODUCTS
of the ExternalProject install step.
Motivation
As of CMake 3.2 (in 557aef0b), ExternalProject_Add() has supported the BUILD_BYPRODUCTS
option, which can be used to explicitly declare that a file is generated by the build command (may be required for Ninja generator).
``BUILD_BYPRODUCTS <file>...`` .. versionadded:: 3.2 Specifies files that will be generated by the build command but which might or might not have their modification time updated by subsequent builds. These ultimately get passed through as ``BYPRODUCTS`` to the build step's own underlying call to :command:`add_custom_command`.
However, this only is available for the ExternalProject build step (or custom steps created by ExternalProject_Add_Step)
Often times, your file may instead rely on ExternalProject install step (e.g. because you are using a third-party library).
This generally seems to be fine, since generally you'd have an add_dependency(xxxx externalproject-that-adds-the-library)
, so the install step will normally always be run before trying to access the BYPRODUCT. Still, it's probably worth having an explicit INSTALL_BYPRODUCTS
option in ExternalProject_Add
.
A quick search using GitHub Code Search of "BUILD_BYPRODUCTS <INSTALL_DIR>"
shows 110 files using a BUILD_BYPRODUCTS that depends on the <INSTALL_DIR>
, so they're probably all actually BYPRODUCTS of the install step.
Proposal
Add an INSTALL_BYPRODUCTS
option to ExternalProject_Add
that can be used to declare that files are BYPRODUCTS
of the ExternalProject install step, instead of the build step.
Implementation details
I'd be happy to make an MR for this. I think it's as simple as copying the current code for BUILD_BYPRODUCTS
.
It might be a bit harder for me to write a test case for it, but I don't mind giving it a go!
As a side-note, it might also be worth updating the ExternalProject_Add *_BYPRODUCTS
docs to mention that this may be required by Ninja
generator. There's already a link to add_custom_command, which explains it, but it's not obvious if you're just using ExternalProject.
Related Issues
- I believe
INSTALL_BYPRODUCTS
would be the best way to fix #23056 (closed).