I’m using cmake 3.28.3 on Windows 10 and trying to use execute_process to call ‘npm update’ after copying package.json to binary dir.
With plain “COMMAND npm update” cmake couldn’t find npm, so I tried using the find_program path for NPM.
This returns a valid path (“C:/Program Files/nodejs/npm”) but it contains a space which aways gets me hella confused. I tried this:
COMMAND ${NPM_PATH} update
…and got…
%1 is not a valid Win32 application
I tried this:
COMMAND “${NPM_PATH}” update
…and got the same thing. I tried this:
COMMAND \“${NPM_PATH}\” update
…and got…
Access is denied.
I’m guessing I’ve correctly escaped spaces here (and I can sort of see what’s going on having used system() in C myself) but there seems to be a permissions problem of some kind, maybe because the command I want is in Program Files?
I can install the modules globally in the meantime to work around this, but it’d be nice to get the ‘local’ version working.
But what’s strange is that I don’t have the same problem with “COMMAND npx node-gyp build”…that just works even though npx is in the same dir as npm, is also not a bat file etc etc, they seem to be identical. Might do the cmd /C thing for both…
On the other hand, add_custom_command does seem to ‘use a shell’ (that’s why npx is working) which I think is what have may initially have confused me.