ExternalProject Build Byproduct Default for Relative Paths
I am using the ExternalProject module for two projects and in both cases I need to list build byproducts. The problem is that in both cases I need to list them relative to the build. Thinking about this, it makes little sense to have build byproducts that are not relative to the build. On the other hand, getting the PREFIX
property via ExternaProject_Get_Property
can only be done after the external project is added, but I want to specify the build byproducts as I am adding the project so there is a chicken & egg problem. Why not make the build byproducts relative to the prefix by default? I know they are not guaranteed to be in the install (or the build) tree, but they probably should default to that.
Currently I am doing
set(FOO_BYPRODUCTS foo bar)
list(TRANSFORM FOO_BYPRODUCTS PREPEND "<foo_path>")
ExternalProjectAdd(foo
...
BUILD_BYPRODUCTS "${FOO_BYPRODUCTS}")
add_executable(bar bar.cpp "${FOO_BYPRODUCTS}")
where I had to find <foo_path>
manually by trial and error.
@ben.boeckel suggested on my original post to just support <PREFIX>
and <BINARY_DIR>
expansions in the arguments. Expanding variables makes more sense yet it will ultimately not support what I would like to see. If I understand correctly, this would still require me to use a list, but then I would also want those expanded names to be available at the add_executable call
. With some sort of default, I could probably do this with
set(FOO_BYPRODUCTS foo bar)
ExternalProjectAdd(foo
...
BUILD_BYPRODUCTS "${FOO_BYPRODUCTS}")
ExternalProject_Get_Property(foo BUILD_BYPRODUCTS)
add_executable(bar bar.cpp "${BUILD_BYPRODUCTS}")
where the BUILD_BYPRODUCTS
variable now has all the expanded names.