I need a way to include the esbuild binary from the node_modules directory of my project in the cpack archive in a way that npm ci, which downloads the esbuild package from npm, gets run before the copy operation is started.
From what I learnt, copying a file to the cpack archive needs to be done with an install() statement, so I have successfully done that using this:
However, I need to make sure that ${PROJECT_SOURCE_DIR}/node_modules gets created by running npm ci before this code is run. I already have the code to run npm ci:
but I’m not able to find a way to link these 2 together because the install() statement doesn’t accept a DEPENDS field where I can pass ${PROJECT_SOURCE_DIR}/node_modules.
Is there any way of accomplishing what I want, even without using the install() statement?
I believe the trick is that you need to turn the esbuild binary into a target, then it’s trivial to add the dependency. Something like this should work:
add_custom_target(esbuild_bin ALL
COMMAND echo "Preparing esbuild binary"
DEPENDS ${PROJECT_SOURCE_DIR}/node_modules
)
Right but how do I add the esbuild_bin target as a dependency to the install()? IIUC, there’s no way of specifying a dependency on install() currently.